[Coin-discuss] Making changes to coefficients in existing rowsin OSI

Jan-Willem Goossens j.goossens at t75.nl
Fri Jan 6 05:19:41 EST 2006


Hi,

About changing matrix coefficients: Assuming you're not changing a lot of
coefficients, why not use OsiClpSolverInterface's

  ///
  void modifyCoefficient(int row, int column, double newElement,
			bool keepZero=false)
	{modelPtr_->modifyCoefficient(row,column,newElement, keepZero);}


for this?



Personally, since I'm using OsiCpx and OsiClp, I just hacked in a

	  virtual void setCoef(int rowIndex,
				  int columnIndex,
				  double elementValue);

in OsiSolverInterface, and implemented it as

/* Set a coefficient of a column in a row */
void
OsiClpSolverInterface::setCoef(int rowIndex, int columnIndex, double
elementValue)
{
#ifndef NDEBUG
	int n = modelPtr_->numberColumns();
	if (columnIndex<0||columnIndex>=n) {
		indexError(columnIndex,"setCoef");
	}
	int m = modelPtr_->numberRows();
	if (rowIndex<0||rowIndex>=m) {
		indexError(rowIndex,"setCoef");
	}
#endif
	modifyCoefficient(rowIndex, columnIndex, elementValue, false);	// last
argument is keepZero
}

and

void
OsiCpxSolverInterface::setCoef(int rowIndex, int columnIndex, double
elementValue)
{
  debugMessage("OsiCpxSolverInterface::setCoef(%d, %d, %g)\n", rowIndex,
columnIndex, elementValue);

  int err = CPXchgcoef( env_, getMutableLpPtr(), rowIndex, columnIndex,
elementValue);

  checkCPXerror( err, "CPXchgcoef", "setCoef" );
}



but I'm not sure if SetCoef functionality is in line with the generic OSI
ideas..
Hope this is useful,

Jan-Willem


> Stuart,
>
> Try building model as a CoinModel and use
> OsiSolverInterface:loadFromCoinModel.  CoinModel allows for more
> lightweight modification of model.
>
> You will see an artificial usage in Test/OsiClpSolverInterfacetest.cpp
>
> John Forrest
>
>
>
>              "Thorncraft,
>              Stuart"
>              <stuart at iesys.com                                          To
>              .au>                      <coin-discuss at list.coin-or.org>
>              Sent by:                                                   cc
>              coin-discuss-boun
>              ces at list.coin-or.                                     Subject
>              org                       [Coin-discuss] Making changes to
>                                        coefficients in existing rows in
>                                        OSI
>              01/04/06 08:54 PM
>
>
>              Please respond to
>              Discussions about
>                 open source
>                software for
>                 Operations
>                  Research
>
>
>
>
>
>
> Hi
>
> I’ve been using the OSI CLP interface to construct and solve the same
> optimisation problem repeatedly but with different row bounds, column
> bounds and decision-variable coefficients.  I’d like to be able to do
> this
> by making only minor changes to the existing optimisation rather than
> regenerate the problem completely from scratch.
>
> I note that the “setColBounds” and “setRowBounds” methods can be
> used for
> changing the bounds on existing columns or rows but could not find a
> similar method that can be called to change decision variable
> coefficients.
>
> So my question is what is the best way to make changes to
> decision-variable
> coefficients using OSI?  E.g. does a method exist to do this or is it
> necessary to delete the relevant row(s) and recreate them?
>
> Apologies if I’ve missed something in the OSI interface.
>
> Thanks
> Stuart
>
>
>
>             *******************************************************************************
>
>
>             This e-mail (which includes any attachments) is intended only
>             for the use of the individual or entity named above and may
>             contain information that is confidential and privileged and
> the
>             copyright of Intelligent Energy Systems Pty Ltd or a third
>             party. Any views expressed in this e-mail are those of the
>             individual sender, except where the sender specifically states
>             them to be the views of Intelligent Energy Systems Pty Ltd.
>             There is no warranty that this e-mail is error or virus free.
>             If you are not the intended recipient, you must not disclose
> or
>             use the information contained in it. If you have received this
>             e-mail in error, please notify the sender immediately by
> return
>             e-mail and delete the original message.
>             _______________________________________________
>             Coin-discuss mailing list
>             Coin-discuss at list.coin-or.org
>             http://list.coin-or.org/mailman/listinfo/coin-discuss
>
>
>
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-discuss
>




More information about the Coin-discuss mailing list