// Copyright (C) 2002, 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 "CbcOrClpParam.hpp" #include #include #include #ifdef COIN_HAS_CBC #ifdef COIN_HAS_CLP #include "OsiClpSolverInterface.hpp" #include "ClpSimplex.hpp" #endif #include "CbcModel.hpp" #endif #include "CoinHelperFunctions.hpp" #ifdef COIN_HAS_CLP #include "ClpSimplex.hpp" #include "ClpFactorization.hpp" #endif #ifdef COIN_HAS_READLINE #include #include #endif #ifdef COIN_HAS_CBC // from CoinSolve static char coin_prompt[]="Coin:"; #else static char coin_prompt[]="Clp:"; #endif static bool doPrinting=true; std::string afterEquals=""; void setCbcOrClpPrinting(bool yesNo) { doPrinting=yesNo; } //############################################################################# // Constructors / Destructor / Assignment //############################################################################# //------------------------------------------------------------------- // Default Constructor //------------------------------------------------------------------- CbcOrClpParam::CbcOrClpParam () : type_(INVALID), lowerDoubleValue_(0.0), upperDoubleValue_(0.0), lowerIntValue_(0), upperIntValue_(0), lengthName_(0), lengthMatch_(0), definedKeyWords_(), name_(), shortHelp_(), longHelp_(), action_(INVALID), currentKeyWord_(-1), display_(false), intValue_(-1), doubleValue_(-1.0), stringValue_(""), whereUsed_(7) { } // Other constructors CbcOrClpParam::CbcOrClpParam (std::string name, std::string help, double lower, double upper, CbcOrClpParameterType type, bool display) : type_(type), lowerIntValue_(0), upperIntValue_(0), definedKeyWords_(), name_(name), shortHelp_(help), longHelp_(), action_(type), currentKeyWord_(-1), display_(display), intValue_(-1), doubleValue_(-1.0), stringValue_(""), whereUsed_(7) { lowerDoubleValue_ = lower; upperDoubleValue_ = upper; gutsOfConstructor(); } CbcOrClpParam::CbcOrClpParam (std::string name, std::string help, int lower, int upper, CbcOrClpParameterType type, bool display) : type_(type), lowerDoubleValue_(0.0), upperDoubleValue_(0.0), definedKeyWords_(), name_(name), shortHelp_(help), longHelp_(), action_(type), currentKeyWord_(-1), display_(display), intValue_(-1), doubleValue_(-1.0), stringValue_(""), whereUsed_(7) { gutsOfConstructor(); lowerIntValue_ = lower; upperIntValue_ = upper; } // Other strings will be added by append CbcOrClpParam::CbcOrClpParam (std::string name, std::string help, std::string firstValue, CbcOrClpParameterType type,int whereUsed, bool display) : type_(type), lowerDoubleValue_(0.0), upperDoubleValue_(0.0), lowerIntValue_(0), upperIntValue_(0), definedKeyWords_(), name_(name), shortHelp_(help), longHelp_(), action_(type), currentKeyWord_(0), display_(display), intValue_(-1), doubleValue_(-1.0), stringValue_(""), whereUsed_(whereUsed) { gutsOfConstructor(); definedKeyWords_.push_back(firstValue); } // Action CbcOrClpParam::CbcOrClpParam (std::string name, std::string help, CbcOrClpParameterType type,int whereUsed, bool display) : type_(type), lowerDoubleValue_(0.0), upperDoubleValue_(0.0), lowerIntValue_(0), upperIntValue_(0), definedKeyWords_(), name_(name), shortHelp_(help), longHelp_(), action_(type), currentKeyWord_(-1), display_(display), intValue_(-1), doubleValue_(-1.0), stringValue_("") { whereUsed_=whereUsed; gutsOfConstructor(); } //------------------------------------------------------------------- // Copy constructor //------------------------------------------------------------------- CbcOrClpParam::CbcOrClpParam (const CbcOrClpParam & rhs) { type_ = rhs.type_; lowerDoubleValue_ = rhs.lowerDoubleValue_; upperDoubleValue_ = rhs.upperDoubleValue_; lowerIntValue_ = rhs.lowerIntValue_; upperIntValue_ = rhs.upperIntValue_; lengthName_ = rhs.lengthName_; lengthMatch_ = rhs.lengthMatch_; definedKeyWords_ = rhs.definedKeyWords_; name_ = rhs.name_; shortHelp_ = rhs.shortHelp_; longHelp_ = rhs.longHelp_; action_ = rhs.action_; currentKeyWord_ = rhs.currentKeyWord_; display_=rhs.display_; intValue_=rhs.intValue_; doubleValue_=rhs.doubleValue_; stringValue_=rhs.stringValue_; whereUsed_=rhs.whereUsed_; } //------------------------------------------------------------------- // Destructor //------------------------------------------------------------------- CbcOrClpParam::~CbcOrClpParam () { } //---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- CbcOrClpParam & CbcOrClpParam::operator=(const CbcOrClpParam& rhs) { if (this != &rhs) { type_ = rhs.type_; lowerDoubleValue_ = rhs.lowerDoubleValue_; upperDoubleValue_ = rhs.upperDoubleValue_; lowerIntValue_ = rhs.lowerIntValue_; upperIntValue_ = rhs.upperIntValue_; lengthName_ = rhs.lengthName_; lengthMatch_ = rhs.lengthMatch_; definedKeyWords_ = rhs.definedKeyWords_; name_ = rhs.name_; shortHelp_ = rhs.shortHelp_; longHelp_ = rhs.longHelp_; action_ = rhs.action_; currentKeyWord_ = rhs.currentKeyWord_; display_=rhs.display_; intValue_=rhs.intValue_; doubleValue_=rhs.doubleValue_; stringValue_=rhs.stringValue_; whereUsed_=rhs.whereUsed_; } return *this; } void CbcOrClpParam::gutsOfConstructor() { std::string::size_type shriekPos = name_.find('!'); lengthName_ = name_.length(); if ( shriekPos==std::string::npos ) { //does not contain '!' lengthMatch_= lengthName_; } else { lengthMatch_=shriekPos; name_ = name_.substr(0,shriekPos)+name_.substr(shriekPos+1); lengthName_--; } } // Insert string (only valid for keywords) void CbcOrClpParam::append(std::string keyWord) { definedKeyWords_.push_back(keyWord); } int CbcOrClpParam::matches (std::string input) const { // look up strings to do more elegantly if (input.length()>lengthName_) { return 0; } else { unsigned int i; for (i=0;i=lengthMatch_) { return 1; } else { // matched but too short return 2; } } } // Returns name which could match std::string CbcOrClpParam::matchName ( ) const { if (lengthMatch_==lengthName_) return name_; else return name_.substr(0,lengthMatch_)+"("+name_.substr(lengthMatch_)+")"; } // Returns parameter option which matches (-1 if none) int CbcOrClpParam::parameterOption ( std::string check ) const { int numberItems = definedKeyWords_.size(); if (!numberItems) { return -1; } else { int whichItem=0; unsigned int it; for (it=0;it=length2) { break; } } else { whichItem++; } } if (whichItem=0&¤tKeyWord_<(int)definedKeyWords_.size()); std::string current = definedKeyWords_[currentKeyWord_]; std::string::size_type shriekPos = current.find('!'); if ( shriekPos!=std::string::npos ) { //contains '!' current = current.substr(0,shriekPos)+ "("+current.substr(shriekPos+1)+")"; } std::cout<<";\n\tcurrent "<"<=65&&input[i]==' ') { temp[n]='\0'; std::cout<=1&&type_<400) { CoinReadPrintit(longHelp_.c_str()); if (type_\n",lowerDoubleValue_,upperDoubleValue_, doubleValue_); assert (upperDoubleValue_>lowerDoubleValue_); } else if (type_\n",lowerIntValue_,upperIntValue_,intValue_); assert (upperIntValue_>lowerIntValue_); } else if (type_upperDoubleValue_) { std::cout<getDblParam(OsiDualTolerance,oldValue); model->setDblParam(OsiDualTolerance,value); break; case PRIMALTOLERANCE: model->getDblParam(OsiPrimalTolerance,oldValue); model->setDblParam(OsiPrimalTolerance,value); break; default: break; } if (doPrinting) std::cout<upperDoubleValue_) { std::cout<setDualTolerance(value); break; case PRIMALTOLERANCE: model->setPrimalTolerance(value); break; #endif case DUALBOUND: model->setDualBound(value); break; case PRIMALWEIGHT: model->setInfeasibilityCost(value); break; #ifndef COIN_HAS_CBC case TIMELIMIT: model->setMaximumSeconds(value); break; #endif case OBJSCALE: model->setObjectiveScale(value); break; case RHSSCALE: model->setRhsScale(value); break; case PRESOLVETOLERANCE: model->setDblParam(ClpPresolveTolerance,value); break; default: break; } return 0; } } double CbcOrClpParam::doubleParameter (ClpSimplex * model) const { double value; switch(type_) { #ifndef COIN_HAS_CBC case DUALTOLERANCE: value=model->dualTolerance(); break; case PRIMALTOLERANCE: value=model->primalTolerance(); break; #endif case DUALBOUND: value=model->dualBound(); break; case PRIMALWEIGHT: value=model->infeasibilityCost(); break; #ifndef COIN_HAS_CBC case TIMELIMIT: value=model->maximumSeconds(); break; #endif case OBJSCALE: value=model->objectiveScale(); break; case RHSSCALE: value=model->rhsScale(); break; default: value=doubleValue_; break; } return value; } int CbcOrClpParam::setIntParameter (ClpSimplex * model,int value) { int oldValue = intValue_; if (valueupperIntValue_) { std::cout<setLogLevel(value); if (value>2) model->factorization()->messageLevel(8); else model->factorization()->messageLevel(0); break; case MAXFACTOR: model->factorization()->maximumPivots(value); break; case PERTVALUE: model->setPerturbation(value); break; case MAXITERATION: model->setMaximumIterations(value); break; case SPECIALOPTIONS: model->setSpecialOptions(value); #ifdef COIN_HAS_CBC case THREADS: model->setNumberThreads(value); break; #endif default: break; } return 0; } } int CbcOrClpParam::intParameter (ClpSimplex * model) const { int value; switch(type_) { #ifndef COIN_HAS_CBC case SOLVERLOGLEVEL: value=model->logLevel(); break; #endif case MAXFACTOR: value=model->factorization()->maximumPivots(); break; break; case PERTVALUE: value=model->perturbation(); break; case MAXITERATION: value=model->maximumIterations(); break; case SPECIALOPTIONS: value=model->specialOptions(); break; #ifndef COIN_HAS_CBC case THREADS: value = model->numberThreads(); #endif default: value=intValue_; break; } return value; } #endif int CbcOrClpParam::checkDoubleParameter (double value) const { if (valueupperDoubleValue_) { std::cout<getDblParam(OsiDualTolerance,value)); break; case PRIMALTOLERANCE: assert(model->getDblParam(OsiPrimalTolerance,value)); break; default: return doubleValue_; break; } return value; } int CbcOrClpParam::setIntParameter (OsiSolverInterface * model,int value) { if (valueupperIntValue_) { std::cout<messageHandler()->setLogLevel(value); break; default: break; } if (doPrinting) std::cout<messageHandler()->logLevel(); break; default: value=intValue_; break; } return value; } int CbcOrClpParam::setDoubleParameter (CbcModel &model,double value) { if (valueupperDoubleValue_) { std::cout< (model.solver()); //ClpSimplex * lpSolver = clpSolver->getModelPtr(); //lpSolver->setMaximumSeconds(value); model.setDblParam(CbcModel::CbcMaximumSeconds,value) ; } break ; case DUALTOLERANCE: case PRIMALTOLERANCE: setDoubleParameter(model.solver(),value); return 0; // to avoid message default: break; } if (doPrinting) std::cout<upperIntValue_) { std::cout<logLevel(); model.messageHandler()->setLogLevel(CoinAbs(value)); break; case SOLVERLOGLEVEL: oldValue = model.solver()->messageHandler()->logLevel(); model.solver()->messageHandler()->setLogLevel(value); break; case MAXNODES: oldValue=model.getIntParam(CbcModel::CbcMaxNumNode); model.setIntParam(CbcModel::CbcMaxNumNode,value); break; case MAXSOLS: oldValue=model.getIntParam(CbcModel::CbcMaxNumSol); model.setIntParam(CbcModel::CbcMaxNumSol,value); break; case STRONGBRANCHING: oldValue=model.numberStrong(); model.setNumberStrong(value); break; case NUMBERBEFORE: oldValue=model.numberBeforeTrust(); model.setNumberBeforeTrust(value); break; case NUMBERANALYZE: oldValue=model.numberAnalyzeIterations(); model.setNumberAnalyzeIterations(value); break; case NUMBERMINI: oldValue=model.sizeMiniTree(); model.setSizeMiniTree(value); break; case CUTPASSINTREE: oldValue=model.getMaximumCutPasses(); model.setMaximumCutPasses(value); break; case CUTPASS: oldValue=model.getMaximumCutPassesAtRoot(); model.setMaximumCutPassesAtRoot(value); break; #ifdef COIN_HAS_CBC #ifdef CBC_THREAD case THREADS: oldValue=model.getNumberThreads(); model.setNumberThreads(value); break; #endif #endif default: break; } if (doPrinting) std::cout<logLevel(); break; case SOLVERLOGLEVEL: value = model.solver()->messageHandler()->logLevel(); break; case MAXNODES: value = model.getIntParam(CbcModel::CbcMaxNumNode); break; case MAXSOLS: value = model.getIntParam(CbcModel::CbcMaxNumSol); break; case STRONGBRANCHING: value=model.numberStrong(); break; case NUMBERBEFORE: value=model.numberBeforeTrust(); break; case NUMBERANALYZE: value=model.numberAnalyzeIterations(); break; case NUMBERMINI: value=model.sizeMiniTree(); break; case CUTPASSINTREE: value=model.getMaximumCutPasses(); break; case CUTPASS: value=model.getMaximumCutPassesAtRoot(); break; #ifdef COIN_HAS_CBC #ifdef CBC_THREAD case THREADS: value = model.getNumberThreads(); #endif #endif default: value=intValue_; break; } return value; } #endif // Sets current parameter option using string void CbcOrClpParam::setCurrentOption ( const std::string value ) { int action = parameterOption(value); if (action>=0) currentKeyWord_=action; } // Sets current parameter option void CbcOrClpParam::setCurrentOption ( int value , bool printIt) { if (printIt&&value!=currentKeyWord_) std::cout<<"Option for "<upperIntValue_) { std::cout<upperDoubleValue_) { std::cout<0) { if (CbcOrClpRead_mode0) { if (CbcOrClpRead_mode0) { if (CbcOrClpRead_mode0) { if (CbcOrClpRead_mode 0 to do n passes." ); #endif parameters[numberParameters++]= CbcOrClpParam("import","Import model from mps file", IMPORT,3); parameters[numberParameters-1].setLonghelp ( "This will read an MPS format file from the given file name. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to '', i.e. it must be set. If you have libgz then it can read compressed\ files 'xxxxxxxx.gz'.." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("inc!rement","A valid solution must be at least this \ much better than last integer solution", -1.0e20,1.0e20,INCREMENT); parameters[numberParameters-1].setLonghelp ( "Whenever a solution is found the bound on solutions is set to solution (in a minimization\ sense) plus this. If it is not set then the code will try and work one out e.g. if \ all objective coefficients are multiples of 0.01 and only integer variables have entries in \ objective then this can be set to 0.01. Be careful if you set this negative!" ); parameters[numberParameters++]= CbcOrClpParam("inf!easibilityWeight","Each integer infeasibility is expected \ to cost this much", 0.0,1.0e20,INFEASIBILITYWEIGHT); parameters[numberParameters-1].setLonghelp ( "A primitive way of deciding which node to explore next. Satisfying each integer infeasibility is \ expected to cost this much." ); parameters[numberParameters++]= CbcOrClpParam("initialS!olve","Solve to continuous", SOLVECONTINUOUS); parameters[numberParameters-1].setLonghelp ( "This just solves the problem to continuous - without adding any cuts" ); parameters[numberParameters++]= CbcOrClpParam("integerT!olerance","For an optimal solution \ no integer variable may be this away from an integer value", 1.0e-20,0.5,INTEGERTOLERANCE); parameters[numberParameters-1].setLonghelp ( "Beware of setting this smaller than the primal tolerance." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("keepN!ames","Whether to keep names from import", "on",KEEPNAMES); parameters[numberParameters-1].append("off"); parameters[numberParameters-1].setLonghelp ( "It saves space to get rid of names so if you need to you can set this to off. \ This needs to be set before the import of model - so -keepnames off -import xxxxx.mps." ); parameters[numberParameters++]= CbcOrClpParam("KKT","Whether to use KKT factorization", "off",KKT,7,false); parameters[numberParameters-1].append("on"); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("knapsack!Cuts","Whether to use Knapsack cuts", "off",KNAPSACKCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "This switches on knapsack cuts (either at root or in entire tree) \ See branchAndCut for information on options." ); parameters[numberParameters++]= CbcOrClpParam("lift!AndProjectCuts","Whether to use Lift and Project cuts", "off",LANDPCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "Lift and project cuts - may be expensive to compute. \ See branchAndCut for information on options." ); parameters[numberParameters++]= CbcOrClpParam("local!TreeSearch","Whether to use local treesearch", "off",LOCALTREE); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setLonghelp ( "This switches on a local search algorithm when a solution is found. This is from \ Fischetti and Lodi and is not really a heuristic although it can be used as one. \ When used from Coin solve it has limited functionality. It is not switched on when \ heuristics are switched on." ); #endif #ifndef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("log!Level","Level of detail in Solver output", -1,63,SOLVERLOGLEVEL); #else parameters[numberParameters++]= CbcOrClpParam("log!Level","Level of detail in Coin branch and Cut output", -63,63,LOGLEVEL); parameters[numberParameters-1].setIntValue(1); #endif parameters[numberParameters-1].setLonghelp ( "If 0 then there should be no output in normal circumstances. 1 is probably the best\ value for most uses, while 2 and 3 give more information." ); parameters[numberParameters++]= CbcOrClpParam("max!imize","Set optimization direction to maximize", MAXIMIZE,7); parameters[numberParameters-1].setLonghelp ( "The default is minimize - use 'maximize' for maximization.\n\ You can also use the parameters 'direction maximize'." ); #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("maxF!actor","Maximum number of iterations between \ refactorizations", 1,999999,MAXFACTOR); parameters[numberParameters-1].setLonghelp ( "If this is at its initial value of 200 then in this executable clp will guess at a\ value to use. Otherwise the user can set a value. The code may decide to re-factorize\ earlier for accuracy." ); parameters[numberParameters++]= CbcOrClpParam("maxIt!erations","Maximum number of iterations before \ stopping", 0,2147483647,MAXITERATION); parameters[numberParameters-1].setLonghelp ( "This can be used for testing purposes. The corresponding library call\n\ \tsetMaximumIterations(value)\n can be useful. If the code stops on\ seconds or by an interrupt this will be treated as stopping on maximum iterations" ); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("maxN!odes","Maximum number of nodes to do", -1,2147483647,MAXNODES); parameters[numberParameters-1].setLonghelp ( "This is a repeatable way to limit search. Normally using time is easier \ but then the results may not be repeatable." ); parameters[numberParameters++]= CbcOrClpParam("maxS!olutions","Maximum number of solutions to get", 1,2147483647,MAXSOLS); parameters[numberParameters-1].setLonghelp ( "You may want to stop after (say) two solutions or an hour." ); #endif parameters[numberParameters++]= CbcOrClpParam("min!imize","Set optimization direction to minimize", MINIMIZE,7); parameters[numberParameters-1].setLonghelp ( "The default is minimize - use 'maximize' for maximization.\n\ This should only be necessary if you have previously set maximization \ You can also use the parameters 'direction minimize'." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("mipO!ptions","Dubious options for mip", 0,COIN_INT_MAX,MIPOPTIONS,false); parameters[numberParameters++]= CbcOrClpParam("more!MipOptions","More dubious options for mip", -1,COIN_INT_MAX,MOREMIPOPTIONS,false); parameters[numberParameters++]= CbcOrClpParam("mixed!IntegerRoundingCuts","Whether to use Mixed Integer Rounding cuts", "off",MIXEDCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "This switches on mixed integer rounding cuts (either at root or in entire tree) \ See branchAndCut for information on options." ); #endif parameters[numberParameters++]= CbcOrClpParam("mess!ages","Controls if Clpnnnn is printed", "off",MESSAGES); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setLonghelp ("The default behavior is to put out messages such as:\n\ Clp0005 2261 Objective 109.024 Primal infeas 944413 (758)\n\ but this program turns this off to make it look more friendly. It can be useful\ to turn them back on if you want to be able to 'grep' for particular messages or if\ you intend to override the behavior of a particular message." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("miniT!ree","Size of fast mini tree", 0,COIN_INT_MAX,NUMBERMINI,false); parameters[numberParameters-1].setLonghelp ( "The idea is that I can do a small tree fast. \ This is a first try and will hopefully become more sophisticated." ); parameters[numberParameters++]= CbcOrClpParam("miplib","Do some of miplib test set", MIPLIB,3); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("netlib","Solve entire netlib test set", NETLIB_EITHER,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp and then solves the netlib test set using dual or primal.\ The user can set options before e.g. clp -presolve off -netlib" ); #ifdef REAL_BARRIER parameters[numberParameters++]= CbcOrClpParam("netlibB!arrier","Solve entire netlib test set with barrier", NETLIB_BARRIER,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp and then solves the netlib test set using barrier.\ The user can set options before e.g. clp -kkt on -netlib" ); #endif parameters[numberParameters++]= CbcOrClpParam("netlibD!ual","Solve entire netlib test set (dual)", NETLIB_DUAL,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp and then solves the netlib test set using dual.\ The user can set options before e.g. clp -presolve off -netlib" ); parameters[numberParameters++]= CbcOrClpParam("netlibP!rimal","Solve entire netlib test set (primal)", NETLIB_PRIMAL,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp and then solves the netlib test set using primal.\ The user can set options before e.g. clp -presolve off -netlibp" ); parameters[numberParameters++]= CbcOrClpParam("netlibT!une","Solve entire netlib test set with 'best' algorithm", NETLIB_TUNE,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp and then solves the netlib test set using whatever \ works best. I know this is cheating but it also stresses the code better by doing a \ mixture of stuff. The best algorithm was chosen on a Linux ThinkPad using native cholesky \ with University of Florida ordering." ); parameters[numberParameters++]= CbcOrClpParam("network","Tries to make network matrix", NETWORK,7,false); parameters[numberParameters-1].setLonghelp ( "Clp will go faster if the matrix can be converted to a network. The matrix\ operations may be a bit faster with more efficient storage, but the main advantage\ comes from using a network factorization. It will probably not be as fast as a \ specialized network code." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("node!Strategy","What strategy to use to select nodes", "hybrid",NODESTRATEGY); parameters[numberParameters-1].append("fewest"); parameters[numberParameters-1].append("depth"); parameters[numberParameters-1].append("upfewest"); parameters[numberParameters-1].append("downfewest"); parameters[numberParameters-1].append("updepth"); parameters[numberParameters-1].append("downdepth"); parameters[numberParameters-1].setLonghelp ( "Normally before a solution the code will choose node with fewest infeasibilities. \ You can choose depth as the criterion. You can also say if up or down branch must \ be done first (the up down choice will carry on after solution). \ Default has now been changed to hybrid which is breadth first on small depth nodes then fewest." ); parameters[numberParameters++]= CbcOrClpParam("numberA!nalyze","Number of analysis iterations", -COIN_INT_MAX,COIN_INT_MAX,NUMBERANALYZE,false); parameters[numberParameters-1].setLonghelp ( "This says how many iterations to spend at root node analyzing problem. \ This is a first try and will hopefully become more sophisticated." ); #endif parameters[numberParameters++]= CbcOrClpParam("objective!Scale","Scale factor to apply to objective", -1.0e20,1.0e20,OBJSCALE,false); parameters[numberParameters-1].setLonghelp ( "If the objective function has some very large values, you may wish to scale them\ internally by this amount. It can also be set by autoscale. It is applied after scaling" ); parameters[numberParameters-1].setDoubleValue(1.0); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("outDup!licates","takes duplicate rows etc out of integer model", OUTDUPROWS,7,false); #endif parameters[numberParameters++]= CbcOrClpParam("output!Format","Which output format to use", 1,6,OUTPUTFORMAT); parameters[numberParameters-1].setLonghelp ( "Normally export will be done using normal representation for numbers and two values\ per line. You may want to do just one per line (for grep or suchlike) and you may wish\ to save with absolute accuracy using a coded version of the IEEE value. A value of 2 is normal.\ otherwise odd values gives one value per line, even two. Values 1,2 give normal format, 3,4\ gives greater precision, while 5,6 give IEEE values. When used for exporting a basis 1 does not save \ values, 2 saves values, 3 with greater accuracy and 4 in IEEE." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("passC!uts","Number of cut passes at root node", -999999,999999,CUTPASS); parameters[numberParameters-1].setLonghelp ( "The default is 100 passes if less than 500 columns, 100 passes (but \ stop if drop small if less than 5000 columns, 20 otherwise" ); parameters[numberParameters++]= CbcOrClpParam("passF!easibilityPump","How many passes in feasibility pump", 0,10000,FPUMPITS); parameters[numberParameters-1].setLonghelp ( "This fine tunes Feasibility Pump by doing more or fewer passes." ); parameters[numberParameters-1].setIntValue(20); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("passP!resolve","How many passes in presolve", -200,100,PRESOLVEPASS,false); parameters[numberParameters-1].setLonghelp ( "Normally Presolve does 5 passes but you may want to do less to make it\ more lightweight or do more if improvements are still being made. As Presolve will return\ if nothing is being taken out, you should not normally need to use this fine tuning." ); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("passT!reeCuts","Number of cut passes in tree", -999999,999999,CUTPASSINTREE); parameters[numberParameters-1].setLonghelp ( "The default is one pass" ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("pertV!alue","Method of perturbation", -5000,102,PERTVALUE,false); parameters[numberParameters++]= CbcOrClpParam("perturb!ation","Whether to perturb problem", "on",PERTURBATION); parameters[numberParameters-1].append("off"); parameters[numberParameters-1].setLonghelp ( "Perturbation helps to stop cycling, but Clp uses other measures for this.\ However large problems and especially ones with unit elements and unit rhs or costs\ benefit from perturbation. Normally Clp tries to be intelligent, but you can switch this off.\ The Clp library has this off by default. This program has it on by default." ); parameters[numberParameters++]= CbcOrClpParam("PFI","Whether to use Product Form of Inverse in simplex", "off",PFI,7,false); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setLonghelp ( "By default clp uses Forrest-Tomlin L-U update. If you are masochistic you can switch it off." ); parameters[numberParameters++]= CbcOrClpParam("plus!Minus","Tries to make +- 1 matrix", PLUSMINUS,7,false); parameters[numberParameters-1].setLonghelp ( "Clp will go slightly faster if the matrix can be converted so that the elements are\ not stored and are known to be unit. The main advantage is memory use. Clp may automatically\ see if it can convert the problem so you should not need to use this." ); parameters[numberParameters++]= CbcOrClpParam("pO!ptions","Dubious print options", 0,COIN_INT_MAX,PRINTOPTIONS,false); parameters[numberParameters-1].setIntValue(0); parameters[numberParameters-1].setLonghelp ( "If this is > 0 then presolve will give more information and branch and cut will give statistics" ); parameters[numberParameters++]= CbcOrClpParam("preO!pt","Presolve options", 0,COIN_INT_MAX,PRESOLVEOPTIONS,false); #endif parameters[numberParameters++]= CbcOrClpParam("presolve","Whether to presolve problem", "on",PRESOLVE); parameters[numberParameters-1].append("off"); parameters[numberParameters-1].append("more"); parameters[numberParameters-1].append("file"); parameters[numberParameters-1].setLonghelp ( "Presolve analyzes the model to find such things as redundant equations, equations\ which fix some variables, equations which can be transformed into bounds etc etc. For the\ initial solve of any problem this is worth doing unless you know that it will have no effect. \ on will normally do 5 passes while using 'more' will do 10. If the problem is very large you may need \ to write the original to file using 'file'." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("preprocess","Whether to use integer preprocessing", "off",PREPROCESS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("save"); parameters[numberParameters-1].append("equal"); parameters[numberParameters-1].append("sos"); parameters[numberParameters-1].append("trysos"); parameters[numberParameters-1].append("equalall"); parameters[numberParameters-1].append("strategy"); parameters[numberParameters-1].append("aggregate"); parameters[numberParameters-1].setLonghelp ( "This tries to reduce size of model in a similar way to presolve and \ it also tries to strengthen the model - this can be very useful and is worth trying. \ Save option saves on file presolved.mps. equal will turn <= cliques into \ ==. sos will create sos sets if all 0-1 in sets (well one extra is allowed) \ and no overlaps. trysos is same but allows any number extra. equalall will turn all \ valid inequalities into equalities with integer slacks. strategy is as \ on but uses CbcStrategy." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("preT!olerance","Tolerance to use in presolve", 1.0e-20,1.0e12,PRESOLVETOLERANCE); parameters[numberParameters-1].setLonghelp ( "The default is 1.0e-8 - you may wish to try 1.0e-7 if presolve says the problem is \ infeasible and you have awkward numbers and you are sure the problem is really feasible." ); parameters[numberParameters++]= CbcOrClpParam("primalP!ivot","Primal pivot choice algorithm", "auto!matic",PRIMALPIVOT); parameters[numberParameters-1].append("exa!ct"); parameters[numberParameters-1].append("dant!zig"); parameters[numberParameters-1].append("part!ial"); parameters[numberParameters-1].append("steep!est"); parameters[numberParameters-1].append("change"); parameters[numberParameters-1].append("sprint"); parameters[numberParameters-1].setLonghelp ( "Clp can use any pivot selection algorithm which the user codes as long as it\ implements the features in the abstract pivot base class. The Dantzig method is implemented\ to show a simple method but its use is deprecated. Exact devex is the method of choice and there\ are two variants which keep all weights updated but only scan a subset each iteration.\ Partial switches this on while change initially does dantzig until the factorization\ becomes denser. This is still a work in progress." ); parameters[numberParameters++]= CbcOrClpParam("primalS!implex","Do primal simplex algorithm", PRIMALSIMPLEX); parameters[numberParameters-1].setLonghelp ( "This command solves the current model using the primal algorithm.\ The default is to use exact devex.\ The time and iterations may be affected by settings such as presolve, scaling, crash\ and also by column selection method, infeasibility weight and dual and primal tolerances." ); #endif parameters[numberParameters++]= CbcOrClpParam("primalT!olerance","For an optimal solution \ no primal infeasibility may exceed this value", 1.0e-20,1.0e12,PRIMALTOLERANCE); parameters[numberParameters-1].setLonghelp ( "Normally the default tolerance is fine, but you may want to increase it a\ bit if a primal run seems to be having a hard time" ); #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("primalW!eight","Initially algorithm acts as if it \ costs this much to be infeasible", 1.0e-20,1.0e20,PRIMALWEIGHT); parameters[numberParameters-1].setLonghelp ( "The primal algorithm in Clp is a single phase algorithm as opposed to a two phase\ algorithm where you first get feasible then optimal. So Clp is minimizing this weight times\ the sum of primal infeasibilities plus the true objective function (in minimization sense).\ Too high a value may mean more iterations, while too low a bound means\ the code may go all the way and then have to increase the weight in order to get feasible.\ OSL had a heuristic to\ adjust bounds, maybe we need that here." ); #endif parameters[numberParameters++]= CbcOrClpParam("printi!ngOptions","Print options", "normal",INTPRINT,3); parameters[numberParameters-1].append("integer"); parameters[numberParameters-1].append("special"); parameters[numberParameters-1].append("rows"); parameters[numberParameters-1].append("all"); parameters[numberParameters-1].setLonghelp ( "This changes the amount and format of printing a solution:\nnormal - nonzero column variables \n\ integer - nonzero integer column variables\n\ special - in format suitable for OsiRowCutDebugger\n\ rows - nonzero column variables and row activities\n\ all - all column variables and row activities.\n\ \nFor non-integer problems 'integer' and 'special' act like 'normal'. \ Also see printMask for controlling output." ); parameters[numberParameters++]= CbcOrClpParam("printM!ask","Control printing of solution on a mask", PRINTMASK,3); parameters[numberParameters-1].setLonghelp ( "If set then only those names which match mask are printed in a solution. \ '?' matches any character and '*' matches any set of characters. \ The default is '' i.e. unset so all variables are printed. \ This is only active if model has names." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("prio!rityIn","Import priorities etc from file", PRIORITYIN,3); parameters[numberParameters-1].setLonghelp ( "This will read a file with priorities from the given file name. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to '', i.e. it must be set. This can not read from compressed files. \ File is in csv format with allowed headings - name, number, priority, direction, up, down, solution. Exactly one of\ name and number must be given." ); parameters[numberParameters++]= CbcOrClpParam("probing!Cuts","Whether to use Probing cuts", "off",PROBINGCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].append("forceOnBut"); parameters[numberParameters-1].append("forceOnStrong"); parameters[numberParameters-1].append("forceOnButStrong"); parameters[numberParameters-1].setLonghelp ( "This switches on probing cuts (either at root or in entire tree) \ See branchAndCut for information on options. \ but strong options do more probing" ); parameters[numberParameters++]= CbcOrClpParam("pumpT!une","Dubious ideas for feasibility pump", 0,100000000,FPUMPTUNE); parameters[numberParameters-1].setLonghelp ( "This fine tunes Feasibility Pump \n\ \t>=1000000 use as accumulate switch\n\ \t>=1000 use index+1 as number of large loops\n\ \t>=100 use 0.05 objvalue as increment\n\ \t>=10 use +0.1 objvalue for cutoff (add)\n\ \t1 == fix ints at bounds, 2 fix all integral ints, 3 and continuous at bounds" ); parameters[numberParameters-1].setIntValue(0); #endif parameters[numberParameters++]= CbcOrClpParam("quit","Stops clp execution", EXIT); parameters[numberParameters-1].setLonghelp ( "This stops the execution of Clp, end, exit, quit and stop are synonyms" ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("ratio!Gap","Stop when gap between best possible and \ best less than this fraction of larger of two", 0.0,1.0e20,GAPRATIO); parameters[numberParameters-1].setDoubleValue(0.0); parameters[numberParameters-1].setLonghelp ( "If the gap between best solution and best possible solution is less than this fraction \ of the objective value at the root node then the search will terminate. See 'allowableGap' for a \ way of using absolute value rather than fraction." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("reallyO!bjectiveScale","Scale factor to apply to objective in place", -1.0e20,1.0e20,OBJSCALE2,false); parameters[numberParameters-1].setLonghelp ( "You can set this to -1.0 to test maximization or other to stress code" ); parameters[numberParameters-1].setDoubleValue(1.0); parameters[numberParameters++]= CbcOrClpParam("reallyS!cale","Scales model in place", REALLY_SCALE,7,false); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("reduce!AndSplitCuts","Whether to use Reduce-and-Split cuts", "off",REDSPLITCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "This switches on reduce and split cuts (either at root or in entire tree) \ See branchAndCut for information on options." ); parameters[numberParameters++]= CbcOrClpParam("residual!CapacityCuts","Whether to use Residual Capacity cuts", "off",RESIDCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "Residual capacity cuts. \ See branchAndCut for information on options." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("restore!Model","Restore model from binary file", RESTORE); parameters[numberParameters-1].setLonghelp ( "This reads data save by saveModel from the given file. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to 'default.prob'." ); parameters[numberParameters++]= CbcOrClpParam("reverse","Reverses sign of objective", REVERSE,7,false); parameters[numberParameters-1].setLonghelp ( "Useful for testing if maximization works correctly" ); parameters[numberParameters++]= CbcOrClpParam("rhs!Scale","Scale factor to apply to rhs and bounds", -1.0e20,1.0e20,RHSSCALE,false); parameters[numberParameters-1].setLonghelp ( "If the rhs or bounds have some very large meaningful values, you may wish to scale them\ internally by this amount. It can also be set by autoscale" ); parameters[numberParameters-1].setDoubleValue(1.0); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("Rins","Whether to try Relaxed Induced Neighborhood Search", "off",RINS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setLonghelp ( "This switches on Relaxed induced neighborhood Search." ); parameters[numberParameters++]= CbcOrClpParam("round!ingHeuristic","Whether to use Rounding heuristic", "off",ROUNDING); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("do"); parameters[numberParameters-1].setLonghelp ( "This switches on a simple (but effective) rounding heuristic at each node of tree. \ The Do option switches on before preprocessing." ); #endif parameters[numberParameters++]= CbcOrClpParam("saveM!odel","Save model to binary file", SAVE); parameters[numberParameters-1].setLonghelp ( "This will save the problem to the given file name for future use\ by restoreModel. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to 'default.prob'." ); parameters[numberParameters++]= CbcOrClpParam("saveS!olution","saves solution to file", SAVESOL); parameters[numberParameters-1].setLonghelp ( "This will write a binary solution file to the given file name. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to 'solution.file'. To read the file use fread(int) twice to pick up number of rows \ and columns, then fread(double) to pick up objective value, then pick up row activities, row duals, column \ activities and reduced costs - see bottom of CbcOrClpParam.cpp for code that reads or writes file. \ If name contains '_fix_read_' then does not write but reads and will fix all variables" ); parameters[numberParameters++]= CbcOrClpParam("scal!ing","Whether to scale problem", "off",SCALING); parameters[numberParameters-1].append("equi!librium"); parameters[numberParameters-1].append("geo!metric"); parameters[numberParameters-1].append("auto!matic"); parameters[numberParameters-1].setLonghelp ( "Scaling can help in solving problems which might otherwise fail because of lack of\ accuracy. It can also reduce the number of iterations. It is not applied if the range\ of elements is small. When unscaled it is possible that there may be small primal and/or\ infeasibilities." ); parameters[numberParameters-1].setCurrentOption(3); // say auto #ifndef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("sec!onds","Maximum seconds", -1.0,1.0e12,TIMELIMIT); parameters[numberParameters-1].setLonghelp ( "After this many seconds clp will act as if maximum iterations had been reached \ (if value >=0). \ In this program it is really only useful for testing but the library function\n\ \tsetMaximumSeconds(value)\n can be useful." ); #else parameters[numberParameters++]= CbcOrClpParam("sec!onds","maximum seconds", -1.0,1.0e12,TIMELIMIT_BAB); parameters[numberParameters-1].setLonghelp ( "After this many seconds coin solver will act as if maximum nodes had been reached." ); #endif parameters[numberParameters++]= CbcOrClpParam("sleep","for debug", DUMMY,7,false); parameters[numberParameters-1].setLonghelp ( "If passed to solver fom ampl, then ampl will wait so that you can copy .nl file for debug." ); #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("slp!Value","Number of slp passes before primal", -1,50000,SLPVALUE,false); parameters[numberParameters-1].setLonghelp ( "If you are solving a quadratic problem using primal then it may be helpful to do some \ sequential Lps to get a good approximate solution." ); #endif parameters[numberParameters++]= CbcOrClpParam("solu!tion","Prints solution to file", SOLUTION); parameters[numberParameters-1].setLonghelp ( "This will write a primitive solution file to the given file name. It will use the default\ directory given by 'directory'. A name of '$' will use the previous value for the name. This\ is initialized to 'stdout'. The amount of output can be varied using printi!ngOptions or printMask." ); #ifdef COIN_HAS_CLP #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("solv!e","Solve problem", BAB); parameters[numberParameters-1].setLonghelp ( "If there are no integer variables then this just solves LP. If there are integer variables \ this does branch and cut." ); parameters[numberParameters++]= CbcOrClpParam("sos!Options","Whether to use SOS from AMPL", "off",SOS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setCurrentOption("on"); parameters[numberParameters-1].setLonghelp ( "Normally if AMPL says there are SOS variables they should be used, but sometime sthey should\ be turned off - this does so." ); parameters[numberParameters++]= CbcOrClpParam("slog!Level","Level of detail in Solver output", -1,63,SOLVERLOGLEVEL); parameters[numberParameters-1].setLonghelp ( "If 0 then there should be no output in normal circumstances. 1 is probably the best\ value for most uses, while 2 and 3 give more information." ); #else // allow solve as synonym for dual parameters[numberParameters++]= CbcOrClpParam("solv!e","Solve problem using dual simplex", BAB); parameters[numberParameters-1].setLonghelp ( "Just so can use solve for clp as well as in cbc" ); #endif #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("spars!eFactor","Whether factorization treated as sparse", "on",SPARSEFACTOR,7,false); parameters[numberParameters-1].append("off"); parameters[numberParameters++]= CbcOrClpParam("special!Options","Dubious options for Simplex - see ClpSimplex.hpp", 0,COIN_INT_MAX,SPECIALOPTIONS,false); parameters[numberParameters++]= CbcOrClpParam("sprint!Crash","Whether to try sprint crash", -1,5000000,SPRINT); parameters[numberParameters-1].setLonghelp ( "For long and thin problems this program may solve a series of small problems\ created by taking a subset of the columns. I introduced the idea as 'Sprint' after\ an LP code of that name of the 60's which tried the same tactic (not totally successfully).\ Cplex calls it 'sifting'. -1 is automatic choice, 0 is off, n is number of passes" ); parameters[numberParameters++]= CbcOrClpParam("stat!istics","Print some statistics", STATISTICS); parameters[numberParameters-1].setLonghelp ( "This command prints some statistics for the current model.\ If log level >1 then more is printed.\ These are for presolved model if presolve on (and unscaled)." ); #endif parameters[numberParameters++]= CbcOrClpParam("stop","Stops clp execution", EXIT); parameters[numberParameters-1].setLonghelp ( "This stops the execution of Clp, end, exit, quit and stop are synonyms" ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("strengthen","Create strengthened problem", STRENGTHEN,3); parameters[numberParameters-1].setLonghelp ( "This creates a new problem by applying the root node cuts. All tight constraints \ will be in resulting problem" ); parameters[numberParameters++]= CbcOrClpParam("strong!Branching","Number of variables to look at in strong branching", 0,999999,STRONGBRANCHING); parameters[numberParameters-1].setLonghelp ( "In order to decide which variable to branch on, the code will choose up to this number \ of unsatisfied variables to do mini up and down branches on. Then the most effective one is chosen. \ If a variable is branched on many times then the previous average up and down costs may be used - \ see number before trust." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("subs!titution","How long a column to substitute for in presolve", 0,10000,SUBSTITUTION,false); parameters[numberParameters-1].setLonghelp ( "Normally Presolve gets rid of 'free' variables when there are no more than 3 \ variables in column. If you increase this the number of rows may decrease but number of \ elements may increase." ); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("testO!si","Test OsiObject stuff", -1,COIN_INT_MAX,TESTOSI,false); #endif #ifdef CBC_THREAD parameters[numberParameters++]= CbcOrClpParam("thread!s","Number of threads to try and use", -100,10000,THREADS,false); parameters[numberParameters-1].setLonghelp ( "To use multiple threads, set threads to number wanted. It may be better \ to use one or two more than number of cpus available. If 100+n then n threads and \ threads used in sub-trees, if 200+n use threads for root cuts, 300+n - both." ); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("tighten!Factor","Tighten bounds using this times largest \ activity at continuous solution", 1.0e-3,1.0e20,TIGHTENFACTOR,false); parameters[numberParameters-1].setLonghelp ( "This sleazy trick can help on some problems." ); #endif #ifdef COIN_HAS_CLP parameters[numberParameters++]= CbcOrClpParam("tightLP","Poor person's preSolve for now", TIGHTEN,7,false); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("trust!PseudoCosts","Number of branches before we trust pseudocosts", -1,2000000,NUMBERBEFORE); parameters[numberParameters-1].setLonghelp ( "Using strong branching computes pseudo-costs. After this many times for a variable we just \ trust the pseudo costs and do not do any more strong branching." ); #endif #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("tune!PreProcess","Dubious tuning parameters", 0,20000000,PROCESSTUNE,false); parameters[numberParameters-1].setLonghelp ( "For making equality cliques this is minimumsize. Also for adding \ integer slacks. May be used for more later \ If <1000 that is what it does. If <1000000 - numberPasses is (value/1000)-1 and tune is tune %1000. \ If >= 1000000! - numberPasses is (value/1000000)-1 and tune is tune %1000000. In this case if tune is now still >=10000 \ numberPassesPerInnerLoop is changed from 10 to (tune-10000)-1 and tune becomes tune % 10000!!!!! - happy? - \ so to keep normal limit on cliques of 5, do 3 major passes (include presolves) but only doing one tightening pass per major pass - \ you would use 3010005 (I think)" ); parameters[numberParameters++]= CbcOrClpParam("two!MirCuts","Whether to use Two phase Mixed Integer Rounding cuts", "off",TWOMIRCUTS); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].append("root"); parameters[numberParameters-1].append("ifmove"); parameters[numberParameters-1].append("forceOn"); parameters[numberParameters-1].setLonghelp ( "This switches on two phase mixed integer rounding cuts (either at root or in entire tree) \ See branchAndCut for information on options." ); #endif parameters[numberParameters++]= CbcOrClpParam("unitTest","Do unit test", UNITTEST,3); parameters[numberParameters-1].setLonghelp ( "This exercises the unit test for clp" ); parameters[numberParameters++]= CbcOrClpParam("userClp","Hand coded Clp stuff", USERCLP); parameters[numberParameters-1].setLonghelp ( "There are times e.g. when using AMPL interface when you may wish to do something unusual. \ Look for USERCLP in main driver and modify sample code." ); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("userCbc","Hand coded Cbc stuff", USERCBC); parameters[numberParameters-1].setLonghelp ( "There are times e.g. when using AMPL interface when you may wish to do something unusual. \ Look for USERCBC in main driver and modify sample code." ); #endif parameters[numberParameters++]= CbcOrClpParam("vector","Whether to use vector? Form of matrix in simplex", "off",VECTOR,7,false); parameters[numberParameters-1].append("on"); parameters[numberParameters-1].setLonghelp ( "If this is on and ClpPackedMatrix uses extra column copy in odd format." ); parameters[numberParameters++]= CbcOrClpParam("verbose","Switches on longer help on single ?", 0,15,VERBOSE,false); parameters[numberParameters-1].setLonghelp ( "Set to 1 to get short help with ? list, 2 to get long help, 3 for both. (add 4 to just get ampl ones)." ); parameters[numberParameters-1].setIntValue(0); #ifdef COIN_HAS_CBC parameters[numberParameters++]= CbcOrClpParam("vub!heuristic","Type of vub heuristic", -2,20,VUBTRY,false); parameters[numberParameters-1].setLonghelp ( "If set will try and fix some integer variables" ); parameters[numberParameters-1].setIntValue(-1); #endif assert(numberParametersnumberRows(); int numberColumns=lpSolver->numberColumns(); int numberRowsFile; int numberColumnsFile; double objectiveValue; fread(&numberRowsFile,sizeof(int),1,fp); fread(&numberColumnsFile,sizeof(int),1,fp); fread(&objectiveValue,sizeof(double),1,fp); double * dualRowSolution = lpSolver->dualRowSolution(); double * primalRowSolution = lpSolver->primalRowSolution(); double * dualColumnSolution = lpSolver->dualColumnSolution(); double * primalColumnSolution = lpSolver->primalColumnSolution(); if (mode) { // swap int k=numberRows; numberRows=numberColumns; numberColumns=k; double * temp; temp = dualRowSolution; dualRowSolution = primalColumnSolution; primalColumnSolution=temp; temp = dualColumnSolution; dualColumnSolution = primalRowSolution; primalRowSolution=temp; } if (numberRows>numberRowsFile||numberColumns>numberColumnsFile) { std::cout<<"Mismatch on rows and/or columns - giving up"<setObjectiveValue(objectiveValue); if (numberRows==numberRowsFile&&numberColumns==numberColumnsFile) { fread(primalRowSolution,sizeof(double),numberRows,fp); fread(dualRowSolution,sizeof(double),numberRows,fp); fread(primalColumnSolution,sizeof(double),numberColumns,fp); fread(dualColumnSolution,sizeof(double),numberColumns,fp); } else { std::cout<<"Mismatch on rows and/or columns - truncating"<(lpSolver); restoreSolution(solver,fileName,0); // fix all int logLevel=solver->logLevel(); int iColumn; int numberColumns=solver->numberColumns(); double * primalColumnSolution = solver->primalColumnSolution(); double * columnLower = solver->columnLower(); double * columnUpper = solver->columnUpper(); for (iColumn=0;iColumncolumnUpper[iColumn]) { if (value >columnUpper[iColumn]+1.0e-6&&logLevel>1) printf("%d value of %g - bounds %g %g\n", iColumn,value,columnLower[iColumn],columnUpper[iColumn]); value=columnUpper[iColumn]; } else if (value1) printf("%d value of %g - bounds %g %g\n", iColumn,value,columnLower[iColumn],columnUpper[iColumn]); value=columnLower[iColumn]; } columnLower[iColumn]=value; columnUpper[iColumn]=value; } return; } } FILE * fp=fopen(fileName.c_str(),"wb"); if (fp) { int numberRows=lpSolver->numberRows(); int numberColumns=lpSolver->numberColumns(); double objectiveValue = lpSolver->objectiveValue(); fwrite(&numberRows,sizeof(int),1,fp); fwrite(&numberColumns,sizeof(int),1,fp); fwrite(&objectiveValue,sizeof(double),1,fp); double * dualRowSolution = lpSolver->dualRowSolution(); double * primalRowSolution = lpSolver->primalRowSolution(); fwrite(primalRowSolution,sizeof(double),numberRows,fp); fwrite(dualRowSolution,sizeof(double),numberRows,fp); double * dualColumnSolution = lpSolver->dualColumnSolution(); double * primalColumnSolution = lpSolver->primalColumnSolution(); fwrite(primalColumnSolution,sizeof(double),numberColumns,fp); fwrite(dualColumnSolution,sizeof(double),numberColumns,fp); fclose(fp); } else { std::cout<<"Unable to open file "<