15 using namespace Ipopt;
16 using namespace Couenne;
19 int CouenneBranchingObject::nOrbBr = 0;
20 int CouenneBranchingObject::maxDepthOrbBranch = -1;
21 int CouenneBranchingObject::nSGcomputations = 0;
29 void CouenneBranchingObject::branchCore (OsiSolverInterface *solver,
int indVar,
int way,
bool integer,
double brpt,
37 if ((doFBBT_ && problem_ -> doFBBT ()) ||
38 (doConvCuts_ && simulate_ && cutGen_))
43 if (problem_ -> orbitalBranching ()) {
56 std::vector< int > *branch_orbit = problem_ -> Find_Orbit (indVar);
59 lb = solver -> getColLower () [indVar],
60 ub = solver -> getColUpper () [indVar],
61 ob_brpt = lb + (ub-lb) / (branch_orbit -> size () + 1),
64 brpt = OB_weight * ob_brpt + (1-OB_weight) * brpt;
66 if (jnlst_ -> ProduceOutput (J_ERROR,
J_BRANCHING)) {
68 printf (
"Branch: x%d <= %g [%g,%g]\n",
70 integer ? floor (brpt) : brpt,
71 solver -> getColLower () [indVar],
72 solver -> getColUpper () [indVar]);
74 if (problem_ -> bestSol ()) {
76 if ((solver -> getColUpper () [indVar] > problem_ -> bestSol () [indVar]) &&
77 (brpt < problem_ -> bestSol () [indVar]))
79 printf (
"Branching rule EXCLUDES optimal solution\n");
81 for (
int i=0; i<problem_ -> nVars (); i++)
83 if ((solver -> getColLower () [indVar] > problem_ -> bestSol () [indVar] +
COUENNE_EPS) ||
84 (solver -> getColUpper () [indVar] < problem_ -> bestSol () [indVar] -
COUENNE_EPS))
86 {printf (
"This node does not include optimal solution\n");
break;}
94 solver -> setColUpper (indVar, integer ? floor (brpt) : brpt);
96 if (!simulate_ && (problem_ -> orbitalBranching ())){
100 problem_ -> ChangeBounds (solver -> getColLower (),
101 solver -> getColUpper (),
102 problem_ -> nVars ());
104 problem_ -> Compute_Symmetry ();
108 if (chg_bds) chg_bds [indVar].
setUpper (t_chg_bounds::CHANGED);
121 if (!simulate_ && (problem_ -> orbitalBranching ())){
123 problem_ -> ChangeBounds (solver -> getColLower (),
124 solver -> getColUpper (),
125 problem_ -> nVars ());
127 problem_ -> Compute_Symmetry ();
131 std::vector< int > *branch_orbit = problem_ -> Find_Orbit (indVar);
133 jnlst_ -> Printf (J_ERROR,
J_BRANCHING,
"Branch Symm (%d vars):", branch_orbit -> size ());
135 if (!simulate_ && (branch_orbit -> size () > 1))
143 lb = solver -> getColLower () [indVar],
144 ub = solver -> getColUpper () [indVar],
145 ob_brpt = lb + (ub-lb) / ((
double) branch_orbit -> size () + 1),
150 brpt = OB_weight * ob_brpt + (1-OB_weight) * brpt;
152 for (std::vector<int>::iterator it = branch_orbit -> begin (); it != branch_orbit ->
end (); ++it) {
153 assert (*it < problem_ -> nVars ());
157 if (jnlst_ -> ProduceOutput (J_ERROR,
J_BRANCHING)) {
158 printf (
" x%d>%g [%g,%g]",
160 integer ? ceil (brpt) : brpt,
161 solver -> getColLower () [*it],
162 solver -> getColUpper () [*it]);
164 if (problem_ -> bestSol () &&
165 (solver -> getColLower () [*it] < problem_ -> bestSol () [*it]) &&
166 (brpt > problem_ -> bestSol () [*it]) && !brExclude)
170 if (problem_ -> bestSol ()) {
172 for (
int i=0; i<problem_ -> nVars (); i++)
174 if (((solver -> getColLower () [indVar] > problem_ -> bestSol () [indVar] +
COUENNE_EPS) ||
175 (solver -> getColUpper () [indVar] < problem_ -> bestSol () [indVar] -
COUENNE_EPS))) {
184 if ((integer ? ceil (brpt) : brpt) > solver -> getColLower () [*it]) {
186 solver -> setColLower (*it, integer ? ceil (brpt) : brpt);
187 if (chg_bds) chg_bds [*it].
setLower (t_chg_bounds::CHANGED);
191 if (jnlst_ -> ProduceOutput (J_ERROR,
J_BRANCHING)) {
192 if (brExclude) printf (
" (Branching EXCLUDES optimal solution)");
193 if (nodeExclude) printf (
" (This node does not contain optimal solution)");
215 if (jnlst_ -> ProduceOutput (J_ERROR,
J_BRANCHING)) {
217 printf (
"Branch: x%d <= %g [%g,%g] (opt %g)\n",
219 integer ? floor (brpt) : brpt,
220 solver -> getColLower () [indVar],
221 solver -> getColUpper () [indVar],
222 problem_ -> bestSol () ? problem_ -> bestSol () [indVar] : 0.);
224 if (problem_ -> bestSol ()) {
226 if ((solver -> getColUpper () [indVar] >= problem_ -> bestSol () [indVar]) &&
227 (brpt < problem_ -> bestSol () [indVar]))
229 printf (
"Branching EXCLUDES optimal solution\n");
231 for (
int i=0; i<problem_ -> nVars (); i++)
233 if ((solver -> getColLower () [i] > problem_ -> bestSol () [i] +
COUENNE_EPS) ||
234 (solver -> getColUpper () [i] < problem_ -> bestSol () [i] -
COUENNE_EPS))
236 {printf (
"This node does not contain optimal solution: x%d in [%g,%g] (%g)\n",
237 i, solver -> getColLower () [i], solver -> getColUpper () [i], problem_ -> bestSol () [i]);
break;}
242 solver -> setColUpper (indVar, integer ? floor (brpt +
COUENNE_EPS) : brpt);
243 assert (solver -> getColUpper () [indVar] <= brpt +
COUENNE_EPS);
244 if (chg_bds) chg_bds [indVar].
setUpper (t_chg_bounds::CHANGED);
248 if (jnlst_ -> ProduceOutput (J_ERROR,
J_BRANCHING)) {
250 printf (
"Branch: x%d >= %g [%g,%g] (opt %g)\n",
252 integer ? ceil (brpt) : brpt,
253 solver -> getColLower () [indVar],
254 solver -> getColUpper () [indVar],
255 problem_ -> bestSol () ? problem_ -> bestSol () [indVar] : 0.);
257 if (problem_ -> bestSol ()) {
259 if ((solver -> getColLower () [indVar] <= problem_ -> bestSol () [indVar]) &&
260 (brpt > problem_ -> bestSol () [indVar]))
262 printf (
"Branching EXCLUDES optimal solution\n");
265 for (
int i=0; i<problem_ -> nVars (); i++)
267 if ((solver -> getColLower () [indVar] > problem_ -> bestSol () [indVar] +
COUENNE_EPS) ||
268 (solver -> getColUpper () [indVar] < problem_ -> bestSol () [indVar] -
COUENNE_EPS))
270 {printf (
"This node does not contain optimal solution: x%d in [%g,%g] (%g)\n",
271 i, solver -> getColLower () [i], solver -> getColUpper () [i], problem_ -> bestSol () [i]);
break;}
276 solver -> setColLower (indVar, integer ? ceil (brpt -
COUENNE_EPS) : brpt);
277 if (chg_bds) chg_bds [indVar].
setLower (t_chg_bounds::CHANGED);
status of lower/upper bound of a variable, to be checked/modified in bound tightening ...
void setLower(ChangeStatus lower)
const Ipopt::EJournalCategory J_BRANCHING(Ipopt::J_USER1)
void setUpper(ChangeStatus upper)