本文整理汇总了C++中OsiClpSolverInterface::specialOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::specialOptions方法的具体用法?C++ OsiClpSolverInterface::specialOptions怎么用?C++ OsiClpSolverInterface::specialOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::specialOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CbcSubProblem
// inner part of dive
int
CbcHeuristicDive::solution(double & solutionValue, int & numberNodes,
int & numberCuts, OsiRowCut ** cuts,
CbcSubProblem ** & nodes,
double * newSolution)
{
#ifdef DIVE_DEBUG
int nRoundInfeasible = 0;
int nRoundFeasible = 0;
#endif
int reasonToStop = 0;
double time1 = CoinCpuTime();
int numberSimplexIterations = 0;
int maxSimplexIterations = (model_->getNodeCount()) ? maxSimplexIterations_
: maxSimplexIterationsAtRoot_;
// but can't be exactly coin_int_max
maxSimplexIterations = CoinMin(maxSimplexIterations,COIN_INT_MAX>>3);
OsiSolverInterface * solver = cloneBut(6); // was model_->solver()->clone();
# ifdef COIN_HAS_CLP
OsiClpSolverInterface * clpSolver
= dynamic_cast<OsiClpSolverInterface *> (solver);
if (clpSolver) {
ClpSimplex * clpSimplex = clpSolver->getModelPtr();
int oneSolveIts = clpSimplex->maximumIterations();
oneSolveIts = CoinMin(1000+2*(clpSimplex->numberRows()+clpSimplex->numberColumns()),oneSolveIts);
clpSimplex->setMaximumIterations(oneSolveIts);
if (!nodes) {
// say give up easily
clpSimplex->setMoreSpecialOptions(clpSimplex->moreSpecialOptions() | 64);
} else {
// get ray
int specialOptions = clpSimplex->specialOptions();
specialOptions &= ~0x3100000;
specialOptions |= 32;
clpSimplex->setSpecialOptions(specialOptions);
clpSolver->setSpecialOptions(clpSolver->specialOptions() | 1048576);
if ((model_->moreSpecialOptions()&16777216)!=0) {
// cutoff is constraint
clpSolver->setDblParam(OsiDualObjectiveLimit, COIN_DBL_MAX);
}
}
}
# endif
const double * lower = solver->getColLower();
const double * upper = solver->getColUpper();
const double * rowLower = solver->getRowLower();
const double * rowUpper = solver->getRowUpper();
const double * solution = solver->getColSolution();
const double * objective = solver->getObjCoefficients();
double integerTolerance = model_->getDblParam(CbcModel::CbcIntegerTolerance);
double primalTolerance;
solver->getDblParam(OsiPrimalTolerance, primalTolerance);
int numberRows = matrix_.getNumRows();
assert (numberRows <= solver->getNumRows());
int numberIntegers = model_->numberIntegers();
const int * integerVariable = model_->integerVariable();
double direction = solver->getObjSense(); // 1 for min, -1 for max
double newSolutionValue = direction * solver->getObjValue();
int returnCode = 0;
// Column copy
const double * element = matrix_.getElements();
const int * row = matrix_.getIndices();
const CoinBigIndex * columnStart = matrix_.getVectorStarts();
const int * columnLength = matrix_.getVectorLengths();
#ifdef DIVE_FIX_BINARY_VARIABLES
// Row copy
const double * elementByRow = matrixByRow_.getElements();
const int * column = matrixByRow_.getIndices();
const CoinBigIndex * rowStart = matrixByRow_.getVectorStarts();
const int * rowLength = matrixByRow_.getVectorLengths();
#endif
// Get solution array for heuristic solution
int numberColumns = solver->getNumCols();
memcpy(newSolution, solution, numberColumns*sizeof(double));
// vectors to store the latest variables fixed at their bounds
int* columnFixed = new int [numberIntegers];
double* originalBound = new double [numberIntegers+2*numberColumns];
double * lowerBefore = originalBound+numberIntegers;
double * upperBefore = lowerBefore+numberColumns;
memcpy(lowerBefore,lower,numberColumns*sizeof(double));
memcpy(upperBefore,upper,numberColumns*sizeof(double));
double * lastDjs=newSolution+numberColumns;
bool * fixedAtLowerBound = new bool [numberIntegers];
PseudoReducedCost * candidate = new PseudoReducedCost [numberIntegers];
double * random = new double [numberIntegers];
int maxNumberAtBoundToFix = static_cast<int> (floor(percentageToFix_ * numberIntegers));
assert (!maxNumberAtBoundToFix||!nodes);
// count how many fractional variables
int numberFractionalVariables = 0;
for (int i = 0; i < numberIntegers; i++) {
random[i] = randomNumberGenerator_.randomDouble() + 0.3;
int iColumn = integerVariable[i];
double value = newSolution[iColumn];
if (fabs(floor(value + 0.5) - value) > integerTolerance) {
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
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();
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);