17 #include "CoinHelperFunctions.hpp"
19 using namespace Ipopt;
20 using namespace Couenne;
25 CouenneObject::CouenneObject ():
31 strategy_ (MID_INTERVAL),
40 pseudoMultType_ (INFEASIBILITY) {}
54 strategy_ (MID_INTERVAL),
63 pseudoMultType_ (INFEASIBILITY) {
74 printf (
"created Expression Object: ");
reference_ -> print ();
80 printf (
" with %s strategy [clamp=%g, alpha=%g]\n",
102 strategy_ (MID_INTERVAL),
111 pseudoMultType_ (INFEASIBILITY) {
121 cutGen_ (src.cutGen_),
122 problem_ (src.problem_),
123 reference_ (src.reference_),
124 strategy_ (src.strategy_),
127 lp_clamp_ (src.lp_clamp_),
128 feas_tolerance_ (src.feas_tolerance_),
129 doFBBT_ (src.doFBBT_),
130 doConvCuts_ (src.doConvCuts_),
131 downEstimate_ (src.downEstimate_),
132 upEstimate_ (src.upEstimate_),
133 pseudoMultType_ (src.pseudoMultType_) {}
142 if (value < lb) value = lb;
143 else if (value > ub) value = ub;
145 return CoinMin (value - floor (value +
COUENNE_EPS),
152 const OsiBranchingInformation *
info,
164 printf (
"CouObj::createBranch on ");
187 selectBranch (
this, info,
188 brVar, brPts, brDist, whichWay);
194 brPts = (
double *) realloc (brPts,
sizeof (
double));
195 brDist = (
double *) realloc (brDist, 2 *
sizeof (
double));
197 double point = info -> solution_ [
reference_ -> Index ()];
202 if (point > floor (point)) {improv = brDist [0] = point - floor (point);}
203 if (point < ceil (point)) {improv = CoinMin (improv, brDist [1] = ceil (point) - point);}
205 point -= floor (point);
229 printf (
"brpts for ");
reference_ -> print ();
231 printf (
" is on "); brVar -> print ();
232 printf (
" @ %.12g [%.12g,%.12g]\n", *brPts,
234 problem_ -> Ub (brVar -> Index ()));
239 printf (
"### warning, infeas = %g for ", improv);
245 int index = brVar -> Index ();
246 if (info -> lower_ [index] >=
248 printf (
"### warning, tiny bounding box [%g,%g] for x_%d\n",
249 info -> lower_ [index],
250 info -> upper_ [index], index);
261 if (brPts) free (brPts);
262 if (brDist) free (brDist);
270 const OsiBranchingInformation *
info)
const {
278 int objInd =
problem_ -> Obj (0) -> Body () -> Index ();
281 lb = objInd >= 0 ? info -> lower_ [objInd] :
problem_ -> Obj (0) -> Body () -> Value (),
286 fabs (ub - lb) / (1.e-3 + CoinMin (fabs (ub), fabs (lb)));
289 if (currentGap < 1
e-3) {
293 assert ((currentGap >= 0.) &&
296 curAlpha = currentGap *
alpha_ + (1 - currentGap);
301 curAlpha += (1 -
alpha_) / (1. + currentGap);
312 return (0.5 * (l + u));
319 else return CoinMax ((l+u)/2, (
AGGR_MUL * (-1. + u)));
323 else return CoinMin ((l+u)/2, (
AGGR_MUL * (1. + l)));
326 CouNumber point = curAlpha * x + (1. - curAlpha) * (l + u) / 2.;
338 const OsiBranchingInformation *
info)
const {
357 printf (
"Couenne: unknown branching point selection strategy\n");
385 double point = info -> solution_ [refInd];
392 if (retval < intInfeas) {
403 CoinMax (retval,
intInfeasibility (point, info -> lower_ [refInd], info -> upper_ [refInd])) :
418 info -> lower_ [refInd],
419 info -> upper_ [refInd]) : 0.;
422 vval = info -> solution_ [
reference_ -> Index ()],
424 denom = CoinMax (1.,
reference_ -> Image () -> gradientNorm (info -> solution_));
427 if (CoinIsnan (fval)) {
440 ratio = (CoinMax (1., fabs (vval)) /
441 CoinMax (1., fabs (fval)));
453 printf (
" infeas %g: ", retval);
468 info -> lower_ [refInd],
469 info -> upper_ [refInd])) :
481 base -> options () -> GetStringValue (
"pseudocost_mult", s,
"couenne.");
490 base -> options() -> GetStringValue (
"branch_fbbt", s,
"couenne.");
doFBBT_ = (s==
"yes");
491 base -> options() -> GetStringValue (
"branch_conv_cuts", s,
"couenne.");
doConvCuts_ = (s==
"yes");
493 base -> options() -> GetNumericValue (
"feas_tolerance",
feas_tolerance_,
"couenne.");
496 base -> options () -> GetStringValue (
"branch_pt_select", brtype,
"couenne.");
503 else if (brtype ==
"mid-point") {
505 base -> options () -> GetNumericValue (
"branch_midpoint_alpha",
alpha_,
"couenne.");
510 base -> options () -> GetNumericValue (
"branch_lp_clamp",
lp_clamp_,
"couenne.");
515 std::string br_operator =
"";
522 base -> options () -> GetStringValue (
"branch_pt_select_pow", brtype,
"couenne.");
526 if (fabs (expon - 2.) <
COUENNE_EPS) br_operator =
"sqr";
527 else if (fabs (expon - 3.) <
COUENNE_EPS) br_operator =
"cube";
528 else if (expon < 0.) br_operator =
"negpow";
529 else br_operator =
"pow";
533 br_operator = (
reference_ -> Image () -> ArgList () [0] -> Index () !=
534 reference_ -> Image () -> ArgList () [1] -> Index ()) ?
546 if (br_operator !=
"") {
548 char select [40], sel_clamp [40];
550 sprintf (select,
"branch_pt_select_%s", br_operator.c_str ());
551 sprintf (sel_clamp,
"branch_lp_clamp_%s", br_operator.c_str ());
552 base -> options () -> GetStringValue (select, brtype,
"couenne.");
553 base -> options () -> GetNumericValue (sel_clamp, lp_clamp_fun,
"couenne.");
563 else if (brtype ==
"mid-point") {
566 base -> options () -> GetNumericValue (
"branch_midpoint_alpha", alpha_fun,
"couenne.");
588 lower = info -> lower_ [index],
589 upper = info -> upper_ [index];
607 point = info -> solution_ [index];
629 if (point < lower + delta)
630 point = lower + delta;
631 else if (point > upper - delta)
632 point = upper - delta;
658 printf (
"Couenne: invalid estimate setting procedure\n");
Cut Generator for linear convexifications.
const double large_bound
if |branching point| > this, change it
CouenneObject()
empty constructor (for unused objects)
const CouNumber feas_tolerance_default
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)$.
CouNumber alpha_
Combination parameter for the mid-point branching point selection strategy.
virtual OsiBranchingObject * createBranch(OsiSolverInterface *, const OsiBranchingInformation *, int) const
create CouenneBranchingObject or CouenneThreeWayBranchObj based on this object
exprVar * reference_
The (auxiliary) variable this branching object refers to.
const double Couenne_large_bound
used to declare LP unbounded
"Spatial" branching object.
void setEstimates(const OsiBranchingInformation *info, CouNumber *infeasibility, CouNumber *brpt) const
set up/down estimates based on branching information
enum brSelStrat strategy_
Branching point selection strategy.
static const double init_estimate
const Ipopt::EJournalCategory J_BRANCHING(Ipopt::J_USER1)
bool doFBBT_
shall we do Feasibility based Bound Tightening (FBBT) at branching?
CouNumber feas_tolerance_
feasibility tolerance (equal to that of CouenneProblem)
double downEstimate_
down estimate (to be used in pseudocost)
CouenneProblem * problem_
pointer to Couenne problem
CouNumber minMaxDelta(funtriplet *ft, CouNumber lb, CouNumber ub)
void fint fint fint real fint real real real real real real real real real * e
const CouNumber default_alpha
void setParameters(Bonmin::BabSetupBase *base)
set object parameters by reading from command line
A class to have all elements necessary to setup a branch-and-bound.
static double ratio(Bigint *a, Bigint *b)
bool doConvCuts_
shall we add convexification cuts at branching?
virtual double intInfeasibility(double value, double lb, double ub) const
integer infeasibility: min {value - floor(value), ceil(value) - value}
Class for MINLP problems with symbolic information.
const CouNumber closeToBounds
CouNumber getBrPoint(funtriplet *ft, CouNumber x0, CouNumber l, CouNumber u, const OsiBranchingInformation *info=NULL) const
pick branching point based on current strategy
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
const CouNumber max_pseudocost
double CouNumber
main number type in Couenne
enum pseudocostMult pseudoMultType_
multiplier type for pseudocost
double upEstimate_
up estimate (to be used in pseudocost)
CouNumber midInterval(CouNumber x, CouNumber l, CouNumber u, const OsiBranchingInformation *info=NULL) const
returns a point "inside enough" a given interval, or x if it already is.
CouenneCutGenerator * cutGen_
pointer to cut generator (not necessary, can be NULL)
CouNumber lp_clamp_
Defines safe interval percentage for using LP point as a branching point.
const CouNumber default_clamp
JnlstPtr jnlst_
SmartPointer to the Journalist.
virtual double infeasibility(const OsiBranchingInformation *info, int &way) const
compute infeasibility of this variable, |w - f(x)| (where w is the auxiliary variable defined as w = ...
virtual double checkInfeasibility(const OsiBranchingInformation *info) const
compute infeasibility of this variable, |w - f(x)|, where w is the auxiliary variable defined as w = ...
CouNumber maxHeight(funtriplet *ft, CouNumber lb, CouNumber ub)
void fint fint fint real fint real * x
bool isInteger(CouNumber x)
is this number integer?