本文整理汇总了C++中OsiSolverInterface::getIntParam方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiSolverInterface::getIntParam方法的具体用法?C++ OsiSolverInterface::getIntParam怎么用?C++ OsiSolverInterface::getIntParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiSolverInterface
的用法示例。
在下文中一共展示了OsiSolverInterface::getIntParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
delete ws;
// Resolve.
solver->resolve();
if (!solver->isProvenOptimal()) {
// Become infeasible, can do nothing.
bStatus = -2;
goto TERM_CREATE;
}
else {
// Save new lp solution.
memcpy(saveSolution, solver->getColSolution(),
numCols * sizeof(double));
objValue = solver->getObjSense() * solver->getObjValue();
}
}
else {
delete ws;
break;
}
}
} // EOF 2 pass
//--------------------------------------------------
// If we have a set of first time object,
// branch up and down to initialize pseudo-cost.
//--------------------------------------------------
numFirsts = static_cast<int> (firstObjects.size());
if (numFirsts > 0) {
CoinWarmStart * ws = solver->getWarmStart();
solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit);
int maxIter = ALPS_MAX(model->getAveIterations(), 50);
solver->setIntParam(OsiMaxNumIterationHotStart, maxIter);
solver->markHotStart();
lbInd = new int [numFirsts];
ubInd = new int [numFirsts];
newLB = new double [numFirsts];
newUB = new double [numFirsts];
for (i = 0; i < numFirsts && bStatus != -2; ++i) {
colInd = firstObjects[i]->columnIndex();
lpX = saveSolution[colInd];
BlisStrongBranch(model, objValue, colInd, lpX,
saveLower, saveUpper,
downKeep, downGood, downDeg,
upKeep, upGood, upDeg);
if(!downKeep && !upKeep) {
// Both branch can be fathomed
bStatus = -2;
}
else if (!downKeep) {
// Down branch can be fathomed.
lbInd[numLowerTightens] = colInd;
newLB[numLowerTightens++] = ceil(lpX);
//break;
}
示例2: if
//.........这里部分代码省略.........
else {
// Save new lp solution.
memcpy(saveSolution, solver->getColSolution(),
numCols * sizeof(double));
objValue = solver->getObjSense() * solver->getObjValue();
}
}
else {
delete ws;
break;
}
}
} // EOF 2 pass
//--------------------------------------------------
// If we have a set of first time object,
// branch up and down to initialize pseudo-cost.
//--------------------------------------------------
numFirsts = static_cast<int> (firstObjects.size());
//std::cout << "PSEUDO: numFirsts = " << numFirsts << std::endl;
if (numFirsts > 0) {
//std::cout << "PSEUDO: numFirsts = " << numFirsts << std::endl;
//--------------------------------------------------
// Backup solver status and mark hot start.
//--------------------------------------------------
saveLower = new double[numCols];
saveUpper = new double[numCols];
memcpy(saveLower, lower, numCols * sizeof(double));
memcpy(saveUpper, upper, numCols * sizeof(double));
CoinWarmStart * ws = solver->getWarmStart();
solver->getIntParam(OsiMaxNumIterationHotStart, saveLimit);
aveIterations = ALPS_MIN(50, aveIterations);
solver->setIntParam(OsiMaxNumIterationHotStart, aveIterations);
solver->markHotStart();
lbInd = new int [numFirsts];
ubInd = new int [numFirsts];
newLB = new double [numFirsts];
newUB = new double [numFirsts];
for (i = 0; i < numFirsts && bStatus != -2; ++i) {
colInd = firstObjects[i]->columnIndex();
lpX = saveSolution[colInd];
BlisStrongBranch(model, objValue, colInd, lpX,
saveLower, saveUpper,
downKeep, downGood, downDeg,
upKeep, upGood, upDeg);
if(!downKeep && !upKeep) {
// Both branch can be fathomed
bStatus = -2;
}
else if (!downKeep) {
// Down branch can be fathomed.
lbInd[numLowerTightens] = colInd;
newLB[numLowerTightens++] = ceil(lpX);
}
else if (!upKeep) {
示例3: fixed
/* This is a utility function which does strong branching on
a list of objects and stores the results in OsiHotInfo.objects.
On entry the object sequence is stored in the OsiHotInfo object
and maybe more.
It returns -
-1 - one branch was infeasible both ways
0 - all inspected - nothing can be fixed
1 - all inspected - some can be fixed (returnCriterion==0)
2 - may be returning early - one can be fixed (last one done) (returnCriterion==1)
3 - returning because max time
*/
int
OsiChooseStrong::doStrongBranching( OsiSolverInterface * solver,
OsiBranchingInformation *info,
int numberToDo, int returnCriterion)
{
// Might be faster to extend branch() to return bounds changed
double * saveLower = NULL;
double * saveUpper = NULL;
int numberColumns = solver->getNumCols();
solver->markHotStart();
const double * lower = info->lower_;
const double * upper = info->upper_;
saveLower = CoinCopyOfArray(info->lower_,numberColumns);
saveUpper = CoinCopyOfArray(info->upper_,numberColumns);
numResults_=0;
int returnCode=0;
double timeStart = CoinCpuTime();
for (int iDo=0;iDo<numberToDo;iDo++) {
OsiHotInfo * result = results_ + iDo;
// For now just 2 way
OsiBranchingObject * branch = result->branchingObject();
assert (branch->numberBranches()==2);
/*
Try the first direction. Each subsequent call to branch() performs the
specified branch and advances the branch object state to the next branch
alternative.)
*/
OsiSolverInterface * thisSolver = solver;
if (branch->boundBranch()) {
// ordinary
branch->branch(solver);
// maybe we should check bounds for stupidities here?
solver->solveFromHotStart() ;
} else {
// adding cuts or something
thisSolver = solver->clone();
branch->branch(thisSolver);
// set hot start iterations
int limit;
thisSolver->getIntParam(OsiMaxNumIterationHotStart,limit);
thisSolver->setIntParam(OsiMaxNumIteration,limit);
thisSolver->resolve();
}
// can check if we got solution
// status is 0 finished, 1 infeasible and 2 unfinished and 3 is solution
int status0 = result->updateInformation(thisSolver,info,this);
numberStrongIterations_ += thisSolver->getIterationCount();
if (status0==3) {
// new solution already saved
if (trustStrongForSolution_) {
info->cutoff_ = goodObjectiveValue_;
status0=0;
}
}
if (solver!=thisSolver)
delete thisSolver;
// Restore bounds
for (int j=0;j<numberColumns;j++) {
if (saveLower[j] != lower[j])
solver->setColLower(j,saveLower[j]);
if (saveUpper[j] != upper[j])
solver->setColUpper(j,saveUpper[j]);
}
/*
Try the next direction
*/
thisSolver = solver;
if (branch->boundBranch()) {
// ordinary
branch->branch(solver);
// maybe we should check bounds for stupidities here?
solver->solveFromHotStart() ;
} else {
// adding cuts or something
thisSolver = solver->clone();
branch->branch(thisSolver);
// set hot start iterations
int limit;
thisSolver->getIntParam(OsiMaxNumIterationHotStart,limit);
thisSolver->setIntParam(OsiMaxNumIteration,limit);
thisSolver->resolve();
}
// can check if we got solution
// status is 0 finished, 1 infeasible and 2 unfinished and 3 is solution
int status1 = result->updateInformation(thisSolver,info,this);
numberStrongDone_++;
numberStrongIterations_ += thisSolver->getIterationCount();
if (status1==3) {
//.........这里部分代码省略.........