本文整理汇总了C++中CoinPackedVector::getMaxIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CoinPackedVector::getMaxIndex方法的具体用法?C++ CoinPackedVector::getMaxIndex怎么用?C++ CoinPackedVector::getMaxIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoinPackedVector
的用法示例。
在下文中一共展示了CoinPackedVector::getMaxIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sepaBenders
//.........这里部分代码省略.........
*result = SCIP_INFEASIBLE;
addedPoolCut = true;
break;
}
}
if (addedPoolCut)
{
DSPdebugMessage("Added pool cut\n");
/** free memory */
SCIPfreeMemoryArray(scip, &vals);
return SCIP_OKAY;
}
}
#endif
/** generate Benders cuts */
assert(tss_);
tss_->generateCuts(nvars_, vals, &cs);
/** If found Benders cuts */
for (int i = 0; i < cs.sizeCuts(); ++i)
{
/** get cut pointer */
OsiRowCut * rc = cs.rowCutPtr(i);
if (!rc) continue;
const CoinPackedVector cutrow = rc->row();
if (cutrow.getNumElements() == 0) continue;
/** is optimality cut? */
bool isOptimalityCut = false;
for (int j = nvars_ - naux_; j < nvars_; ++j)
{
if (cutrow.getMaxIndex() == j)
{
isOptimalityCut = true;
break;
}
}
double efficacy = rc->violated(vals) / cutrow.twoNorm();
SCIP_Bool isEfficacious = efficacy > 1.e-6;
#define KK_TEST
#ifdef KK_TEST
if (SCIPgetStage(scip) == SCIP_STAGE_INITSOLVE ||
SCIPgetStage(scip) == SCIP_STAGE_SOLVING)
{
/** create empty row */
SCIP_ROW * row = NULL;
SCIP_CALL(SCIPcreateEmptyRowCons(scip, &row, conshdlr, "benders", rc->lb(), SCIPinfinity(scip),
FALSE, /**< is row local? */
FALSE, /**< is row modifiable? */
FALSE /**< is row removable? can this be TRUE? */));
/** cache the row extension and only flush them if the cut gets added */
SCIP_CALL(SCIPcacheRowExtensions(scip, row));
/** collect all non-zero coefficients */
for (int j = 0; j < cutrow.getNumElements(); ++j)
SCIP_CALL(SCIPaddVarToRow(scip, row, vars_[cutrow.getIndices()[j]], cutrow.getElements()[j]));
DSPdebugMessage("found Benders (%s) cut: act=%f, lhs=%f, norm=%f, eff=%f, min=%f, max=%f (range=%f)\n",
isOptimalityCut ? "opti" : "feas",
SCIPgetRowLPActivity(scip, row), SCIProwGetLhs(row), SCIProwGetNorm(row),
SCIPgetCutEfficacy(scip, sol, row),