Scippy

GCG

Branch-and-Price & Column Generation for Everyone

cons_masterbranch.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file cons_masterbranch.c
30 * @brief constraint handler for storing the branching decisions at each node of the tree
31 * @author Gerald Gamrath
32 * @author Martin Bergner
33 * @author Christian Puchert
34 * @author Marcel Schmickerath
35 * @author Erik Muehmer
36 */
37
38/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39/* #define SCIP_DEBUG */
40#include <assert.h>
41#include <string.h>
42
43#include "gcg/gcg.h"
44#include "gcg/branch_generic.h"
46#include "gcg/cons_origbranch.h"
47#include "gcg/relax_gcg.h"
48#include "gcg/pricer_gcg.h"
49#include "gcg/pub_colpool.h"
50#include "gcg/gcgvarhistory.h"
52#include "gcg/mastersepacut.h"
53
54
55/*#define CHECKPROPAGATEDVARS*/
56
57/* constraint handler properties */
58#define CONSHDLR_NAME "masterbranch"
59#define CONSHDLR_DESC "store branching decision at nodes of the tree constraint handler"
60#define CONSHDLR_ENFOPRIORITY 0 /**< priority of the constraint handler for constraint enforcing */
61#define CONSHDLR_CHECKPRIORITY 2000000 /**< priority of the constraint handler for checking feasibility */
62#define CONSHDLR_PROPFREQ 1 /**< frequency for propagating domains; zero means only preprocessing propagation */
63#define CONSHDLR_EAGERFREQ 100 /**< frequency for using all instead of only the useful constraints in separation,
64 * propagation and enforcement, -1 for no eager evaluations, 0 for first only */
65#define CONSHDLR_DELAYPROP FALSE /**< should propagation method be delayed, if other propagators found reductions? */
66#define CONSHDLR_NEEDSCONS TRUE /**< should the constraint handler be skipped, if no constraints are available? */
67#define CONSHDLR_PROPTIMING SCIP_PROPTIMING_ALWAYS
68
69#define EVENTHDLR_NAME "origvarbound"
70#define EVENTHDLR_DESC "event handler for bound changes on original variables"
71
72
73/** constraint data for masterbranch constraints */
75{
76 char* name; /**< name of the constraint */
77 int npropvars; /**< number of variables that existed the last time the related node was propagated,
78 used to determine whether the constraint should be repropagated */
79 SCIP_Bool needprop; /**< should the constraint be propagated? */
80 SCIP_NODE* node; /**< the node at which the constraint is sticking */
81 int nactivated; /**< number of times the constraint has been activated so far */
82
83 SCIP_CONS* parentcons; /**< the masterbranch constraint of the parent node */
84 SCIP_CONS** childconss; /**< array of the masterbranch constraints of child nodes */
85 int nchildconss; /**< number of the masterbranch constraints of child nodes */
86 int maxchildconss; /**< capacity of childconss array */
87 SCIP_CONS* probingtmpcons; /**< pointer to save the last child in the childconss array if it is overwritten in probing mode */
88 SCIP_CONS* origcons; /**< the corresponding origbranch cons in the original program */
89
90 GCG_BRANCHDATA* branchdata; /**< branching data stored by the branching rule at the corresponding origcons constraint
91 * containing information about the branching restrictions */
92 GCG_BRANCHRULE* branchrule; /**< branching rule that created the corresponding node in the original problem and imposed
93 * branching restrictions */
94
95 /* pointer to the last variable that we have seen, any newer variables are unseen */
96 GCG_VARHISTORY* knownvarhistory; /**< pointer to the history of priced variables */
97
98 /* local bound changes on original variables that belong to a unique block */
99 SCIP_VAR** localbndvars; /**< original variables of bound changes stored at the current node */
100 SCIP_BOUNDTYPE* localbndtypes; /**< types of the bound changes stored at the current node */
101 SCIP_Real* localnewbnds; /**< new bounds for the bound changes stored at the current node */
102 SCIP_Real* localoldbnds; /**< old bounds for the bound changes stored at the current node */
103
104 int* nlocalbndchgstreated; /**< number of bound changes of the nodes on the way from the current node to
105 * the root node that have been treated so far */
106 int maxlocalbndchgstreated; /**< capacity of nlocalbndchgstreated */
107 int nlocalbndchgs; /**< number of bound changes */
108 int maxlocalbndchgs; /**< capacity of corresponding arrays */
109 int nbranchingchgs; /**< number of bound changes due to branching (<= nlocalbndchgs) */
110
111 /* local bound changes on original variables that have been directly copied to the master problem */
112 SCIP_VAR** copiedvars; /**< original variables on which local bounds were changed */
113 GCG_BOUNDTYPE* copiedvarbndtypes; /**< types of the new local bounds of the coped original variables */
114 SCIP_Real* copiedvarbnds; /**< new lower/upper bounds of the coped original variables */
115 int ncopiedvarbnds; /**< number of new local bounds stored */
116 int maxcopiedvarbnds; /**< size of copiedvars, copiedvarbndtypes, and copiedvarbnds arrays */
117
118 /* constraints that enforce the branching restrictions on the original problem */
119 SCIP_CONS** origbranchconss; /**< constraints in the original problem that enforce the branching decision */
120 int norigbranchconss; /**< number of constraints in the original problem that enforce the branching decision */
121 int maxorigbranchconss; /**< capacity of origbranchconss array */
122
123 /* information needed to update cuts generated by master separators */
124 GCG_EXTENDEDMASTERCONSDATA** addedcuts; /**< master separator cuts which were created in the node defined by this branch */
125 int naddedcuts; /**< number of master separator cuts which were added in this node */
126 int firstnewcut; /**< index of first cut from this node in active cuts */
127 SCIP_Bool addedcutsinit; /**< indicates if above data structures have been initialized */
128 SCIP_Bool nodestoredcuts; /**< indicates if any cuts were stored at this node */
129};
130
131/** constraint handler data */
133{
134 GCG* gcg; /**< GCG data structure */
135 /* active masterbranch constraints on the path from the root node to the current node */
136 SCIP_CONS** stack; /**< stack for storing active constraints */
137 int nstack; /**< number of elements on the stack */
138 int maxstacksize; /**< maximum size of the stack */
139
140 /* global bound changes on the original problem */
141 SCIP_VAR** pendingvars; /**< pricing variables or master variable copies corresponding to pending bound changes (global bound changes) */
142 SCIP_BOUNDTYPE* pendingbndtypes; /**< types of the pending bound changes (global bound changes) */
143 SCIP_Real* pendingnewbnds; /**< new bounds corresponding to pending bound changes (global bound changes) */
144 SCIP_HASHMAP* pendingvarmaplb; /**< maps vars to indices of the pendingvars array for global lower bound changes */
145 SCIP_HASHMAP* pendingvarmapub; /**< maps vars to indices of the pendingvars array for global upper bound changes */
146 int npendingbnds; /**< number of pending bound changes (global bound changes) */
147 SCIP_Bool pendingbndsactivated; /**< were pending bound changes already activated? */
148 int maxpendingbnds; /**< size of the array corresponding to pending bound changes */
149 SCIP_Bool enforceproper; /**< should proper variables be enforced? */
150
151 /* information needed by applyLocalBndchgsToPricedMastervars */
152 SCIP_VAR*** collectedbndvars; /**< collected original variables of bound changes stored for each block */
153 SCIP_Real** collectedlbnds; /**< collected upper bound changes for each block */
154 SCIP_Real** collectedubnds; /**< collected upper bound changes for each block */
155 int maxblocknum; /**< maximal number of blocks that can be handled by the collected* arrays */
156 int* ncollectedbndvars; /**< number of collected bndvars per block */
157 int* maxcollectedbndvars;/**< capacity of the collected* arrays per block */
158 int** linkingvaridxs; /**< position of linking vars in collectedbndvars */
159 int maxlinkingvaridxs; /**< capacity of linkingvaridxs */
160};
161
163{
164 GCG* gcg; /**< GCG data structure */
165};
166
167/*
168 * Local methods
169 */
170
171/**< updates a master separator cut with all the variables it 'missed' while being inactive */
172static
174 GCG* gcg, /**< SCIP data structure */
175 GCG_EXTENDEDMASTERCONSDATA* mastersepacut /**< master separator cut */
176 )
177{
178 SCIP* scip;
179 GCG_VARHISTORY* varhistory;
180
181 assert(gcg != NULL);
182 assert(mastersepacut != NULL);
183
186 assert(varhistory != NULL);
187
188 while( GCGvarhistoryHasNext(varhistory) )
189 {
190 SCIP_VAR* mastervar;
191 SCIP_VAR** origvars;
192 SCIP_VAR** pricingvars;
193 SCIP_Real* pricingvals;
194 SCIP_Real coef;
195 int blocknr;
196 int npricingvars;
197 int nnonzeros;
198 int j;
199
200 SCIP_CALL( GCGvarhistoryNext(scip, &varhistory) );
201 SCIP_CALL( GCGvarhistoryGetVar(varhistory, &mastervar) );
202
203 assert(mastervar != NULL);
204 if( SCIPvarIsDeleted(mastervar) )
205 {
206 SCIPdebugMessage("Skipping deleted Variable <%s>!\n", SCIPvarGetName(mastervar));
207 continue;
208 }
209 assert(GCGvarIsMaster(mastervar));
210
211 /* get the pricing variables corresponding to the original variables which define the master variable */
212 npricingvars = GCGmasterVarGetNOrigvars(mastervar);
213 origvars = GCGmasterVarGetOrigvars(mastervar);
214 pricingvals = GCGmasterVarGetOrigvals(mastervar);
215 SCIPallocBufferArray(scip, &pricingvars, npricingvars);
216 nnonzeros = 0;
217 for( j = 0; j < npricingvars; j++ )
218 {
219 pricingvars[j] = GCGoriginalVarGetPricingVar(origvars[j]);
220 assert(pricingvars[j] != NULL);
221 if( pricingvals[j] != 0.0 )
222 nnonzeros++;
223 }
224
225 /* compute the coefficient for this master variable */
226 coef = 0.0;
227 if( (npricingvars > 0) && (nnonzeros > 0) )
228 {
229 blocknr = GCGvarGetBlock(pricingvars[0]);
230 SCIP_CALL( GCGmastersepacutGetExtendedmasterconsCoeff(gcg, mastersepacut, pricingvars, pricingvals, npricingvars,
231 blocknr, NULL, &coef) );
232 }
233
234 /* add variable with its coefficient to the cut */
235 if( !SCIPisZero(scip, coef) )
236 {
237 SCIP_ROW* mastercutrow;
238
239 mastercutrow = GCGextendedmasterconsGetRow(mastersepacut);
240 assert(mastercutrow != NULL);
241 SCIP_CALL( SCIPaddVarToRow(scip, mastercutrow, mastervar, coef) );
242 }
243
244 SCIPfreeBufferArrayNull(scip, &pricingvars);
245 }
246
247 return SCIP_OKAY;
248}
249
250
251/** remove the mastersepacuts generated and applied at this node from activecuts */
252static
254 GCG* gcg, /**< GCG data structure */
255 SCIP_CONSDATA* consdata, /**< data of current constraint */
256 SCIP_CONSHDLRDATA* conshdlrdata /**< masterbranch constraint handler data */
257 )
258{
259 assert(gcg != NULL);
260 assert(consdata != NULL);
261
263
264 return SCIP_OKAY;
265}
266
267/** add the mastersepacuts generated and applied at this node to active cuts */
268static
270 GCG* gcg, /**< GCG data structure */
271 SCIP_CONSDATA* consdata, /**< consdata of current constraint */
272 SCIP_CONSHDLRDATA* conshdlrdata /**< constraint handler data */
273 )
274{
275 int nactivecuts;
276 int j;
277
278 assert(gcg != NULL);
279 assert(consdata != NULL);
280 assert(consdata->addedcutsinit);
281 assert(conshdlrdata != NULL);
282
283 SCIPdebugMessage("add stored cuts: node %lli of type: %i\n", SCIPnodeGetNumber(consdata->node), SCIPnodeGetType(consdata->node));
284
285 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
286 assert(consdata->firstnewcut == nactivecuts);
287
288 /* store the current number of activecuts */
289 consdata->firstnewcut = nactivecuts;
290
291 /* if this node did not store any cuts, we do nothing */
292 if( !consdata->nodestoredcuts )
293 return SCIP_OKAY;
294
295 assert(SCIPnodeGetType(consdata->node) == SCIP_NODETYPE_FORK
298
299 for( j = 0; j < consdata->naddedcuts; j++ )
300 {
301 /* we update the cut to include all the master variables which were generated while the cut was inactive */
302 SCIP_CALL( addMissedVariables(gcg, consdata->addedcuts[j]) );
303 /* we add this cut to activecuts */
305
306#ifdef SCIP_DEBUG
307 SCIP_ROW* mastercutrow = NULL;
308
309 mastercutrow = GCGextendedmasterconsGetRow(consdata->addedcuts[j]);
310 assert(mastercutrow != NULL);
311 SCIPdebugMessage("add to active cuts: update row %s from node %lli and add it to active cuts\n",
312 SCIProwGetName(mastercutrow), SCIPnodeGetNumber(consdata->node));
313#endif
314 }
315
316 return SCIP_OKAY;
317}
318
319/** stores the mastersepacuts generated and applied at this node to the branchdata */
320static
322 GCG* gcg, /**< GCG data structure */
323 SCIP_CONSDATA* consdata, /**< constraint data of current constraint */
324 SCIP_CONSHDLRDATA* conshdlrdata /**< constraint handler data */
325 )
326{
327 GCG_EXTENDEDMASTERCONSDATA** activecuts;
328 int nactivecuts;
329 int j;
330
331 assert(gcg != NULL);
332 assert(consdata != NULL);
333 assert(!consdata->addedcutsinit);
334
335
336 SCIPdebugMessage("init added cuts: remove and free new inactive rows from node %lli of type %i\n",
337 SCIPnodeGetNumber(consdata->node), SCIPnodeGetType(consdata->node));
338
339 /* cleanup (remove AND free) the rows generated at node which have already been removed from the LP */
341
342 /* the only type of nodes which can store rows */
343 if( !(SCIPnodeGetType(consdata->node) == SCIP_NODETYPE_FORK
345 || SCIPnodeGetType(consdata->node) == SCIP_NODETYPE_SUBROOT) )
346 {
347 consdata->nodestoredcuts = FALSE;
348 consdata->addedcutsinit = TRUE;
349 return SCIP_OKAY;
350 }
351
352 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
353 activecuts = GCGgetActiveMastersepacuts(gcg);
354 consdata->naddedcuts = 0;
355 assert(consdata->firstnewcut <= nactivecuts);
356
357 /* no cuts were applied at this node --> nothing to store */
358 if( consdata->firstnewcut == nactivecuts )
359 {
360 SCIPdebugMessage("init consdata: no cuts to store\n");
361 consdata->nodestoredcuts = FALSE;
362 consdata->addedcutsinit = TRUE;
363 return SCIP_OKAY;
364 }
365 consdata->naddedcuts = nactivecuts - consdata->firstnewcut;
366
367 SCIPdebugMessage("init consdata: store %i cuts for (pseudo)fork/subroot\n",
368 consdata->naddedcuts);
369
370 /* copy, store and capture the cuts */
372 &(activecuts[consdata->firstnewcut]), consdata->naddedcuts) );
373 for( j = 0; j < consdata->naddedcuts; j++ )
374 {
376 }
377 consdata->nodestoredcuts = TRUE;
378 consdata->addedcutsinit = TRUE;
379
380 return SCIP_OKAY;
381}
382
383/** initialize the consdata data structure */
384static
386 GCG* gcg, /**< GCG data structure*/
387 SCIP_CONS* cons /**< constraint for which the consdata is created */
388 )
389{
390#ifdef SCIP_DEBUG
391 SCIP_CONS* origcons_parent;
392 SCIP_CONS* parent_origcons;
393#endif
394
395 SCIP* masterprob;
396 SCIP_CONSDATA* consdata;
397 SCIP_CONSHDLR* conshdlr;
398 SCIP_CONSHDLRDATA* conshdlrdata;
399 SCIP_CONS* origcons;
400
401 SCIP_DOMCHG* domchg;
402 SCIP_BOUNDCHG* boundchg;
403 SCIP_VAR* boundchgvar;
404
405 int i;
406
407 assert(gcg != NULL);
408
409 masterprob = GCGgetMasterprob(gcg);
410 assert(masterprob != NULL);
411 assert(GCGisMaster(masterprob));
412 assert(cons != NULL);
413
414 /* get constraint handler */
415 conshdlr = SCIPfindConshdlr(masterprob, CONSHDLR_NAME);
416 assert(conshdlr != NULL);
417 assert(SCIPconsGetHdlr(cons) == conshdlr);
418
419 /* get constraint handler data */
420 conshdlrdata = SCIPconshdlrGetData(conshdlr);
421 assert(conshdlrdata != NULL);
422
423 /* get constraint data */
424 consdata = SCIPconsGetData(cons);
425 assert(consdata != NULL);
426
427 /* get corresponding origbranch constraint in the original problem */
429 assert(origcons != NULL);
430
431 if( consdata->origcons == NULL ) /*rootnode?*/
432 {
433 SCIPdebugMessage("set root origcons\n");
434 consdata->origcons = origcons;
435 GCGconsOrigbranchSetMastercons(origcons, cons);
436 }
437 else if( consdata->origcons != origcons )
438 {
439 // todo: Check this case.
440 SCIPdebugMessage("B&B trees could be out of sync\n");
441 }
442
443 /* @fixme: Why should anything else happen? */
444 if( GCGconsOrigbranchGetNChildconss(origcons) == 0 )
445 {
446 consdata->nchildconss = 0;
447 consdata->childconss = NULL;
448 }
449
450 /*GCGconsOrigbranchSetMastercons(origcons, cons);*/
451
452
453#ifdef SCIP_DEBUG
454 if( consdata->parentcons != NULL )
455 parent_origcons = SCIPconsGetData(consdata->parentcons)->origcons;
456 else
457 parent_origcons = NULL;
458
459 if( consdata->origcons != NULL )
460 origcons_parent = GCGconsOrigbranchGetParentcons(consdata->origcons);
461 else
462 origcons_parent = NULL;
463
464 SCIPdebugMessage("cons: %s, origcons: %s, parent: %s => %s\n", SCIPconsGetName(cons), consdata->origcons == NULL? "NULL" : SCIPconsGetName( consdata->origcons ),
465 parent_origcons == NULL? "NULL" : SCIPconsGetName(parent_origcons), origcons_parent == NULL? "NULL" : SCIPconsGetName(origcons_parent) );
466#endif
467
468 assert(SCIPgetCurrentNode(masterprob) == consdata->node || consdata->node == SCIPgetRootNode(masterprob));
469/* assert((SCIPgetNNodesLeft(masterprob)+SCIPgetNNodes(masterprob) == 1) == (consdata->node == SCIPgetRootNode(masterprob))); */
471 assert(consdata->parentcons != NULL || SCIPnodeGetDepth(consdata->node) == 0);
472
473 assert(consdata->parentcons == NULL ||
475
476 consdata->maxlocalbndchgstreated = SCIPcalcMemGrowSize(masterprob, conshdlrdata->nstack+1);
477 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &consdata->nlocalbndchgstreated, (size_t)consdata->maxlocalbndchgstreated) );
478
479 /* get all bound changes at the corresponding node in the original problem */
480
482 consdata->nlocalbndchgs = SCIPdomchgGetNBoundchgs(domchg);
483 consdata->nlocalbndchgstreated[conshdlrdata->nstack] = consdata->nlocalbndchgs;
484
485 if( consdata->nlocalbndchgs > 0 )
486 {
487 consdata->maxlocalbndchgs = SCIPcalcMemGrowSize(masterprob, consdata->nlocalbndchgs);
488 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &consdata->localbndvars, consdata->maxlocalbndchgs) );
489 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &consdata->localbndtypes, consdata->maxlocalbndchgs) );
490 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &consdata->localnewbnds, consdata->maxlocalbndchgs) );
491 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &consdata->localoldbnds, consdata->maxlocalbndchgs) );
492 }
493 else
494 {
495 consdata->maxlocalbndchgs = 0;
496 }
497
498 consdata->nbranchingchgs = 0;
499
500 for( i = 0; i < consdata->nlocalbndchgs; ++i )
501 {
502 boundchg = SCIPdomchgGetBoundchg(domchg, i);
503
504 consdata->localbndvars[i] = SCIPboundchgGetVar(boundchg);
505 consdata->localnewbnds[i] = SCIPboundchgGetNewbound(boundchg);
506 consdata->localbndtypes[i] = SCIPboundchgGetBoundtype(boundchg);
507
509 {
510 consdata->nbranchingchgs++;
511 assert(consdata->nbranchingchgs == i+1);
512 }
513 }
514
515 consdata->needprop = TRUE;
516
517 assert((consdata->parentcons == NULL) == (conshdlrdata->nstack == 0));
518 if( consdata->parentcons != NULL )
519 {
520 SCIP_CONSDATA* parentdata = SCIPconsGetData(consdata->parentcons);
521
522 assert(consdata->parentcons == conshdlrdata->stack[conshdlrdata->nstack-1]);
523 assert(SCIPconsGetData(conshdlrdata->stack[0])->parentcons == NULL);
524
525 /* check whether bound changes were added in nodes on the path
526 * to the current node after activation of the parent node
527 */
528 for( i = 1; i < conshdlrdata->nstack; ++i )
529 {
530 int ndomboundchgs;
531 SCIP_CONSDATA* stackconsdata = SCIPconsGetData(conshdlrdata->stack[i]);
532 domchg = SCIPnodeGetDomchg(GCGconsOrigbranchGetNode(stackconsdata->origcons));
533 ndomboundchgs = SCIPdomchgGetNBoundchgs(domchg);
534
535 assert(ndomboundchgs >= parentdata->nlocalbndchgstreated[i]);
536
537 if( ndomboundchgs != parentdata->nlocalbndchgstreated[i] )
538 {
539 int diff;
540 int j;
541
542 diff = ndomboundchgs - parentdata->nlocalbndchgstreated[i];
543
544 if( consdata->maxlocalbndchgs < consdata->nlocalbndchgs + diff )
545 {
546 int newmaxsize = SCIPcalcMemGrowSize(masterprob, consdata->nlocalbndchgs + diff);
547 SCIP_CALL(SCIPreallocBlockMemoryArray(masterprob, &consdata->localbndvars, consdata->maxlocalbndchgs,
548 (size_t) newmaxsize));
549 SCIP_CALL(SCIPreallocBlockMemoryArray(masterprob, &consdata->localbndtypes, consdata->maxlocalbndchgs,
550 (size_t) newmaxsize));
551 SCIP_CALL(SCIPreallocBlockMemoryArray(masterprob, &consdata->localnewbnds, consdata->maxlocalbndchgs,
552 (size_t) newmaxsize));
553 SCIP_CALL(SCIPreallocBlockMemoryArray(masterprob, &consdata->localoldbnds, consdata->maxlocalbndchgs,
554 (size_t) newmaxsize));
555 consdata->maxlocalbndchgs = newmaxsize;
556 }
557
558 /* add bound changes to the boundchanges array */
559 for( j = 0; j < ndomboundchgs; ++j )
560 {
561 int bndchgindex;
562 SCIP_BOUNDTYPE boundchgtype;
563 SCIP_Real boundchgnewbound;
564
565 boundchg = SCIPdomchgGetBoundchg(domchg, j);
566 boundchgvar = SCIPboundchgGetVar(boundchg);
567 boundchgtype = SCIPboundchgGetBoundtype(boundchg);
568 boundchgnewbound = SCIPboundchgGetNewbound(boundchg);
569
570 if( j < stackconsdata->nlocalbndchgstreated[i] )
571 {
572 assert(stackconsdata->localbndvars[j] == boundchgvar
573 && SCIPisEQ(masterprob, stackconsdata->localnewbnds[j], boundchgnewbound)
574 && stackconsdata->localbndtypes[j] == boundchgtype);
575 continue;
576 }
577 if( j < parentdata->nlocalbndchgstreated[i] )
578 continue;
579
580 bndchgindex = consdata->nlocalbndchgs + j - parentdata->nlocalbndchgstreated[i];
581
582 consdata->localbndvars[bndchgindex] = boundchgvar;
583 consdata->localnewbnds[bndchgindex] = boundchgnewbound;
584 consdata->localbndtypes[bndchgindex] = boundchgtype;
585 }
586
587 consdata->nlocalbndchgs += diff;
588 }
589
590 consdata->nlocalbndchgstreated[i] = ndomboundchgs;
591 }
592 /* store the master cuts (generated and) applied at parent node in parent constraint data, when
593 * - parent master cuts have not been stored yet, because the corresponding constraint was not deactivated */
594 if( !parentdata->addedcutsinit && SCIPnodeGetType(consdata->node) == SCIP_NODETYPE_FOCUSNODE )
595 SCIP_CALL( initializeAddedCuts(gcg, parentdata, conshdlrdata) );
596 }
597
598 /* store the number of activecuts at activation */
600
601 SCIPdebugMessage("init cons data: firstnewcut %i in node %lli\n", consdata->firstnewcut, SCIPnodeGetNumber(consdata->node));
602
603 return SCIP_OKAY;
604}
605
606/** add a global bound change on the original problem to the pending bound changes array */
607static
609 SCIP* scip, /**< SCIP data structure */
610 SCIP_VAR* var, /**< variable on which the bound change is applied (corresponding master variable copy or pricing variable) */
611 SCIP_BOUNDTYPE boundtype, /**< type of the bound (lower or upper) */
612 SCIP_Real oldbound, /**< previous bound value */
613 SCIP_Real newbound /**< new bound value */
614 )
615{
616 SCIP_CONSHDLR* conshdlr;
617 SCIP_CONSHDLRDATA* conshdlrdata;
618 SCIP_HASHMAP* pendingvarmap;
619 int idx;
620
621 assert(scip != NULL);
622
623 /* get constraint handler */
625 if( conshdlr == NULL )
626 {
627 SCIPerrorMessage("masterbranch constraint handler not found\n");
628 return SCIP_PLUGINNOTFOUND;
629 }
630
631 /* get constraint handler data */
632 conshdlrdata = SCIPconshdlrGetData(conshdlr);
633 assert(conshdlrdata != NULL);
634 assert((conshdlrdata->npendingbnds > 0) || conshdlrdata->pendingbndsactivated);
635
636 pendingvarmap = (boundtype == SCIP_BOUNDTYPE_LOWER) ? conshdlrdata->pendingvarmaplb : conshdlrdata->pendingvarmapub;
637 idx = SCIPhashmapGetImageInt(pendingvarmap, var);
638 if( idx != INT_MAX )
639 {
640 assert(conshdlrdata->pendingvars[idx] == var);
641 assert(conshdlrdata->pendingbndtypes[idx] == boundtype);
642 conshdlrdata->pendingnewbnds[idx] = newbound;
643 }
644 else
645 {
646 /* reallocate memory if needed */
647 if( conshdlrdata->npendingbnds >= conshdlrdata->maxpendingbnds )
648 {
649 int newsize = SCIPcalcMemGrowSize(scip, conshdlrdata->npendingbnds+5);
650 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->pendingvars), conshdlrdata->maxpendingbnds, newsize) );
651 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->pendingbndtypes), conshdlrdata->maxpendingbnds, newsize) );
652 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->pendingnewbnds), conshdlrdata->maxpendingbnds, newsize) );
653 conshdlrdata->maxpendingbnds = newsize;
654 }
655
656 /* store pending bound change */
657 conshdlrdata->pendingvars[conshdlrdata->npendingbnds] = var;
658 conshdlrdata->pendingbndtypes[conshdlrdata->npendingbnds] = boundtype;
659 conshdlrdata->pendingnewbnds[conshdlrdata->npendingbnds] = newbound;
660 SCIP_CALL( SCIPhashmapInsertInt(pendingvarmap, var, conshdlrdata->npendingbnds) );
661 conshdlrdata->npendingbnds++;
662 conshdlrdata->pendingbndsactivated = FALSE;
663 }
664
665 return SCIP_OKAY;
666}
667
668/** For a given global bound change on a pricing variable, check if the global bounds on all corresponding original variables are still the same
669 *
670 * @return TRUE if the variable is in a relevant block AND all variables identical to it have the same bounds
671 */
672static
674 SCIP* scip, /**< SCIP data structure */
675 SCIP_VAR* bndvar, /**< pricing variable whose new global bound is to be checked */
676 SCIP_BOUNDTYPE bndtype, /**< type of the new global bound */
677 SCIP_Real bound /**< new global bound */
678 )
679{
680 SCIP_VAR** identvars;
681 int nidentvars;
682 SCIP_Bool identical;
683
684 assert(GCGvarIsPricing(bndvar));
685
686 /* get all identical variables */
687 identvars = GCGpricingVarGetOrigvars(bndvar);
688 nidentvars = GCGpricingVarGetNOrigvars(bndvar);
689
690 identical = TRUE;
691
692 /* If the variable was not aggregated, there is nothing to check */
693 if( nidentvars > 1 )
694 {
695 int i;
696
697 /* Check if the bounds of all identical variables are equal to the one of the representative */
698 for( i = 0; i < nidentvars; ++i )
699 {
700 SCIP_Real identbound = bndtype == SCIP_BOUNDTYPE_UPPER ? SCIPvarGetUbGlobal(identvars[i]) : SCIPvarGetLbGlobal(identvars[i]);
701 if( !SCIPisEQ(scip, identbound, bound) )
702 {
703 SCIPwarningMessage(scip, "Var <%s> has new global %s bound %g, but identical var <%s> has %g -- don't know how to handle!\n",
704 SCIPvarGetName(bndvar), bndtype == SCIP_BOUNDTYPE_UPPER ? "upper" : "lower",
705 bound, SCIPvarGetName(identvars[i]), identbound);
706 identical = FALSE;
707 }
708 }
709 }
710
711 return identical;
712}
713
714/** apply global bound changes on original problem variables either
715 * to their copies in the master problem and/or to the corresponding pricing problem variables
716 */
717static
719 GCG* gcg, /* GCG data structure */
720 SCIP_CONSHDLRDATA* conshdlrdata /* constraint handler data */
721 )
722{
723 SCIP* masterprob;
724 SCIP* origscip;
725 int i;
726
727 masterprob = GCGgetMasterprob(gcg);
728 assert(masterprob != NULL);
729 assert(GCGisMaster(masterprob));
730
731 assert(conshdlrdata != NULL);
732
733 /* get original problem */
734 origscip = GCGgetOrigprob(gcg);
735 assert(origscip != NULL);
736
737 if( !conshdlrdata->pendingbndsactivated )
738 {
739 assert(conshdlrdata->npendingbnds > 0);
740 for( i = 0; i < conshdlrdata->npendingbnds; i++ )
741 {
742 /* This should not have an effect on linking variables */
743 assert(GCGvarIsMaster(conshdlrdata->pendingvars[i]) || GCGvarIsPricing(conshdlrdata->pendingvars[i]));
744
745 if( GCGvarIsMaster(conshdlrdata->pendingvars[i]) )
746 {
747 if( conshdlrdata->pendingbndtypes[i] == SCIP_BOUNDTYPE_LOWER )
748 {
749 if( SCIPisLT(masterprob, SCIPvarGetLbGlobal(conshdlrdata->pendingvars[i]), conshdlrdata->pendingnewbnds[i]) )
750 {
751 SCIPdebugMessage("Global lower bound of mastervar <%s> set to %g\n", SCIPvarGetName(conshdlrdata->pendingvars[i]),
752 conshdlrdata->pendingnewbnds[i]);
753 SCIP_CALL( SCIPchgVarLbGlobal(masterprob, conshdlrdata->pendingvars[i], conshdlrdata->pendingnewbnds[i]) );
754 }
755 }
756 else
757 {
758 if( SCIPisGT(masterprob, SCIPvarGetUbGlobal(conshdlrdata->pendingvars[i]), conshdlrdata->pendingnewbnds[i]) )
759 {
760 SCIPdebugMessage("Global upper bound of mastervar <%s> set to %g\n", SCIPvarGetName(conshdlrdata->pendingvars[i]),
761 conshdlrdata->pendingnewbnds[i]);
762 SCIP_CALL( SCIPchgVarUbGlobal(masterprob, conshdlrdata->pendingvars[i], conshdlrdata->pendingnewbnds[i]) );
763 }
764 }
765 }
766 else
767 {
768 /* this is a global boundchange on a variable that belongs to a block,
769 * we have to adjust the bound of the corresponding variable in the pricing problem
770 */
771
772 /* check if all identical variables have the same global bound */
773 if( !checkAggregatedGlobalBounds(origscip, conshdlrdata->pendingvars[i], conshdlrdata->pendingbndtypes[i], conshdlrdata->pendingnewbnds[i]) )
774 continue;
775
776 if( conshdlrdata->pendingbndtypes[i] == SCIP_BOUNDTYPE_LOWER )
777 {
779 conshdlrdata->pendingvars[i], conshdlrdata->pendingnewbnds[i]) );
780 }
781 else
782 {
784 conshdlrdata->pendingvars[i], conshdlrdata->pendingnewbnds[i]) );
785 }
786 }
787 }
788 conshdlrdata->pendingbndsactivated = TRUE;
789 }
790
791 return SCIP_OKAY;
792}
793
794/** apply global bound changes on original problem variables to the master problem */
795static
797 GCG* gcg, /**< GCG data structure */
798 SCIP_CONSHDLRDATA* conshdlrdata, /**< constraint handler data */
799 int* propcount /**< number of applied bound changes */
800 )
801{
802 SCIP* masterprob;
803 SCIP_VAR** vars;
804 int nvars;
805 int i;
806 int k;
807
808 masterprob = GCGgetMasterprob(gcg);
809 assert(masterprob != NULL);
810 assert(GCGisMaster(masterprob));
811
812 /* get master problem variables generated during pricing */
815
816 assert((conshdlrdata->npendingbnds > 0) || conshdlrdata->pendingbndsactivated);
817
818 /* iterate over all master variables and apply global bound changes */
819 if( conshdlrdata->npendingbnds > 0 && conshdlrdata->pendingbndsactivated )
820 {
821 for( i = 0; i < nvars; i++ )
822 {
823 SCIP_Bool ismastervarrelevant;
824 SCIP_VAR** origvars;
825 SCIP_HASHMAP* origvals;
826 int norigvars;
827 int blocknr;
828 blocknr = GCGvarGetBlock(vars[i]);
829
830 /* get the original variables that are contained in the master variable */
831 assert(GCGvarIsMaster(vars[i]));
832 norigvars = GCGmasterVarGetNOrigvars(vars[i]);
833 origvars = GCGmasterVarGetOrigvars(vars[i]);
834 origvals = GCGmasterVarGetOrigvalmap(vars[i]);
835
836 assert(blocknr < GCGgetNPricingprobs(conshdlrdata->gcg));
837 assert(norigvars >= 0);
838 assert(origvars != NULL || norigvars == 0);
839
840 /* only look at master variables not globally fixed to zero that belong to a block */
841 ismastervarrelevant = !SCIPisFeasZero(masterprob, SCIPvarGetUbGlobal(vars[i]));
842 ismastervarrelevant = ismastervarrelevant && (norigvars > 0);
843 ismastervarrelevant = ismastervarrelevant && (blocknr >= 0 || GCGmasterVarIsLinking(vars[i])); /*lint !e613*/
844 if( !ismastervarrelevant )
845 continue;
846
847 /* iterate over global bound changes on the original variables
848 * that have not yet been checked for the master variables
849 */
850 for( k = 0; k < conshdlrdata->npendingbnds; k++ )
851 {
852 int bndchgblocknr;
853 SCIP_VAR** bndchgorigvars;
854 SCIP_Real val;
855
856 assert(!GCGvarIsOriginal(conshdlrdata->pendingvars[k]));
857
858 bndchgblocknr = GCGvarGetBlock(conshdlrdata->pendingvars[k]);
859 if( GCGvarIsMaster(conshdlrdata->pendingvars[k]) )
860 {
861 assert(bndchgblocknr == -1);
862 bndchgorigvars = GCGmasterVarGetOrigvars(conshdlrdata->pendingvars[k]);
863 }
864 else if( GCGvarIsPricing(conshdlrdata->pendingvars[k]) )
865 bndchgorigvars = GCGpricingVarGetOrigvars(conshdlrdata->pendingvars[k]);
866 else
867 {
868 SCIPerrorMessage("Variable %s is not pricing nor master.\n", SCIPvarGetName(conshdlrdata->pendingvars[k]));
869 assert(GCGvarIsMaster(conshdlrdata->pendingvars[k]) || GCGvarIsPricing(conshdlrdata->pendingvars[k]));
870 bndchgorigvars = NULL;
871 }
872 assert(bndchgblocknr < GCGgetNPricingprobs(conshdlrdata->gcg));
873 assert(bndchgorigvars != NULL);
874 assert(origvars != NULL);
875
876 /* The bound change is only relevant for the master variable if either
877 * - the bound change was performed in the same block as the master variable, or
878 * - the master variable is a copied linking variable and the bound change was performed
879 * in one of the blocks that the variable is linking
880 */
881 if( (bndchgblocknr != blocknr )
882 && !(GCGmasterVarIsLinking(vars[i]) && GCGisLinkingVarInBlock(origvars[0], bndchgblocknr)) )
883 continue;
884
885 assert(bndchgorigvars[0] != NULL);
886
887 val = SCIPhashmapGetImageReal(origvals, bndchgorigvars[0]);
888 /* variables belong to the same block -> set origval to 0.0 if not in map */
889 if( val == SCIP_INVALID )
890 val = 0.0;
891
892 /* if the variable contains a part of the branching variable that violates the bound,
893 * fix the master variable to 0
894 */
895 /* @todo: This is the wrong way to treat bound changes on original variable copies in the master problem;
896 * I think they have already been treated during constraint activation
897 */
898
899 assert(GCGvarGetBlock(bndchgorigvars[0]) == blocknr || (GCGisLinkingVarInBlock(bndchgorigvars[0], blocknr))); /*lint !e613*/
900
901 /* new lower bound */
902 if( conshdlrdata->pendingbndtypes[k] == SCIP_BOUNDTYPE_LOWER &&
903 SCIPisFeasLT(masterprob, val, conshdlrdata->pendingnewbnds[k]) )
904 {
905 SCIP_CALL( SCIPchgVarUbGlobal(masterprob, vars[i], 0.0) );
906 ++(*propcount);
907 break;
908 }
909 /* new upper bound */
910 if( conshdlrdata->pendingbndtypes[k] == SCIP_BOUNDTYPE_UPPER &&
911 SCIPisFeasGT(masterprob, val, conshdlrdata->pendingnewbnds[k]) )
912 {
913 SCIP_CALL( SCIPchgVarUbGlobal(masterprob, vars[i], 0.0) );
914 ++(*propcount);
915 break;
916 }
917 }
918 }
919 conshdlrdata->pendingbndsactivated = TRUE;
920 conshdlrdata->npendingbnds = 0;
923
924 SCIPdebugMessage("Finished handling of pending global bound changes: %d changed bounds\n", *propcount);
925 }
926
927 return SCIP_OKAY;
928}
929
930/** reset bound changes on pricing variables (called when a node is deactivated) */
931static
933 GCG* gcg, /**< GCG data structure */
934 SCIP_VAR* pricingvar, /**< variable on which the bound change should be performed */
935 SCIP_CONSDATA* consdata, /**< constraint data structure */
936 int i, /**< index of the information in the constraint data structure */
937 int blocknr /**< number of the pricing problem */
938 )
939{
940 SCIP* masterprob = GCGgetMasterprob(gcg);
941
942 assert(masterprob != NULL);
943 assert(pricingvar != NULL);
944 assert(consdata != NULL);
945 assert(consdata->nactivated >= 1);
946 assert(consdata->localbndvars != NULL);
947 assert(consdata->localbndtypes != NULL);
948 assert(consdata->localnewbnds != NULL);
949 assert(consdata->localoldbnds != NULL);
950
951 assert(blocknr >= 0 && blocknr < GCGgetNPricingprobs(gcg));
952
953 /* lower bound was changed */
954 if( consdata->localbndtypes[i] == SCIP_BOUNDTYPE_LOWER )
955 {
956 if( GCGgetNIdenticalBlocks(gcg, blocknr) > 1 || GCGgetNIdenticalBlocks(gcg, blocknr) == 0 )
957 return SCIP_OKAY;
958
959 assert(SCIPisGE(masterprob, SCIPvarGetLbLocal(pricingvar), consdata->localnewbnds[i])
960 || SCIPisLE(masterprob, SCIPvarGetLbLocal(pricingvar), SCIPvarGetLbGlobal(consdata->localbndvars[i])));
961
962 if( SCIPisEQ(masterprob, SCIPvarGetLbGlobal(consdata->localbndvars[i]), consdata->localnewbnds[i]) )
963 return SCIP_OKAY;
964
965 if( SCIPisGT(masterprob, consdata->localoldbnds[i], consdata->localnewbnds[i]) )
966 return SCIP_OKAY;
967
968 if( SCIPisGT(masterprob, SCIPvarGetLbGlobal(consdata->localbndvars[i]), consdata->localoldbnds[i]) )
969 {
970 SCIP_CALL( SCIPchgVarLb(GCGgetPricingprob(gcg, blocknr), pricingvar, SCIPvarGetLbGlobal(consdata->localbndvars[i])) );
971 SCIPdebugMessage("relaxed lower bound of pricing var %s from %g to global bound %g (%s)\n",
972 SCIPvarGetName(pricingvar), consdata->localnewbnds[i], SCIPvarGetLbGlobal(consdata->localbndvars[i]), consdata->name);
973 }
974 else
975 {
976 SCIP_CALL( SCIPchgVarLb(GCGgetPricingprob(gcg, blocknr), pricingvar, consdata->localoldbnds[i]) );
977 SCIPdebugMessage("relaxed lower bound of pricing var %s from %g to %g (%s)\n",
978 SCIPvarGetName(pricingvar), consdata->localnewbnds[i], consdata->localoldbnds[i], consdata->name);
979 }
980 }
981 /* upper bound was changed */
982 else
983 {
984 if( GCGgetNIdenticalBlocks(gcg, blocknr) > 1 || GCGgetNIdenticalBlocks(gcg, blocknr) == 0 )
985 return SCIP_OKAY;
986
987 assert(SCIPisLE(masterprob, SCIPvarGetUbLocal(pricingvar), consdata->localnewbnds[i])
988 || SCIPisGE(masterprob, SCIPvarGetUbLocal(pricingvar), SCIPvarGetUbGlobal(consdata->localbndvars[i])));
989
990 if( SCIPisEQ(masterprob, SCIPvarGetUbGlobal(consdata->localbndvars[i]), consdata->localnewbnds[i]) )
991 return SCIP_OKAY;
992
993 if( SCIPisLT(masterprob, consdata->localoldbnds[i], consdata->localnewbnds[i]) )
994 return SCIP_OKAY;
995
996 if( SCIPisLT(masterprob, SCIPvarGetUbGlobal(consdata->localbndvars[i]), consdata->localoldbnds[i]) )
997 {
998 SCIP_CALL( SCIPchgVarUb(GCGgetPricingprob(gcg, blocknr), pricingvar, SCIPvarGetUbGlobal(consdata->localbndvars[i])) );
999 SCIPdebugMessage("relaxed upper bound of pricing var %s from %g to global bound %g (%s)\n",
1000 SCIPvarGetName(pricingvar), consdata->localnewbnds[i], SCIPvarGetUbGlobal(consdata->localbndvars[i]), consdata->name);
1001 }
1002 else
1003 {
1004 SCIP_CALL( SCIPchgVarUb(GCGgetPricingprob(gcg, blocknr), pricingvar, consdata->localoldbnds[i]) );
1005 SCIPdebugMessage("relaxed upper bound of pricing var %s from %g to %g (%s)\n",
1006 SCIPvarGetName(pricingvar), consdata->localnewbnds[i], consdata->localoldbnds[i], consdata->name);
1007 }
1008 }
1009
1010 return SCIP_OKAY;
1011}
1012
1013/** perform bound changes on pricing variables (called when a node is activated) */
1014static
1016 GCG* gcg, /**< GCG data structure */
1017 SCIP_VAR* pricingvar, /**< variable on which the bound change should be performed */
1018 SCIP_CONSDATA* consdata, /**< constraint data structure */
1019 int i, /**< index of the information in the constraint data structure */
1020 int blocknr /**< number of the pricing problem */
1021 )
1022{
1023 SCIP* masterprob;
1024
1025 assert(gcg != NULL);
1026 assert(pricingvar != NULL);
1027 assert(consdata != NULL);
1028 assert(consdata->nactivated >= 1);
1029 assert(consdata->localbndvars != NULL);
1030 assert(consdata->localbndtypes != NULL);
1031 assert(consdata->localnewbnds != NULL);
1032 assert(consdata->localoldbnds != NULL);
1033
1034 masterprob = GCGgetMasterprob(gcg);
1035 assert(masterprob != NULL);
1036 assert(blocknr >= 0 && blocknr < GCGgetNPricingprobs(gcg));
1037
1038 /* lower bound was changed */
1039 if( consdata->localbndtypes[i] == SCIP_BOUNDTYPE_LOWER )
1040 {
1041 consdata->localoldbnds[i] = SCIPvarGetLbLocal(pricingvar);
1042
1043 if( SCIPisGT(masterprob, consdata->localnewbnds[i], consdata->localoldbnds[i]) )
1044 {
1045 SCIP_CALL( SCIPchgVarLb(GCGgetPricingprob(gcg, blocknr), pricingvar, consdata->localnewbnds[i]) );
1046 SCIPdebugMessage("tightened lower bound of var %s from %g to %g\n",
1047 SCIPvarGetName(pricingvar), consdata->localoldbnds[i], consdata->localnewbnds[i]);
1048 }
1049 }
1050 /* upper bound was changed */
1051 else
1052 {
1053 assert(consdata->localbndtypes[i] == SCIP_BOUNDTYPE_UPPER);
1054
1055 consdata->localoldbnds[i] = SCIPvarGetUbLocal(pricingvar);
1056
1057 if( SCIPisLT(masterprob, consdata->localnewbnds[i], consdata->localoldbnds[i]) )
1058 {
1059 SCIP_CALL( SCIPchgVarUb(GCGgetPricingprob(gcg, blocknr), pricingvar, consdata->localnewbnds[i]) );
1060 SCIPdebugMessage("tightened upper bound of var %s from %g to %g\n",
1061 SCIPvarGetName(pricingvar), consdata->localoldbnds[i], consdata->localnewbnds[i]);
1062 }
1063 }
1064
1065 return SCIP_OKAY;
1066}
1067
1068/** For a given local bound change on an original variable, check if the bounds on the variables identical to it are the same
1069 *
1070 * @note If the variable is represented by another one, we check only the representative;
1071 * otherwise, we check all variables identical to it
1072 *
1073 * @return TRUE if the variable is in a relevant block AND all variables identical to it have the same bounds
1074 */
1075static
1077 SCIP* scip, /**< SCIP data structure */
1078 SCIP_VAR** bndvars, /**< all variables whose local bounds were changed */
1079 SCIP_Real* bounds, /**< corresponding new local bounds */
1080 int nbndvars, /**< number of all variables whose local bounds were changed */
1081 SCIP_VAR* bndvar, /**< original variable whose local bound was changed and which is to be checked */
1082 SCIP_BOUNDTYPE bndtype, /**< type of the new local bound */
1083 SCIP_VAR* pricingvar /**< pricing variable corresponding to the original variable */
1084 )
1085{
1086 SCIP_VAR** identvars;
1087 int nidentvars;
1088
1089 assert(GCGvarIsOriginal(bndvar));
1090 assert(GCGvarIsPricing(pricingvar));
1091
1092 /* get variables with which the original variable was aggregated */
1093 identvars = GCGpricingVarGetOrigvars(pricingvar);
1094 nidentvars = GCGpricingVarGetNOrigvars(pricingvar);
1095
1096 /* First case: The variable is not represented by another one - check the bounds of all variables it represents */
1097 if( identvars[0] == bndvar )
1098 {
1099 SCIP_Bool identical = TRUE;
1100
1101 /* If the variable was not aggregated, there is nothing to check */
1102 if( nidentvars > 1 )
1103 {
1104 int i;
1105 int j;
1106 SCIP_Real* identbounds; /* most recent bounds of all identical variables */
1107
1108 SCIP_CALL( SCIPallocBufferArray(scip, &identbounds, nidentvars) );
1109 for( j = 0; j < nidentvars; ++j )
1110 identbounds[j] = SCIP_INVALID;
1111
1112 /* For all variables on which a bound was changed *and* which are identical to the current variable,
1113 * get the most recent bound
1114 */
1115 for( i = 0; i < nbndvars; ++i )
1116 {
1117 assert(GCGvarIsOriginal(bndvars[i]));
1118
1119 if( GCGvarGetBlock(bndvars[i]) < 0 )
1120 continue;
1121
1122 if( GCGpricingVarGetOrigvars(GCGoriginalVarGetPricingVar(bndvars[i]))[0] == identvars[0] )
1123 for( j = 0; j < nidentvars; ++j )
1124 if( identvars[j] == bndvars[i] )
1125 identbounds[j] = bounds[i];
1126 }
1127
1128 /* Check if the bounds of all identical variables are equal to the one of the representative */
1129 for( j = 1; j < nidentvars; ++j )
1130 {
1131 if( !SCIPisEQ(scip, identbounds[j], identbounds[0]) )
1132 {
1133 SCIPwarningMessage(scip, "Var <%s> has new local %s bound %g, but identical var <%s> has %g -- don't know how to handle!\n",
1134 SCIPvarGetName(bndvar), bndtype == SCIP_BOUNDTYPE_UPPER ? "upper" : "lower",
1135 identbounds[0], SCIPvarGetName(identvars[j]), identbounds[j]);
1136 identical = FALSE;
1137 }
1138 }
1139
1140 SCIPfreeBufferArray(scip, &identbounds);
1141 }
1142
1143 return identical;
1144 }
1145
1146 /* Second case: The variable is represented by another one due to aggregation; check if its representative has the same bound */
1147 else
1148 {
1149 int i;
1150 SCIP_Real reprbound;
1151 SCIP_Real bound;
1152
1153 /* Get the most recent bound for the bound change variable as well as for its representative */
1154 reprbound = SCIP_INVALID;
1155 bound = SCIP_INVALID;
1156 for( i = 0; i < nbndvars; ++i )
1157 {
1158 assert(GCGvarIsOriginal(bndvars[i]));
1159
1160 if( bndvars[i] == identvars[0] )
1161 reprbound = bounds[i];
1162 else if( bndvars[i] == bndvar )
1163 bound = bounds[i];
1164 }
1165
1166 /* Check if the bounds are equal */
1167 if( !SCIPisEQ(scip, bound, reprbound) )
1168 {
1169 SCIPwarningMessage(scip, "Var <%s> has new local %s bound %g, but representative <%s> has %g -- don't know how to handle!\n",
1170 SCIPvarGetName(bndvar), bndtype == SCIP_BOUNDTYPE_UPPER ? "upper" : "lower",
1171 bound, SCIPvarGetName(identvars[0]), reprbound);
1172 }
1173
1174 /* Since the block is not relevant, there is no corresponding pricing variable */
1175 return FALSE;
1176 }
1177}
1178
1179/** apply local bound changes in the original problem to the pricing problems */
1180static
1182 GCG* gcg, /* GCG data structure */
1183 SCIP_CONS* cons /* current masterbranch constraint */
1184 )
1185{
1186 SCIP* masterprob;
1187 SCIP_CONSDATA* consdata;
1188 int i;
1189
1190 masterprob = GCGgetMasterprob(gcg);
1191 assert(masterprob != NULL);
1192 assert(GCGisMaster(masterprob));
1193
1194 /* get constraint data */
1195 consdata = SCIPconsGetData(cons);
1196 assert(consdata != NULL);
1197
1198 /* iterate over all local bound changes in the original problem */
1199 for( i = 0; i < consdata->nlocalbndchgs; i++ )
1200 {
1201 int blocknr;
1202 assert(GCGvarIsOriginal(consdata->localbndvars[i]));
1203 blocknr = GCGvarGetBlock(consdata->localbndvars[i]);
1204 assert(blocknr < GCGgetNPricingprobs(gcg));
1205
1206 /* if variable belongs to no block, skip it here because the bound changes are treated in the propagation */
1207 if( blocknr == -1 )
1208 continue;
1209
1210 else if( blocknr >= 0 )
1211 {
1212 if( checkAggregatedLocalBounds(masterprob, consdata->localbndvars, consdata->localnewbnds, consdata->nlocalbndchgs, consdata->localbndvars[i],
1213 consdata->localbndtypes[i], GCGoriginalVarGetPricingVar(consdata->localbndvars[i])) )
1214 {
1215 SCIPdebugMessage("adjusting bound of pricing var <%s>\n", SCIPvarGetName(consdata->localbndvars[i]));
1216 /* set corresponding bound in the pricing problem */
1217 SCIP_CALL( tightenPricingVarBound(gcg, GCGoriginalVarGetPricingVar(consdata->localbndvars[i]), consdata, i, blocknr) );
1218 }
1219 }
1220
1221 else if( blocknr == -2 )
1222 {
1223 int j;
1224 int npricingprobs;
1225 SCIP_VAR** pricingvars;
1226 SCIP_Bool aggregated;
1227
1228 npricingprobs = GCGgetNPricingprobs(gcg);
1229 pricingvars = GCGlinkingVarGetPricingVars(consdata->localbndvars[i]);
1230 aggregated = FALSE;
1231 /* check the blocks in which the linking variable appears */
1232 for( j = 0; j < npricingprobs; ++j )
1233 {
1234 if( pricingvars[j] == NULL )
1235 continue;
1236
1237 if( !checkAggregatedLocalBounds(masterprob, consdata->localbndvars, consdata->localnewbnds, consdata->nlocalbndchgs,
1238 consdata->localbndvars[i], consdata->localbndtypes[i], pricingvars[j]) )
1239 aggregated = TRUE;
1240 }
1241 if( aggregated )
1242 continue;
1243
1244 SCIPdebugMessage("adjusting bound of linking pricing var <%s>\n", SCIPvarGetName(consdata->localbndvars[i]));
1245
1246 /* set corresponding bound in the pricing problem */
1247 for( j = 0; j < npricingprobs; ++j )
1248 {
1249 if( pricingvars[j] == NULL )
1250 continue;
1251
1252 SCIP_CALL( tightenPricingVarBound(gcg, pricingvars[j], consdata, i, j) );
1253 }
1254 }
1255
1256 else
1257 {
1258 SCIPerrorMessage("blocknr = %d is not valid! This is a serious error!", GCGvarGetBlock(consdata->localbndvars[i]));
1259 SCIPABORT();
1260 }
1261 }
1262
1263 return SCIP_OKAY;
1264}
1265
1266/** undo local bound changes in the original problem to the pricing problems */
1267static
1269 GCG* gcg, /* GCG data structure */
1270 SCIP_CONS* cons /* current masterbranch constraint */
1271 )
1272{
1273 SCIP_CONSDATA* consdata;
1274 int i;
1275
1276 /* get constraint data */
1277 consdata = SCIPconsGetData(cons);
1278 assert(consdata != NULL);
1279
1280 /* iterate over all local bound changes in the original problem */
1281 for( i = consdata->nlocalbndchgs - 1; i >= 0; i-- )
1282 {
1283 int blocknr;
1284 blocknr = GCGvarGetBlock(consdata->localbndvars[i]);
1285 assert(GCGvarIsOriginal(consdata->localbndvars[i]));
1286 assert(blocknr < GCGgetNPricingprobs(gcg));
1287
1288 /* if variable belongs to no block, local bound in master was set, is reset automatically */
1289 if( blocknr == -1 )
1290 continue;
1291
1292 else if( blocknr >= 0 )
1293 {
1294 assert(GCGgetPricingprob(gcg, GCGvarGetBlock(consdata->localbndvars[i])) != NULL);
1295
1296 /* reset corresponding bound in the pricing problem */
1297
1299 GCGoriginalVarGetPricingVar(consdata->localbndvars[i]), consdata, i, blocknr));
1300 }
1301 else if( blocknr == -2 )
1302 {
1303 int j;
1304 SCIP_VAR** pricingvars;
1305 int npricingprobs;
1306
1307 /* if the variable is linking, we have to perform the same step as above for every existing block*/
1308 assert(GCGoriginalVarIsLinking(consdata->localbndvars[i]));
1309 pricingvars = GCGlinkingVarGetPricingVars(consdata->localbndvars[i]);
1310 npricingprobs = GCGgetNPricingprobs(gcg);
1311
1312 /* reset corresponding bound in the pricing problem */
1313 /* lower bound was changed */
1314 for( j = 0; j < npricingprobs; ++j )
1315 {
1316 assert(GCGgetPricingprob(gcg, j) != NULL);
1317 if( pricingvars[j] == NULL )
1318 continue;
1319
1320 assert(GCGgetPricingprob(gcg, j) != NULL);
1321
1322 /* reset corresponding bound in the pricing problem */
1323 SCIP_CALL( resetPricingVarBound(gcg, pricingvars[j], consdata, i, j) );
1324 }
1325 }
1326 else
1327 {
1328 SCIPerrorMessage("blocknr = %d is not valid! This is a serious error!", blocknr);
1329 SCIPABORT();
1330 }
1331 }
1332
1333 return SCIP_OKAY;
1334}
1335
1336static
1338 SCIP* scip,
1339 SCIP_CONSHDLRDATA *conshdlrdata,
1340 int blocknr,
1341 int minsize
1342 )
1343{
1344 int oldsize = conshdlrdata->maxcollectedbndvars[blocknr];
1345 if( oldsize < minsize )
1346 {
1347 int newsize = SCIPcalcMemGrowSize(scip, minsize);
1348 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->collectedbndvars[blocknr]), oldsize, newsize) );
1349 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->collectedlbnds[blocknr]), oldsize, newsize) );
1350 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->collectedubnds[blocknr]), oldsize, newsize) );
1351 conshdlrdata->maxcollectedbndvars[blocknr] = newsize;
1352 }
1353 return SCIP_OKAY;
1354}
1355
1356static
1358 SCIP* scip,
1359 SCIP_CONSHDLRDATA *conshdlrdata,
1360 int minsize
1361)
1362{
1363 int oldsize = conshdlrdata->maxlinkingvaridxs;
1364 if( oldsize < minsize )
1365 {
1366 int newsize = SCIPcalcMemGrowSize(scip, minsize);
1367 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->linkingvaridxs), oldsize, newsize) );
1368 BMSclearMemoryArray(&conshdlrdata->linkingvaridxs[oldsize], (newsize - oldsize));
1369 conshdlrdata->maxlinkingvaridxs = newsize;
1370 }
1371 return SCIP_OKAY;
1372}
1373
1374/** apply local bound changes on the original variables on newly generated master variables */
1375static
1377 GCG* gcg, /**< GCG data structure */
1378 SCIP_CONSHDLRDATA* conshdlrdata, /**< constraint handler data */
1379 SCIP_CONS* cons, /**< current masterbranch constraint */
1380 int* propcount /**< number of applied bound changes */
1381 )
1382{
1383 SCIP* origprob;
1384 SCIP* masterprob;
1385 SCIP_CONSDATA* consdata;
1386 SCIP_CONSDATA* curconsdata;
1387 SCIP_VAR** vars;
1388 int nvars;
1389
1390 masterprob = GCGgetMasterprob(gcg);
1391 assert(masterprob != NULL);
1392 assert(GCGisMaster(masterprob));
1393
1394 origprob = GCGgetOrigprob(gcg);
1395
1396 assert(conshdlrdata != NULL);
1397
1398 /* get constraint data */
1399 consdata = SCIPconsGetData(cons);
1400 assert(consdata != NULL);
1401
1402 /* get master problem variables generated during pricing */
1405
1406 if( consdata->npropvars < nvars )
1407 {
1408 SCIP_CONS *curcons;
1409 SCIP_HASHMAP *origvar2idx;
1410 int nbndvars;
1411 int nlocalbndchgs;
1412 int i;
1413 int j;
1414 int k;
1415 SCIP_VAR*** collectedbndvars;
1416 SCIP_Real** collectedlbnds;
1417 SCIP_Real** collectedubnds;
1418 int* ncollectedbndvars;
1419 int hashmapsize;
1420 int nblocks;
1421 int blocknr;
1422 SCIP_VAR *bndvar;
1423 int idx;
1424 SCIP_Real bnd;
1425 SCIP_Bool islinking;
1426 int* linkingvaridxs;
1427 int nlinkingvars;
1428
1429 nblocks = GCGgetNPricingprobs(gcg);
1430 nlinkingvars = 0;
1431
1432 collectedbndvars = conshdlrdata->collectedbndvars;
1433 collectedlbnds = conshdlrdata->collectedlbnds;
1434 collectedubnds = conshdlrdata->collectedubnds;
1435 ncollectedbndvars = conshdlrdata->ncollectedbndvars;
1436
1437 BMSclearMemoryArray(ncollectedbndvars, conshdlrdata->maxblocknum);
1438
1439 /* propagate local bound changes on the path from the current node to the root */
1440 curcons = cons;
1441 hashmapsize = 0;
1442 while ( curcons != NULL )
1443 {
1444 curconsdata = SCIPconsGetData(curcons);
1445 assert(curconsdata != NULL);
1446 //if( curconsdata->npropvars == nvars )
1447 // break;
1448 hashmapsize += (conshdlrdata->enforceproper ? curconsdata->nlocalbndchgs : curconsdata->nbranchingchgs);
1449 curcons = curconsdata->parentcons;
1450 }
1451 if( hashmapsize > SCIPgetNVars(origprob))
1452 hashmapsize = SCIPgetNVars(origprob);
1453
1454 SCIP_CALL(SCIPhashmapCreate(&origvar2idx, SCIPblkmem(masterprob), hashmapsize));
1455
1456 curcons = cons;
1457 nbndvars = 0;
1458 while ( curcons != NULL)
1459 {
1460 curconsdata = SCIPconsGetData(curcons);
1461 assert(curconsdata != NULL);
1462 //if( curconsdata->npropvars == nvars )
1463 // break;
1464
1465 /* propagate all bound changes or only the branching bound changes, depending on the setting for the enforcement of proper variables */
1466 nlocalbndchgs = (conshdlrdata->enforceproper ? curconsdata->nlocalbndchgs : curconsdata->nbranchingchgs);
1467
1468 /* iterate over bound changes performed at the current node's equivalent in the original tree */
1469 for ( k = 0; k < nlocalbndchgs; ++k )
1470 {
1471 linkingvaridxs = NULL;
1472 bndvar = curconsdata->localbndvars[k];
1473 islinking = GCGoriginalVarIsLinking(bndvar);
1474
1475 /* get the block the original variable is in */
1476 blocknr = GCGvarGetBlock(bndvar);
1477 assert(GCGvarIsOriginal(bndvar));
1478 assert(blocknr < nblocks);
1479
1480 if( blocknr >= 0 || islinking)
1481 {
1482 idx = SCIPhashmapGetImageInt(origvar2idx, bndvar);
1483 bnd = curconsdata->localnewbnds[k];
1484
1485 if( islinking )
1486 {
1487 blocknr = 0;
1488 if( idx < INT_MAX )
1489 {
1490 linkingvaridxs = conshdlrdata->linkingvaridxs[idx];
1491 }
1492 else
1493 {
1494 ensureLinkingvarIndxsSize(masterprob, conshdlrdata, nlinkingvars + 1);
1495 linkingvaridxs = conshdlrdata->linkingvaridxs[nlinkingvars];
1496 if( linkingvaridxs == NULL )
1497 {
1498 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &linkingvaridxs, conshdlrdata->maxblocknum) );
1499 conshdlrdata->linkingvaridxs[nlinkingvars] = linkingvaridxs;
1500 }
1501 SCIPhashmapInsertInt(origvar2idx, bndvar, nlinkingvars);
1502 ++nlinkingvars;
1503
1504 for( i = 0; i < nblocks; ++i )
1505 linkingvaridxs[i] = INT_MAX;
1506 }
1507 }
1508
1509 do
1510 {
1511 assert(blocknr >= 0 && blocknr < GCGgetNPricingprobs(gcg));
1512
1513 if( islinking )
1514 {
1515 if( !GCGisLinkingVarInBlock(bndvar, blocknr) )
1516 continue;
1517
1518 idx = linkingvaridxs[blocknr];
1519 }
1520
1521 if( curconsdata->localbndtypes[k] == SCIP_BOUNDTYPE_LOWER )
1522 {
1523 if( idx < INT_MAX )
1524 {
1525 if( collectedlbnds[blocknr][idx] == SCIP_INVALID || collectedlbnds[blocknr][idx] < bnd )
1526 collectedlbnds[blocknr][idx] = bnd;
1527 }
1528 else
1529 {
1530 SCIP_CALL( ensureCollectedBndvarsSize(masterprob, conshdlrdata, blocknr, ncollectedbndvars[blocknr] + 1) );
1531 if ( islinking )
1532 linkingvaridxs[blocknr] = ncollectedbndvars[blocknr];
1533 else
1534 SCIPhashmapInsertInt(origvar2idx, bndvar, ncollectedbndvars[blocknr]);
1535 collectedbndvars[blocknr][ncollectedbndvars[blocknr]] = bndvar;
1536 collectedlbnds[blocknr][ncollectedbndvars[blocknr]] = bnd;
1537 collectedubnds[blocknr][ncollectedbndvars[blocknr]] = SCIP_INVALID;
1538 ++ncollectedbndvars[blocknr];
1539 ++nbndvars;
1540 }
1541 }
1542 else
1543 {
1544 if( idx < INT_MAX )
1545 {
1546 if( collectedubnds[blocknr][idx] == SCIP_INVALID || collectedubnds[blocknr][idx] > bnd )
1547 collectedubnds[blocknr][idx] = bnd;
1548 }
1549 else
1550 {
1551 SCIP_CALL( ensureCollectedBndvarsSize(masterprob, conshdlrdata, blocknr, ncollectedbndvars[blocknr] + 1) );
1552 if ( islinking )
1553 linkingvaridxs[blocknr] = ncollectedbndvars[blocknr];
1554 else
1555 SCIPhashmapInsertInt(origvar2idx, bndvar, ncollectedbndvars[blocknr]);
1556 collectedbndvars[blocknr][ncollectedbndvars[blocknr]] = bndvar;
1557 collectedubnds[blocknr][ncollectedbndvars[blocknr]] = bnd;
1558 collectedlbnds[blocknr][ncollectedbndvars[blocknr]] = SCIP_INVALID;
1559 ++ncollectedbndvars[blocknr];
1560 ++nbndvars;
1561 }
1562 }
1563 }
1564 while( islinking && (++blocknr) < nblocks );
1565 }
1566 }
1567 /* proceed with the parent node */
1568 curcons = curconsdata->parentcons;
1569 }
1570
1571 if( nbndvars > 0 )
1572 {
1573 SCIP_Real lbnd;
1574 SCIP_Real ubnd;
1575 SCIP_HASHMAP* origvals;
1576 SCIP_Real origval;
1577
1578 /* iterate over all master variables created after the current node was left the last time */
1579 for ( i = consdata->npropvars; i < nvars; i++ )
1580 {
1581 assert(GCGvarIsMaster(vars[i]));
1582 blocknr = GCGvarGetBlock(vars[i]);
1583 assert(blocknr >= 0 && blocknr < GCGgetNPricingprobs(gcg));
1584
1585 /** @todo check if this really works with linking variables */
1586
1587 /* only look at variables not already fixed to 0 or that belong to no block */
1588 if( SCIPisFeasZero(masterprob, SCIPvarGetUbLocal(vars[i])) )
1589 continue;
1590
1591 origvals = GCGmasterVarGetOrigvalmap(vars[i]);
1592
1593 /* iterate over all original variables whose bound was changed */
1594 for ( j = 0; j < ncollectedbndvars[blocknr]; j++ )
1595 {
1596 bndvar = collectedbndvars[blocknr][j];
1597
1598 assert(GCGvarGetBlock(bndvar) == blocknr || (GCGoriginalVarIsLinking(bndvar) && GCGisLinkingVarInBlock(bndvar, blocknr)));
1599
1600 origval = SCIPhashmapGetImageReal(origvals, bndvar);
1601 /* variables belong to the same block -> set origval to 0.0 if not in map */
1602 if( origval == SCIP_INVALID )
1603 origval = 0.0;
1604 lbnd = collectedlbnds[blocknr][j];
1605 ubnd = collectedubnds[blocknr][j];
1606
1607 /* branching imposes new bound */
1608 if( (lbnd != SCIP_INVALID && SCIPisFeasLT(masterprob, origval, lbnd))
1609 || (ubnd != SCIP_INVALID && SCIPisFeasGT(masterprob, origval, ubnd)) )
1610 {
1611 SCIPdebugMessage("Changing upper bound of var %s\n", SCIPvarGetName(vars[i]));
1612 SCIP_CALL(SCIPchgVarUb(masterprob, vars[i], 0.0));
1613 ++(*propcount);
1614 break;
1615 }
1616 }
1617 }
1618 }
1619 SCIPhashmapFree(&origvar2idx);
1620 }
1621
1622 SCIPdebugMessage("Finished propagation of newly created variables: %d changed bounds\n", *propcount);
1623
1624 return SCIP_OKAY;
1625}
1626
1627/** apply local bound changes on original variables that have been directly copied to the master problem */
1628static
1630 GCG* gcg, /**< GCG data structure */
1631 SCIP_CONS* cons, /**< current masterbranch constraint */
1632 int* propcount /**< number of applied bound changes */
1633 )
1634{
1635 SCIP* masterprob;
1636 SCIP_CONSDATA* consdata;
1637 int i;
1638
1639 masterprob = GCGgetMasterprob(gcg);
1640 assert(masterprob != NULL);
1641
1642 /* get constraint data */
1643 consdata = SCIPconsGetData(cons);
1644 assert(consdata != NULL);
1645
1646 /* apply local bound changes */
1647 for( i = 0; i < consdata->nlocalbndchgs; i++ )
1648 {
1649 SCIP_VAR* mastervar;
1650
1651 assert(GCGvarIsOriginal(consdata->localbndvars[i]));
1652
1653 /** @todo this might lead to an error with linking variables ? */
1654 if( GCGvarGetBlock(consdata->localbndvars[i]) >= 0 )
1655 continue;
1656
1657 assert(GCGoriginalVarGetNMastervars(consdata->localbndvars[i]) >= 1);
1658
1659 mastervar = GCGoriginalVarGetMastervars(consdata->localbndvars[i])[0];
1660 assert(GCGvarGetBlock(mastervar) == -1);
1661
1662 if( consdata->localbndtypes[i] == SCIP_BOUNDTYPE_LOWER )
1663 {
1664 if( SCIPisLT(masterprob, SCIPvarGetLbLocal(mastervar), consdata->localnewbnds[i]) )
1665 {
1666 SCIP_CALL( SCIPchgVarLb(masterprob, mastervar, consdata->localnewbnds[i]) );
1667 ++(*propcount);
1668 SCIPdebugMessage("changed lb of copied original var %s locally to %g\n", SCIPvarGetName(consdata->localbndvars[i]), consdata->localnewbnds[i]);
1669 }
1670 }
1671 else
1672 {
1673 if( SCIPisGT(masterprob, SCIPvarGetUbLocal(mastervar), consdata->localnewbnds[i]) )
1674 {
1675 SCIP_CALL( SCIPchgVarUb(masterprob, mastervar, consdata->localnewbnds[i]) );
1676 ++(*propcount);
1677 SCIPdebugMessage("changed ub of copied original var %s locally to %g\n", SCIPvarGetName(consdata->localbndvars[i]), consdata->localnewbnds[i]);
1678 }
1679 }
1680 }
1681
1682 SCIPdebugMessage("Finished propagation of bounds of copied original variables: %d bounds changed.\n", *propcount);
1683
1684 return SCIP_OKAY;
1685}
1686
1687/** forward the seen history */
1688static
1690 GCG* gcg, /**< GCG data structure */
1691 SCIP_CONSDATA* consdata /**< constraint data */
1692 )
1693{
1694 SCIP* masterprob;
1695 assert(gcg != NULL);
1696 masterprob = GCGgetMasterprob(gcg);
1697 assert(consdata != NULL);
1698
1699 if( consdata->branchrule == NULL )
1700 {
1701 SCIP_CALL( GCGvarhistoryJumpToLatest(masterprob, consdata->knownvarhistory) );
1702 }
1703 else
1704 {
1705 SCIP_VAR* var = NULL;
1706 while( GCGvarhistoryHasNext(consdata->knownvarhistory) )
1707 {
1708 SCIP_CALL( GCGvarhistoryNext(masterprob, &consdata->knownvarhistory) );
1709 SCIP_CALL( GCGvarhistoryGetVar(consdata->knownvarhistory, &var) );
1710 assert(var != NULL);
1711 if( SCIPvarIsDeleted(var) )
1712 {
1713 SCIPdebugMessage("Skipping deleted Variable <%s>!\n", SCIPvarGetName(var));
1714 continue;
1715 }
1716 SCIP_CALL( GCGrelaxBranchNewCol(gcg, consdata->branchrule, consdata->branchdata, var) );
1717 }
1718 }
1719
1720 return SCIP_OKAY;
1721}
1722
1723/*
1724 * Callback methods
1725 */
1726
1727
1728/** destructor of constraint handler to free constraint handler data (called when SCIP is exiting) */
1729static
1730SCIP_DECL_CONSFREE(consFreeMasterbranch)
1731{
1732 SCIP_CONSHDLRDATA* conshdlrdata;
1733
1734 assert(scip != NULL);
1735 assert(conshdlr != NULL);
1736 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1737
1738 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1739 assert(conshdlrdata != NULL);
1740
1741 /* free constraint handler storage */
1742 assert(conshdlrdata->stack == NULL);
1743 SCIPfreeMemory(scip, &conshdlrdata);
1744
1745 return SCIP_OKAY;
1746}
1747
1748
1749/** initialization method of constraint handler (called after problem was transformed) */
1750static
1751SCIP_DECL_CONSINIT(consInitMasterbranch)
1752{ /*lint --e{715}*/
1753 SCIP_CONSHDLRDATA* conshdlrdata;
1754
1755 assert(scip != NULL);
1756 assert(conshdlr != NULL);
1757 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1758
1759 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1760 assert(conshdlrdata != NULL);
1761
1762 /* prepare stack */
1763 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &conshdlrdata->stack, conshdlrdata->maxstacksize) );
1764 conshdlrdata->nstack = 0;
1765
1766 /* prepare pending bound changes */
1767 conshdlrdata->npendingbnds = 0;
1768 conshdlrdata->maxpendingbnds = SCIPcalcMemGrowSize(scip, 1);
1769 conshdlrdata->pendingbndsactivated = TRUE;
1770 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->pendingvars), conshdlrdata->maxpendingbnds) );
1771 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->pendingbndtypes), conshdlrdata->maxpendingbnds) );
1772 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->pendingnewbnds), conshdlrdata->maxpendingbnds) );
1773 SCIP_CALL( SCIPhashmapCreate(&conshdlrdata->pendingvarmaplb, SCIPblkmem(scip), conshdlrdata->maxpendingbnds) );
1774 SCIP_CALL( SCIPhashmapCreate(&conshdlrdata->pendingvarmapub, SCIPblkmem(scip), conshdlrdata->maxpendingbnds) );
1775
1776 conshdlrdata->maxblocknum = SCIPcalcMemGrowSize(scip, GCGgetNPricingprobs(conshdlrdata->gcg));
1777 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->collectedbndvars), conshdlrdata->maxblocknum) );
1778 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->collectedlbnds), conshdlrdata->maxblocknum) );
1779 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->collectedubnds), conshdlrdata->maxblocknum) );
1780 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->ncollectedbndvars), conshdlrdata->maxblocknum) );
1781 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(conshdlrdata->maxcollectedbndvars), conshdlrdata->maxblocknum) );
1782 BMSclearMemoryArray(conshdlrdata->collectedbndvars, conshdlrdata->maxblocknum);
1783 BMSclearMemoryArray(conshdlrdata->collectedlbnds, conshdlrdata->maxblocknum);
1784 BMSclearMemoryArray(conshdlrdata->collectedubnds, conshdlrdata->maxblocknum);
1785 BMSclearMemoryArray(conshdlrdata->ncollectedbndvars, conshdlrdata->maxblocknum);
1786 BMSclearMemoryArray(conshdlrdata->maxcollectedbndvars, conshdlrdata->maxblocknum);
1787
1788 conshdlrdata->maxlinkingvaridxs = 0;
1789 conshdlrdata->linkingvaridxs = NULL;
1790
1791 return SCIP_OKAY;
1792}
1793
1794
1795/** solving process initialization method of constraint handler (called when branch and bound process is about to begin) */
1796static
1797SCIP_DECL_CONSINITSOL(consInitsolMasterbranch)
1798{ /*lint --e{715}*/
1799 SCIP_CONS* cons;
1800 SCIP_CONSHDLRDATA* conshdlrdata;
1801
1802 assert(scip != NULL);
1803 assert(conshdlr != NULL);
1804 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1805
1806 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1807 assert(conshdlrdata != NULL);
1808
1809 /* create masterbranch constraint for the root node */
1810 SCIP_CALL( GCGcreateConsMasterbranch(conshdlrdata->gcg, &cons, "root-masterbranch", NULL, NULL, NULL, NULL, NULL, 0, 0) );
1812
1813 conshdlrdata->nstack = 1;
1814 conshdlrdata->stack[0] = cons;
1815
1816 return SCIP_OKAY;
1817}
1818
1819static
1820SCIP_DECL_CONSEXITSOL(consExitSolMasterbranch)
1821{
1822 SCIP_CONSHDLRDATA* conshdlrdata;
1823 int i;
1824 int j;
1825
1826 assert(scip != NULL);
1827 assert(conshdlr != NULL);
1828 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1829
1830 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1831 assert(conshdlrdata != NULL);
1832
1833 /* we release all the mastersepacuts stored in the data of all the constraints which have not been deleted yet:
1834 * normally we release the mastercuts via/in consDeleteMasterbranch, but some constraints are only deleted after SCIP_STAGE_EXITSOLVE
1835 * and at that point, we cannot free rows anymore */
1836 for( i = 0; i < nconss; i++ )
1837 {
1838 SCIP_CONSDATA* consdata;
1839
1840 consdata = SCIPconsGetData(conss[i]);
1841 if( consdata->addedcutsinit )
1842 {
1843 if( consdata->nodestoredcuts )
1844 {
1845 for( j = 0; j < consdata->naddedcuts; j++ )
1846 {
1847 SCIP_CALL( GCGreleaseMastersepacut(conshdlrdata->gcg, &(consdata->addedcuts[j])) );
1848 }
1849 SCIPfreeBlockMemoryArray(scip, &(consdata->addedcuts), consdata->naddedcuts);
1850 consdata->naddedcuts = 0;
1851 }
1852 }
1853 consdata->nodestoredcuts = FALSE;
1854 consdata->addedcutsinit = TRUE;
1855 }
1856
1857 return SCIP_OKAY;
1858}
1859
1860
1861/** deinitialization method of constraint handler (called before transformed problem is freed) */
1862static
1863SCIP_DECL_CONSEXIT(consExitMasterbranch)
1864{ /*lint --e{715}*/
1865 SCIP_CONSHDLRDATA* conshdlrdata;
1866 int i;
1867
1868 assert(scip != NULL);
1869 assert(conshdlr != NULL);
1870 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1871
1872 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1873 assert(conshdlrdata != NULL);
1874 assert(conshdlrdata->nstack == 1 || SCIPgetNNodes(scip) == 0);
1875
1876 /* free stack */
1877 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->stack), conshdlrdata->maxstacksize);
1878 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->pendingvars), conshdlrdata->maxpendingbnds);
1879 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->pendingbndtypes), conshdlrdata->maxpendingbnds);
1880 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->pendingnewbnds), conshdlrdata->maxpendingbnds);
1881 SCIPhashmapFree(&conshdlrdata->pendingvarmaplb);
1882 SCIPhashmapFree(&conshdlrdata->pendingvarmapub);
1883
1884 for( i = 0; i < conshdlrdata->maxblocknum; ++i )
1885 {
1886 if( conshdlrdata->maxcollectedbndvars[i] > 0)
1887 {
1888 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedbndvars[i]), conshdlrdata->maxcollectedbndvars[i]);
1889 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedlbnds[i]), conshdlrdata->maxcollectedbndvars[i]);
1890 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedubnds[i]), conshdlrdata->maxcollectedbndvars[i]);
1891 }
1892 }
1893 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedbndvars), conshdlrdata->maxblocknum);
1894 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedlbnds), conshdlrdata->maxblocknum);
1895 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->collectedubnds), conshdlrdata->maxblocknum);
1896 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->ncollectedbndvars), conshdlrdata->maxblocknum);
1897 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->maxcollectedbndvars), conshdlrdata->maxblocknum);
1898
1899 for( i = 0; i < conshdlrdata->maxlinkingvaridxs; ++i )
1900 {
1901 if( conshdlrdata->linkingvaridxs[i] != NULL)
1902 SCIPfreeBlockMemoryArray(scip, &(conshdlrdata->linkingvaridxs[i]), conshdlrdata->maxblocknum);
1903 else
1904 break;
1905 }
1906 SCIPfreeBlockMemoryArrayNull(scip, &(conshdlrdata->linkingvaridxs), conshdlrdata->maxlinkingvaridxs);
1907
1908 return SCIP_OKAY;
1909}
1910
1911
1912/** constraint activation notification method of constraint handler */
1913static
1914SCIP_DECL_CONSACTIVE(consActiveMasterbranch)
1915{
1916 SCIP_CONSHDLRDATA* conshdlrdata;
1917 SCIP_CONSDATA* consdata;
1918
1919 assert(scip != NULL);
1920 assert(conshdlr != NULL);
1921 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
1922 assert(cons != NULL);
1923
1924 /* get constraint handler data */
1925 conshdlrdata = SCIPconshdlrGetData(conshdlr);
1926 assert(conshdlrdata != NULL);
1927 assert(conshdlrdata->stack != NULL);
1928
1929 /* get constraint data */
1930 consdata = SCIPconsGetData(cons);
1931 assert(consdata != NULL);
1932 assert((consdata->node == NULL) == (consdata->parentcons == NULL));
1933
1934 /* @fixme: This is a hack */
1935 if( consdata->node == NULL )
1936 {
1937 SCIPdebugMessage("root node not present in masterconsdata!\n");
1938 consdata->node = SCIPgetRootNode(scip);
1939 }
1940
1941 assert(consdata->node != NULL);
1942
1943 SCIPdebugMessage("Activating branch master constraint: <%s>[stack size: %d].\n", SCIPconsGetName(cons), conshdlrdata->nstack+1);
1944 /* If the node is activated the first time, we have to initialize the constraint data first */
1945 if( consdata->nactivated == 0 )
1946 {
1947 SCIPdebugPrintf("for the first time\n");
1948 SCIP_CALL( initializeConsdata(conshdlrdata->gcg, cons) );
1949 }
1950 else
1951 SCIPdebugPrintf("\n");
1952
1953 consdata->nactivated++;
1954
1955 /* The node has to be repropagated if new variables were created after the node was left the last time
1956 * or if new bound changes on directly transferred variables were found
1957 */
1958 assert(GCGmasterGetNPricedvars(conshdlrdata->gcg) >= consdata->npropvars);
1959 if( GCGmasterGetNPricedvars(conshdlrdata->gcg) > consdata->npropvars || consdata->ncopiedvarbnds > 0 )
1960 {
1961 consdata->needprop = TRUE;
1962 SCIP_CALL( SCIPrepropagateNode(scip, consdata->node) );
1963 }
1964
1965 if( consdata->nlocalbndchgs - consdata->nlocalbndchgstreated[conshdlrdata->nstack] > 0 )
1966 SCIPdebugMessage("added %d boundchanges from previous nodes!\n", consdata->nlocalbndchgs - consdata->nlocalbndchgstreated[conshdlrdata->nstack]);
1967
1968 /* put constraint on the stack */
1969 if( conshdlrdata->nstack >= conshdlrdata->maxstacksize )
1970 {
1971 int newsize = SCIPcalcMemGrowSize(scip, conshdlrdata->nstack+1);
1972 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrdata->stack), conshdlrdata->maxstacksize, newsize) );
1973
1974 SCIPdebugMessage("reallocating Memory for stack! %d --> %d\n", conshdlrdata->maxstacksize, newsize);
1975 conshdlrdata->maxstacksize = newsize;
1976 }
1977
1978 conshdlrdata->stack[conshdlrdata->nstack] = cons;
1979 (conshdlrdata->nstack)++;
1980
1981 SCIPdebugMessage("Activating masterbranch constraint: <%s> [stack size: %d], needprop = %u.\n",
1982 consdata->name, conshdlrdata->nstack, consdata->needprop);
1983
1984 /* apply global bound changes in the original problem to the pricing problems */
1985 SCIP_CALL( applyGlobalBndchgsToPricingprobs(conshdlrdata->gcg, conshdlrdata) );
1986
1987 /* apply local bound changes in the original problem to the pricing problems */
1988 SCIP_CALL( applyLocalBndchgsToPricingprobs(conshdlrdata->gcg, cons) );
1989
1990 /* call branching specific activation method */
1991 if( consdata->branchrule != NULL )
1992 {
1993 SCIP_CALL( GCGrelaxBranchActiveMaster(conshdlrdata->gcg, consdata->branchrule, consdata->branchdata) );
1994 }
1995
1996 /* forward history of node we are activating */
1997 forwardUpdateSeenHistory(conshdlrdata->gcg, consdata);
1998 /* forward history of possible ancestor nodes (all active) */
1999 SCIP_CONS* parentcons = consdata->parentcons;
2000 SCIP_CONSDATA* parentconsdata;
2001 while( parentcons != NULL )
2002 {
2003 parentconsdata = SCIPconsGetData(parentcons);
2005 parentcons = parentconsdata->parentcons;
2006 }
2007
2008 SCIPdebugMessage("Activation of node %lli of type %i with cons %s\n", SCIPnodeGetNumber(consdata->node),
2009 SCIPnodeGetType(consdata->node), consdata->name);
2010
2011 if( consdata->addedcutsinit )
2012 {
2013 assert(SCIPnodeGetType(consdata->node) != SCIP_NODETYPE_FOCUSNODE);
2014 assert(consdata->nactivated >= 1);
2015 SCIP_CALL( addStoredCutsToActiveCuts(conshdlrdata->gcg, consdata, conshdlrdata) );
2016 }
2017
2018 /* if tree is currently probing, we do not clear generated cuts
2019 * - the cuts in generated cuts may not have been separated yet, as separation store gets switched when probing */
2020 if( SCIPnodeGetType(consdata->node) == SCIP_NODETYPE_FOCUSNODE )
2021 SCIP_CALL( GCGclearGeneratedMastersepacuts(conshdlrdata->gcg) ); // potentially: move to pricing
2022
2023 return SCIP_OKAY;
2024}
2025
2026/** constraint deactivation notification method of constraint handler */
2027static
2028SCIP_DECL_CONSDEACTIVE(consDeactiveMasterbranch)
2029{
2030 SCIP_CONSHDLRDATA* conshdlrdata;
2031 SCIP_CONSDATA* consdata;
2032
2033 assert(scip != NULL);
2034 assert(conshdlr != NULL);
2035 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
2036 assert(cons != NULL);
2037
2038 /* get constraint handler data */
2039 conshdlrdata = SCIPconshdlrGetData(conshdlr);
2040 assert(conshdlrdata != NULL);
2041 assert(conshdlrdata->stack != NULL || conshdlrdata->nstack == 1);
2042 assert(conshdlrdata->nstack > 0);
2043 assert(conshdlrdata->nstack == 1 || cons == conshdlrdata->stack[conshdlrdata->nstack-1]);
2044
2045 /* get constraint data */
2046 consdata = SCIPconsGetData(cons);
2047 assert(consdata != NULL);
2048 assert(consdata->nactivated >= 1);
2049
2050 if( !conshdlrdata->pendingbndsactivated )
2051 {
2052 SCIPdebugMessage("We need repropagation\n");
2053 consdata->needprop = TRUE;
2054 }
2055
2057 consdata->npropvars = GCGmasterGetNPricedvars(conshdlrdata->gcg);
2058
2059 /* remove constraint from the stack */
2060 (conshdlrdata->nstack)--;
2061
2062 SCIPdebugMessage("Deactivating masterbranch constraint: <%s> [stack size: %d].\n",
2063 consdata->name, conshdlrdata->nstack);
2064
2065 /* undo local bound changes in the original problem to the pricing problems */
2066 SCIP_CALL( undoLocalBndchgsToPricingprobs(conshdlrdata->gcg, cons) );
2067
2068 /* call branching specific deactivation method */
2069 if( consdata->branchrule != NULL )
2070 {
2071 SCIP_CALL( GCGrelaxBranchDeactiveMaster(conshdlrdata->gcg, consdata->branchrule, consdata->branchdata) );
2072 }
2073
2075
2076 SCIPdebugMessage("Deactivation of node %lli of type %i with cons %s\n", SCIPnodeGetNumber(consdata->node),
2077 SCIPnodeGetType(consdata->node), consdata->name);
2078
2079 /* node is deactivated without any of its children being activated:
2080 * - store the mastersepacuts which were (generated and) applied in this node in the data of its defining branch */
2081 if( !consdata->addedcutsinit )
2082 SCIP_CALL( initializeAddedCuts(conshdlrdata->gcg, consdata, conshdlrdata) );
2083
2084 /* remove all the mastercuts (generated and) applied at this node from activecuts */
2085 SCIP_CALL( removeStoredCutsFromActiveCuts(conshdlrdata->gcg, consdata, conshdlrdata) );
2086
2087 return SCIP_OKAY;
2088}
2089
2090
2091/** frees specific constraint data */
2092static
2093SCIP_DECL_CONSDELETE(consDeleteMasterbranch)
2094{
2095 SCIP* origscip;
2096 SCIP_CONSHDLRDATA* conshdlrdata;
2097 SCIP_CONSDATA* parentconsdata;
2098 SCIP_CONSDATA** childconsdatas;
2099 SCIP_CONS** childconss;
2100 int nchildconss;
2101 int i;
2102 int j;
2103
2104 assert(scip != NULL);
2105 assert(conshdlr != NULL);
2106
2107 assert(cons != NULL);
2108 assert(consdata != NULL);
2109 assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
2110 assert(*consdata != NULL);
2111
2112 conshdlrdata = SCIPconshdlrGetData(conshdlr);
2113 assert(conshdlrdata != NULL);
2114
2115 /* get original problem */
2116 origscip = GCGgetOrigprob(conshdlrdata->gcg);
2117 assert(origscip != NULL);
2118
2119 SCIPdebugMessage("Deleting masterbranch constraint: <%s>.\n", (*consdata)->name);
2120
2121 /* remove original branching constraints if not yet done
2122 * (might happen if node is cut off before branching decisions are transferred to the original problem)
2123 */
2125
2126 /* free arrays with local bound changes on copied original variables */
2127 if( (*consdata)->maxcopiedvarbnds > 0 )
2128 {
2129 SCIPfreeBlockMemoryArrayNull(scip, &((*consdata)->copiedvars), (*consdata)->maxcopiedvarbnds);
2130 SCIPfreeBlockMemoryArrayNull(scip, &((*consdata)->copiedvarbndtypes), (*consdata)->maxcopiedvarbnds);
2131 SCIPfreeBlockMemoryArrayNull(scip, &((*consdata)->copiedvarbnds), (*consdata)->maxcopiedvarbnds);
2132 }
2133
2134 /* free arrays with local bound changes on original variables belonging to a unique block */
2135 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->nlocalbndchgstreated, (*consdata)->maxlocalbndchgstreated);
2136 if( (*consdata)->maxlocalbndchgs > 0 )
2137 {
2138 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->localoldbnds, (*consdata)->maxlocalbndchgs);
2139 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->localnewbnds, (*consdata)->maxlocalbndchgs);
2140 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->localbndtypes, (*consdata)->maxlocalbndchgs);
2141 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->localbndvars, (*consdata)->maxlocalbndchgs);
2142 }
2143
2144 assert((*consdata)->origcons == NULL || GCGconsOrigbranchGetMastercons((*consdata)->origcons) == cons);
2145
2146 /* allow the correspondig branchrule to delete the branch data */
2147 if( (*consdata)->branchdata != NULL && (*consdata)->branchrule != NULL )
2148 {
2149 SCIP_Bool force = ((*consdata)->origcons == NULL);
2150 SCIP_CALL( GCGrelaxBranchDataDelete(conshdlrdata->gcg, (*consdata)->branchrule, &(*consdata)->branchdata, FALSE, force) );
2151 if( (*consdata)->origcons != NULL && (*consdata)->branchdata == NULL )
2152 GCGconsOrigbranchSetBranchdata((*consdata)->origcons, NULL);
2153 }
2154
2155 (*consdata)->branchdata = NULL;
2156
2157 /* set the mastercons pointer of the corresponding origcons to NULL */
2158 if( (*consdata)->origcons != NULL )
2159 {
2160 GCGconsOrigbranchSetMastercons((*consdata)->origcons, NULL);
2161 }
2162
2163 assert((*consdata)->knownvarhistory != NULL);
2164 SCIP_CALL( GCGvarhistoryFreeReference(scip, &(*consdata)->knownvarhistory) );
2165
2166 /* remove branching constraints at child nodes */
2167 nchildconss = (*consdata)->nchildconss;
2168 if( nchildconss > 0 )
2169 {
2170 SCIP_CALL( SCIPallocBufferArray(scip, &childconsdatas, nchildconss) );
2171 SCIP_CALL( SCIPallocBufferArray(scip, &childconss, nchildconss) );
2172
2173 for( i = 0; i < nchildconss; ++i )
2174 {
2175 if( (*consdata)->childconss != NULL && (*consdata)->childconss[i] != NULL )
2176 {
2177 childconsdatas[i] = SCIPconsGetData((*consdata)->childconss[i]);
2178 childconss[i] = (*consdata)->childconss[i];
2179 }
2180 else
2181 {
2182 childconsdatas[i] = NULL;
2183 childconss[i] = NULL;
2184 }
2185 }
2186
2187 /* delete childnodes */
2188 for( i = 0; i < nchildconss; ++i )
2189 {
2190 SCIPdebugMessage("Deleting %d childnodes\n", nchildconss);
2191
2192 if( childconss[i] != NULL )
2193 {
2194 /*SCIP_CALL( consDeleteMasterbranch(scip, conshdlr, childcons[i], &childconsdatas[i]) );*/
2195 SCIP_CALL( SCIPreleaseCons(scip, &childconss[i]) );
2196 childconss[i] = NULL;
2197 }
2198 }
2199
2200 SCIPfreeBufferArray(scip, &childconss);
2201 SCIPfreeBufferArray(scip, &childconsdatas);
2202 }
2203 assert((*consdata)->nchildconss == 0);
2204
2205 /* set the pointer in the parent node to NULL */
2206 if( (*consdata)->parentcons != NULL )
2207 {
2208 SCIP_Bool isinprobing;
2209#ifndef NDEBUG
2210 SCIP_Bool childdeleted = FALSE;
2211#endif
2212
2213 parentconsdata = SCIPconsGetData((*consdata)->parentcons);
2214
2215 isinprobing = (SCIPgetStage(scip) <= SCIP_STAGE_SOLVING && SCIPinProbing(scip)) || (SCIPgetStage(origscip) <= SCIP_STAGE_SOLVING && SCIPinProbing(origscip));
2216 if( isinprobing )
2217 parentconsdata->probingtmpcons = NULL;
2218
2219 for( i = 0; i < parentconsdata->nchildconss; ++i )
2220 {
2221 if( parentconsdata->childconss[i] == cons )
2222 {
2223 parentconsdata->childconss[i] = parentconsdata->childconss[parentconsdata->nchildconss-1];
2224
2225 parentconsdata->childconss[parentconsdata->nchildconss-1] = NULL;
2226 parentconsdata->nchildconss--;
2227#ifndef NDEBUG
2228 childdeleted = TRUE;
2229#endif
2230 break;
2231 }
2232 }
2233 assert(childdeleted || isinprobing);
2234 }
2235
2236 SCIPfreeBlockMemoryArrayNull(scip, &(*consdata)->childconss, (*consdata)->maxchildconss);
2237
2238 if( (*consdata)->name != NULL )
2239 {
2240 SCIPfreeBlockMemoryArray(scip, &(*consdata)->name, strlen((*consdata)->name)+1);
2241 }
2242
2243 /* we delete all the data associated with the mastercuts from the constraint data */
2244 conshdlrdata = SCIPconshdlrGetData(conshdlr);
2245 assert(conshdlrdata != NULL);
2246
2247 if( (*consdata)->addedcutsinit )
2248 {
2249 SCIPdebugMessage("delete master: node stored cuts %i\n", (*consdata)->nodestoredcuts);
2250
2251 if( (*consdata)->nodestoredcuts )
2252 {
2253 SCIPdebugMessage("delete master: release %i cuts and free addedcuts\n", (*consdata)->naddedcuts);
2254
2255 for( j = 0; j < (*consdata)->naddedcuts; j++ )
2256 {
2257 SCIP_CALL( GCGreleaseMastersepacut(conshdlrdata->gcg, &((*consdata)->addedcuts[j])) );
2258 }
2259 SCIPfreeBlockMemoryArray(scip, &((*consdata)->addedcuts), (*consdata)->naddedcuts);
2260 (*consdata)->naddedcuts = 0;
2261 }
2262 }
2263
2264 SCIPfreeBlockMemoryNull(scip, consdata);
2265 *consdata = NULL;
2266
2267 return SCIP_OKAY;
2268}
2269
2270
2271/** domain propagation method of constraint handler */
2272static
2273SCIP_DECL_CONSPROP(consPropMasterbranch)
2274{ /*lint --e{715}*/
2275 SCIP_CONSHDLRDATA* conshdlrdata;
2276 SCIP_CONS* cons;
2277 SCIP_CONSDATA* consdata;
2278
2279 int propcount;
2280
2281 assert(conshdlr != NULL);
2282 conshdlrdata = SCIPconshdlrGetData(conshdlr);
2283 assert(conshdlrdata != NULL);
2284 assert(conshdlrdata->stack != NULL);
2285
2286 *result = SCIP_DIDNOTRUN;
2287
2288 /* the constraint data of the cons related to the current node */
2289 cons = conshdlrdata->stack[conshdlrdata->nstack-1];
2290 assert(cons != NULL);
2291
2292 consdata = SCIPconsGetData(cons);
2293 assert(consdata != NULL);
2294
2295 if( conshdlrdata->npendingbnds == 0 && !consdata->needprop && consdata->ncopiedvarbnds == 0 )
2296 {
2297 SCIPdebugMessage("No propagation of masterbranch constraint needed: <%s>, stack size = %d.\n",
2298 consdata->name, conshdlrdata->nstack);
2299
2300 return SCIP_OKAY;
2301 }
2302
2303 SCIPdebugMessage("Starting propagation of masterbranch constraint: <%s>, stack size = %d, newvars = %d, npendingbnds = %d, npropbounds = %d.\n",
2304 consdata->name, conshdlrdata->nstack, GCGmasterGetNPricedvars(conshdlrdata->gcg) - consdata->npropvars, conshdlrdata->npendingbnds, consdata->ncopiedvarbnds);
2305
2306 propcount = 0;
2307
2308 if( conshdlrdata->npendingbnds > 0 )
2309 {
2310 *result = SCIP_DIDNOTFIND;
2311
2312 if( !conshdlrdata->pendingbndsactivated )
2313 {
2314 /* apply global bound changes in the original problem to the pricing problems */
2315 SCIP_CALL(applyGlobalBndchgsToPricingprobs(conshdlrdata->gcg, conshdlrdata));
2316 }
2317
2318 /* apply global bound changes on original problem variables to the master problem */
2319 SCIP_CALL( applyGlobalBndchgsToPricedMastervars(conshdlrdata->gcg, conshdlrdata, &propcount) );
2320
2322 }
2323
2324 if( consdata->needprop || consdata->ncopiedvarbnds != 0 )
2325 {
2326 *result = SCIP_DIDNOTFIND;
2327
2328 /* apply local bound changes on the original variables on newly generated master variables */
2329 SCIP_CALL( applyLocalBndchgsToPricedMastervars(conshdlrdata->gcg, conshdlrdata, cons, &propcount) );
2330
2331 /* apply local bound changes on original variables that have been directly copied to the master problem */
2332 SCIP_CALL( applyLocalBndchgsToCopiedMastervars(conshdlrdata->gcg, cons, &propcount) );
2333
2334 /* call branching rule specific propagation method */
2335 if ( consdata->branchrule != NULL )
2336 {
2337 /** @todo count number of propagations */
2338 SCIP_CALL( GCGrelaxBranchPropMaster(conshdlrdata->gcg, consdata->branchrule, consdata->branchdata, result) );
2339 }
2340
2341 consdata->needprop = FALSE;
2342 consdata->npropvars = GCGmasterGetNPricedvars(conshdlrdata->gcg);
2343 }
2344
2345 if( *result != SCIP_CUTOFF && propcount > 0 )
2346 *result = SCIP_REDUCEDDOM;
2347
2348 return SCIP_OKAY;
2349}
2350
2351
2352/** enforcement method for LP solutions */
2353static
2354SCIP_DECL_CONSENFOLP(consEnfolpMasterbranch)
2355{ /*lint --e{715}*/
2356 *result = SCIP_FEASIBLE;
2357
2358 return SCIP_OKAY;
2359}
2360
2361/** enforcement method for pseudo solutions */
2362static
2363SCIP_DECL_CONSENFOPS(consEnfopsMasterbranch)
2364{ /*lint --e{715}*/
2365 *result = SCIP_FEASIBLE;
2366
2367 return SCIP_OKAY;
2368}
2369
2370/** check method for solutions */
2371static
2372SCIP_DECL_CONSCHECK(consCheckMasterbranch)
2373{ /*lint --e{715}*/
2374 *result = SCIP_FEASIBLE;
2375
2376 return SCIP_OKAY;
2377}
2378
2379/** variable lock method */
2380static
2381SCIP_DECL_CONSLOCK(consLockMasterbranch)
2382{ /*lint --e{715}*/
2383 return SCIP_OKAY;
2384}
2385
2386
2387/*
2388 * Callback methods of event handler
2389 */
2390
2391/** solving process initialization method of event handler (called when branch and bound process is about to begin) */
2392static
2393SCIP_DECL_EVENTINITSOL(eventInitsolOrigvarbound)
2394{ /*lint --e{715}*/
2395 SCIP_VAR** vars;
2396 int nvars;
2397 int i;
2398
2399 vars = SCIPgetVars(scip);
2400 nvars = SCIPgetNVars(scip);
2401
2402 for( i = 0; i < nvars; i++ )
2403 {
2405 eventhdlr, NULL, NULL) );
2406 }
2407
2408 return SCIP_OKAY;
2409}
2410
2411/** eventhdlr destructor */
2412static
2413SCIP_DECL_EVENTFREE(eventFreeOrigvarbound)
2414{
2415 SCIP_EVENTHDLRDATA* eventhdlrdata;
2416
2417 eventhdlrdata = SCIPeventhdlrGetData(eventhdlr);
2418 assert(eventhdlrdata != NULL);
2419
2420 SCIPfreeBlockMemory(scip, &eventhdlrdata);
2421
2422 return SCIP_OKAY;
2423}
2424
2425/** execution method of event handler */
2426static
2427SCIP_DECL_EVENTEXEC(eventExecOrigvarbound)
2428{ /*lint --e{715}*/
2429 SCIP* masterscip;
2430 SCIP_EVENTTYPE eventtype;
2431 SCIP_EVENTHDLRDATA* eventhdlrdata;
2432 SCIP_VAR* var;
2433 SCIP_Real oldbound;
2434 SCIP_Real newbound;
2435 int blocknr;
2436#ifdef SCIP_DEBUG
2437 SCIP_Bool handled = FALSE;
2438#endif
2439 SCIP_VAR** mastervars;
2440#ifndef NDEBUG
2441 int nmastervars;
2442 SCIP_Real* mastervals;
2443#endif
2444
2445 eventhdlrdata = SCIPeventhdlrGetData(eventhdlr);
2446 assert(eventhdlrdata != NULL);
2447
2448 /* get master problem */
2449 masterscip = GCGgetMasterprob(eventhdlrdata->gcg);
2450 assert(masterscip != NULL);
2451
2452 /* get event data */
2453 eventtype = SCIPeventGetType(event);
2454 var = SCIPeventGetVar(event);
2455 oldbound = SCIPeventGetOldbound(event);
2456 newbound = SCIPeventGetNewbound(event);
2457
2458 SCIPdebugMessage("eventexec: eventtype = 0x%x, var = %s, oldbound = %f, newbound = %f\n", (unsigned int) eventtype, SCIPvarGetName(var), oldbound, newbound);
2459
2460 if( GCGgetDecompositionMode(eventhdlrdata->gcg) != GCG_DECMODE_DANTZIGWOLFE || !GCGrelaxIsInitialized(eventhdlrdata->gcg) )
2461 {
2462// assert(SCIPvarGetData(var) == NULL);
2463 SCIPdebugMessage("Ignoring since in presolving / propagating.\n");
2464 return SCIP_OKAY;
2465 }
2466
2467 if( !SCIPisTransformed(masterscip) )
2468 {
2469 GCGinitializeMasterProblemSolve(eventhdlrdata->gcg);
2470 }
2471
2472 assert(GCGvarIsOriginal(var));
2473 blocknr = GCGvarGetBlock(var);
2474
2475 mastervars = GCGoriginalVarGetMastervars(var);
2476#ifndef NDEBUG
2477 nmastervars = GCGoriginalVarGetNMastervars(var);
2478 mastervals = GCGoriginalVarGetMastervals(var);
2479#endif
2480
2481 assert(SCIPgetStage(masterscip) >= SCIP_STAGE_TRANSFORMED);
2482
2483 /* A global bound change might turn the current relaxation solution invalid */
2485 && (((eventtype & SCIP_EVENTTYPE_GLBCHANGED) != 0 && SCIPisFeasLT(scip, SCIPgetRelaxSolVal(scip, var), newbound))
2486 || ((eventtype & SCIP_EVENTTYPE_GUBCHANGED) != 0 && SCIPisFeasGT(scip, SCIPgetRelaxSolVal(scip, var), newbound))) )
2487 {
2489 }
2490
2491 /* deal with variables present in the pricing */
2492 if( blocknr >= 0 && GCGisPricingprobRelevant(eventhdlrdata->gcg, blocknr) )
2493 {
2494 SCIPdebugMessage("Pricing var!\n");
2495 if( (eventtype & SCIP_EVENTTYPE_GLBCHANGED) != 0 )
2496 {
2497#ifdef SCIP_DEBUG
2498 handled = TRUE;
2499#endif
2500 SCIP_CALL( addPendingBndChg(masterscip, GCGoriginalVarGetPricingVar(var), SCIP_BOUNDTYPE_LOWER, oldbound, newbound) );
2501 }
2502 if( (eventtype & SCIP_EVENTTYPE_GUBCHANGED) != 0 )
2503 {
2504#ifdef SCIP_DEBUG
2505 handled = TRUE;
2506#endif
2507 SCIP_CALL( addPendingBndChg(masterscip, GCGoriginalVarGetPricingVar(var), SCIP_BOUNDTYPE_UPPER, oldbound, newbound) );
2508 }
2509 }
2510 /* deal with variables appearing in the master only */
2511 if( blocknr == -1 )
2512 {
2513 assert(nmastervars == 1);
2514 assert(mastervals[0] == 1);
2515 assert(mastervars[0] != NULL);
2516
2517 SCIPdebugMessage("Master var!\n");
2518 if( (eventtype & SCIP_EVENTTYPE_GLBCHANGED) != 0 )
2519 {
2520#ifdef SCIP_DEBUG
2521 handled = TRUE;
2522#endif
2523 SCIP_CALL( addPendingBndChg(masterscip, mastervars[0], SCIP_BOUNDTYPE_LOWER, oldbound, newbound) );
2524 }
2525 if( (eventtype & SCIP_EVENTTYPE_GUBCHANGED) != 0 )
2526 {
2527#ifdef SCIP_DEBUG
2528 handled = TRUE;
2529#endif
2530 SCIP_CALL( addPendingBndChg(masterscip, mastervars[0], SCIP_BOUNDTYPE_UPPER, oldbound, newbound) );
2531 }
2532 }
2533 /* deal with linking variables */
2534 if( blocknr == -2 )
2535 {
2536 int npricingprobs;
2537 SCIP_VAR** pricingvars;
2538 int i;
2539
2540 SCIPdebugMessage("Linking var!\n");
2541 pricingvars = GCGlinkingVarGetPricingVars(var);
2542 npricingprobs = GCGgetNPricingprobs(eventhdlrdata->gcg);
2543
2544 assert(nmastervars >= 1);
2545 assert(mastervals[0] == 1);
2546 assert(mastervars[0] != NULL);
2547 assert(GCGvarGetBlock(mastervars[0]) == -1);
2548
2549 if( (eventtype & SCIP_EVENTTYPE_GLBCHANGED) != 0 )
2550 {
2551#ifdef SCIP_DEBUG
2552 handled = TRUE;
2553#endif
2554 /* add the bound change in the master */
2555 SCIP_CALL( addPendingBndChg(masterscip, mastervars[0], SCIP_BOUNDTYPE_LOWER, oldbound, newbound) );
2556
2557 /* add the bound change to the pricing problems */
2558 for( i = 0; i < npricingprobs; ++i )
2559 {
2560 if( pricingvars[i] == NULL )
2561 continue;
2562#ifdef SCIP_DEBUG
2563 handled = TRUE;
2564#endif
2565 SCIP_CALL( addPendingBndChg(masterscip, pricingvars[i], SCIP_BOUNDTYPE_LOWER, oldbound, newbound) );
2566 }
2567 }
2568 if( (eventtype & SCIP_EVENTTYPE_GUBCHANGED) != 0 )
2569 {
2570#ifdef SCIP_DEBUG
2571 handled = TRUE;
2572#endif
2573 /* add the bound change in the master */
2574 SCIP_CALL( addPendingBndChg(masterscip, mastervars[0], SCIP_BOUNDTYPE_UPPER, oldbound, newbound) );
2575
2576 /* add the bound change to the pricing problems */
2577 for( i = 0; i < npricingprobs; ++i )
2578 {
2579 if( pricingvars[i] == NULL )
2580 continue;
2581#ifdef SCIP_DEBUG
2582 handled = TRUE;
2583#endif
2584 SCIP_CALL( addPendingBndChg(masterscip, pricingvars[i], SCIP_BOUNDTYPE_UPPER, oldbound, newbound) );
2585 }
2586
2587 }
2588
2589 }
2590#ifdef SCIP_DEBUG
2591 if( !handled )
2592 {
2593 SCIPdebugMessage("Effectively ignoring this change\n");
2594 }
2595#endif
2596
2597 return SCIP_OKAY;
2598}
2599
2600
2601/*
2602 * interface methods
2603 */
2604
2605
2606/** creates the handler for masterbranch constraints and includes it in SCIP */
2608 GCG* gcg /**< GCG data structure */
2609 )
2610{
2611 SCIP* masterprob;
2612 SCIP* origscip;
2613 SCIP_CONSHDLR* conshdlr;
2614 SCIP_CONSHDLRDATA* conshdlrdata;
2615 SCIP_EVENTHDLR* eventhdlr;
2616 SCIP_EVENTHDLRDATA* eventhdlrdata;
2617
2618 masterprob = GCGgetMasterprob(gcg);
2619 assert(masterprob != NULL);
2620
2621 /* get original problem */
2622 origscip = GCGgetOrigprob(gcg);
2623 assert(origscip != NULL);
2624
2625 SCIP_CALL( SCIPallocMemory(masterprob, &conshdlrdata) );
2626 conshdlrdata->gcg = gcg;
2627 conshdlrdata->stack = NULL;
2628 conshdlrdata->nstack = 0;
2629 conshdlrdata->maxstacksize = 25;
2630
2631 /* include constraint handler */
2634 consEnfolpMasterbranch, consEnfopsMasterbranch, consCheckMasterbranch, consLockMasterbranch,
2635 conshdlrdata) );
2636 assert(conshdlr != NULL);
2637
2638 SCIP_CALL( SCIPsetConshdlrFree(masterprob, conshdlr, consFreeMasterbranch) );
2639 SCIP_CALL( SCIPsetConshdlrInit(masterprob, conshdlr, consInitMasterbranch) );
2640 SCIP_CALL( SCIPsetConshdlrExit(masterprob, conshdlr, consExitMasterbranch) );
2641 SCIP_CALL( SCIPsetConshdlrInitsol(masterprob, conshdlr, consInitsolMasterbranch) );
2642 SCIP_CALL( SCIPsetConshdlrExitsol(masterprob, conshdlr, consExitSolMasterbranch) );
2643 SCIP_CALL( SCIPsetConshdlrDelete(masterprob, conshdlr, consDeleteMasterbranch) );
2644 SCIP_CALL( SCIPsetConshdlrActive(masterprob, conshdlr, consActiveMasterbranch) );
2645 SCIP_CALL( SCIPsetConshdlrDeactive(masterprob, conshdlr, consDeactiveMasterbranch) );
2646 SCIP_CALL( SCIPsetConshdlrProp(masterprob, conshdlr, consPropMasterbranch, CONSHDLR_PROPFREQ,
2648
2649 /* create event handler data */
2650 SCIP_CALL( SCIPallocBlockMemory(origscip, &eventhdlrdata) );
2651 eventhdlrdata->gcg = gcg;
2652
2653 /* include event handler into original SCIP */
2655 eventExecOrigvarbound, eventhdlrdata) );
2656 assert(eventhdlr != NULL);
2657
2658 /* set non fundamental callbacks via setter functions */
2659 SCIP_CALL( SCIPsetEventhdlrInitsol(origscip, eventhdlr, eventInitsolOrigvarbound) );
2660 SCIP_CALL( SCIPsetEventhdlrFree(origscip, eventhdlr, eventFreeOrigvarbound) );
2661
2662 SCIP_CALL( SCIPaddBoolParam(origscip, "relaxing/gcg/enforceproper",
2663 "should propagated bound changes in the original be enforced in the master (only proper vars)?",
2664 &conshdlrdata->enforceproper, FALSE, TRUE, NULL, NULL) );
2665
2666 return SCIP_OKAY;
2667}
2668
2669/** creates and captures a masterbranch constraint */
2671 GCG* gcg, /**< GCG data structure */
2672 SCIP_CONS** cons, /**< pointer to hold the created constraint */
2673 const char* name, /**< name of the constraint */
2674 SCIP_NODE* node, /**< node at which the constraint should be created */
2675 SCIP_CONS* parentcons, /**< parent constraint */
2676 GCG_BRANCHRULE* branchrule, /**< pointer to the branching rule */
2677 GCG_BRANCHDATA* branchdata, /**< branching data */
2678 SCIP_CONS** origbranchconss, /**< original constraints enforcing the branching decision */
2679 int norigbranchconss, /**< number of original constraints */
2680 int maxorigbranchconss /**< capacity of origbranchconss */
2681 )
2682{
2683 SCIP* masterprob;
2684 SCIP_CONSHDLR* conshdlr;
2685 SCIP_CONSDATA* consdata;
2686
2687 masterprob = GCGgetMasterprob(gcg);
2688 assert(masterprob != NULL);
2689 assert(node != NULL || parentcons == NULL);
2690 if( node != NULL )
2691 assert((parentcons == NULL) == (SCIPnodeGetDepth(node) == 0));
2692 else
2693 assert(parentcons == NULL);
2694
2695 assert(SCIPgetStage(masterprob) <= SCIP_STAGE_SOLVING);
2696
2697 /* find the masterbranch constraint handler */
2698 conshdlr = SCIPfindConshdlr(masterprob, CONSHDLR_NAME);
2699 assert(conshdlr != NULL);
2700
2701 /* create constraint data */
2702 SCIP_CALL( SCIPallocBlockMemory(masterprob, &consdata) );
2703
2704 SCIP_CALL( SCIPduplicateBlockMemoryArray(masterprob, &(consdata->name), name, strlen(name)+1) );
2705
2706 consdata->npropvars = 0;
2707 consdata->needprop = TRUE;
2708 consdata->node = node;
2709 consdata->nactivated = 0;
2710
2711 consdata->parentcons = parentcons;
2712 consdata->childconss = NULL;
2713 consdata->nchildconss = 0;
2714 consdata->maxchildconss = 0;
2715 consdata->probingtmpcons = NULL;
2716 consdata->origcons = NULL;
2717
2718 consdata->branchdata = branchdata;
2719 consdata->branchrule = branchrule;
2720
2721 consdata->knownvarhistory = NULL;
2723
2724 consdata->localbndvars = NULL;
2725 consdata->localbndtypes = NULL;
2726 consdata->localnewbnds = NULL;
2727 consdata->localoldbnds = NULL;
2728 consdata->nlocalbndchgstreated = NULL;
2729 consdata->maxlocalbndchgstreated = 0;
2730 consdata->nlocalbndchgs = 0;
2731 consdata->maxlocalbndchgs = 0;
2732 consdata->nbranchingchgs = 0;
2733
2734 consdata->copiedvars = NULL;
2735 consdata->copiedvarbndtypes = NULL;
2736 consdata->copiedvarbnds = NULL;
2737 consdata->ncopiedvarbnds = 0;
2738 consdata->maxcopiedvarbnds = 0;
2739
2740 consdata->maxorigbranchconss = maxorigbranchconss;
2741 consdata->origbranchconss = origbranchconss;
2742 consdata->norigbranchconss = norigbranchconss;
2743
2744 /* initialize structures for managing separator generated cuts for master problem*/
2745 consdata->addedcuts = NULL;
2746 consdata->naddedcuts = 0;
2747 consdata->firstnewcut = 0;
2748 consdata->nodestoredcuts = FALSE;
2749 consdata->addedcutsinit = FALSE;
2750
2751 SCIPdebugMessage("Creating masterbranch constraint with parent %p.\n", (void*) parentcons);
2752
2753 /* create constraint */
2754 SCIP_CALL( SCIPcreateCons(masterprob, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, TRUE,
2755 TRUE, FALSE, FALSE, FALSE, TRUE) );
2756
2757 /* add the new masterbranch constraint to the parent node's masterbranch constraint data
2758 * (unless the current node is the root node)
2759 */
2760 if( parentcons != NULL )
2761 {
2762 SCIP_CONSDATA* parentdata;
2763
2764 parentdata = SCIPconsGetData(parentcons);
2765 assert(parentdata != NULL);
2766
2767 if( SCIPinProbing(masterprob) || SCIPinProbing(GCGgetOrigprob(gcg)) )
2768 {
2769 parentdata->probingtmpcons = *cons;
2770 }
2771 else
2772 {
2773 int newmaxsize;
2774 ++parentdata->nchildconss;
2775 newmaxsize = SCIPcalcMemGrowSize(masterprob, parentdata->nchildconss);
2776 if( parentdata->nchildconss == 1 )
2777 {
2778 SCIP_CALL( SCIPallocBlockMemoryArray(masterprob, &(parentdata->childconss), newmaxsize) );
2779 parentdata->childconss[0] = NULL;
2780 }
2781 else
2782 {
2783 SCIP_CALL( SCIPreallocBlockMemoryArray(masterprob, &(parentdata->childconss), parentdata->maxchildconss, newmaxsize) );
2784 parentdata->childconss[parentdata->nchildconss - 1] = NULL;
2785 }
2786 parentdata->maxchildconss = newmaxsize;
2787
2788 assert(parentdata->childconss[parentdata->nchildconss - 1] == NULL);
2789 parentdata->childconss[parentdata->nchildconss - 1] = *cons;
2790
2791 // stash limit settings until branching is applied to the original problem
2793 }
2794 }
2795
2796 return SCIP_OKAY;
2797}
2798
2799/** returns the name of the constraint */
2801 SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */
2802 )
2803{
2804 SCIP_CONSDATA* consdata;
2805
2806 consdata = SCIPconsGetData(cons);
2807 assert(consdata != NULL);
2808
2809 return consdata->name;
2810}
2811
2812/** returns the node in the B&B tree at which the given masterbranch constraint is sticking */
2814 SCIP_CONS* cons /**< constraint pointer */
2815 )
2816{
2817 SCIP_CONSDATA* consdata;
2818
2819 consdata = SCIPconsGetData(cons);
2820 assert(consdata != NULL);
2821
2822 return consdata->node;
2823}
2824
2825/** returns the masterbranch constraint of the B&B father of the node at which the
2826 * given masterbranch constraint is sticking
2827 */
2829 SCIP_CONS* cons /**< constraint pointer */
2830 )
2831{
2832 SCIP_CONSDATA* consdata;
2833
2834 consdata = SCIPconsGetData(cons);
2835 assert(consdata != NULL);
2836
2837 return consdata->parentcons;
2838}
2839
2840/** returns the number of masterbranch constraints of the children of the node at which the
2841 * given masterbranch constraint is sticking
2842 */
2844 SCIP_CONS* cons /**< constraint pointer */
2845 )
2846{
2847 SCIP_CONSDATA* consdata;
2848
2849 consdata = SCIPconsGetData(cons);
2850 assert(consdata != NULL);
2851
2852 return consdata->nchildconss;
2853}
2854
2855/** returns a masterbranch constraint of a child of the node at which the
2856 * given masterbranch constraint is sticking
2857 */
2859 SCIP_CONS* cons, /**< constraint pointer */
2860 int childnr /**< index of the child node */
2861 )
2862{
2863 SCIP_CONSDATA* consdata;
2864
2865 consdata = SCIPconsGetData(cons);
2866 assert(consdata != NULL);
2867 assert(consdata->childconss != NULL);
2868
2869 assert(consdata->nchildconss > childnr);
2870
2871 return consdata->childconss[childnr];
2872}
2873
2874/** returns the origbranch constraint of the node in the original program corresponding to the node
2875 * at which the given masterbranch constraint is sticking
2876 */
2878 SCIP_CONS* cons /**< constraint pointer */
2879 )
2880{
2881 SCIP_CONSDATA* consdata;
2882
2883 consdata = SCIPconsGetData(cons);
2884 assert(consdata != NULL);
2885
2886 return consdata->origcons;
2887}
2888
2889/** sets the origbranch constraint of the node in the master program corresponding to the node
2890 * at which the given masterbranchbranch constraint is sticking
2891 */
2893 SCIP_CONS* cons, /**< constraint pointer */
2894 SCIP_CONS* origcons /**< original branching constraint */
2895 )
2896{
2897 SCIP_CONSDATA* consdata;
2898
2899 consdata = SCIPconsGetData(cons);
2900 assert(consdata != NULL);
2901 assert(consdata->origcons == NULL || origcons == NULL);
2902
2903 consdata->origcons = origcons;
2904}
2905
2906/** returns the branching data for a given masterbranch constraint */
2908 SCIP_CONS* cons /**< constraint pointer */
2909 )
2910{
2911 SCIP_CONSDATA* consdata;
2912
2913 consdata = SCIPconsGetData(cons);
2914 assert(consdata != NULL);
2915
2916 return consdata->branchdata;
2917}
2918
2920 SCIP_CONS* cons, /**< masterbranch constraint for which the branching data is requested */
2921 GCG_BRANCHDATA* branchdata /**< branching data */
2922 )
2923{
2924 SCIP_CONSDATA* consdata;
2925
2926 consdata = SCIPconsGetData(cons);
2927 assert(consdata != NULL);
2928
2929 consdata->branchdata = branchdata;
2930}
2931
2932/** returns the branching rule of the constraint */
2934 SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */
2935 )
2936{
2937 SCIP_CONSDATA* consdata;
2938
2939 consdata = SCIPconsGetData(cons);
2940 assert(consdata != NULL);
2941
2942 return consdata->branchrule;
2943}
2944
2945/** adds a bound change on an original variable that was directly copied to the master problem */
2947 GCG* gcg, /**< GCG data structure */
2948 SCIP_CONS* cons, /**< masterbranch constraint to which the bound change is added */
2949 SCIP_VAR* var, /**< variable on which the bound change was performed */
2950 GCG_BOUNDTYPE boundtype, /**< bound type of the bound change */
2951 SCIP_Real newbound /**< new bound of the variable after the bound change */
2952 )
2953{
2954 SCIP_CONSDATA* consdata;
2955 SCIP* scip;
2956
2957 assert(gcg != NULL);
2958
2960 assert(GCGisMaster(scip));
2961 assert(cons != NULL);
2962 assert(var != NULL);
2963
2964 /* get constraint data */
2965 consdata = SCIPconsGetData(cons);
2966 assert(consdata != NULL);
2967
2968 /* realloc the arrays, if needed */
2969 if( consdata->ncopiedvarbnds >= consdata->maxcopiedvarbnds )
2970 {
2971 int newsize = SCIPcalcMemGrowSize(scip, consdata->ncopiedvarbnds+1);
2972 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(consdata->copiedvars), consdata->maxcopiedvarbnds, newsize) );
2973 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(consdata->copiedvarbndtypes), consdata->maxcopiedvarbnds, newsize) );
2974 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(consdata->copiedvarbnds), consdata->maxcopiedvarbnds, newsize) );
2975 consdata->maxcopiedvarbnds = newsize;
2976 }
2977
2978 SCIPdebugMessage("Bound change on copied original variable stored at masterbranch constraint: <%s>.\n", SCIPconsGetName(cons));
2979
2980 /* store the new bound change */
2981 consdata->copiedvars[consdata->ncopiedvarbnds] = var;
2982 consdata->copiedvarbndtypes[consdata->ncopiedvarbnds] = boundtype;
2983 consdata->copiedvarbnds[consdata->ncopiedvarbnds] = newbound;
2984 consdata->ncopiedvarbnds++;
2985
2986 /* mark the corresponding master node to be repropagated */
2987 SCIP_CALL( SCIPrepropagateNode(scip, consdata->node) );
2988
2989 return SCIP_OKAY;
2990}
2991
2992/** returns the constraints in the original problem that enforce the branching decision */
2994 SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */
2995 )
2996{
2997 SCIP_CONSDATA* consdata;
2998
2999 consdata = SCIPconsGetData(cons);
3000 assert(consdata != NULL);
3001
3002 return consdata->origbranchconss;
3003}
3004
3005/** returns the number of constraints in the original problem that enforce the branching decision */
3007 SCIP_CONS* cons /**< masterbranch constraint for which the data is requested */
3008 )
3009{
3010 SCIP_CONSDATA* consdata;
3011
3012 consdata = SCIPconsGetData(cons);
3013 assert(consdata != NULL);
3014
3015 return consdata->norigbranchconss;
3016}
3017
3018/** releases the constraints in the original problem that enforce the branching decision
3019 * and frees the array holding the constraints
3020 */
3022 GCG* gcg, /**< GCG instance */
3023 SCIP_CONS* cons /**< masterbranch constraint for which the data is freed */
3024 )
3025{
3026 SCIP* origscip;
3027 SCIP* masterscip;
3028 SCIP_CONSDATA* consdata;
3029
3030 masterscip = GCGgetMasterprob(gcg);
3031 origscip = GCGgetOrigprob(gcg);
3032 assert(GCGisMaster(masterscip));
3033 assert(GCGisOriginal(origscip));
3034
3035 consdata = SCIPconsGetData(cons);
3036 assert(consdata != NULL);
3037
3038 if( consdata->norigbranchconss > 0 )
3039 {
3040 int c;
3041
3042 for( c = consdata->norigbranchconss - 1; c >= 0; --c )
3043 {
3044 SCIP_CALL( SCIPreleaseCons(origscip, &consdata->origbranchconss[c]) );
3045 }
3046 SCIPfreeBlockMemoryArray(masterscip, &consdata->origbranchconss, consdata->maxorigbranchconss);
3047 consdata->origbranchconss = NULL;
3048 consdata->norigbranchconss = 0;
3049 consdata->maxorigbranchconss = 0;
3050 }
3051
3052 return SCIP_OKAY;
3053}
3054
3055/** returns the masterbranch constraint of the current node */
3057 GCG* gcg /**< GCG data structure */
3058 )
3059{
3060 SCIP* scip;
3061 SCIP_CONSHDLR* conshdlr;
3062 SCIP_CONSHDLRDATA* conshdlrdata;
3063
3064 assert(gcg != NULL);
3065
3067 assert(GCGisMaster(scip));
3068
3069 /* get constraint handler */
3070 conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3071 assert(conshdlr != NULL);
3072
3073 /* get constraint handler data */
3074 conshdlrdata = SCIPconshdlrGetData(conshdlr);
3075 assert(conshdlrdata != NULL);
3076 assert(conshdlrdata->stack != NULL);
3077
3078 if( conshdlrdata->nstack == 0 || SCIPgetStage(scip) > SCIP_STAGE_SOLVING )
3079 return NULL;
3080
3081 assert(conshdlrdata->stack[conshdlrdata->nstack-1] != NULL);
3082 return conshdlrdata->stack[conshdlrdata->nstack-1];
3083}
3084
3085/** returns the stack and the number of elements on it */
3087 GCG* gcg, /**< GCG data structure */
3088 SCIP_CONS*** stack, /**< return value: pointer to the stack */
3089 int* nstackelements /**< return value: pointer to int, for number of elements on the stack */
3090 )
3091{
3092 SCIP* scip;
3093 SCIP_CONSHDLR* conshdlr;
3094 SCIP_CONSHDLRDATA* conshdlrdata;
3095
3096 assert(gcg != NULL);
3098 conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3099 assert(conshdlr != NULL);
3100
3101 conshdlrdata = SCIPconshdlrGetData(conshdlr);
3102 assert(conshdlrdata != NULL);
3103 assert(conshdlrdata->stack != NULL);
3104
3105 *stack = conshdlrdata->stack;
3106 *nstackelements = conshdlrdata->nstack;
3107}
3108
3109/** returns the number of elements on the stack */
3111 GCG* gcg /**< GCG data structure */
3112 )
3113{
3114 SCIP* scip;
3115 SCIP_CONSHDLR* conshdlr;
3116 SCIP_CONSHDLRDATA* conshdlrdata;
3117
3118 assert(gcg != NULL);
3120 conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3121 assert(conshdlr != NULL);
3122
3123 conshdlrdata = SCIPconshdlrGetData(conshdlr);
3124 assert(conshdlrdata != NULL);
3125 assert(conshdlrdata->stack != NULL);
3126
3127 return conshdlrdata->nstack;
3128}
3129
3130/** adds initial constraint to root node */
3132 GCG* gcg /**< GCG data structure */
3133 )
3134{
3135 SCIP* scip;
3136 SCIP_CONSHDLR* conshdlr;
3137 SCIP_CONSHDLRDATA* conshdlrdata;
3138 SCIP_CONS* cons;
3139
3140 assert(gcg != NULL);
3142 conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3143 assert(conshdlr != NULL);
3144
3145 conshdlrdata = SCIPconshdlrGetData(conshdlr);
3146 assert(conshdlrdata != NULL);
3147 cons = conshdlrdata->stack[0];
3148 conshdlrdata->stack[0] = NULL;
3149 assert(conshdlrdata->nstack == 1);
3150 conshdlrdata->nstack = 0;
3151
3153 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
3154
3155 return SCIP_OKAY;
3156}
3157
3158/** adjusts the firstnewcut bookkeeping of all active masterbranch nodes after a master separator
3159 * cut has been removed from the active cuts at the given position
3160 */
3162 GCG* gcg, /**< GCG data structure */
3163 int removedidx /**< position the removed cut had in the active cuts */
3164 )
3165{
3166 SCIP* masterprob;
3167 SCIP_CONSHDLR* conshdlr;
3168 SCIP_CONSHDLRDATA* conshdlrdata;
3169 int i;
3170
3171 assert(gcg != NULL);
3172 assert(removedidx >= 0);
3173
3174 masterprob = GCGgetMasterprob(gcg);
3175 conshdlr = SCIPfindConshdlr(masterprob, CONSHDLR_NAME);
3176 assert(conshdlr != NULL);
3177
3178 conshdlrdata = SCIPconshdlrGetData(conshdlr);
3179 assert(conshdlrdata != NULL);
3180
3181 for( i = 0; i < conshdlrdata->nstack; ++i )
3182 {
3183 SCIP_CONSDATA* consdata;
3184
3185 if( conshdlrdata->stack[i] == NULL )
3186 continue;
3187
3188 consdata = SCIPconsGetData(conshdlrdata->stack[i]);
3189 assert(consdata != NULL);
3190
3191 if( consdata->firstnewcut > removedidx )
3192 {
3193 assert(consdata->firstnewcut > 0);
3194 --consdata->firstnewcut;
3195 }
3196 }
3197
3198 return SCIP_OKAY;
3199}
3200
3201/** check whether the node was generated by generic branching */
3203 GCG* gcg /**< GCG data structure */
3204 )
3205{
3206 SCIP_CONS* mastercons;
3207 GCG_BRANCHRULE* branchrule;
3208
3209 assert(gcg != NULL);
3210
3212
3213 /* @todo: Why might mastercons be NULL? */
3214 if( mastercons == NULL || SCIPnodeGetDepth(GCGconsMasterbranchGetNode(mastercons)) == 0 )
3215 return FALSE;
3216
3217 branchrule = GCGconsMasterbranchGetBranchrule(mastercons);
3218
3219 if( branchrule == NULL || strcmp(SCIPbranchruleGetName(GCGbranchGetScipBranchrule(branchrule)), "generic") != 0 )
3220 return FALSE;
3221
3222 return TRUE;
3223}
3224
3225/** checks the consistency of the masterbranch constraints in the problem */
3227 GCG* gcg /**< GCG data structure */
3228 )
3229{
3230 SCIP* scip;
3231 SCIP_CONSHDLR* conshdlr;
3232 int nconss;
3233#ifndef NDEBUG
3234 int i;
3235 SCIP_CONS** conss;
3236#endif
3237
3238 assert(gcg != NULL);
3240 conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
3241 assert(conshdlr != NULL);
3242
3243 nconss = SCIPconshdlrGetNConss(conshdlr);
3244#ifndef NDEBUG
3245 conss = SCIPconshdlrGetConss(conshdlr);
3246
3247 for( i = 0; i < nconss; i++ )
3248 {
3249 SCIP_CONSDATA* consdata;
3250#ifdef SCIP_DEBUG
3251 SCIP_CONS* parent_origcons;
3252 SCIP_CONS* origcons_parent;
3253#endif
3254
3255 consdata = SCIPconsGetData(conss[i]);
3256 assert(consdata != NULL);
3257
3258 assert(consdata->probingtmpcons == NULL || SCIPinProbing(scip));
3259 assert(consdata->probingtmpcons == NULL || SCIPconsGetData(consdata->probingtmpcons)->parentcons == conss[i]);
3260 assert(consdata->origcons == NULL || GCGconsOrigbranchGetMastercons(consdata->origcons) == conss[i]);
3261
3262#ifdef SCIP_DEBUG
3263 if( consdata->parentcons != NULL )
3264 parent_origcons = SCIPconsGetData(consdata->parentcons)->origcons;
3265 else
3266 parent_origcons = NULL;
3267
3268 if( consdata->origcons != NULL )
3269 origcons_parent = GCGconsOrigbranchGetParentcons(consdata->origcons);
3270 else
3271 origcons_parent = NULL;
3272
3273 SCIPdebugMessage("cons: %s (node %p), origcons: %s, parent %s: %s => %s\n",
3274 SCIPconsGetName(conss[i]),
3275 (void*) consdata->node,
3276 consdata->origcons == NULL? "NULL" : SCIPconsGetName(consdata->origcons),
3277 consdata->parentcons == NULL? "NULL" : SCIPconsGetName(consdata->parentcons),
3278 parent_origcons == NULL? "NULL" : SCIPconsGetName(parent_origcons),
3279 origcons_parent == NULL? "NULL" : SCIPconsGetName(origcons_parent) );
3280#endif
3281 }
3282#endif
3283
3284 SCIPdebugMessage("checked consistency of %d masterbranch constraints, all ok!\n", nconss);
3285}
branching rule based on vanderbeck's generic branching scheme
SCIP_BRANCHRULE * GCGbranchGetScipBranchrule(GCG_BRANCHRULE *branchrule)
Definition: branchgcg.c:102
static SCIP_RETCODE forwardUpdateSeenHistory(GCG *gcg, SCIP_CONSDATA *consdata)
SCIP_RETCODE GCGincludeConshdlrMasterbranch(GCG *gcg)
#define CONSHDLR_NEEDSCONS
static SCIP_RETCODE undoLocalBndchgsToPricingprobs(GCG *gcg, SCIP_CONS *cons)
#define CONSHDLR_CHECKPRIORITY
static SCIP_RETCODE initializeAddedCuts(GCG *gcg, SCIP_CONSDATA *consdata, SCIP_CONSHDLRDATA *conshdlrdata)
void GCGconsMasterbranchSetBranchdata(SCIP_CONS *cons, GCG_BRANCHDATA *branchdata)
#define CONSHDLR_DESC
static SCIP_DECL_CONSCHECK(consCheckMasterbranch)
GCG_BRANCHRULE * GCGconsMasterbranchGetBranchrule(SCIP_CONS *cons)
static SCIP_RETCODE addMissedVariables(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *mastersepacut)
static SCIP_DECL_CONSDELETE(consDeleteMasterbranch)
SCIP_CONS * GCGconsMasterbranchGetOrigcons(SCIP_CONS *cons)
SCIP_RETCODE GCGconsMasterbranchAddRootCons(GCG *gcg)
static SCIP_Bool checkAggregatedGlobalBounds(SCIP *scip, SCIP_VAR *bndvar, SCIP_BOUNDTYPE bndtype, SCIP_Real bound)
static SCIP_RETCODE addPendingBndChg(SCIP *scip, SCIP_VAR *var, SCIP_BOUNDTYPE boundtype, SCIP_Real oldbound, SCIP_Real newbound)
SCIP_CONS * GCGconsMasterbranchGetParentcons(SCIP_CONS *cons)
void GCGconsMasterbranchSetOrigcons(SCIP_CONS *cons, SCIP_CONS *origcons)
static SCIP_RETCODE applyLocalBndchgsToCopiedMastervars(GCG *gcg, SCIP_CONS *cons, int *propcount)
static SCIP_RETCODE applyLocalBndchgsToPricedMastervars(GCG *gcg, SCIP_CONSHDLRDATA *conshdlrdata, SCIP_CONS *cons, int *propcount)
static SCIP_DECL_CONSEXITSOL(consExitSolMasterbranch)
void GCGconsMasterbranchCheckConsistency(GCG *gcg)
int GCGconsMasterbranchGetNOrigbranchConss(SCIP_CONS *cons)
static SCIP_DECL_CONSINITSOL(consInitsolMasterbranch)
static SCIP_RETCODE ensureCollectedBndvarsSize(SCIP *scip, SCIP_CONSHDLRDATA *conshdlrdata, int blocknr, int minsize)
static SCIP_RETCODE ensureLinkingvarIndxsSize(SCIP *scip, SCIP_CONSHDLRDATA *conshdlrdata, int minsize)
static SCIP_RETCODE resetPricingVarBound(GCG *gcg, SCIP_VAR *pricingvar, SCIP_CONSDATA *consdata, int i, int blocknr)
static SCIP_DECL_CONSPROP(consPropMasterbranch)
static SCIP_DECL_CONSLOCK(consLockMasterbranch)
#define CONSHDLR_PROPTIMING
GCG_BRANCHDATA * GCGconsMasterbranchGetBranchdata(SCIP_CONS *cons)
char * GCGconsMasterbranchGetName(SCIP_CONS *cons)
static SCIP_DECL_EVENTFREE(eventFreeOrigvarbound)
static SCIP_RETCODE applyLocalBndchgsToPricingprobs(GCG *gcg, SCIP_CONS *cons)
SCIP_CONS * GCGconsMasterbranchGetActiveCons(GCG *gcg)
static SCIP_RETCODE applyGlobalBndchgsToPricingprobs(GCG *gcg, SCIP_CONSHDLRDATA *conshdlrdata)
static SCIP_DECL_CONSINIT(consInitMasterbranch)
SCIP_RETCODE GCGconsMasterbranchActiveCutRemoved(GCG *gcg, int removedidx)
int GCGconsMasterbranchGetNChildconss(SCIP_CONS *cons)
static SCIP_DECL_EVENTINITSOL(eventInitsolOrigvarbound)
static SCIP_RETCODE addStoredCutsToActiveCuts(GCG *gcg, SCIP_CONSDATA *consdata, SCIP_CONSHDLRDATA *conshdlrdata)
int GCGconsMasterbranchGetNStackelements(GCG *gcg)
static SCIP_DECL_CONSENFOPS(consEnfopsMasterbranch)
static SCIP_DECL_CONSEXIT(consExitMasterbranch)
static SCIP_Bool checkAggregatedLocalBounds(SCIP *scip, SCIP_VAR **bndvars, SCIP_Real *bounds, int nbndvars, SCIP_VAR *bndvar, SCIP_BOUNDTYPE bndtype, SCIP_VAR *pricingvar)
SCIP_Bool GCGcurrentNodeIsGeneric(GCG *gcg)
SCIP_CONS * GCGconsMasterbranchGetChildcons(SCIP_CONS *cons, int childnr)
#define CONSHDLR_PROPFREQ
static SCIP_RETCODE removeStoredCutsFromActiveCuts(GCG *gcg, SCIP_CONSDATA *consdata, SCIP_CONSHDLRDATA *conshdlrdata)
static SCIP_DECL_EVENTEXEC(eventExecOrigvarbound)
static SCIP_DECL_CONSFREE(consFreeMasterbranch)
#define CONSHDLR_EAGERFREQ
#define EVENTHDLR_DESC
SCIP_RETCODE GCGcreateConsMasterbranch(GCG *gcg, SCIP_CONS **cons, const char *name, SCIP_NODE *node, SCIP_CONS *parentcons, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_CONS **origbranchconss, int norigbranchconss, int maxorigbranchconss)
static SCIP_RETCODE initializeConsdata(GCG *gcg, SCIP_CONS *cons)
static SCIP_DECL_CONSDEACTIVE(consDeactiveMasterbranch)
#define CONSHDLR_ENFOPRIORITY
static SCIP_RETCODE tightenPricingVarBound(GCG *gcg, SCIP_VAR *pricingvar, SCIP_CONSDATA *consdata, int i, int blocknr)
void GCGconsMasterbranchGetStack(GCG *gcg, SCIP_CONS ***stack, int *nstackelements)
static SCIP_RETCODE applyGlobalBndchgsToPricedMastervars(GCG *gcg, SCIP_CONSHDLRDATA *conshdlrdata, int *propcount)
#define CONSHDLR_NAME
static SCIP_DECL_CONSACTIVE(consActiveMasterbranch)
#define EVENTHDLR_NAME
static SCIP_DECL_CONSENFOLP(consEnfolpMasterbranch)
SCIP_RETCODE GCGconsMasterbranchAddCopiedVarBndchg(GCG *gcg, SCIP_CONS *cons, SCIP_VAR *var, GCG_BOUNDTYPE boundtype, SCIP_Real newbound)
#define CONSHDLR_DELAYPROP
SCIP_NODE * GCGconsMasterbranchGetNode(SCIP_CONS *cons)
SCIP_CONS ** GCGconsMasterbranchGetOrigbranchConss(SCIP_CONS *cons)
SCIP_RETCODE GCGconsMasterbranchReleaseOrigbranchConss(GCG *gcg, SCIP_CONS *cons)
constraint handler for storing the branching decisions at each node of the tree
int GCGconsOrigbranchGetNChildconss(SCIP_CONS *cons)
SCIP_CONS * GCGconsOrigbranchGetParentcons(SCIP_CONS *cons)
SCIP_CONS * GCGconsOrigbranchGetMastercons(SCIP_CONS *cons)
SCIP_NODE * GCGconsOrigbranchGetNode(SCIP_CONS *cons)
void GCGconsOrigbranchSetBranchdata(SCIP_CONS *cons, GCG_BRANCHDATA *branchdata)
SCIP_CONS * GCGconsOrigbranchGetActiveCons(GCG *gcg)
void GCGconsOrigbranchSetMastercons(SCIP_CONS *cons, SCIP_CONS *mastercons)
constraint handler for storing the branching decisions at each node of the tree
#define SCIP_INVALID
#define SCIP_Bool
#define SCIP_Real
#define SCIPABORT()
#define SCIP_CALL(x)
#define TRUE
#define FALSE
SCIP_RETCODE GCGaddActiveMastersepacut(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *mastersepacut)
SCIP_RETCODE GCGremoveNewInactiveMastersepacuts(GCG *gcg, int startidx)
SCIP_RETCODE GCGclearGeneratedMastersepacuts(GCG *gcg)
int GCGgetNActiveMastersepacuts(GCG *gcg)
SCIP_RETCODE GCGshrinkActiveMastersepacuts(GCG *gcg, int newnrows)
GCG_EXTENDEDMASTERCONSDATA ** GCGgetActiveMastersepacuts(GCG *gcg)
event handler which manages the active master separator cuts
SCIP_ROW * GCGextendedmasterconsGetRow(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG interface methods.
SCIP_Bool GCGvarIsOriginal(SCIP_VAR *var)
Definition: gcgvar.c:231
SCIP_VAR ** GCGlinkingVarGetPricingVars(SCIP_VAR *var)
Definition: gcgvar.c:488
int GCGmasterVarGetNOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:971
SCIP_VAR ** GCGoriginalVarGetMastervars(SCIP_VAR *var)
Definition: gcgvar.c:666
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:1100
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition: gcgvar.c:247
SCIP_Real * GCGoriginalVarGetMastervals(SCIP_VAR *var)
Definition: gcgvar.c:684
SCIP_VAR * GCGoriginalVarGetPricingVar(SCIP_VAR *var)
Definition: gcgvar.c:281
SCIP_Bool GCGmasterVarIsLinking(SCIP_VAR *var)
Definition: gcgvar.c:913
SCIP_VAR ** GCGmasterVarGetOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:993
SCIP_Bool GCGisLinkingVarInBlock(SCIP_VAR *var, int block)
Definition: gcgvar.c:1149
int GCGpricingVarGetNOrigvars(SCIP_VAR *var)
Definition: gcgvar.c:1082
SCIP_Bool GCGvarIsMaster(SCIP_VAR *var)
Definition: gcgvar.c:176
SCIP_Real * GCGmasterVarGetOrigvals(SCIP_VAR *var)
Definition: gcgvar.c:1017
SCIP_HASHMAP * GCGmasterVarGetOrigvalmap(SCIP_VAR *var)
Definition: gcgvar.c:1064
int GCGoriginalVarGetNMastervars(SCIP_VAR *var)
Definition: gcgvar.c:648
int GCGvarGetBlock(SCIP_VAR *var)
Definition: gcgvar.c:1118
SCIP_RETCODE GCGvarhistoryFreeReference(SCIP *scip, GCG_VARHISTORY **pointer)
SCIP_RETCODE GCGvarhistoryNext(SCIP *scip, GCG_VARHISTORY **pointer)
SCIP_RETCODE GCGvarhistoryJumpToLatest(SCIP *scip, GCG_VARHISTORY *pointer)
SCIP_RETCODE GCGvarhistoryGetVar(GCG_VARHISTORY *pointer, SCIP_VAR **var)
Definition: gcgvarhistory.c:72
SCIP_RETCODE GCGvarhistoryCopyReference(SCIP *scip, GCG_VARHISTORY **pointer, GCG_VARHISTORY *source)
SCIP_Bool GCGvarhistoryHasNext(GCG_VARHISTORY *pointer)
Definition: gcgvarhistory.c:96
methods for managing variable history
int GCGmasterGetNPricedvars(GCG *gcg)
GCG_VARHISTORY * GCGgetCurrentVarhistoryReference(GCG *gcg)
GCG_COLPOOL * GCGgetColpool(GCG *gcg)
SCIP_VAR ** GCGmasterGetPricedvars(GCG *gcg)
SCIP_RETCODE GCGcolpoolPropagateGlobalBounds(GCG_COLPOOL *colpool)
Definition: colpool.c:486
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition: relax_gcg.c:4075
SCIP_Bool GCGisOriginal(SCIP *scip)
Definition: misc.c:699
GCG_EXPORT SCIP_Bool GCGrelaxIsInitialized(GCG *gcg)
Definition: relax_gcg.c:5145
SCIP * GCGgetOrigprob(GCG *gcg)
Definition: gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition: relax_gcg.c:4185
SCIP_Bool GCGisMaster(SCIP *scip)
Definition: misc.c:709
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition: relax_gcg.c:4113
SCIP * GCGgetMasterprob(GCG *gcg)
Definition: gcg.cpp:99
GCG_EXPORT GCG_DECMODE GCGgetDecompositionMode(GCG *gcg)
Definition: relax_gcg.c:5294
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition: relax_gcg.c:4132
SCIP_Bool SCIPisTransformed(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
SCIP_Real SCIPhashmapGetImageReal(SCIP_HASHMAP *hashmap, void *origin)
int SCIPhashmapGetImageInt(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
SCIP_RETCODE SCIPhashmapInsertInt(SCIP_HASHMAP *hashmap, void *origin, int image)
SCIP_RETCODE SCIPhashmapRemoveAll(SCIP_HASHMAP *hashmap)
SCIP_RETCODE SCIPaddConsNode(SCIP *scip, SCIP_NODE *node, SCIP_CONS *cons, SCIP_NODE *validnode)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
const char * SCIPbranchruleGetName(SCIP_BRANCHRULE *branchrule)
SCIP_RETCODE SCIPsetConshdlrInit(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINIT((*consinit)))
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)
SCIP_RETCODE SCIPincludeConshdlrBasic(SCIP *scip, SCIP_CONSHDLR **conshdlrptr, const char *name, const char *desc, int enfopriority, int chckpriority, int eagerfreq, SCIP_Bool needscons, SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_CONSHDLRDATA *conshdlrdata)
SCIP_RETCODE SCIPsetConshdlrDeactive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
SCIP_RETCODE SCIPsetConshdlrFree(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSFREE((*consfree)))
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPsetConshdlrExit(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXIT((*consexit)))
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetConshdlrExitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITSOL((*consexitsol)))
SCIP_RETCODE SCIPsetConshdlrInitsol(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITSOL((*consinitsol)))
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
SCIP_RETCODE SCIPsetConshdlrActive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPsetEventhdlrInitsol(SCIP *scip, SCIP_EVENTHDLR *eventhdlr, SCIP_DECL_EVENTINITSOL((*eventinitsol)))
SCIP_RETCODE SCIPincludeEventhdlrBasic(SCIP *scip, SCIP_EVENTHDLR **eventhdlrptr, const char *name, const char *desc, SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
SCIP_EVENTHDLRDATA * SCIPeventhdlrGetData(SCIP_EVENTHDLR *eventhdlr)
SCIP_RETCODE SCIPsetEventhdlrFree(SCIP *scip, SCIP_EVENTHDLR *eventhdlr, SCIP_DECL_EVENTFREE((*eventfree)))
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_Real SCIPeventGetOldbound(SCIP_EVENT *event)
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
SCIP_Real SCIPeventGetNewbound(SCIP_EVENT *event)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeBufferArray(scip, ptr)
#define SCIPfreeMemory(scip, ptr)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPfreeBlockMemoryNull(scip, ptr)
#define SCIPfreeBufferArrayNull(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
SCIP_DOMCHG * SCIPnodeGetDomchg(SCIP_NODE *node)
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
int SCIPnodeGetDepth(SCIP_NODE *node)
SCIP_Bool SCIPinProbing(SCIP *scip)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
const char * SCIProwGetName(SCIP_ROW *row)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
SCIP_Bool SCIPvarIsDeleted(SCIP_VAR *var)
SCIP_BOUNDTYPE SCIPboundchgGetBoundtype(SCIP_BOUNDCHG *boundchg)
SCIP_VAR * SCIPboundchgGetVar(SCIP_BOUNDCHG *boundchg)
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_BOUNDCHG * SCIPdomchgGetBoundchg(SCIP_DOMCHG *domchg, int pos)
SCIP_BOUNDCHGTYPE SCIPboundchgGetBoundchgtype(SCIP_BOUNDCHG *boundchg)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPboundchgGetNewbound(SCIP_BOUNDCHG *boundchg)
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPdomchgGetNBoundchgs(SCIP_DOMCHG *domchg)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPgetRelaxSolVal(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPisRelaxSolValid(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPmarkRelaxSolInvalid(SCIP *scip)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition: gcgvar.c:159
#define NULL
SCIP_RETCODE GCGmastersepacutGetExtendedmasterconsCoeff(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *mastersepacut, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars, int probnr, GCG_COL *gcgcol, SCIP_Real *coef)
SCIP_RETCODE GCGcaptureMastersepacut(GCG_EXTENDEDMASTERCONSDATA *mastersepacut)
Definition: mastersepacut.c:86
GCG_MASTERSEPACUT * GCGextendedmasterconsGetMastersepacut(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_VARHISTORY * GCGmastersepacutGetVarHistory(GCG_MASTERSEPACUT *mastersepacut)
SCIP_RETCODE GCGreleaseMastersepacut(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA **mastersepacut)
#define BMSclearMemoryArray(ptr, num)
GCG variable pricer.
public methods for storing cols in a col pool
#define SCIPerrorMessage
#define SCIPdebugMessage
#define SCIPdebugPrintf
SCIP_RETCODE GCGrelaxBranchActiveMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition: relax_gcg.c:3781
SCIP_RETCODE GCGrelaxBranchPropMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_RESULT *result)
Definition: relax_gcg.c:3837
SCIP_RETCODE GCGrelaxBranchNewCol(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_VAR *mastervar)
Definition: relax_gcg.c:3885
SCIP_RETCODE GCGrelaxBranchDataDelete(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA **branchdata, SCIP_Bool origbranch, SCIP_Bool force)
Definition: relax_gcg.c:3858
SCIP_RETCODE GCGinitializeMasterProblemSolve(GCG *gcg)
Definition: relax_gcg.c:5686
SCIP_RETCODE GCGstashLimitSettings(GCG *gcg)
Definition: relax_gcg.c:5700
SCIP_RETCODE GCGrelaxBranchDeactiveMaster(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
Definition: relax_gcg.c:3809
GCG relaxator.
Definition: struct_gcg.h:55
SCIP_Bool needprop
GCG_VARHISTORY * knownvarhistory
SCIP_VAR ** localbndvars
GCG_BOUNDTYPE * copiedvarbndtypes
SCIP_CONS ** childconss
SCIP_BOUNDTYPE * localbndtypes
GCG_EXTENDEDMASTERCONSDATA ** addedcuts
SCIP_VAR ** copiedvars
SCIP_NODE * node
GCG_BRANCHDATA * branchdata
GCG_BRANCHRULE * branchrule
SCIP_Real * copiedvarbnds
SCIP_Bool nodestoredcuts
SCIP_Bool addedcutsinit
SCIP_CONS * parentcons
SCIP_Real * localnewbnds
SCIP_CONS * origcons
SCIP_CONS * probingtmpcons
SCIP_CONS ** origbranchconss
SCIP_Real * localoldbnds
SCIP_VAR *** collectedbndvars
SCIP_HASHMAP * pendingvarmapub
SCIP_Real ** collectedubnds
SCIP_BOUNDTYPE * pendingbndtypes
SCIP_Real ** collectedlbnds
SCIP_Real * pendingnewbnds
SCIP_Bool pendingbndsactivated
SCIP_HASHMAP * pendingvarmaplb
enum GCG_BoundType GCG_BOUNDTYPE
@ GCG_DECMODE_DANTZIGWOLFE
Definition: type_decomp.h:62
#define SCIP_EVENTTYPE_BOUNDCHANGED
#define SCIP_EVENTTYPE_GUBCHANGED
#define SCIP_EVENTTYPE_GBDCHANGED
#define SCIP_EVENTTYPE_GLBCHANGED
uint64_t SCIP_EVENTTYPE
SCIP_BOUNDTYPE_UPPER
SCIP_BOUNDTYPE_LOWER
enum SCIP_BoundType SCIP_BOUNDTYPE
SCIP_DIDNOTRUN
SCIP_CUTOFF
SCIP_FEASIBLE
SCIP_REDUCEDDOM
SCIP_DIDNOTFIND
SCIP_PLUGINNOTFOUND
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE
SCIP_STAGE_TRANSFORMED
SCIP_STAGE_SOLVING
SCIP_NODETYPE_FORK
SCIP_NODETYPE_PSEUDOFORK
SCIP_NODETYPE_SUBROOT
SCIP_NODETYPE_FOCUSNODE
SCIP_BOUNDCHGTYPE_BRANCHING