本文整理汇总了C++中OsiCuts::colCut方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiCuts::colCut方法的具体用法?C++ OsiCuts::colCut怎么用?C++ OsiCuts::colCut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiCuts
的用法示例。
在下文中一共展示了OsiCuts::colCut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gutsOfCopy
//-------------------------------------------------------------------
void OsiCuts::gutsOfCopy(const OsiCuts& source)
{
assert( sizeRowCuts()==0 );
assert( sizeColCuts()==0 );
assert( sizeCuts()==0 );
int i;
int ne = source.sizeRowCuts();
for (i=0; i<ne; i++) insert( source.rowCut(i) );
ne = source.sizeColCuts();
for (i=0; i<ne; i++) insert( source.colCut(i) );
}
示例2: eq
//--------------------------------------------------------------------------
// test EKKsolution methods.
void
CglProbingUnitTest(
const OsiSolverInterface * baseSiP,
const std::string mpsDir )
{
# ifdef CGL_DEBUG
int i ; // define just once
# endif
CoinRelFltEq eq(0.000001);
// Test default constructor
{
CglProbing aGenerator;
}
// Test copy & assignment
{
CglProbing rhs;
{
CglProbing bGenerator;
CglProbing cGenerator(bGenerator);
rhs=bGenerator;
}
}
{
OsiCuts osicuts;
CglProbing test1;
OsiSolverInterface * siP = baseSiP->clone();
int nColCuts;
int nRowCuts;
std::string fn = mpsDir+"p0033";
siP->readMps(fn.c_str(),"mps");
siP->initialSolve();
// just unsatisfied variables
test1.generateCuts(*siP,osicuts);
nColCuts = osicuts.sizeColCuts();
nRowCuts = osicuts.sizeRowCuts();
std::cout<<"There are "<<nRowCuts<<" probing cuts"<<std::endl;
{
std::cout<<"there are "<<nColCuts<<" probing column cuts"<<std::endl;
#ifdef CGL_DEBUG
const double * lo = siP->getColLower();
const double * up = siP->getColUpper();
for (i=0; i<nColCuts; i++){
OsiColCut ccut;
CoinPackedVector cpv;
ccut = osicuts.colCut(i);
cpv = ccut.lbs();
int n = cpv.getNumElements();
int j;
const int * indices = cpv.getIndices();
double* elements = cpv.getElements();
for (j=0;j<n;j++) {
int icol=indices[j];
if (elements[j]>lo[icol])
std::cout<<"Can increase lb on "<<icol<<" from "<<lo[icol]<<
" to "<<elements[j]<<std::endl;
}
cpv = ccut.ubs();
n = cpv.getNumElements();
indices = cpv.getIndices();
elements = cpv.getElements();
for (j=0;j<n;j++) {
int icol=indices[j];
if (elements[j]<up[icol])
std::cout<<"Can decrease ub on "<<icol<<" from "<<up[icol]<<
" to "<<elements[j]<<std::endl;
}
}
#endif
}
#ifdef CGL_DEBUG
for (i=0; i<nRowCuts; i++){
OsiRowCut rcut;
CoinPackedVector rpv;
const double * colsol = siP->getColSolution();
rcut = osicuts.rowCut(i);
rpv = rcut.row();
const int n = rpv.getNumElements();
const int * indices = rpv.getIndices();
double* elements = rpv.getElements();
double sum2=0.0;
int k=0;
double lb=rcut.lb();
double ub=rcut.ub();
for (k=0; k<n; k++){
int column=indices[k];
sum2 += colsol[column]*elements[k];
}
if (sum2 >ub + 1.0e-7 ||sum2 < lb - 1.0e-7) {
std::cout<<"Cut "<<i<<" lb "<<lb<<" solution "<<sum2<<" ub "<<ub<<std::endl;
//.........这里部分代码省略.........