本文整理汇总了C++中OsiSolverInterface::setRowUpper方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiSolverInterface::setRowUpper方法的具体用法?C++ OsiSolverInterface::setRowUpper怎么用?C++ OsiSolverInterface::setRowUpper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiSolverInterface
的用法示例。
在下文中一共展示了OsiSolverInterface::setRowUpper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyBounds
// Apply bounds
void OsiSolverBranch::applyBounds(OsiSolverInterface &solver, int way) const
{
int base = way + 1;
assert(way == -1 || way == 1);
int numberColumns = solver.getNumCols();
const double *columnLower = solver.getColLower();
int i;
for (i = start_[base]; i < start_[base + 1]; i++) {
int iColumn = indices_[i];
if (iColumn < numberColumns) {
double value = CoinMax(bound_[i], columnLower[iColumn]);
solver.setColLower(iColumn, value);
} else {
int iRow = iColumn - numberColumns;
const double *rowLower = solver.getRowLower();
double value = CoinMax(bound_[i], rowLower[iRow]);
solver.setRowLower(iRow, value);
}
}
const double *columnUpper = solver.getColUpper();
for (i = start_[base + 1]; i < start_[base + 2]; i++) {
int iColumn = indices_[i];
if (iColumn < numberColumns) {
double value = CoinMin(bound_[i], columnUpper[iColumn]);
solver.setColUpper(iColumn, value);
} else {
int iRow = iColumn - numberColumns;
const double *rowUpper = solver.getRowUpper();
double value = CoinMin(bound_[i], rowUpper[iRow]);
solver.setRowUpper(iRow, value);
}
}
}
示例2: etol
//.........这里部分代码省略.........
/** If we found an upper bound, then do the dual fixing **/
if (Ub < objSense*nSolver->getInfinity()){
sym_environment *env =
dynamic_cast<OsiSymSolverInterface *>(nSolver)->getSymphonyEnvironment();
for (i = 0; i < uCols; i++){
if (newUbVal[i] == 1){
// Try fixing it to zero
newUbVal[i] = 0;
sym_get_lb_for_new_rhs(env, 0, NULL, NULL, uCols, newLbInd,
newLbVal, uCols, newUbInd, newUbVal,
&newLb);
if (objSense*newLb > Ub + etol){
//Victory! This variable can be fixed to 1 permanently
newLbVal[i] = 1;
}
//Set upper bound back to 1
newUbVal[i] = 1;
if (newLbVal[i] == 0){
// Try fixing it to one
newLbVal[i] = 1;
sym_get_lb_for_new_rhs(env, 0, NULL, NULL, uCols, newLbInd,
newLbVal, uCols, newUbInd, newUbVal,
&newLb);
if (objSense*newLb > Ub + etol){
//Victory! This variable can be fixed to 0 permanently
newUbVal[i] = 0;
}
newLbVal[i] = 0;
}
}
}
}
/** Now set the row bounds to account for fixings **/
/** This is probably very frgaile. Assuming interdiction
rows come last. It would be better to set variable
bounds directly, but this doesn't seem to work right now. **/
int iRowStart = lRows-uCols;
#if 1
for(i = iRowStart; i < lRows; i++){
nSolver->setRowLower(i, newLbVal[i-iRowStart]);
nSolver->setRowUpper(i, newUbVal[i-iRowStart]);
}
#else
for(i = 0; i < uCols; i++){
nSolver->setColLower(i, newLbVal[i]);
nSolver->setColUpper(i, newUbVal[i]);
}
#endif
delete[] newUbInd;
delete[] newLbInd;
delete[] newUbVal;
delete[] newLbVal;
}else{
#endif
//FIXME: NEED TO GET ROW SENSE HERE
/** Get contribution of upper-level columns **/
double * upComp = new double[lRows];
CoinFillN(upComp, lRows, 0.0);
for(i = 0; i < lRows; i++){
index1 = lRowIndices[i];
for(j = 0; j < uCols; j++){
index2 = uColIndices[j];
coeff = matrix->getCoefficient(index1, index2);
if (coeff != 0){
upComp[i] += coeff * lpSol[index2];
}
}
}
/** Correct the row bounds to account for fixed upper-level vars **/
for(i = 0; i < lRows; i++){
nSolver->setRowLower(i, rowLb[i] - upComp[i]);
nSolver->setRowUpper(i, rowUb[i] - upComp[i]);
}
delete [] upComp;
#if SYMPHONY_VERSION_IS_WS
}
#endif
//I don't think this is needed
//if(!getWarmStart())
// setWarmStart(nSolver->getWarmStart());
return nSolver;
}