[Coin-discuss] OsiSolverInterface use and in particular OsiClpSolverInterface
Vivian De Smedt
vivian at vdesmedt.com
Sun Dec 15 12:53:55 EST 2002
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).
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.
More information about the Coin-discuss
mailing list