[Coin-discuss] OsiSolverInterface use and in particular OsiClpSolverInterface

Matthew Saltzman mjs at ces.clemson.edu
Sun Dec 15 18:57:56 EST 2002


On Sun, 15 Dec 2002, Vivian De Smedt wrote:

> Dear Osi,
>
> There is many ways to specify an lp/mip problem through the OsiSolverInterface:
> You can
>   - use one of the many guts of loadProblem,
>   - use readMps api,
>   - add variables using addCol then constraints using addRow,
>   - call addRow then call setObjCoeff, setColLower, setColUpper
>   - call addRow then call setObjCoeff, setColBounds
>   - ...
>
> Some are supported by the OsiSolverInterface interface of some solvers some
> not.
>
> In particular the third one seems to be supported by the implementation of
> at least Cpx, Glpk but not by the Clp (the probleme seems that before
> calling loadProblem the ClpModel class seems not to be initialized leading
> to a casscade of memory access violations.
>
> I temporaly solve the problem by initalizing the instance with a code like:
>
> 	double dEmpty = 0;
> 	int iEmpty = 0;
> 	s->loadProblem(0, 0, &iEmpty, &iEmpty, &dEmpty, &dEmpty, &dEmpty, &dEmpty,
> &dEmpty, &dEmpty);
>
> I will be glad if we could read somewhere the list of methodes to set or
> modify a problem that should be supported by all the interfaces to be able
> to write cross solver code (because for the moment it's nearly impossible
> we need to test the code for each solver, debug it and even write solver
> specific code).

I agree, and we'll get there.  I certainly think that all problem creation
and modification methods should be supported by all solver interfaces, at
least for the problem types they can handle.  For current SIs, that's easy
as they all support MILPs.  Later on, when we get nonlinear SIs, that will
be a bit trickier.

I'll look at this particular one if John Forrest doesn't beat me to it.

> Vivian De Smedt.
>
> PS:
>
> maybe in ClpModel.cpp could we replace
>
> double * resizeDouble(double * array , int size, int newSize, double fill)
> {
>    if (array&&size!=newSize) {
>      int i;
>      double * newArray = new double[newSize];
>      memcpy(newArray,array,min(newSize,size)*sizeof(double));
>      delete [] array;
>      array = newArray;
>      for (i=size;i<newSize;i++)
>        array[i]=fill;
>    }
>    return array;
> }
>
> by:
>
> double * resizeDouble(double * array , int size, int newSize, double fill)
> {
>    if (size!=newSize) {
>      int i;
>      double * newArray = new double[newSize];
>      memcpy(newArray,array,min(newSize,size)*sizeof(double));
>      delete [] array;
>      array = newArray;
>      for (i=size;i<newSize;i++)
>        array[i]=fill;
>    }
>    return array;
> }
>
> to allows deferencing the result of an array that were resized.

The difference here is that in the original code, you can't resize a
nonexistent array.  I'm not sure what the original spec called for, but
that's not completely unreasonable.  In what context is it a problem for
you?

-- 
		Matthew Saltzman

Clemson University Math Sciences
mjs at clemson.edu
http://www.math.clemson.edu/~mjs




More information about the Coin-discuss mailing list