[Coin-lpsolver] Calling resolve() when simplex interface is enabled

Mikhail Nediak nediakm at math.mcmaster.ca
Tue Apr 22 14:33:13 EDT 2003


Hi,

I have a question: should one expect to be able to call resolve() when
simplex interface is enabled? Right now, it seems that the call itself
may go through but something gets corrupted. I have attached a small
example that illustrates the problem (looks like Segmentation Fault in
one of the destructors). If the line 33 is commented in, the problem
disappears. When an overhead of enable/disable operations is significant
(and it could be), it is probably better to allow resolve() while in
enabled state. Any comments from community?

Best,
Mikhail Nediak
-------------- next part --------------
#include "OsiSolverInterface.hpp"
#include "OsiClpSolverInterface.hpp"
#include <iostream>

using namespace std;

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();

  cout << "Solving initial model:" << endl;
  initialModel.initialSolve();
  cout << initialModel.getIterationCount() 
       << " simplex iterations." << endl << endl;

  OsiSimplexInterface *si = dynamic_cast<OsiSimplexInterface*>(&initialModel);
  int* cstat = new int[nc + nr];
  int* rstat = new int[nr];
  cout << "Extracting optimal basis:" << endl;
  si->enableSimplexInterface(true);
  si->getBasisStatus(cstat, cstat + nc);
  CoinFillN(rstat, nr, (int)CoinWarmStartBasis::atLowerBound);

  cout << "Applying optimal basis to a copy of initial model:" << endl;
  OsiClpSolverInterface copyOfInitialModel(initialModel);
  si = dynamic_cast<OsiSimplexInterface*>(&copyOfInitialModel);
  si->enableSimplexInterface(true);
  si->setBasisStatus(cstat, cstat + nc);
  //si->disableSimplexInterface();
  cout << "Running resolve() on a copy to test:" << endl;
  copyOfInitialModel.resolve();
  cout << copyOfInitialModel.getIterationCount() 
       << " simplex iterations." << endl << endl;

  delete[] cstat;
  delete[] rstat;
  return 0;
}


More information about the Clp mailing list