本文整理汇总了C++中OsiRowCut::print方法的典型用法代码示例。如果您正苦于以下问题:C++ OsiRowCut::print方法的具体用法?C++ OsiRowCut::print怎么用?C++ OsiRowCut::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsiRowCut
的用法示例。
在下文中一共展示了OsiRowCut::print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: quadCuts
void exprQuad::quadCuts (expression *w, OsiCuts &cs, const CouenneCutGenerator *cg){
#ifdef DEBUG
std::cout<<"Expression has "<< lcoeff_.size () <<" linear terms and "
<< nqterms_ <<" quadratic terms." << std::endl;
printf ("Q:");
for (sparseQ::iterator row = matrix_.begin (); row != matrix_.end (); ++row) {
int xind = row -> first -> Index ();
for (sparseQcol::iterator col = row -> second.begin (); col != row -> second.end (); ++col)
printf (" <%d,%d,%g>", xind, col -> first -> Index (), col -> second);
}
printf ("\nb:");
for (lincoeff::iterator el = lcoeff_.begin (); el != lcoeff_.end (); ++el)
//for (int i=0; i < nlterms_; i++)
printf (" <%d,%g>", el -> first -> Index (), el -> second);//index_ [i], coeff_ [i]);
if (c0_)
printf ("; <c0 = %g>", c0_);
printf ("\nBounds: var val lb ub eigval scaled\n");
int index = 0;
for (std::map <exprVar *, std::pair <CouNumber, CouNumber> >::iterator i = bounds_.begin ();
i != bounds_.end (); ++i, index++) {
printf ("%3d:\t", index);
i -> first -> print (); printf ("\t");
printf (" %8g [%8g, %8g]",
(*(i -> first)) (), i -> second.first, i -> second.second);
CouNumber
lb = cg -> Problem () -> Lb (i -> first -> Index ()),
ub = cg -> Problem () -> Ub (i -> first -> Index ());
if ((eigen_.size () > 0) &&
(fabs (ub-lb) > COUENNE_EPS))
printf (" --> %8g %8g",
eigen_.begin () -> first,
eigen_.begin () -> first / (ub-lb));
printf ("\n");
}
#endif
// Get on which side constraint is violated to get the good lambda
CouNumber
varVal = (*w) (),
exprVal = (*this) (),
lambda =
(eigen_.size () == 0) ? 0. :
(varVal < exprVal) ?
CoinMin (0., eigen_.begin () -> first) : // Use under-estimator
CoinMax (0., eigen_.rbegin () -> first), // Use over-estimator
convVal = 0.;
enum auxSign sign = cg -> Problem () -> Var (w -> Index ()) -> sign ();
// if this is a "semi"-auxiliary, check if necessary to separate
if ((sign == expression::AUX_GEQ && varVal > exprVal) ||
(sign == expression::AUX_LEQ && varVal < exprVal))
return;
const CouenneProblem& problem = *(cg -> Problem ());
const int numcols = problem.nVars ();
const double
*colsol = problem.X (), // current solution
*lower = problem.Lb (), // lower bound
*upper = problem.Ub (); // upper
// compute lower or upper convexification and check if it contains
// the current point
if (fabs (lambda) > COUENNE_EPS) {
convVal = exprVal;
// there is a convexification, check if out of current point
for (std::map <exprVar *, std::pair <CouNumber, CouNumber> >::iterator i = bounds_.begin ();
i != bounds_.end (); ++i) {
int ind = i -> first -> Index ();
CouNumber
xi = colsol [ind],
lb = lower [ind],
ub = upper [ind],
delta = ub-lb;
if (fabs (delta) > COUENNE_EPS)
convVal += lambda * (xi-lb) * (ub-xi) / (delta * delta);
}
if (varVal < exprVal) {if (convVal < varVal) return;}
else {if (convVal > varVal) return;}
//.........这里部分代码省略.........