本文整理汇总了C++中Column::lBound方法的典型用法代码示例。如果您正苦于以下问题:C++ Column::lBound方法的具体用法?C++ Column::lBound怎么用?C++ Column::lBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Column
的用法示例。
在下文中一共展示了Column::lBound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genColumn
int Variable::genColumn(
Active<Constraint, Variable> *actCon,
Column &col) const
{
double eps = master_->machineEps();
double minusEps = -eps;
int n = actCon->number();
expand();
for (int i = 0; i < n; i++) {
double co = (*actCon)[i]->coeff(this);
if (co > eps || co < minusEps) col.insert(i,co);
}
col.obj(obj());
col.lBound(lBound());
col.uBound(uBound());
compress();
return col.nnz();
}
示例2: addVars
void LpSub::addVars(
ArrayBuffer<Variable*> &vars,
ArrayBuffer<FSVarStat*> &fsVarStat,
ArrayBuffer<double> &lb,
ArrayBuffer<double> &ub)
{
// LpSub::addVars(): local variables
ArrayBuffer<int> delVar(vars.size(),false); //!< the eliminated variables
Array<double> rhsDelta(0,sub_->nCon()-1, 0.0); //!< the correction of the rhs
double vValue;
double coeff;
bool modifyRhs = false; //!< if \a true the modification of rhs required
int oldNCol = trueNCol();
int n = trueNCol();
Variable *v;
// divide the added variables in eliminable and non-eliminable ones
int nVariables = vars.size();
for (int i = 0; i < nVariables; i++) {
v = vars[i];
if(fsVarStat[i]->fixedOrSet()) {
if (eliminable(i)) {
//! the new variable is eliminated
delVar.push(i);
vValue = elimVal(fsVarStat[i], lb[i], ub[i]);
valueAdd_ += v->obj() * vValue;
orig2lp_[nOrigVar_++] = -1;
const int nCon = sub_->nCon();
for (int c = 0; c < nCon; c++) {
coeff = sub_->constraint(c)->coeff(v);
if (fabs(coeff) > master_->eps()) {
rhsDelta[c] += vValue * coeff;
modifyRhs = true;
}
}
}
else {
// the new variable is fixed in the LP
orig2lp_[nOrigVar_++] = n;
lp2orig_[n] = oldNCol + i;
++n;
lb[i] = ub[i] = elimVal(fsVarStat[i], lb[i], ub[i]);
}
}
else {
// the new variable will be added to the LP explicitly
orig2lp_[nOrigVar_++] = n;
lp2orig_[n] = oldNCol + i;
++n;
}
}
// remove the fixed and set added variables
if (delVar.size()) {
vars.leftShift(delVar);
fsVarStat.leftShift(delVar);
lb.leftShift(delVar);
ub.leftShift(delVar);
}
// generate the column of the added variable and add them to the LP
ArrayBuffer<Column*> newCols(vars.size(),false);
//!< new columns added to the constraint matrix
Column colBuf(master_, nRow()); //!< buffer for generated columns
Column *col;
nVariables = vars.size();
for(int i = 0; i < nVariables; i++) {
vars[i]->genColumn(sub_->actCon(), colBuf);
col = new Column(master_, colBuf.nnz());
col->copy(colBuf);
col->obj(colBuf.obj());
col->uBound(colBuf.uBound());
col->lBound(colBuf.lBound());
newCols.push(col);
colBuf.clear();
}
LP::addCols(newCols);
// modify the right hand side if fixed or set variables are added
if (modifyRhs) {
const int nCon = sub_->nCon();
Array<double> newRhs(nCon);
for(int c = 0; c < nCon; c++)
newRhs[c] = rhs(c) - rhsDelta[c];
changeRhs(newRhs);
}
// LpSub::addVars(): clean up
for(int i = 0; i < nVariables; i++)
delete newCols[i];
}