[Coin-lpsolver] OsiSimplexInterface behavior for Clp

Mikhail Nediak nediakm at math.mcmaster.ca
Thu Apr 10 17:04:01 EDT 2003


Hi,

I am trying a transformation of LP which would convert all constraints
into equalities and row activities into regular structural variables (see
the attached code). In this case, if we have a (let's suppose, feasible)
basis for the original problem, then we can transform, almost trivially,
and apply it to the second problem. I have attempted to do this with
set/getBasisStatus functions of OsiSimplexInterface. However,
setBasisStatus causes

osiclp1: ClpNonLinearCost.cpp:410: void
ClpNonLinearCost::checkInfeasibilities(bool): Assertion
`fabs(value-upperValue)<=primalTolerance*1.0001' failed.

If I understand correctly, this happens because row activity tolerance and
the tolerance for structural variables are different.
So I was wondering what would be the best way to correct this situation.
Changing tolerances could be a solution but only if basis does stay
feasible (one may want some different transformation). I could try to just
comment out the assert but I am not sure if the rest of the code will work
(assert was there to bail out of a strange situation, right?). Finally,
should the solver care at all about basis feasibility when it is in the
"OsiSimplexInerface enabled" mode? My expectation was that user takes over
the responsibility of tracking the feasibility after OsiSimplexInerface
was enabled.

Please advise.

Best regards,
Mikhail Nediak


-------------- next part --------------
#include "OsiSolverInterface.hpp"
#include "OsiClpSolverInterface.hpp"

int main(int argc, char* argv[])
{
  if (argc < 2) return -1;
  OsiClpSolverInterface initialModel;
  initialModel.readMps(argv[1],"mps");
  int nr = initialModel.getNumRows();
  int nc = initialModel.getNumCols();
  double *l = new double[nc + nr];
  double *u = new double[nc + nr];
  CoinCopyN(initialModel.getColLower(), nc, l);
  CoinCopyN(initialModel.getColUpper(), nc, u);
  CoinCopyN(initialModel.getRowLower(), nr, l + nc);
  CoinCopyN(initialModel.getRowUpper(), nr, u + nc);
  CoinPackedMatrix mat(*(initialModel.getMatrixByCol()));
  int row;
  for (row = 0; row < nr; row++) {
    int index = row;
    double value = -1;
    mat.appendCol(1, &index, &value);
  }
  double* zeros = new double[nr];
  CoinFillN(zeros, nr, 0.0);
  OsiClpSolverInterface modifiedModel;
  modifiedModel.loadProblem(mat, l, u, initialModel.getObjCoefficients(),
			    zeros, zeros);

  initialModel.initialSolve();
  OsiSimplexInterface *si = dynamic_cast<OsiSimplexInterface*>(&initialModel);
  int* cstat = new int[nc + nr];
  int* rstat = new int[nr];
  si->enableSimplexInterface(true);
  si->getBasisStatus(cstat, cstat + nc);
  CoinFillN(rstat, nr, (int)CoinWarmStartBasis::atLowerBound);

  si = dynamic_cast<OsiSimplexInterface*>(&modifiedModel);
  si->enableSimplexInterface(true);
  si->setBasisStatus(cstat, rstat);

  return 0;
}


More information about the Clp mailing list