[Osi] OsiCpx writeLp not working
Matthew Galati
magh at lehigh.edu
Mon Jun 2 14:16:11 EDT 2008
Note - this happens after a call to addCols because I changed to
KEEPCACHED_ALL.
However, if I switch back to KEEPCACHED_ROW, getObjCoefficients works,
but I am back to getColSolution fails with Cplex Error 1217.
> It looks like the problem is related to the actual OsiCpx implementation.
>
> Notice, if obj_ is non null, it does not get the new objective vector.
> That means, if a column is added, it does not get the new information.
> This is obviously not good. Ticket #62 added.
>
> //------------------------------------------------------------------
> const double * OsiCpxSolverInterface::getObjCoefficients() const
> {
> debugMessage("OsiCpxSolverInterface::getObjCoefficients()\n");
>
> if ( obj_==NULL )
> {
> int ncols = CPXgetnumcols( env_, getMutableLpPtr() );
> if( ncols > 0 )
> {
> obj_ = new double[ncols];
> int err = CPXgetobj( env_, getMutableLpPtr(), obj_, 0,
> ncols-1 );
> checkCPXerror( err, "CPXgetobj", "getObjCoefficients" );
> }
> }
> return obj_;
> }
>
>
>
>> There seems to be a bigger problem at hand here.
>>
>> I start out with 5 columns in an OsiCpx object.
>>
>> If I use the base class Osi::getObjValue( ) after adding a column, I
>> get the correct number of columns, but junk back from
>> getObjCoefficients( ) and getColSolution( )
>>
>> MVG inside OsiSolverInterface nc = 6
>> OsiCpxSolverInterface::getObjCoefficients()
>> OsiCpxSolverInterface::getColSolution()
>> OsiCpxSolverInterface::getDblParam(4)
>> objOffset = 0
>> MVG getObjValue i:0, retVal: -0, objCo: -15 colSol: 0
>> MVG getObjValue i:1, retVal: -2.44186, objCo: -15 colSol: 0.162791
>> MVG getObjValue i:2, retVal: -10.1163, objCo: -15 colSol: 0.511628
>> MVG getObjValue i:3, retVal: -12.5581, objCo: -15 colSol: 0.162791
>> MVG getObjValue i:4, retVal: -12.5581, objCo: -15 colSol: 0
>> MVG getObjValue i:5, retVal: -12.5581, objCo: 1.56391e-311 colSol:
>> 7.20064e-313
>> OsiCpxSolverInterface::getNumCols()
>> MVG inside OsiSolverInterface nc = 6
>>
>>
>>> If I addCols to my OsiCpx object -- it correctly keeps the
>>> information in memory, however when I call writeLp it calls the
>>> native Osi writer and does not seem to have my new columns - it only
>>> has the original problem. I assume this once again has something to
>>> do with cached information.
>>>
>>> One quick fix suggestion -- use Cpx's native LP writer just like we
>>> do for MPS. This is suggested in ticket 61.
>>>
>>> void OsiCpxSolverInterface::writeLp(const char *filename,
>>> const char *extension,
>>> double epsilon,
>>> int numberAcross,
>>> int decimals,
>>> double objSense,
>>> bool useRowNames) const
>>> {
>>> debugMessage("OsiCpxSolverInterface::writeLp(%s, %s, %g)\n",
>>> filename, extens\
>>> ion, objSense);
>>>
>>> // *FIXME* : this will not output ctype information to the MPS file
>>> char filetype[4] = "LP";
>>> std::string f(filename);
>>> std::string e(extension);
>>> std::string fullname = f + "." + e;
>>> int err = CPXwriteprob( env_, getMutableLpPtr(),
>>> const_cast<char*>( fullname.\
>>> c_str() ), filetype );
>>> checkCPXerror( err, "CPXwriteprob", "writeLp" );
>>> }
>>>
>>>
>>> _______________________________________________
>>> Osi mailing list
>>> Osi at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/osi
>>>
>>
>
More information about the Osi
mailing list