11 #include "CoinHelperFunctions.hpp"
21 using namespace Ipopt;
22 using namespace Couenne;
35 varSelection_ (varSelection) {
38 printf (
"created Variable Object: ");
40 printf (
" with %s strategy [clamp=%g, alpha=%g]\n",
55 const OsiBranchingInformation *
info,
64 info -> upper_,
false);
66 OsiBranchingObject *obj = NULL;
81 brpt = info -> solution_ [indVar],
82 l = info -> lower_ [indVar],
83 u = info -> upper_ [indVar];
93 #define LARGE_VALUE 1e8
109 (brpt > u - width)) brpt = .5 * (l+u);
break;
111 info -> lower_ [indVar],
112 info -> upper_ [indVar], info);
break;
113 default: assert (
false);
135 jnlst_ -> Printf (J_ITERSUMMARY,
J_BRANCHING,
":::: creating branching on x_%d @%g [%g,%g]\n",
137 info -> solution_ [indVar],
138 info -> lower_ [indVar],
139 info -> upper_ [indVar]);
141 obj = criticalObject ?
157 criticalObject = NULL;
160 printf (
"---------- computeBRPT for ");
162 printf (
" [%g,%g]\n",
175 maxdist = - COIN_DBL_MAX;
185 std::set <int> deplist =
problem_ -> Dependence () [index];
187 for (std::set <int>::iterator i = deplist.begin (); i != deplist.end (); ++i) {
196 printf (
" dependence: ");
198 if (
reference_ -> Image ()) {printf (
" := "); obj ->
Reference () -> Image () -> print ();}
206 -> selectBranch (obj, info,
207 brVar, brPts, brDist, whichWay);
211 brPts = (
double *) realloc (brPts,
sizeof (
double));
212 brDist = (
double *) realloc (brDist, 2 *
sizeof (
double));
214 double point = info -> solution_ [obj ->
Reference () -> Index ()];
219 if (point > floor (point)) {improv = brDist [0] = point - floor (point);}
220 if (point < ceil (point)) {improv = CoinMin (improv, brDist [1] = ceil (point) - point);}
222 point -= floor (point);
228 printf (
" --> Branching on ");
232 printf (
" at %g, improv %g <%g>, indices = %d,%d\n",
233 *brPts, improv, maxdist, index, brVar -> Index ());
238 (brVar -> Index () == index) &&
239 (fabs (improv) > maxdist) &&
242 criticalObject = (
problem_ -> Objects () [*i]);
244 brdistDn = brDist [0];
245 brdistUp = brDist [1];
258 bestPt = info -> solution_ [index];
262 l = info -> lower_ [index],
263 u = info -> upper_ [index],
269 bestPt = CoinMax (l + width, CoinMin (bestPt, u - width));
273 if ((bestPt < l + width) || (bestPt > u - width))
284 if (CoinMin (fabs (bestPt - l), fabs (bestPt - u)) < 1
e-3) {
285 printf (
"computed failsafe %g [%g,%g] for ", bestPt, l,u);
298 brPts = (
double *) realloc (brPts,
sizeof (
double));
302 printf (
" ::: failsafe: %g [%g,%g] for ",
303 bestPt, info -> lower_ [index], info -> upper_ [index]);
311 if (CoinMin (fabs (bestPt - info -> lower_ [index]),
312 fabs (bestPt - info -> upper_ [index])) < 1
e-3) {
313 printf (
" computed %g [%g,%g] for ",
314 bestPt, info -> lower_ [index], info -> upper_ [index]);
330 if (brPts) free (brPts);
331 if (brDist) free (brDist);
341 const OsiBranchingInformation *
info)
const {
346 double val = info -> solution_ [index];
349 solver -> setColLower (index, val-
TOL);
350 solver -> setColUpper (index, val+
TOL);
360 const std::vector <CouenneObject *> &objects =
problem_ -> Objects ();
362 for (std::set <int>::const_iterator depvar = deplist. begin ();
363 depvar != deplist.
end (); ++depvar)
Cut Generator for linear convexifications.
const double large_bound
if |branching point| > this, change it
virtual bool isCuttable() const
are we on the bad or good side of the expression?
virtual OsiBranchingObject * createBranch(OsiSolverInterface *, const OsiBranchingInformation *, int) const
create CouenneBranchingObject or CouenneThreeWayBranchObj based on this object
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)$.
virtual double feasibleRegion(OsiSolverInterface *, const OsiBranchingInformation *) const
fix nonlinear coordinates of current integer-nonlinear feasible solution
CouNumber alpha_
Combination parameter for the mid-point branching point selection strategy.
exprVar * reference_
The (auxiliary) variable this branching object refers to.
"Spatial" branching object.
enum brSelStrat strategy_
Branching point selection strategy.
const Ipopt::EJournalCategory J_BRANCHING(Ipopt::J_USER1)
bool doFBBT_
shall we do Feasibility based Bound Tightening (FBBT) at branching?
CouNumber computeBranchingPoint(const OsiBranchingInformation *info, int &bestWay, const CouenneObject *&criticalObject) const
Method computing the branching point.
double downEstimate_
down estimate (to be used in pseudocost)
CouenneProblem * problem_
pointer to Couenne problem
void fint fint fint real fint real real real real real real real real real * e
A class to have all elements necessary to setup a branch-and-bound.
int varSelection_
branching scheme used.
bool doConvCuts_
shall we add convexification cuts at branching?
Class for MINLP problems with symbolic information.
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.
exprVar * Reference() const
return reference auxiliary variable
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.
JnlstPtr jnlst_
SmartPointer to the Journalist.
bool isInteger(CouNumber x)
is this number integer?