本文整理汇总了C++中SolutionPtr::setDualOfCons方法的典型用法代码示例。如果您正苦于以下问题:C++ SolutionPtr::setDualOfCons方法的具体用法?C++ SolutionPtr::setDualOfCons怎么用?C++ SolutionPtr::setDualOfCons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolutionPtr
的用法示例。
在下文中一共展示了SolutionPtr::setDualOfCons方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
// Gap closed by using knapsack cover cuts.
Double gapknap = 0.0;
/*******************************************************************/
if (violknapcuts >= 1) {
// Reload problem to engine.
// Check if we should reload the modified problem.
e.clear();
const Double * xupdated;
if (WARMSTART == 1) {
// Set initial point as the solution of root solution.
xupdated = sol->getPrimal();
rel->setInitialPoint(xupdated);
}
// Load the modified problem.
e.load(rel);
// warmstart continues.
if (WARMSTART == 1) {
// Before presolve, we set initial primal and
// dual solutions as the root solution.
SolutionPtr solupdated = (SolutionPtr) new Solution(initobj, xupdated, rel);
// Create new dual solution.
const Double * dualofvars = sol->getDualOfVars();
solupdated->setDualOfVars(dualofvars);
const Double * initdualofcons = sol->getDualOfCons();
UInt numconsupdated = rel->getNumCons();
Double * dualofcons = new Double[numconsupdated];
memcpy(dualofcons, initdualofcons, numcons*sizeof(Double));
for (UInt indexx = numcons; indexx < numconsupdated; ++indexx) {
dualofcons[indexx] = 0.0;
}
solupdated->setDualOfCons(dualofcons);
FilterWSPtr warmstart = (FilterWSPtr) new FilterSQPWarmStart();
warmstart->setPoint(solupdated);
e.loadFromWarmStart(warmstart);
delete [] dualofcons;
}
// Solution time after adding knapsack cover cuts to relaxation.
timer->start();
// Resolve the problem.
e.solve();
/*******************************************************************/
// Solution time of knapsack cover cuts added problem.
timemod = timer->query();
timer->stop();
// Objective value after adding knapsack cover cuts.
endobj = e.getSolutionValue();
// Gap closed by using knapsack cover cuts.
gapknap = (endobj-initobj)/fabs(initobj) * 100;
/*******************************************************************/
} else {
/*******************************************************************/
// Solution time of knapsack cover cuts added problem.
timemod = timeinit;
// Objective value after adding knapsack cover cuts.
endobj = initobj;
// Gap closed by using knapsack cover cuts.
gapknap = 0.0;
/*******************************************************************/
}