[Coin-discuss] patch to loadProblem cplex version.
Vivian.DeSmedt at aisystems.be
Vivian.DeSmedt at aisystems.be
Mon Jan 27 11:58:11 EST 2003
Dear Osi,
In order to pass my small test suite. I propose this patch to the
loadProblem version of the Osi cplex interface:
Could someone validate my change and integrate the patch.
Regard,
Vivian.
void
OsiCpxSolverInterface::loadProblem(const int numcols, const int numrows,
const int* start, const int* index,
const double* value,
const double* collb, const double* colub,
const double* obj,
const char* rowsen, const double* rowrhs,
const double* rowrng )
{
const int nc = numcols;
const int nr = numrows;
if( nr == 0 || nc == 0 ) {
// empty LP? -> kill old LP
gutsOfDestructor();
return;
}
assert( rowsen != NULL );
assert( rowrhs != NULL );
int i;
// Set column values to defaults if NULL pointer passed
int * len = new int[nc + 1];
double * clb = new double[nc];
double * cub = new double[nc];
double * ob = new double[nc];
double * rr = new double[nr];
double * rhs = new double[nr];
char * sen = new char[nr];
std::adjacent_difference(start, start + (nc+1), len);
if ( collb != NULL )
CoinDisjointCopyN(collb, nc, clb);
else
CoinFillN(clb, nc, 0.0);
if ( colub!=NULL )
CoinDisjointCopyN(colub, nc, cub);
else
CoinFillN(cub, nc, getInfinity());
if ( obj!=NULL )
CoinDisjointCopyN(obj, nc, ob);
else
CoinFillN(ob, nc, 0.0);
if ( rowrng != NULL ) {
for ( i=0; i<nr; i++ ) {
if (rowsen[i] == 'R') {
if ( rowrng[i] >= 0 ) {
rhs[i] = rowrhs[i] - rowrng[i];
rr[i] = rowrng[i];
} else {
rhs[i] = rowrhs[i];
rr[i] = -rowrng[i];
}
} else {
rhs[i] = rowrhs[i];
rr[i] = 0.0;
}
}
} else {
CoinDisjointCopyN(rowrhs, nr, rhs);
}
CoinDisjointCopyN(rowsen, nr, sen);
int objDirection = CPXgetobjsen( env_, getMutableLpPtr() );
int err = CPXcopylp( env_, getLpPtr(),
nc, nr,
// Leave ObjSense alone(set to current value).
objDirection, ob, rhs, sen,
const_cast<int *>(start),
len + 1, const_cast<int *>(index),
const_cast<double *>(value),
clb, cub, rr);
checkCPXerror( err, "CPXcopylp", "loadProblem" );
delete[] len;
delete[] clb;
delete[] cub;
delete[] ob;
delete[] rr;
delete[] rhs;
delete[] sen;
}
More information about the Coin-discuss
mailing list