本文整理汇总了C++中CoinPackedMatrix::verifyMtx方法的典型用法代码示例。如果您正苦于以下问题:C++ CoinPackedMatrix::verifyMtx方法的具体用法?C++ CoinPackedMatrix::verifyMtx怎么用?C++ CoinPackedMatrix::verifyMtx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoinPackedMatrix
的用法示例。
在下文中一共展示了CoinPackedMatrix::verifyMtx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoinPackedMatrix
CbcLagrangeSolver::CbcLagrangeSolver(stochasticInput &input, int scenarioNumber, const vector<double> &lagrangeDiff) {
absgap = ratio = 0.;
nvar1 = input.nFirstStageVars();
int nvar2 = input.nSecondStageVars(scenarioNumber);
int ncons1 = input.nFirstStageCons();
int ncons2 = input.nSecondStageCons(scenarioNumber);
const CoinPackedMatrix &Amat = input.getFirstStageConstraints(),
&Tmat = input.getLinkingConstraints(scenarioNumber),
&Wmat = input.getSecondStageConstraints(scenarioNumber);
int totalVar = nvar1 + nvar2;
int totalCons = ncons1 + ncons2;
CoinBigIndex totalNnz = Amat.getNumElements() + Tmat.getNumElements() + Wmat.getNumElements();
// CoinPackedMatrix takes ownership of these, so we don't free them
CoinBigIndex *starts = new CoinBigIndex[totalVar+1];
double *elts = new double[totalNnz];
int *rowIdx = new int[totalNnz];
CoinBigIndex nnz = 0, start, end;
// put first-stage variables first, as is customary
int const *Aidx = Amat.getIndices();
double const *Aelts = Amat.getElements();
int const *Tidx = Tmat.getIndices();
double const *Telts = Tmat.getElements();
for (int c = 0; c < nvar1; c++) {
starts[c] = nnz;
start = Amat.getVectorFirst(c);
end = Amat.getVectorLast(c);
for (CoinBigIndex j = start; j < end; j++) {
elts[nnz] = Aelts[j];
rowIdx[nnz++] = Aidx[j];
}
start = Tmat.getVectorFirst(c);
end = Tmat.getVectorLast(c);
for (CoinBigIndex j = start; j < end; j++) {
elts[nnz] = Telts[j];
rowIdx[nnz++] = Tidx[j]+ncons1;
}
}
// now W blocks
int rowOffset = ncons1;
int colOffset = nvar1;
int const *Widx = Wmat.getIndices();
double const *Welts = Wmat.getElements();
for (int c = 0; c < nvar2; c++) {
starts[colOffset++] = nnz;
start = Wmat.getVectorFirst(c);
end = Wmat.getVectorLast(c);
for (CoinBigIndex j = start; j < end; j++) {
elts[nnz] = Welts[j];
rowIdx[nnz++] = Widx[j]+rowOffset;
}
}
starts[totalVar] = nnz;
assert(nnz == totalNnz);
CoinPackedMatrix *constr = new CoinPackedMatrix();
int *lens = 0;
constr->assignMatrix(true,totalCons,totalVar,totalNnz,elts,rowIdx,starts,lens);
constr->verifyMtx(); // debugging
// OsiClpSolverInterface takes ownership of these
double *collb = new double[totalVar];
double *colub = new double[totalVar];
double *obj = new double[totalVar];
double *rowlb = new double[totalCons];
double *rowub = new double[totalCons];
concatenateOne(input, collb, &stochasticInput::getFirstStageColLB,
&stochasticInput::getSecondStageColLB, scenarioNumber);
concatenateOne(input, colub, &stochasticInput::getFirstStageColUB,
&stochasticInput::getSecondStageColUB, scenarioNumber);
concatenateOne(input, obj, &stochasticInput::getFirstStageObj,
&stochasticInput::getSecondStageObj, scenarioNumber);
concatenateOne(input, rowlb, &stochasticInput::getFirstStageRowLB,
&stochasticInput::getSecondStageRowLB, scenarioNumber);
concatenateOne(input, rowub, &stochasticInput::getFirstStageRowUB,
&stochasticInput::getSecondStageRowUB, scenarioNumber);
// rescale first-stage objective
double scale = input.scenarioProbability(scenarioNumber);
assert(lagrangeDiff.size() == static_cast<unsigned>(nvar1));
for (int i = 0; i < nvar1; i++) {
obj[i] = scale*obj[i] + lagrangeDiff[i];
}
m.assignProblem(constr, collb, colub, obj, rowlb, rowub);
//.........这里部分代码省略.........