//$Id: //Matthew Galati - magh@lehigh.edu /*-------------------------------------------------------------------------*/ #ifdef _WIN32 #define DLL #endif #include "License.h" #ifdef COIN_USE_XPR #include #include typedef OsiXprSolverInterface OsiXxxSolverInterface; #endif #ifdef COIN_USE_CPX #include typedef OsiCpxSolverInterface OsiXxxSolverInterface; #endif #include using namespace std; void printSolution(OsiXxxSolverInterface* si) { const double * solution = si->getColSolution(); const double objective_value = si->getObjValue(); cout << "\nThe optimal solution is" << endl; for (int i = 0; i < si->getNumCols(); i++) { if (solution[i] != 0) cout << " " << solution[i]; } cout << "\n with objective value = " << objective_value << endl; } /*-------------------------------------------------------------------------*/ int main(int argc, char* argv[]){ getLicense(); try{ OsiXxxSolverInterface* si = new OsiXxxSolverInterface(); si->readMps("fail"); si->initialSolve(); printSolution(si); for (int i = 0; i < si->getNumCols(); i++) { si->setInteger(i); } si->branchAndBound(); printSolution(si); si->initialSolve(); printSolution(si); delete si; } catch(CoinError & ex){ cerr << "Exception:" << ex.message() << endl << " from method " << ex.methodName() << endl << " from class " << ex.className() << endl; }; return 0; }