本文整理汇总了C++中OsiSolverInterface::getRightHandSide方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiSolverInterface::getRightHandSide方法的具体用法?C++ OsiSolverInterface::getRightHandSide怎么用?C++ OsiSolverInterface::getRightHandSide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiSolverInterface
的用法示例。
在下文中一共展示了OsiSolverInterface::getRightHandSide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matrixByRow
//-------------------------------------------------------------------
// Determine row types. Find the VUBS and VLBS.
//-------------------------------------------------------------------
void
CglFlowCover::flowPreprocess(const OsiSolverInterface& si) const
{
CoinPackedMatrix matrixByRow(*si.getMatrixByRow());
int numRows = si.getNumRows();
int numCols = si.getNumCols();
const char* sense = si.getRowSense();
const double* RHS = si.getRightHandSide();
const double* coefByRow = matrixByRow.getElements();
const int* colInds = matrixByRow.getIndices();
const int* rowStarts = matrixByRow.getVectorStarts();
const int* rowLengths = matrixByRow.getVectorLengths();
int iRow = -1;
int iCol = -1;
numCols_ = numCols; // Record col and row numbers for copy constructor
numRows_ = numRows;
if (rowTypes_ != 0) {
delete [] rowTypes_; rowTypes_ = 0;
}
rowTypes_ = new CglFlowRowType [numRows];// Destructor will free memory
// Get integer types
const char * columnType = si.getColType (true);
// Summarize the row type infomation.
int numUNDEFINED = 0;
int numVARUB = 0;
int numVARLB = 0;
int numVAREQ = 0;
int numMIXUB = 0;
int numMIXEQ = 0;
int numNOBINUB = 0;
int numNOBINEQ = 0;
int numSUMVARUB = 0;
int numSUMVAREQ = 0;
int numUNINTERSTED = 0;
int* ind = new int [numCols];
double* coef = new double [numCols];
for (iRow = 0; iRow < numRows; ++iRow) {
int rowLen = rowLengths[iRow];
char sen = sense[iRow];
double rhs = RHS[iRow];
CoinDisjointCopyN(colInds + rowStarts[iRow], rowLen, ind);
CoinDisjointCopyN(coefByRow + rowStarts[iRow], rowLen, coef);
CglFlowRowType rowType = determineOneRowType(si, rowLen, ind, coef,
sen, rhs);
rowTypes_[iRow] = rowType;
switch(rowType) {
case CGLFLOW_ROW_UNDEFINED:
++numUNDEFINED;
break;
case CGLFLOW_ROW_VARUB:
++numVARUB;
break;
case CGLFLOW_ROW_VARLB:
++numVARLB;
break;
case CGLFLOW_ROW_VAREQ:
++numVAREQ;
break;
case CGLFLOW_ROW_MIXUB:
++numMIXUB;
break;
case CGLFLOW_ROW_MIXEQ:
++numMIXEQ;
break;
case CGLFLOW_ROW_NOBINUB:
++numNOBINUB;
break;
case CGLFLOW_ROW_NOBINEQ:
++numNOBINEQ;
break;
case CGLFLOW_ROW_SUMVARUB:
++numSUMVARUB;
break;
case CGLFLOW_ROW_SUMVAREQ:
++numSUMVAREQ;
break;
case CGLFLOW_ROW_UNINTERSTED:
++numUNINTERSTED;
break;
default:
throw CoinError("Unknown row type", "flowPreprocess",
"CglFlowCover");
}
}
delete [] ind; ind = NULL;
//.........这里部分代码省略.........
示例2: generateCuts
//-----------------------------------------------------------------------------
// Generate LSGFC cuts
//-------------------------------------------------------------------
void CglFlowCover::generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
const CglTreeInfo info) const
{
static int count=0;
if (getMaxNumCuts() <= 0) return;
if (getNumFlowCuts() >= getMaxNumCuts()) return;
++count;
#if 0
bool preInit = false;
bool preReso = false;
si.getHintParam(OsiDoPresolveInInitial, preInit);
si.getHintParam(OsiDoPresolveInResolve, preReso);
if (preInit == false && preReso == false) { // Do once
if (doneInitPre_ == false) {
flowPreprocess(si);
doneInitPre_ = true;
}
}
else
#endif
int numberRowCutsBefore = cs.sizeRowCuts();
flowPreprocess(si);
CoinPackedMatrix matrixByRow(*si.getMatrixByRow());
const char* sense = si.getRowSense();
const double* rhs = si.getRightHandSide();
const double* elementByRow = matrixByRow.getElements();
const int* colInd = matrixByRow.getIndices();
const CoinBigIndex* rowStart = matrixByRow.getVectorStarts();
const int* rowLength = matrixByRow.getVectorLengths();
int* ind = 0;
double* coef = 0;
int iRow, iCol;
CglFlowRowType rType;
for (iRow = 0; iRow < numRows_; ++iRow) {
rType = getRowType(iRow);
if( ( rType != CGLFLOW_ROW_MIXUB ) &&
( rType != CGLFLOW_ROW_MIXEQ ) &&
( rType != CGLFLOW_ROW_NOBINUB ) &&
( rType != CGLFLOW_ROW_NOBINEQ ) &&
( rType != CGLFLOW_ROW_SUMVARUB ) &&
( rType != CGLFLOW_ROW_SUMVAREQ ) )
continue;
const int sta = rowStart[iRow]; // Start position of iRow
const int rowLen = rowLength[iRow]; // iRow length / non-zero elements
if (ind != 0) { delete [] ind; ind = 0; }
ind = new int [rowLen];
if (coef != 0) { delete [] coef; coef = 0; }
coef = new double [rowLen];
int lastPos = sta + rowLen;
for (iCol = sta; iCol < lastPos; ++iCol) {
ind[iCol - sta] = colInd[iCol];
coef[iCol - sta] = elementByRow[iCol];
}
OsiRowCut flowCut1, flowCut2, flowCut3;
double violation = 0.0;
bool hasCut = false;
if (sense[iRow] == 'E') {
hasCut = generateOneFlowCut(si, rowLen, ind, coef, 'L',
rhs[iRow], flowCut1, violation);
if (hasCut) { // If find a cut
cs.insert(flowCut1);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
}
hasCut = false;
hasCut = generateOneFlowCut(si, rowLen, ind, coef, 'G',
rhs[iRow], flowCut2, violation);
if (hasCut) {
cs.insert(flowCut2);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
}
}
if (sense[iRow] == 'L' || sense[iRow] == 'G') {
hasCut = generateOneFlowCut(si, rowLen, ind, coef, sense[iRow],
rhs[iRow], flowCut3, violation);
if (hasCut) {
cs.insert(flowCut3);
incNumFlowCuts();
if (getNumFlowCuts() >= getMaxNumCuts())
break;
//.........这里部分代码省略.........