// Copyright (C) 2005, International Business Machines // Corporation and others. All Rights Reserved. #if defined(_MSC_VER) // Turn off compiler warning about long names # pragma warning(disable:4786) #endif #include #include // For Branch and bound #include "CbcModel.hpp" #include "CbcBranchActual.hpp" #include "OsiClpSolverInterface.hpp" #include "CoinMpsIO.hpp" // Time #include "CoinTime.hpp" /************************************************************************ This main program reads in an integer model from an mps file. It then tries to find SOS structure *************************************************************************/ int main (int argc, const char *argv[]) { // Define your favorite OsiSolver OsiClpSolverInterface solver1; // Read in model using argv[1] // and assert that it is a clean model std::string mpsFileName = "sos2"; if (argc>=2) mpsFileName = argv[1]; int numMpsReadErrors = solver1.readMps(mpsFileName.c_str(),""); assert(numMpsReadErrors==0); // at present SOS info is not passed correctly so get from mps reader CoinMpsIO m; CoinSet ** sets=NULL; int numberSOS=0; m.readMps(mpsFileName.c_str(),"",numberSOS,sets); CbcModel model(solver1); // Do sets and priorities CbcObject ** objects = new CbcObject * [numberSOS]; // Set up SOS int iSOS; for (iSOS =0;iSOSnumberEntries(),thisSet->which(),NULL,iSOS,thisSet->setType()); } model.addObjects(numberSOS,objects); for (iSOS=0;iSOS2) { int minutes = atoi(argv[2]); std::cout<<"Stopping after "<=0); model.setDblParam(CbcModel::CbcMaximumSeconds,60.0*minutes); } // Switch off most output model.solver()->setHintParam(OsiDoReducePrint,true,OsiHintTry); if (model.getNumCols()<3000) { model.messageHandler()->setLogLevel(1); //model.solver()->messageHandler()->setLogLevel(0); } else { model.messageHandler()->setLogLevel(2); model.solver()->messageHandler()->setLogLevel(1); } model.messageHandler()->setLogLevel(1); double time1 = CoinCpuTime(); // Do complete search model.branchAndBound(); std::cout<getNumCols(); const double * solution = model.solver()->getColSolution(); int iColumn; std::cout<1.0e-7) std::cout<