cons_origbranch.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program */
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-2018 Operations Research, RWTH Aachen University */
10 /* Zuse Institute Berlin (ZIB) */
11 /* */
12 /* This program is free software; you can redistribute it and/or */
13 /* modify it under the terms of the GNU Lesser General Public License */
14 /* as published by the Free Software Foundation; either version 3 */
15 /* of the License, or (at your option) any later version. */
16 /* */
17 /* This program is distributed in the hope that it will be useful, */
18 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
19 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
20 /* GNU Lesser General Public License for more details. */
21 /* */
22 /* You should have received a copy of the GNU Lesser General Public License */
23 /* along with this program; if not, write to the Free Software */
24 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.*/
25 /* */
26 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
35 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36 /* #define SCIP_DEBUG */
37 /* #define CHECKCONSISTENCY */
38 #include <assert.h>
39 #include <string.h>
40 
41 #include "gcg.h"
42 #include "branch_generic.h"
43 #include "cons_masterbranch.h"
44 #include "cons_origbranch.h"
45 
46 #include "scip/nodesel_bfs.h"
47 #include "scip/nodesel_dfs.h"
48 #include "scip/nodesel_estimate.h"
49 #include "scip/nodesel_hybridestim.h"
50 #include "scip/nodesel_restartdfs.h"
51 #include "scip/branch_allfullstrong.h"
52 #include "scip/branch_fullstrong.h"
53 #include "scip/branch_inference.h"
54 #include "scip/branch_mostinf.h"
55 #include "scip/branch_leastinf.h"
56 #include "scip/branch_pscost.h"
57 #include "scip/branch_random.h"
58 #include "scip/branch_relpscost.h"
59 #include "scip/cons_linear.h"
60 
61 /* constraint handler properties */
62 #define CONSHDLR_NAME "origbranch"
63 #define CONSHDLR_DESC "store branching decision at nodes of the tree constraint handler"
64 #define CONSHDLR_ENFOPRIORITY 0
65 #define CONSHDLR_CHECKPRIORITY 2000000
66 #define CONSHDLR_EAGERFREQ 100
68 #define CONSHDLR_NEEDSCONS TRUE
72 struct SCIP_ConsData
73 {
74  SCIP_NODE* node;
75  SCIP_CONS* parentcons;
76  SCIP_CONS** childconss;
77  int nchildconss;
78  SCIP_CONS* probingtmpcons;
79  SCIP_CONS* mastercons;
81  GCG_BRANCHDATA* branchdata;
83  SCIP_BRANCHRULE* branchrule;
85 };
86 
88 struct SCIP_ConshdlrData
89 {
90  SCIP_CONS** stack;
91  int nstack;
92  int maxstacksize;
93  SCIP_CONS* rootcons;
94 };
95 
96 
97 /*
98  * Callback methods of constraint handler
99  */
100 
102 static
103 SCIP_DECL_CONSFREE(consFreeOrigbranch)
104 { /*lint --e{715}*/
105  SCIP_CONSHDLRDATA* conshdlrData;
106 
107  assert(scip != NULL);
108  assert(conshdlr != NULL);
109  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
110 
111  conshdlrData = SCIPconshdlrGetData(conshdlr);
112  assert(conshdlrData != NULL);
113 
114  SCIPdebugMessage("freeing branch orig constraint handler (nconss = %d)\n", SCIPconshdlrGetNConss(conshdlr));
115 
116  /* free constraint handler storage */
117  assert(conshdlrData->stack == NULL);
118  if( conshdlrData->rootcons != NULL )
119  {
120  SCIP_CALL( SCIPreleaseCons(scip, &conshdlrData->rootcons) );
121  }
122 
123  SCIPfreeMemory(scip, &conshdlrData);
124 
125  return SCIP_OKAY;
126 }
127 
128 
130 static
131 SCIP_DECL_CONSINITSOL(consInitsolOrigbranch)
132 { /*lint --e{715}*/
133  SCIP_CONSHDLRDATA* conshdlrData;
134 
135  assert(scip != NULL);
136  assert(conshdlr != NULL);
137  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
138 
139  conshdlrData = SCIPconshdlrGetData(conshdlr);
140  assert(conshdlrData != NULL);
141 
142  /* prepare stack */
143  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &conshdlrData->stack, conshdlrData->maxstacksize) );
144  assert(conshdlrData->nstack >= 0);
145 
146  /* check consistency */
147  if( conshdlrData->rootcons != NULL )
148  {
149  SCIP_CALL( SCIPreleaseCons(scip, &conshdlrData->rootcons) );
150  conshdlrData->rootcons = NULL;
151  --(conshdlrData->nstack);
152  }
153 
155 
156  return SCIP_OKAY;
157 }
158 
159 
161 static
162 SCIP_DECL_CONSEXITSOL(consExitsolOrigbranch)
163 { /*lint --e{715}*/
164  SCIP_CONSHDLRDATA* conshdlrdata;
165  GCG_BRANCHDATA* branchdata;
166 
167  assert(scip != NULL);
168  assert(conshdlr != NULL);
169  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
170 
171  conshdlrdata = SCIPconshdlrGetData(conshdlr);
172  assert(conshdlrdata != NULL);
173  assert(conshdlrdata->nstack <= 1);
174 
175  SCIPdebugMessage("exiting solution process branch orig constraint handler (nconss = %d)\n", SCIPconshdlrGetNConss(conshdlr));
176 
177  /* check for root */
178  if( conshdlrdata->rootcons != NULL )
179  {
180  branchdata = GCGconsOrigbranchGetBranchdata(conshdlrdata->rootcons);
181 
182  SCIPfreeMemoryNull(scip, &branchdata );
183 
184  SCIP_CALL( SCIPreleaseCons(scip, &conshdlrdata->rootcons) );
185  conshdlrdata->rootcons = NULL;
186  }
187 
188  /* free stack */
189  SCIPfreeBlockMemoryArray(scip, &conshdlrdata->stack, conshdlrdata->maxstacksize);
190  conshdlrdata->stack = NULL;
191 
192  return SCIP_OKAY;
193 }
194 
196 static
197 SCIP_DECL_CONSEXIT(consExitOrigbranch)
198 { /*lint --e{715}*/
199  SCIP_CONSHDLRDATA* conshdlrdata;
200  assert(conshdlr != NULL);
201  assert(scip != NULL);
202  conshdlrdata = SCIPconshdlrGetData(conshdlr);
203  assert(conshdlrdata != NULL);
204 
205  SCIPdebugMessage("exiting transformed branch orig constraint handler (nconss = %d)\n", SCIPconshdlrGetNConss(conshdlr));
206 
207  if( conshdlrdata->rootcons != NULL )
208  {
209  SCIP_CALL( SCIPreleaseCons(scip, &conshdlrdata->rootcons) );
210  conshdlrdata->rootcons = NULL;
211  }
212  return SCIP_OKAY;
213 }
214 
216 static
217 SCIP_DECL_CONSDELETE(consDeleteOrigbranch)
218 { /*lint --e{715}*/
219  SCIP_CONSDATA* parentdata;
220  int i;
221 
222  assert(scip != NULL);
223  assert(conshdlr != NULL);
224  assert(cons != NULL);
225  assert(consdata != NULL);
226  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
227  assert(*consdata != NULL);
228 
229  SCIPdebugMessage("Deleting branch orig constraint: <%s>.\n", SCIPconsGetName(cons));
230 
231  /* set the origcons pointer of the corresponding mastercons to NULL */
232  if( (*consdata)->mastercons != NULL )
233  {
234  assert(GCGconsMasterbranchGetOrigcons((*consdata)->mastercons) == cons);
235  GCGconsMasterbranchSetOrigcons((*consdata)->mastercons, NULL);
236  }
237 
238  /* set the pointer in the parent constraint to NULL */
239  if( (*consdata)->parentcons != NULL )
240  {
241 #ifndef NDEBUG
242  SCIP_Bool childdeleted = FALSE;
243 #endif
244  parentdata = SCIPconsGetData((*consdata)->parentcons);
245 
246  if( SCIPinProbing(scip) )
247  parentdata->probingtmpcons = NULL;
248 
249  for( i = 0; i < parentdata->nchildconss; ++i )
250  {
251  if( parentdata->childconss[i] == cons )
252  {
253 
254  parentdata->childconss[i] = parentdata->childconss[parentdata->nchildconss-1];
255  parentdata->childconss[parentdata->nchildconss-1] = NULL;
256 #ifndef NDEBUG
257  childdeleted = TRUE;
258 #endif
259  (parentdata->nchildconss) -= 1;
260  break;
261  }
262  }
263  assert(childdeleted || SCIPinProbing(scip));
264  }
265 
266  /* no child nodes may exist */
267  for( i = 0; i < (*consdata)->nchildconss; ++i )
268  assert((*consdata)->childconss[i] == NULL);
269 
270  /* delete branchdata if no mastercons is linked which would still need the branchdata;
271  * otherwise, the mastercons deletes the branchdata when it is deleted itself
272  */
273  if( (*consdata)->mastercons == NULL && (*consdata)->branchdata != NULL && (*consdata)->branchrule != NULL )
274  {
275  (*consdata)->branchdata = NULL;
276  }
277 
278  SCIPfreeMemoryArrayNull(scip, &(*consdata)->childconss);
279  (*consdata)->childconss = NULL;
280  (*consdata)->nchildconss = 0;
281 
282  /* free constraint data */
283  SCIPfreeBlockMemory(scip, consdata);
284 
285  return SCIP_OKAY;
286 }
287 
288 
290 static
291 SCIP_DECL_CONSACTIVE(consActiveOrigbranch)
292 { /*lint --e{715}*/
293  SCIP_CONSHDLRDATA* conshdlrData;
294 
295  assert(scip != NULL);
296  assert(conshdlr != NULL);
297  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
298  assert(cons != NULL);
299 
300  conshdlrData = SCIPconshdlrGetData(conshdlr);
301  assert(conshdlrData != NULL);
302  assert(conshdlrData->stack != NULL);
303 
304  assert(SCIPconsGetData(cons) != NULL);
305 
306  if( SCIPconsGetData(cons)->node == NULL )
307  SCIPconsGetData(cons)->node = SCIPgetRootNode(scip);
308 
309  SCIPdebugMessage("Activating branch orig constraint: <%s>[stack size: %d].\n", SCIPconsGetName(cons),
310  conshdlrData->nstack+1);
311 
312  /* put constraint on the stack */
313  if( conshdlrData->nstack >= conshdlrData->maxstacksize )
314  {
315  int newsize = SCIPcalcMemGrowSize(scip, conshdlrData->nstack+1);
316  SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(conshdlrData->stack), conshdlrData->maxstacksize, newsize) );
317  SCIPdebugMessage("reallocating Memory for stack! %d --> %d\n", conshdlrData->maxstacksize, newsize);
318  conshdlrData->maxstacksize = newsize;
319  }
320 
321  /* put constraint on the stack */
322  assert(conshdlrData->stack != NULL);
323  conshdlrData->stack[conshdlrData->nstack] = cons;
324  ++(conshdlrData->nstack);
325 
326  return SCIP_OKAY;
327 }
328 
329 
331 static
332 SCIP_DECL_CONSDEACTIVE(consDeactiveOrigbranch)
333 { /*lint --e{715}*/
334  SCIP_CONSHDLRDATA* conshdlrData;
335 
336  assert(scip != NULL);
337  assert(conshdlr != NULL);
338  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
339  assert(cons != NULL);
340 
341  conshdlrData = SCIPconshdlrGetData(conshdlr);
342  assert(conshdlrData != NULL);
343  assert(conshdlrData->stack != NULL || conshdlrData->nstack <= 1);
344  assert(conshdlrData->nstack <= 1 || cons == conshdlrData->stack[conshdlrData->nstack-1]);
345 
346  assert(SCIPconsGetData(cons) != NULL);
347 
348  SCIPdebugMessage("Deactivating branch orig constraint: <%s> [stack size: %d].\n",
349  SCIPconsGetName(cons), conshdlrData->nstack-1);
350 
351  /* remove constraint from the stack */
352  if( conshdlrData->nstack > 0 )
353  --(conshdlrData->nstack);
354 
355  return SCIP_OKAY;
356 }
357 
359 static
360 SCIP_DECL_CONSENFOLP(consEnfolpOrigbranch)
361 { /*lint --e{715}*/
362  *result = SCIP_FEASIBLE;
363 
364  return SCIP_OKAY;
365 }
366 
368 static
369 SCIP_DECL_CONSENFORELAX(consEnforeOrigbranch)
370 { /*lint --e{715}*/
371  *result = SCIP_FEASIBLE;
372 
373  return SCIP_OKAY;
374 }
375 
376 
378 static
379 SCIP_DECL_CONSENFOPS(consEnfopsOrigbranch)
380 { /*lint --e{715}*/
381  *result = SCIP_FEASIBLE;
382 
383  return SCIP_OKAY;
384 }
385 
387 static
388 SCIP_DECL_CONSCHECK(consCheckOrigbranch)
389 { /*lint --e{715}*/
390  *result = SCIP_FEASIBLE;
391 
392  return SCIP_OKAY;
393 }
394 
396 static
397 SCIP_DECL_CONSLOCK(consLockOrigbranch)
398 { /*lint --e{715}*/
399  return SCIP_OKAY;
400 }
401 
402 /*
403  * interface methods
404  */
405 
406 
408 SCIP_RETCODE SCIPincludeConshdlrOrigbranch(
409  SCIP* scip
410  )
411 {
412  SCIP_CONSHDLRDATA* conshdlrData;
413  SCIP_CONSHDLR* conshdlr;
414 
415  SCIP_CALL( SCIPallocMemory(scip, &conshdlrData) );
416  conshdlrData->stack = NULL;
417  conshdlrData->nstack = 0;
418  conshdlrData->maxstacksize = 25;
419  conshdlrData->rootcons = NULL;
420 
421  /* include constraint handler */
422  SCIP_CALL( SCIPincludeConshdlrBasic(scip, &conshdlr, CONSHDLR_NAME, CONSHDLR_DESC,
424  consEnfolpOrigbranch, consEnfopsOrigbranch, consCheckOrigbranch,
425  consLockOrigbranch, conshdlrData) );
426  assert(conshdlr != NULL);
427 
428  SCIP_CALL( SCIPsetConshdlrEnforelax(scip, conshdlr, consEnforeOrigbranch) );
429  SCIP_CALL( SCIPsetConshdlrFree(scip, conshdlr, consFreeOrigbranch) );
430  SCIP_CALL( SCIPsetConshdlrExit(scip, conshdlr, consExitOrigbranch) );
431  SCIP_CALL( SCIPsetConshdlrInitsol(scip, conshdlr, consInitsolOrigbranch) );
432  SCIP_CALL( SCIPsetConshdlrExitsol(scip, conshdlr, consExitsolOrigbranch) );
433  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteOrigbranch) );
434  SCIP_CALL( SCIPsetConshdlrActive(scip, conshdlr, consActiveOrigbranch) );
435  SCIP_CALL( SCIPsetConshdlrDeactive(scip, conshdlr, consDeactiveOrigbranch) );
436 
437  return SCIP_OKAY;
438 }
439 
440 
442 SCIP_RETCODE GCGcreateConsOrigbranch(
443  SCIP* scip,
444  SCIP_CONS** cons,
445  const char* name,
446  SCIP_NODE* node,
447  SCIP_CONS* parentcons,
448  SCIP_BRANCHRULE* branchrule,
449  GCG_BRANCHDATA* branchdata
451  )
452 {
453  SCIP_CONSHDLR* conshdlr;
454  SCIP_CONSDATA* consdata;
455 
456  assert(scip != NULL);
457  assert((parentcons == NULL) == (node == NULL));
458 
459  /* find the origbranch constraint handler */
460  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
461  assert(conshdlr != NULL);
462 
463  /* create constraint data */
464  SCIP_CALL( SCIPallocBlockMemory(scip, &consdata) );
465 
466  if( branchdata == NULL && branchrule != NULL )
467  {
468  if( strcmp(SCIPbranchruleGetName(branchrule), "generic") == 0 )
469  {
470  SCIP_CALL( GCGbranchGenericCreateBranchdata(scip, &branchdata) );
471  }
472  }
473 
474  /* initialize the fields in the constraint data */
475  consdata->node = node;
476  consdata->parentcons = parentcons;
477  consdata->childconss = NULL;
478  consdata->nchildconss = 0;
479  consdata->probingtmpcons = NULL;
480  consdata->mastercons = NULL;
481  consdata->branchdata = branchdata;
482  consdata->branchrule = branchrule;
483 
484  SCIPdebugMessage("Creating branch orig constraint: <%s> (nconss = %d).\n", name, SCIPconshdlrGetNConss(conshdlr));
485 
486  /* create constraint */
487  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, FALSE,
488  TRUE, FALSE, FALSE, FALSE, TRUE) );
489 
490  /* store the pointer to the new constraint in the origbranch constraint of the parent node */
491  if( parentcons != NULL )
492  {
493  SCIP_CONSDATA* parentdata;
494 
495  parentdata = SCIPconsGetData(parentcons);
496  assert(parentdata != NULL);
497 
498  if( SCIPinProbing(scip) )
499  {
500  parentdata->probingtmpcons = *cons;
501  }
502  else
503  {
504  ++parentdata->nchildconss;
505  if( parentdata->nchildconss == 1 )
506  {
507  SCIP_CALL( SCIPallocMemoryArray(scip, &(parentdata->childconss), parentdata->nchildconss) );
508  parentdata->childconss[0] = NULL;
509  }
510  else
511  {
512  SCIP_CALL( SCIPreallocMemoryArray(scip, &(parentdata->childconss), parentdata->nchildconss) );
513  parentdata->childconss[parentdata->nchildconss - 1] = NULL;
514  }
515  parentdata->childconss[parentdata->nchildconss-1] = *cons;
516  }
517  }
518 
519  return SCIP_OKAY;
520 }
521 
524  SCIP* scip
525  )
526 {
527  SCIP_CONSHDLR* conshdlr;
528  SCIP_CONSHDLRDATA* conshdlrData;
529 
530  assert(scip != NULL);
531  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
532  assert(conshdlr != NULL);
533 
534  conshdlrData = SCIPconshdlrGetData(conshdlr);
535  assert(conshdlrData != NULL);
536  assert(conshdlrData->stack != NULL);
537  assert(conshdlrData->nstack > 0);
538 
539  return conshdlrData->stack[conshdlrData->nstack-1];
540 }
541 
544  SCIP* scip,
545  SCIP_CONS*** stack,
546  int* nstackelements
547  )
548 {
549  SCIP_CONSHDLR* conshdlr;
550  SCIP_CONSHDLRDATA* conshdlrData;
551 
552  assert(scip != NULL);
553  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
554  assert(conshdlr != NULL);
555 
556  conshdlrData = SCIPconshdlrGetData(conshdlr);
557  assert(conshdlrData != NULL);
558  assert(conshdlrData->stack != NULL);
559 
560  *stack = conshdlrData->stack;
561  *nstackelements = conshdlrData->nstack;
562 }
563 
566  SCIP_CONS* cons,
567  GCG_BRANCHDATA* branchdata
568  )
569 {
570  SCIP_CONSDATA* consdata;
571 
572  consdata = SCIPconsGetData(cons);
573  assert(consdata != NULL);
574 
575  consdata->branchdata = branchdata;
576 }
577 
580  SCIP_CONS* cons
581  )
582 {
583  SCIP_CONSDATA* consdata;
584 
585  consdata = SCIPconsGetData(cons);
586  assert(consdata != NULL);
587 
588  return consdata->branchdata;
589 }
590 
592 SCIP_BRANCHRULE* GCGconsOrigbranchGetBranchrule(
593  SCIP_CONS* cons
594  )
595 {
596  SCIP_CONSDATA* consdata;
597  assert(cons != NULL);
598 
599  consdata = SCIPconsGetData(cons);
600  assert(consdata != NULL);
601 
602  return consdata->branchrule;
603 }
604 
606 SCIP_NODE* GCGconsOrigbranchGetNode(
607  SCIP_CONS* cons
608  )
609 {
610  SCIP_CONSDATA* consdata;
611  assert(cons != NULL);
612 
613  consdata = SCIPconsGetData(cons);
614  assert(consdata != NULL);
615 
616  return consdata->node;
617 }
618 
623  SCIP_CONS* cons
625  )
626 {
627  SCIP_CONSDATA* consdata;
628  assert(cons != NULL);
629 
630  consdata = SCIPconsGetData(cons);
631  assert(consdata != NULL);
632 
633  return consdata->parentcons;
634 }
635 
640  SCIP_CONS* cons
641  )
642 {
643  SCIP_CONSDATA* consdata;
644 
645  consdata = SCIPconsGetData(cons);
646  assert(consdata != NULL);
647 
648  return consdata->nchildconss;
649 }
650 
655  SCIP_CONS* cons,
656  int childnr
657  )
658 {
659  SCIP_CONSDATA* consdata;
660 
661  consdata = SCIPconsGetData(cons);
662  assert(consdata != NULL);
663  assert(consdata->childconss != NULL);
664  assert(consdata->nchildconss > childnr);
665 
666  return consdata->childconss[childnr];
667 }
668 
673  SCIP_CONS* cons,
674  SCIP_CONS* mastercons
675  )
676 {
677  SCIP_CONSDATA* consdata;
678  assert(cons != NULL);
679 
680  consdata = SCIPconsGetData(cons);
681  assert(consdata != NULL);
682 
683  consdata->mastercons = mastercons;
684 }
685 
690  SCIP_CONS* cons
692  )
693 {
694  SCIP_CONSDATA* consdata;
695  assert(cons != NULL);
696 
697  consdata = SCIPconsGetData(cons);
698  assert(consdata != NULL);
699 
700  return consdata->mastercons;
701 }
702 
704 SCIP_RETCODE GCGconsOrigbranchAddRootCons(
705  SCIP* scip
706  )
707 {
708  SCIP_CONSHDLR* conshdlr;
709  SCIP_CONSHDLRDATA* conshdlrdata;
710  SCIP_CONS* cons;
711  SCIP_CONS** conss;
712  int nconss;
713  int i;
714 
715  assert(scip != NULL);
716 
717  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
718  assert(conshdlr != NULL);
719 
720  nconss = SCIPconshdlrGetNConss(conshdlr);
721  assert(nconss <= 1);
722  conss = SCIPconshdlrGetConss(conshdlr);
723  for( i = 0; i < nconss; ++i )
724  {
725  SCIP_CALL( SCIPdelCons(scip, conss[i]) );
726  }
727 
728  conshdlrdata = SCIPconshdlrGetData(conshdlr);
729  assert(conshdlrdata != NULL);
730  assert(SCIPconshdlrGetNConss(conshdlr) == 0);
731  if( conshdlrdata->rootcons == NULL )
732  {
733  SCIP_CALL( GCGcreateConsOrigbranch(scip, &cons, "root-origbranch", NULL, NULL, NULL, NULL) );
734  SCIP_CALL( SCIPaddConsNode(scip, SCIPgetRootNode(scip), cons, SCIPgetRootNode(scip)) );
735  conshdlrdata->rootcons = cons;
736  }
737 
738  /* check consistency */
740 
741  return SCIP_OKAY;
742 }
743 
746  SCIP* scip
747  )
748 {
749 #ifdef CHECKCONSISTENCY
750 
751  SCIP_CONSHDLR* conshdlr;
752 
753 #ifndef NDEBUG
754  SCIP_CONS** conss;
755  int nconss;
756  int i;
757 #endif
758 
759  assert(scip != NULL);
760  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
761  if( conshdlr == NULL )
762  {
763  SCIPerrorMessage("origbranch constraint handler not found\n");
764  return;
765  }
766 #ifndef NDEBUG
767  conss = SCIPconshdlrGetConss(conshdlr);
768  nconss = SCIPconshdlrGetNConss(conshdlr);
769 
770  for( i = 0; i < nconss; i++ )
771  {
772  SCIP_CONSDATA* consdata = SCIPconsGetData(conss[i]);
773  assert(consdata != NULL);
774  assert(consdata->node != NULL);
775  assert((consdata->parentcons == NULL) == (SCIPnodeGetDepth(consdata->node) == 0));
777  if( consdata->nchildconss == 2 )
778  assert(consdata->parentcons == NULL || SCIPconsGetData(consdata->parentcons)->childconss[0] == conss[i]
779  || SCIPconsGetData(consdata->parentcons)->childconss[1] == conss[i]
780  || ( SCIPinProbing(scip) && SCIPconsGetData(consdata->parentcons)->probingtmpcons == conss[i]));
781  if( consdata->nchildconss == 2 )
782  assert(consdata->childconss[0] == NULL || SCIPconsGetData(consdata->childconss[0])->parentcons == conss[i]);
783  if( consdata->nchildconss == 2 )
784  assert(consdata->childconss[1] == NULL || SCIPconsGetData(consdata->childconss[1])->parentcons == conss[i]);
785  assert(consdata->probingtmpcons == NULL || SCIPinProbing(scip));
786  assert(consdata->probingtmpcons == NULL || SCIPconsGetData(consdata->probingtmpcons)->parentcons == conss[i]);
787  assert(consdata->mastercons == NULL || GCGconsMasterbranchGetOrigcons(consdata->mastercons) == conss[i]);
788  }
789 #endif
790 #endif
791 }
SCIP_RETCODE SCIPincludeConshdlrOrigbranch(SCIP *scip)
GCG_BRANCHDATA * GCGconsOrigbranchGetBranchdata(SCIP_CONS *cons)
#define CONSHDLR_ENFOPRIORITY
static SCIP_DECL_CONSENFOPS(consEnfopsOrigbranch)
GCG interface methods.
SCIP_NODE * GCGconsOrigbranchGetNode(SCIP_CONS *cons)
SCIP_CONS * rootcons
SCIP_CONS * GCGconsOrigbranchGetChildcons(SCIP_CONS *cons, int childnr)
SCIP_CONS * GCGconsMasterbranchGetOrigcons(SCIP_CONS *cons)
static SCIP_DECL_CONSACTIVE(consActiveOrigbranch)
static SCIP_DECL_CONSLOCK(consLockOrigbranch)
SCIP_RETCODE GCGconsOrigbranchAddRootCons(SCIP *scip)
SCIP_BRANCHRULE * GCGconsOrigbranchGetBranchrule(SCIP_CONS *cons)
void GCGconsOrigbranchSetMastercons(SCIP_CONS *cons, SCIP_CONS *mastercons)
static SCIP_DECL_CONSINITSOL(consInitsolOrigbranch)
int GCGconsOrigbranchGetNChildconss(SCIP_CONS *cons)
static SCIP_DECL_CONSENFOLP(consEnfolpOrigbranch)
static SCIP_DECL_CONSEXIT(consExitOrigbranch)
static SCIP_DECL_CONSDELETE(consDeleteOrigbranch)
SCIP_CONS * GCGconsOrigbranchGetActiveCons(SCIP *scip)
SCIP_CONS * GCGconsOrigbranchGetParentcons(SCIP_CONS *cons)
static SCIP_DECL_CONSDEACTIVE(consDeactiveOrigbranch)
void GCGconsOrigbranchSetBranchdata(SCIP_CONS *cons, GCG_BRANCHDATA *branchdata)
#define CONSHDLR_DESC
static SCIP_DECL_CONSEXITSOL(consExitsolOrigbranch)
SCIP_RETCODE GCGcreateConsOrigbranch(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_NODE *node, SCIP_CONS *parentcons, SCIP_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata)
SCIP_RETCODE GCGbranchGenericCreateBranchdata(SCIP *scip, GCG_BRANCHDATA **branchdata)
static SCIP_DECL_CONSENFORELAX(consEnforeOrigbranch)
#define CONSHDLR_NAME
branching rule based on vanderbeck&#39;s generic branching scheme
constraint handler for storing the branching decisions at each node of the tree
#define CONSHDLR_NEEDSCONS
void GCGconsOrigbranchGetStack(SCIP *scip, SCIP_CONS ***stack, int *nstackelements)
constraint handler for storing the branching decisions at each node of the tree
static SCIP_DECL_CONSCHECK(consCheckOrigbranch)
void GCGconsMasterbranchSetOrigcons(SCIP_CONS *cons, SCIP_CONS *origcons)
SCIP_CONS * GCGconsOrigbranchGetMastercons(SCIP_CONS *cons)
void GCGconsOrigbranchCheckConsistency(SCIP *scip)
static SCIP_DECL_CONSFREE(consFreeOrigbranch)
#define CONSHDLR_CHECKPRIORITY
#define CONSHDLR_EAGERFREQ