本文整理汇总了C++中OsiClpSolverInterface::setObjective方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::setObjective方法的具体用法?C++ OsiClpSolverInterface::setObjective怎么用?C++ OsiClpSolverInterface::setObjective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::setObjective方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setWhen
//.........这里部分代码省略.........
index[randNumTemp] = temp;
}
// Start finding corner points by iteratively doing the following:
// - contruct a randomly tilted objective
// - solve
for (int i = 0; i < numRows; i++) {
// TODO: that 10,000 could be a param in the member data
if (solutions.numberSolutions > 10000)
break;
randNum = intRand(2);
for (int j = 0; j < numCols; j++) {
// for row i and column j vary the coefficient "a bit"
if (randNum == 1)
// if the element is zero, then set the new obj
// coefficient to 0.1 (i.e., round up)
if (fabs(matrix[index[i]][j]) < primalTolerance)
newObj[j] = 0.1;
else
// if the element is nonzero, then increase the new obj
// coefficient "a bit"
newObj[j] = matrix[index[i]][j] * 1.1;
else
// if randnum is 2, then
// if the element is zero, then set the new obj coeffient
// to NEGATIVE 0.1 (i.e., round down)
if (fabs(matrix[index[i]][j]) < primalTolerance)
newObj[j] = -0.1;
else
// if the element is nonzero, then DEcrease the new obj coeffienct "a bit"
newObj[j] = matrix[index[i]][j] * 0.9;
}
// Use the new "tilted" objective
clpSolver->setObjective(newObj);
// Based on the row sense, we decide whether to max or min
if (rowSense[i] == 'L')
clpSolver->setObjSense(-1);
else
clpSolver->setObjSense(1);
// Solve with primal simplex
simplex->primal(1);
// rlh+ll: This was the original code. But we already have the
// model pointer (it's in simplex). And, calling getModelPtr()
// invalidates the cached data in the OsiClpSolverInterface
// object, which means our precious rowsens is lost. So let's
// not use the line below...
/******* clpSolver->getModelPtr()->primal(1); */
printf("---------------------------------------------------------------- %d\n", i);
}
// Iteratively do this process until...
// either you reach the max number of corner points (aka 10K)
// or all the rows have been used as an objective.
// Look at solutions
int numberSolutions = solutions.numberSolutions;
//const char * integerInfo = simplex->integerInformation();
//const double * columnLower = simplex->columnLower();
//const double * columnUpper = simplex->columnUpper();
printf("there are %d solutions\n", numberSolutions);
// Up to here we have all the corner points
// Now we need to do the random walks and roundings
double ** cornerPoints = new double * [numberSolutions];