本文整理汇总了C++中OsiClpSolverInterface::setupForRepeatedUse方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::setupForRepeatedUse方法的具体用法?C++ OsiClpSolverInterface::setupForRepeatedUse怎么用?C++ OsiClpSolverInterface::setupForRepeatedUse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::setupForRepeatedUse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
generator4.setLimit(200);
CglClique generator5;
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
CglMixedIntegerRounding2 mixedGen;
CglFlowCover flowGen;
// Add in generators
// Experiment with -1 and -99 etc
model.addCutGenerator(&generator1,-1,"Probing");
model.addCutGenerator(&generator2,-1,"Gomory");
model.addCutGenerator(&generator3,-1,"Knapsack");
// model.addCutGenerator(&generator4,-1,"RedSplit");
model.addCutGenerator(&generator5,-1,"Clique");
model.addCutGenerator(&flowGen,-1,"FlowCover");
model.addCutGenerator(&mixedGen,-1,"MixedIntegerRounding");
// Say we want timings
int numberGenerators = model.numberCutGenerators();
int iGenerator;
for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
CbcCutGenerator * generator = model.cutGenerator(iGenerator);
generator->setTiming(true);
}
OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
// go faster stripes
if (osiclp) {
// Turn this off if you get problems
// Used to be automatically set
osiclp->setSpecialOptions(128);
if(osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
//osiclp->setupForRepeatedUse(2,0);
osiclp->setupForRepeatedUse(0,0);
}
}
// Uncommenting this should switch off all CBC messages
// model.messagesPointer()->setDetailMessages(10,10000,NULL);
// Allow rounding heuristic
CbcRounding heuristic1(model);
model.addHeuristic(&heuristic1);
// And local search when new solution found
CbcHeuristicLocal heuristic2(model);
model.addHeuristic(&heuristic2);
// Redundant definition of default branching (as Default == User)
CbcBranchUserDecision branch;
model.setBranchingMethod(&branch);
// Definition of node choice
CbcCompareUser compare;
model.setNodeComparison(compare);
// Do initial solve to continuous
model.initialSolve();
// Could tune more
double objValue = model.solver()->getObjSense()*model.solver()->getObjValue();
double minimumDropA=CoinMin(1.0,fabs(objValue)*1.0e-3+1.0e-4);
double minimumDrop= fabs(objValue)*1.0e-4+1.0e-4;
printf("min drop %g (A %g)\n",minimumDrop,minimumDropA);
model.setMinimumDrop(minimumDrop);
示例2: main
//.........这里部分代码省略.........
// try larger limit
generator2.setLimit(300);
CglKnapsackCover generator3;
CglRedSplit generator4;
// try larger limit
generator4.setLimit(200);
CglClique generator5;
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
CglMixedIntegerRounding2 mixedGen;
CglFlowCover flowGen;
// Add in generators
// Experiment with -1 and -99 etc
model.addCutGenerator(&generator1,-1,"Probing");
model.addCutGenerator(&generator2,-1,"Gomory");
model.addCutGenerator(&generator3,-1,"Knapsack");
// model.addCutGenerator(&generator4,-1,"RedSplit");
model.addCutGenerator(&generator5,-1,"Clique");
model.addCutGenerator(&flowGen,-1,"FlowCover");
model.addCutGenerator(&mixedGen,-1,"MixedIntegerRounding");
OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
// go faster stripes
if (osiclp) {
// Turn this off if you get problems
// Used to be automatically set
osiclp->setSpecialOptions(128);
if(osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
//osiclp->setupForRepeatedUse(2,1);
osiclp->setupForRepeatedUse(0,1);
}
}
// Uncommenting this should switch off most CBC messages
//model.messagesPointer()->setDetailMessages(10,5,5000);
// Allow rounding heuristic
CbcRounding heuristic1(model);
model.addHeuristic(&heuristic1);
// And local search when new solution found
CbcHeuristicLocal heuristic2(model);
model.addHeuristic(&heuristic2);
// Redundant definition of default branching (as Default == User)
CbcBranchUserDecision branch;
model.setBranchingMethod(&branch);
// Definition of node choice
CbcCompareUser compare;
model.setNodeComparison(compare);
// Do initial solve to continuous
model.initialSolve();
// Could tune more
double objValue = model.solver()->getObjSense()*model.solver()->getObjValue();
double minimumDropA=CoinMin(1.0,fabs(objValue)*1.0e-3+1.0e-4);
double minimumDrop= fabs(objValue)*1.0e-4+1.0e-4;
printf("min drop %g (A %g)\n",minimumDrop,minimumDropA);
model.setMinimumDrop(minimumDrop);
示例3: main
//.........这里部分代码省略.........
//generator1.setMode(0);
CglGomory generator2;
// try larger limit
generator2.setLimit(300);
CglKnapsackCover generator3;
CglOddHole generator4;
generator4.setMinimumViolation(0.005);
generator4.setMinimumViolationPer(0.00002);
// try larger limit
generator4.setMaximumEntries(200);
CglClique generator5;
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
CglMixedIntegerRounding mixedGen;
CglFlowCover flowGen;
// Add in generators
model.addCutGenerator(&generator1,-1,"Probing");
model.addCutGenerator(&generator2,-1,"Gomory");
model.addCutGenerator(&generator3,-1,"Knapsack");
model.addCutGenerator(&generator4,-1,"OddHole");
model.addCutGenerator(&generator5,-1,"Clique");
model.addCutGenerator(&flowGen,-1,"FlowCover");
model.addCutGenerator(&mixedGen,-1,"MixedIntegerRounding");
OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
// go faster stripes
if (osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
osiclp->setupForRepeatedUse(2,0);
printf("trying slightly less reliable but faster version (? Gomory cuts okay?)\n");
printf("may not be safe if doing cuts in tree which need accuracy (level 2 anyway)\n");
}
// Allow rounding heuristic
CbcRounding heuristic1(model);
model.addHeuristic(&heuristic1);
// And local search when new solution found
CbcHeuristicLocal heuristic2(model);
model.addHeuristic(&heuristic2);
// Redundant definition of default branching (as Default == User)
CbcBranchUserDecision branch;
model.setBranchingMethod(&branch);
// Definition of node choice
CbcCompareUser compare;
model.setNodeComparison(compare);
// Do initial solve to continuous
model.initialSolve();
// Could tune more
model.setMinimumDrop(CoinMin(1.0,
fabs(model.getMinimizationObjValue())*1.0e-3+1.0e-4));
if (model.getNumCols()<500)
model.setMaximumCutPassesAtRoot(-100); // always do 100 if possible
else if (model.getNumCols()<5000)
示例4: main
//.........这里部分代码省略.........
generator5.setStarCliqueReport(false);
generator5.setRowCliqueReport(false);
CglMixedIntegerRounding2 mixedGen;
CglFlowCover flowGen;
// Add in generators
// Experiment with -1 and -99 etc
// This is just for one particular model
model.addCutGenerator(&generator1,-1,"Probing");
//model.addCutGenerator(&generator2,-1,"Gomory");
model.addCutGenerator(&generator2,1,"Gomory");
model.addCutGenerator(&generator3,-1,"Knapsack");
// model.addCutGenerator(&generator4,-1,"RedSplit");
//model.addCutGenerator(&generator5,-1,"Clique");
model.addCutGenerator(&generator5,1,"Clique");
model.addCutGenerator(&flowGen,-1,"FlowCover");
model.addCutGenerator(&mixedGen,-1,"MixedIntegerRounding");
// Add stored cuts (making sure at all depths)
model.addCutGenerator(&stored,1,"Stored",true,false,false,-100,1,-1);
int numberGenerators = model.numberCutGenerators();
int iGenerator;
// Say we want timings
for (iGenerator=0;iGenerator<numberGenerators;iGenerator++) {
CbcCutGenerator * generator = model.cutGenerator(iGenerator);
generator->setTiming(true);
}
OsiClpSolverInterface * osiclp = dynamic_cast< OsiClpSolverInterface*> (model.solver());
// go faster stripes
if (osiclp) {
if(osiclp->getNumRows()<300&&osiclp->getNumCols()<500) {
//osiclp->setupForRepeatedUse(2,0);
osiclp->setupForRepeatedUse(0,0);
}
// Don't allow dual stuff
osiclp->setSpecialOptions(osiclp->specialOptions()|262144);
}
// Uncommenting this should switch off all CBC messages
// model.messagesPointer()->setDetailMessages(10,10000,NULL);
// No heuristics
// Do initial solve to continuous
model.initialSolve();
/* You need the next few lines -
a) so that cut generator will always be called again if it generated cuts
b) it is known that matrix is not enough to define problem so do cuts even
if it looks integer feasible at continuous optimum.
c) a solution found by strong branching will be ignored.
d) don't recompute a solution once found
*/
// Make sure cut generator called correctly (a)
iGenerator=numberGenerators-1;
model.cutGenerator(iGenerator)->setMustCallAgain(true);
// Say cuts needed at continuous (b)
OsiBabSolver oddCuts;
oddCuts.setSolverType(4);
// owing to bug must set after initialSolve
model.passInSolverCharacteristics(&oddCuts);
// Say no to all solutions by strong branching (c)
CbcFeasibilityNoStrong noStrong;
model.setProblemFeasibility(noStrong);
// Say don't recompute solution d)
model.setSpecialOptions(4);
// Could tune more
double objValue = model.solver()->getObjSense()*model.solver()->getObjValue();