本文整理汇总了C++中OsiSolverInterface::getHintParam方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiSolverInterface::getHintParam方法的具体用法?C++ OsiSolverInterface::getHintParam怎么用?C++ OsiSolverInterface::getHintParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiSolverInterface
的用法示例。
在下文中一共展示了OsiSolverInterface::getHintParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoinMax
// Infeasibility - large is 0.5
double
CbcGeneralDepth::infeasibility(const OsiBranchingInformation * /*info*/,
int &/*preferredWay*/) const
{
whichSolution_ = -1;
// should use genuine OsiBranchingInformation usefulInfo = model_->usefulInformation();
// for now assume only called when correct
//if (usefulInfo.depth_>=4&&!model_->parentModel()
// &&(usefulInfo.depth_%2)==0) {
if (true) {
OsiSolverInterface * solver = model_->solver();
OsiClpSolverInterface * clpSolver
= dynamic_cast<OsiClpSolverInterface *> (solver);
if (clpSolver) {
if ((model_->moreSpecialOptions()&33554432)==0) {
ClpNodeStuff * info = nodeInfo_;
info->integerTolerance_ = model_->getIntegerTolerance();
info->integerIncrement_ = model_->getCutoffIncrement();
info->numberBeforeTrust_ = model_->numberBeforeTrust();
info->stateOfSearch_ = model_->stateOfSearch();
// Compute "small" change in branch
int nBranches = model_->getIntParam(CbcModel::CbcNumberBranches);
if (nBranches) {
double average = model_->getDblParam(CbcModel::CbcSumChange) / static_cast<double>(nBranches);
info->smallChange_ =
CoinMax(average * 1.0e-5, model_->getDblParam(CbcModel::CbcSmallestChange));
info->smallChange_ = CoinMax(info->smallChange_, 1.0e-8);
} else {
info->smallChange_ = 1.0e-8;
}
int numberIntegers = model_->numberIntegers();
double * down = new double[numberIntegers];
double * up = new double[numberIntegers];
int * priority = new int[numberIntegers];
int * numberDown = new int[numberIntegers];
int * numberUp = new int[numberIntegers];
int * numberDownInfeasible = new int[numberIntegers];
int * numberUpInfeasible = new int[numberIntegers];
model_->fillPseudoCosts(down, up, priority, numberDown, numberUp,
numberDownInfeasible, numberUpInfeasible);
info->fillPseudoCosts(down, up, priority, numberDown, numberUp,
numberDownInfeasible,
numberUpInfeasible, numberIntegers);
info->presolveType_ = 1;
delete [] down;
delete [] up;
delete [] numberDown;
delete [] numberUp;
delete [] numberDownInfeasible;
delete [] numberUpInfeasible;
bool takeHint;
OsiHintStrength strength;
solver->getHintParam(OsiDoReducePrint, takeHint, strength);
ClpSimplex * simplex = clpSolver->getModelPtr();
int saveLevel = simplex->logLevel();
if (strength != OsiHintIgnore && takeHint && saveLevel == 1)
simplex->setLogLevel(0);
clpSolver->setBasis();
whichSolution_ = simplex->fathomMany(info);
//printf("FAT %d nodes, %d iterations\n",
//info->numberNodesExplored_,info->numberIterations_);
//printf("CbcBranch %d rows, %d columns\n",clpSolver->getNumRows(),
// clpSolver->getNumCols());
model_->incrementExtra(info->numberNodesExplored_,
info->numberIterations_);
// update pseudo costs
double smallest = 1.0e50;
double largest = -1.0;
OsiObject ** objects = model_->objects();
#ifndef NDEBUG
const int * integerVariable = model_->integerVariable();
#endif
for (int i = 0; i < numberIntegers; i++) {
#ifndef NDEBUG
CbcSimpleIntegerDynamicPseudoCost * obj =
dynamic_cast <CbcSimpleIntegerDynamicPseudoCost *>(objects[i]) ;
assert (obj && obj->columnNumber() == integerVariable[i]);
#else
CbcSimpleIntegerDynamicPseudoCost * obj =
static_cast <CbcSimpleIntegerDynamicPseudoCost *>(objects[i]) ;
#endif
if (info->numberUp_[i] > 0) {
if (info->downPseudo_[i] > largest)
largest = info->downPseudo_[i];
if (info->downPseudo_[i] < smallest)
smallest = info->downPseudo_[i];
if (info->upPseudo_[i] > largest)
largest = info->upPseudo_[i];
if (info->upPseudo_[i] < smallest)
smallest = info->upPseudo_[i];
obj->updateAfterMini(info->numberDown_[i],
info->numberDownInfeasible_[i],
info->downPseudo_[i],
info->numberUp_[i],
info->numberUpInfeasible_[i],
info->upPseudo_[i]);
}
}
//printf("range of costs %g to %g\n",smallest,largest);
//.........这里部分代码省略.........
示例2: generateCuts
//-----------------------------------------------------------------------------
// Generate LSGFC cuts
//-------------------------------------------------------------------
void CglFlowCover::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
const CglTreeInfo info) const
{
static int count=0;
if (getMaxNumCuts() <= 0) return;
if (getNumFlowCuts() >= getMaxNumCuts()) return;
++count;
#if 0
bool preInit = false;
bool preReso = false;
si.getHintParam(OsiDoPresolveInInitial, preInit);
si.getHintParam(OsiDoPresolveInResolve, preReso);
if (preInit == false && preReso == false) { // Do once
if (doneInitPre_ == false) {
flowPreprocess(si);
doneInitPre_ = true;
}
}
else
#endif
int numberRowCutsBefore = cs.sizeRowCuts();
flowPreprocess(si);
CoinPackedMatrix matrixByRow(*si.getMatrixByRow());
const char* sense = si.getRowSense();
const double* rhs = si.getRightHandSide();
const double* elementByRow = matrixByRow.getElements();
const int* colInd = matrixByRow.getIndices();
const CoinBigIndex* rowStart = matrixByRow.getVectorStarts();
const int* rowLength = matrixByRow.getVectorLengths();
int* ind = 0;
double* coef = 0;
int iRow, iCol;
CglFlowRowType rType;
for (iRow = 0; iRow < numRows_; ++iRow) {
rType = getRowType(iRow);
if( ( rType != CGLFLOW_ROW_MIXUB ) &&
( rType != CGLFLOW_ROW_MIXEQ ) &&
( rType != CGLFLOW_ROW_NOBINUB ) &&
( rType != CGLFLOW_ROW_NOBINEQ ) &&
( rType != CGLFLOW_ROW_SUMVARUB ) &&
( rType != CGLFLOW_ROW_SUMVAREQ ) )
continue;
const int sta = rowStart[iRow]; // Start position of iRow
const int rowLen = rowLength[iRow]; // iRow length / non-zero elements
if (ind != 0) { delete [] ind; ind = 0; }
ind = new int [rowLen];
if (coef != 0) { delete [] coef; coef = 0; }
coef = new double [rowLen];
int lastPos = sta + rowLen;
for (iCol = sta; iCol < lastPos; ++iCol) {
ind[iCol - sta] = colInd[iCol];
coef[iCol - sta] = elementByRow[iCol];
}
OsiRowCut flowCut1, flowCut2, flowCut3;
double violation = 0.0;
bool hasCut = false;
if (sense[iRow] == 'E') {
hasCut = generateOneFlowCut(si, rowLen, ind, coef, 'L',
rhs[iRow], flowCut1, violation);
if (hasCut) { // If find a cut
cs.insert(flowCut1);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
}
hasCut = false;
hasCut = generateOneFlowCut(si, rowLen, ind, coef, 'G',
rhs[iRow], flowCut2, violation);
if (hasCut) {
cs.insert(flowCut2);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
}
}
if (sense[iRow] == 'L' || sense[iRow] == 'G') {
hasCut = generateOneFlowCut(si, rowLen, ind, coef, sense[iRow],
rhs[iRow], flowCut3, violation);
if (hasCut) {
cs.insert(flowCut3);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
//.........这里部分代码省略.........