11 #include "CglCutGenerator.hpp"
19 #include "CbcTree.hpp"
23 using namespace Ipopt;
24 using namespace Couenne;
39 objValue_ (- DBL_MAX),
43 jnlst_ (base ? base -> journalist () : NULL),
48 base -> options () -> GetIntegerValue (
"convexification_points",
nSamples_,
"couenne.");
52 base -> options () -> GetStringValue (
"convexification_type", s,
"couenne.");
57 base -> options () -> GetStringValue (
"violated_cuts_only", s,
"couenne.");
60 base -> options () -> GetStringValue (
"check_lp", s,
"couenne.");
63 base -> options () -> GetStringValue (
"enable_lp_implied_bounds", s,
"couenne.");
90 CglCutGenerator (src),
92 firstcall_ (src. firstcall_),
93 addviolated_ (src. addviolated_),
94 convtype_ (src. convtype_),
95 nSamples_ (src. nSamples_),
96 problem_ (src. problem_),
97 nrootcuts_ (src. nrootcuts_),
98 ntotalcuts_ (src. ntotalcuts_),
99 septime_ (src. septime_),
100 objValue_ (src. objValue_),
102 BabPtr_ (src. BabPtr_),
103 infeasNode_ (src. infeasNode_),
104 jnlst_ (src. jnlst_),
105 rootTime_ (src. rootTime_),
106 check_lp_ (src. check_lp_),
107 enable_lp_implied_bounds_ (src.enable_lp_implied_bounds_),
108 lastPrintLine(src.lastPrintLine)
112 #define MAX_SLOPE 1e3
122 "warning, discontinuity of %e over an interval of %e\n", y2-y1, x2-x1);
129 return createCut (cs, y1*dx - dy*x1, (dx>0) ? sign : -sign, wi, dx, xi, -dy);
137 {
return createCut (cs, w - slope * x, sign, wi, 1., xi, - slope);}
150 roptions -> AddLowerBoundedIntegerOption
151 (
"convexification_cuts",
152 "Specify the frequency (in terms of nodes) at which couenne ecp cuts are generated.",
154 "A frequency of 0 amounts to never solve the NLP relaxation.");
156 roptions -> AddStringOption2
158 "Check all LPs through an independent call to OsiClpSolverInterface::initialSolve()",
163 roptions -> AddStringOption3
164 (
"convexification_type",
165 "Determines in which point the linear over/under-estimator are generated",
166 "current-point-only",
167 "current-point-only",
"Only at current optimum of relaxation",
168 "uniform-grid",
"Points chosen in a uniform grid between the bounds of the problem",
169 "around-current-point",
"At points around current optimum of relaxation",
170 "For the lower envelopes of convex functions, this is the number of points where a supporting hyperplane is generated. "
171 "This only holds for the initial linearization, as all other linearizations only add at most one cut per expression."
174 roptions -> AddLowerBoundedIntegerOption
175 (
"convexification_points",
176 "Specify the number of points at which to convexify when convexification type "
177 "is uniform-grid or around-current-point.",
181 roptions -> AddStringOption2
182 (
"violated_cuts_only",
183 "Yes if only violated convexification cuts should be added",
188 roptions -> AddStringOption2
189 (
"enable_lp_implied_bounds",
190 "Enable OsiSolverInterface::tightenBounds () -- warning: it has caused "
191 "some trouble to Couenne",
196 roptions -> AddStringOption3
197 (
"multilinear_separation",
198 "Separation for multilinear terms",
200 "none",
"No separation -- just use the four McCormick inequalities",
201 "simple",
"Use one considering lower curve only",
202 "tight",
"Use one considering both curves pi(x) = l_{k+1} and pi(x) = u_{k+1}",
203 "Type of separation for multilinear terms where the dependent variable is also bounded"
210 double cbcLb =
BabPtr_->
model().getBestPossibleObjValue();
211 double lpVal =
BabPtr_->
model().solver()->getObjValue();
218 double bestSolVal = rs->
getVal();
219 printf(
"%10d %8d %6d %10.6f %10.6f %10.6f\n",
220 nbNodes, nbNodesRem, depth, cbcLb, lpVal, bestSolVal);
223 printf(
"%10d %8d %6d %10.6f %10.6f ----------\n",
224 nbNodes, nbNodesRem, depth, cbcLb, lpVal);
227 if((depth < problem_->minDepthPrint_) ||
228 (nbNodes < problem_->minNodePrint_)) {
Cut Generator for linear convexifications.
bool addviolated_
True if we should add the violated cuts only, false if all of them should be added.
CouenneCutGenerator(Bonmin::OsiTMINLPInterface *=NULL, Bonmin::BabSetupBase *base=NULL, CouenneProblem *=NULL, struct ASL *=NULL)
constructor
~CouenneCutGenerator()
destructor
int lastPrintLine
Running count of printed info lines.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
enum conv_type convtype_
what kind of sampling should be performed?
Option category for Couenne.
bool check_lp_
Check all generated LPs through an independent call to OsiClpSolverInterface::initialSolve() ...
const Ipopt::EJournalCategory J_CONVEXIFYING(Ipopt::J_USER3)
JnlstPtr jnlst_
SmartPointer to the Journalist.
void printLineInfo() const
print node, depth, LB/UB/LP info
int addTangent(OsiCuts &, int, int, CouNumber, CouNumber, CouNumber, int) const
add tangent at given poing (x,w) with given slope
A class to have all elements necessary to setup a branch-and-bound.
CouenneRecordBestSol * getRecordBestSol() const
returns recorded best solution
int createCut(OsiCuts &, CouNumber, CouNumber, int, CouNumber, int=-1, CouNumber=0., int=-1, CouNumber=0., bool=false) const
create cut and check violation. Insert and return status
Class for MINLP problems with symbolic information.
bool enable_lp_implied_bounds_
Take advantage of OsiClpSolverInterface::tightenBounds (), known to have caused some problems some ti...
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Add list of options to be read from file.
double CouNumber
main number type in Couenne
int getnvars() const
total number of variables (original + auxiliary)
Bonmin::Bab * BabPtr_
pointer to the Bab object (used to retrieve the current primal bound through bestObj()) ...
CouenneProblem * problem_
pointer to symbolic repr. of constraint, variables, and bounds
int addSegment(OsiCuts &, int, int, CouNumber, CouNumber, CouNumber, CouNumber, int) const
Add half-plane through (x1,y1) and (x2,y2) – resp.
void fint fint fint real fint real real real real real real real real * w
int nSamples_
how many cuts should be added for each function?
const CbcModel & model() const
Get cbc model used to solve.
void fint fint fint real fint real * x