17 using namespace Ipopt;
 
   18 using namespace Couenne;
 
   24                     OsiSolverInterface *solver);
 
   27 int CouenneDisjCuts::getDisjunctions (std::vector <std::pair <OsiCuts *, OsiCuts *> > &disjs, 
 
   28                                       OsiSolverInterface &si, 
 
   30                                       const CglTreeInfo &
info)
 const {
 
   32   OsiBranchingInformation brInfo (&si, 
 
   36   if (jnlst_ -> ProduceOutput (J_MATRIX, 
J_DISJCUTS))
 
   37     for (
int i=0; i<si.getNumCols (); i++)
 
   38       printf (
"%3d. %8g  [%8g %8g]\n", i, 
 
   39               brInfo. solution_ [i], 
 
   44   branchingMethod_ -> setupList (&brInfo, 
true); 
 
   47     ncols  = si.getNumCols (),
 
   50   int nobjs = branchingMethod_ -> numberUnsatisfied ();
 
   54     if (jnlst_ -> ProduceOutput (J_DETAILED, 
J_DISJCUTS)) 
 
   55       printf (
"---   %d disjunctive objects\n", nobjs);
 
   57     const int *candidates = branchingMethod_ -> candidates ();
 
   58     OsiObject **objs = si. objects ();
 
   63     for (
int candInd = 0,      num = 0; 
 
   64          (candInd < nobjs) && (num < numDisjunctions_); 
 
   67       OsiObject *Object = objs [candidates [candInd]];
 
   72       int indVar = Object -> columnNumber ();
 
   77           ((cObj -> checkInfeasibility (&brInfo) == 0.) || 
 
   78            (cObj -> isCuttable ())))                       
 
   81       bool     feasLeft = 
true,  feasRight = 
true;
 
   82       OsiCuts *leftCuts = NULL, *rightCuts = NULL;
 
   85         *saveLower = CoinCopyOfArray (si.getColLower (), ncols),
 
   86         *saveUpper = CoinCopyOfArray (si.getColUpper (), ncols);
 
   88       OsiBranchingObject *brObj = Object -> createBranch (&si, &brInfo, 0); 
 
   91           jnlst_ -> ProduceOutput (J_VECTOR, 
J_DISJCUTS) &&
 
   92           dynamic_cast <CouenneBranchingObject *> (brObj) &&
 
   93           dynamic_cast <CouenneBranchingObject *> (brObj) -> variable ())
 
   94         printf (
"---   cand [%d] is %d: x_%d <>= %g [%g,%g]\n", 
 
   97                 dynamic_cast <CouenneBranchingObject *> (brObj) -> variable () -> Index (), 
 
   99                 couenneCG_->Problem()->Lb(dynamic_cast<CouenneBranchingObject*>(brObj)
 
  100                                           ->variable()->Index ()),
 
  101                 couenneCG_->Problem()->Ub(dynamic_cast<CouenneBranchingObject*>(brObj)
 
  102                                           ->variable()->Index ()));
 
  108           (!cObj && !
BranchingFBBT (couenneCG_ -> Problem (), Object, &si)))
 
  110       else leftCuts = getSingleDisjunction (si); 
 
  113       si.setColLower (saveLower);
 
  114       si.setColUpper (saveUpper);
 
  120       brObj = Object -> createBranch (&si, &brInfo, 1); 
 
  124           (!cObj && !
BranchingFBBT (couenneCG_ -> Problem (), Object, &si)))
 
  126       else rightCuts = getSingleDisjunction (si); 
 
  131       si.setColLower (saveLower);
 
  132       si.setColUpper (saveUpper);
 
  136       if (feasLeft && feasRight) {
 
  140         std::pair <OsiCuts *, OsiCuts *> newpair;
 
  141         newpair.first  = leftCuts;
 
  142         newpair.second = rightCuts;
 
  144         disjs.push_back (newpair);
 
  148       } 
else if (feasLeft) {
 
  150         jnlst_ -> Printf (J_VECTOR, 
J_DISJCUTS, 
"---   disj: infeasible right\n");
 
  151         applyColCuts (si, leftCuts); 
 
  154       } 
else if (feasRight) {
 
  156         jnlst_ -> Printf (J_VECTOR, 
J_DISJCUTS, 
"---   infeasible left\n");
 
  157         applyColCuts (si, rightCuts); 
 
  161         jnlst_ -> Printf (J_VECTOR, 
J_DISJCUTS, 
"---   infeasible!!!\n");
 
  177     if (jnlst_ -> ProduceOutput (J_DETAILED, 
J_DISJCUTS))
 
  178       printf (
"have %d disjunctions\n", (
int) (disjs.size ()));
 
  185     for (std::vector <std::pair <OsiCuts *, OsiCuts *> >::iterator disjI = disjs.begin ();
 
  186          disjI != disjs.end (); ++disjI) {
 
  196           if (jnlst_ -> ProduceOutput (J_VECTOR, 
J_DISJCUTS))
 
  197             printf (
"---   infeasible left [2]!\n");
 
  198           applyColCuts (si, disjI -> second);
 
  203         if (jnlst_ -> ProduceOutput (J_VECTOR, 
J_DISJCUTS))
 
  204           printf (
"---   infeasible right [2]!\n");
 
  205         applyColCuts (si, disjI -> first);
 
  217     for (std::vector <std::pair <OsiCuts *, OsiCuts *> >::iterator disjI = disjs.begin ();
 
  218          disjI != disjs.end (); ++disjI) {
 
  220       CoinPackedVector lowerChg, upperChg;
 
  223       getBoxUnion (si, disjI -> first, disjI -> second, lowerChg, upperChg);
 
  225       if ((lowerChg.getNumElements () > 0) || 
 
  226           (upperChg.getNumElements () > 0)) {
 
  229         cut.setLbs (lowerChg);
 
  230         cut.setUbs (upperChg);
 
  231         applyColCuts (si, &cut);
 
  243 void CouenneDisjCuts::applyColCuts (OsiSolverInterface &si, OsiCuts *cuts)
 const {
 
  245   if (jnlst_ -> ProduceOutput (J_MATRIX, 
J_DISJCUTS)) {
 
  246     printf (
"applying cuts to SI:\n");
 
  248     for (
int i = cuts -> sizeColCuts (); i--;)
 
  249       cuts -> colCutPtr (i) -> print ();
 
  250     printf (
"--------------------\n");
 
  254   for (
int i = cuts -> sizeColCuts (); i--;)
 
  255     applyColCuts (si, cuts -> colCutPtr (i));
 
  260 void CouenneDisjCuts::applyColCuts (OsiSolverInterface &si, OsiColCut *cut)
 const {
 
  263   if (jnlst_ -> ProduceOutput (J_VECTOR, 
J_DISJCUTS)) {
 
  264     printf (
"tightening bounds: "); 
 
  268   const CoinPackedVector
 
  269     &lbs = cut -> lbs (),
 
  270     &ubs = cut -> ubs ();
 
  272   const int    *lind = lbs.getIndices  (), *uind = ubs.getIndices  ();
 
  273   const double *lval = lbs.getElements (), *uval = ubs.getElements (),
 
  274     *oldLower = si.getColLower (), 
 
  275     *oldUpper = si.getColUpper ();
 
  277   for (
int j=lbs.getNumElements (); 
j--; lval++, lind++)
 
  279       si.setColLower (*lind, *lval);
 
  281   for (
int j=ubs.getNumElements (); 
j--; uval++, uind++)
 
  283       si.setColUpper (*uind, *uval);
 
bool BranchingFBBT(CouenneProblem *problem, OsiObject *Object, OsiSolverInterface *solver)
Called from simulateBranch and from disjunctive cut generators when object is not CouenneObject and t...
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real fint fint fint fint * info
OsiObject for auxiliary variables $w=f(x)$. 
const Ipopt::EJournalCategory J_DISJCUTS(Ipopt::J_USER6)
Class for MINLP problems with symbolic information.