本文整理汇总了C++中CoinPackedVector::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ CoinPackedVector::clear方法的具体用法?C++ CoinPackedVector::clear怎么用?C++ CoinPackedVector::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoinPackedVector
的用法示例。
在下文中一共展示了CoinPackedVector::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bf
//@{
template <class BinaryFunction> void
binaryOp(CoinPackedVector& retVal,
const CoinPackedVectorBase& op1, double value,
BinaryFunction bf)
{
retVal.clear();
const int s = op1.getNumElements();
if (s > 0) {
retVal.reserve(s);
const int * inds = op1.getIndices();
const double * elems = op1.getElements();
for (int i=0; i<s; ++i ) {
retVal.insert(inds[i], bf(value, elems[i]));
}
}
}
示例2: _addRows
void OsiIF::_addRows(ArrayBuffer<Row*> &rows)
{
CoinPackedVector *coinrow = new CoinPackedVector();
for (int i = 0; i < rows.size(); i++) {
coinrow->clear();
for (int j = 0; j < rows[i]->nnz(); j++){
coinrow->insert(rows[i]->support(j), rows[i]->coeff(j));
}
lpSolverTime_.start();
osiLP_->addRow(*coinrow, csense2osi(rows[i]->sense()), rows[i]->rhs(), 0.0);
lpSolverTime_.stop();
}
delete coinrow;
lpSolverTime_.start();
numRows_ = osiLP_->getNumRows();
rhs_ = osiLP_->getRightHandSide();
numCols_ = osiLP_->getNumCols();
collower_ = osiLP_->getColLower();
colupper_ = osiLP_->getColUpper();
lpSolverTime_.stop();
}
示例3: _initialize
void OsiIF::_initialize(
OptSense sense,
int nRow,
int maxRow,
int nCol,
int maxCol,
Array<double> &obj,
Array<double> &lBound,
Array<double> &uBound,
Array<Row*> &rows)
{
osiLP_ = getDefaultInterface();
currentSolverType_ = Exact;
// switch off output from the solver
// can be reset in setSolverParameters
osiLP_->setHintParam(OsiDoReducePrint, true, OsiHintDo);
osiLP_->messageHandler()->setLogLevel(0);
master_->setSolverParameters(osiLP_, currentSolverType() == Approx);
numRows_ = nRow;
numCols_ = nCol;
double *lbounds = new double[numCols_];
double *ubounds = new double[numCols_];
double *objectives = new double[numCols_];
CoinPackedVector *coinrow = new CoinPackedVector();
CoinPackedMatrix *matrix = new CoinPackedMatrix(false,0,0);
matrix->setDimensions(0, numCols_);
for (int i = 0; i < numCols_; i++){
lbounds[i] = lBound[i];
ubounds[i] = uBound[i];
objectives[i] = obj[i];
}
if (currentSolverType() == Exact && numRows_ == 0 && master_->defaultLpSolver() == Master::CPLEX) {
loadDummyRow(osiLP_, lbounds, ubounds, objectives);
}
else {
char *senses = new char[numRows_];
double *rhs = new double[numRows_];
double *ranges = new double[numRows_];
for (int i = 0; i < numRows_; i++){
coinrow->clear();
for (int j = 0; j < rows[i]->nnz(); j++){
coinrow->insert(rows[i]->support(j), rows[i]->coeff(j));
}
matrix->appendRow(*coinrow);
senses[i] = csense2osi(rows[i]->sense());
rhs[i] = rows[i]->rhs();
ranges[i] = 0.0;
}
lpSolverTime_.start();
osiLP_->loadProblem(*matrix, lbounds, ubounds, objectives, senses, rhs, ranges);
lpSolverTime_.stop();
freeChar(senses);
freeDouble(rhs);
freeDouble(ranges);
}
// set the sense of the optimization
_sense(sense);
// get the pointers to the solution, reduced costs etc.
lpSolverTime_.start();
numRows_ = osiLP_->getNumRows();
numCols_ = osiLP_->getNumCols();
rhs_ = osiLP_->getRightHandSide();
rowsense_ = osiLP_->getRowSense();
colupper_ = osiLP_->getColUpper();
collower_ = osiLP_->getColLower();
objcoeff_ = osiLP_->getObjCoefficients();
if( ws_ != nullptr )
delete ws_;
//ws_ = dynamic_cast<CoinWarmStartBasis *>(osiLP_->getWarmStart());
ws_=nullptr;
xValStatus_ = recoStatus_ = yValStatus_ = slackStatus_ = basisStatus_ = Missing;
lpSolverTime_.stop();
delete coinrow;
delete matrix;
freeDouble(lbounds);
freeDouble(ubounds);
freeDouble(objectives);
}