本文整理汇总了C++中CoinPackedMatrix::submatrixOfWithDuplicates方法的典型用法代码示例。如果您正苦于以下问题:C++ CoinPackedMatrix::submatrixOfWithDuplicates方法的具体用法?C++ CoinPackedMatrix::submatrixOfWithDuplicates怎么用?C++ CoinPackedMatrix::submatrixOfWithDuplicates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoinPackedMatrix
的用法示例。
在下文中一共展示了CoinPackedMatrix::submatrixOfWithDuplicates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
offset = columnUpper[iColumn];
} else {
// taken care of before
abort();
}
if (offset) {
objOffset += offset * objective[iColumn];
for (CoinBigIndex j = columnStart[iColumn];
j < columnStart[iColumn] + columnLength[iColumn]; j++) {
int iRow = row[j];
if (rowLower[iRow] > -1.0e20)
rowLower[iRow] -= offset * elementByColumn[j];
if (rowUpper[iRow] < 1.0e20)
rowUpper[iRow] -= offset * elementByColumn[j];
}
}
}
int * which = new int[numberRows+numberExtraRows];
rowCopy.reverseOrdering();
rowCopy.transpose();
double * fromRowsLower = new double[numberRows+numberExtraRows];
double * fromRowsUpper = new double[numberRows+numberExtraRows];
double * newObjective = new double[numberRows+numberExtraRows];
double * fromColumnsLower = new double[numberColumns];
double * fromColumnsUpper = new double[numberColumns];
for (iColumn = 0; iColumn < numberColumns; iColumn++) {
// Offset is already in
if (columnUpper[iColumn] >= 1.0e20) {
if (columnLower[iColumn] > -1.0e20) {
fromColumnsLower[iColumn] = -COIN_DBL_MAX;
fromColumnsUpper[iColumn] = objective[iColumn];
} else {
// free
fromColumnsLower[iColumn] = objective[iColumn];
fromColumnsUpper[iColumn] = objective[iColumn];
}
} else if (columnLower[iColumn] <= -1.0e20) {
fromColumnsLower[iColumn] = objective[iColumn];
fromColumnsUpper[iColumn] = COIN_DBL_MAX;
} else {
abort();
}
}
int kRow = 0;
for (iRow = 0; iRow < numberRows; iRow++) {
if (rowLower[iRow] <= -1.0e20) {
assert(rowUpper[iRow] < 1.0e20);
newObjective[kRow] = -rowUpper[iRow];
fromRowsLower[kRow] = -COIN_DBL_MAX;
fromRowsUpper[kRow] = 0.0;
which[kRow] = iRow;
kRow++;
} else if (rowUpper[iRow] >= 1.0e20) {
newObjective[kRow] = -rowLower[iRow];
fromRowsLower[kRow] = 0.0;
fromRowsUpper[kRow] = COIN_DBL_MAX;
which[kRow] = iRow;
kRow++;
} else {
if (rowUpper[iRow] == rowLower[iRow]) {
newObjective[kRow] = -rowLower[iRow];
fromRowsLower[kRow] = -COIN_DBL_MAX;;
fromRowsUpper[kRow] = COIN_DBL_MAX;
which[kRow] = iRow;
kRow++;
} else {
// range
newObjective[kRow] = -rowUpper[iRow];
fromRowsLower[kRow] = -COIN_DBL_MAX;
fromRowsUpper[kRow] = 0.0;
which[kRow] = iRow;
kRow++;
newObjective[kRow] = -rowLower[iRow];
fromRowsLower[kRow] = 0.0;
fromRowsUpper[kRow] = COIN_DBL_MAX;
which[kRow] = iRow;
kRow++;
}
}
}
if (numberExtraRows) {
CoinPackedMatrix newCopy;
newCopy.submatrixOfWithDuplicates(rowCopy, kRow, which);
rowCopy = newCopy;
}
ClpSimplex modelDual;
modelDual.loadProblem(rowCopy, fromRowsLower, fromRowsUpper, newObjective,
fromColumnsLower, fromColumnsUpper);
modelDual.setObjectiveOffset(objOffset);
delete [] fromRowsLower;
delete [] fromRowsUpper;
delete [] fromColumnsLower;
delete [] fromColumnsUpper;
delete [] newObjective;
delete [] which;
delete [] rowLower;
delete [] rowUpper;
modelDual.writeMps("dual.mps");
return 0;
}