本文整理汇总了C++中OsiClpSolverInterface::getMatrixByRow方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiClpSolverInterface::getMatrixByRow方法的具体用法?C++ OsiClpSolverInterface::getMatrixByRow怎么用?C++ OsiClpSolverInterface::getMatrixByRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiClpSolverInterface
的用法示例。
在下文中一共展示了OsiClpSolverInterface::getMatrixByRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setWhen
//.........这里部分代码省略.........
for (int i = 0; i < numCols; i++) {
if (clpSolver->isContinuous(i))
varClassInt[i] = 0;
else
varClassInt[i] = 1;
if (columnType[i] == 2) numGenInt++;
}
// Heuristic is for problems with general integer variables.
// If there are none, quit.
if (numGenInt++ < 1) {
delete [] varClassInt ;
std::cout << "Leaving the Randomized Rounding Heuristic" << std::endl;
return 0;
}
// -Get the rows sense
const char * rowSense;
rowSense = clpSolver->getRowSense();
// -Get the objective coefficients
double *originalObjCoeff = CoinCopyOfArray(clpSolver->getObjCoefficients(), numCols);
// -Get the matrix of the problem
// rlh: look at using sparse representation
double ** matrix = new double * [numRows];
for (int i = 0; i < numRows; i++) {
matrix[i] = new double[numCols];
for (int j = 0; j < numCols; j++)
matrix[i][j] = 0;
}
const CoinPackedMatrix* matrixByRow = clpSolver->getMatrixByRow();
const double * matrixElements = matrixByRow->getElements();
const int * matrixIndices = matrixByRow->getIndices();
const int * matrixStarts = matrixByRow->getVectorStarts();
for (int j = 0; j < numRows; j++) {
for (int i = matrixStarts[j]; i < matrixStarts[j+1]; i++) {
matrix[j][matrixIndices[i]] = matrixElements[i];
}
}
double * newObj = new double [numCols];
srand ( static_cast<unsigned int>(time(NULL) + 1));
int randNum;
// Shuffle the rows:
// Put the rows in a random order
// so that the optimal solution is a different corner point than the
// starting point.
int * index = new int [numRows];
for (int i = 0; i < numRows; i++)
index[i] = i;
for (int i = 0; i < numRows; i++) {
int temp = index[i];
int randNumTemp = i + intRand(numRows - i);
index[i] = index[randNumTemp];
index[randNumTemp] = temp;
}
// Start finding corner points by iteratively doing the following:
// - contruct a randomly tilted objective
// - solve
for (int i = 0; i < numRows; i++) {
// TODO: that 10,000 could be a param in the member data