Scippy

SCIP

Solving Constraint Integer Programs

cons.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2014 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file cons.c
17  * @brief methods for constraints and constraint handlers
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include <assert.h>
25 #include <string.h>
26 #include <ctype.h>
27 
28 #include "scip/def.h"
29 #include "scip/set.h"
30 #include "scip/stat.h"
31 #include "scip/clock.h"
32 #include "scip/var.h"
33 #include "scip/prob.h"
34 #include "scip/tree.h"
35 #include "scip/sepastore.h"
36 #include "scip/cons.h"
37 #include "scip/branch.h"
38 #include "scip/pub_misc.h"
39 
40 #ifndef NDEBUG
41 #include "scip/struct_cons.h"
42 #endif
43 
44 
45 #define AGERESETAVG_INIT 1000.0 /**< initial value of the exponentially decaying weighted sum for ages */
46 #define AGERESETAVG_MIN 100.0 /**< minimal value to use for weighted sum of ages */
47 #define AGERESETAVG_DECAY 0.0005 /**< weight of a new addend in the exponentially decyaing sum */
48 #define AGERESETAVG_AGELIMIT 2.0 /**< in dynamic setting, a constraint is deleted if its age exceeds the
49  * average reset age by this factor */
50 #define AGERESETAVG_OBSOLETEAGE 1.8 /**< in dynamic setting, a constraint is marked obsolete if its age exceeds the
51  * average reset age by this factor */
52 
53 
54 /* #define CHECKCONSARRAYS */
55 
56 
57 /*
58  * dynamic memory arrays
59  */
60 
61 
62 /** resizes conss array to be able to store at least num constraints */
63 static
65  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
66  SCIP_SET* set, /**< global SCIP settings */
67  int num /**< minimal number of slots in array */
68  )
69 {
70  assert(conshdlr != NULL);
71  assert(set != NULL);
72 
73  if( num > conshdlr->consssize )
74  {
75  int newsize;
76 
77  newsize = SCIPsetCalcMemGrowSize(set, num);
78  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->conss, newsize) );
79  conshdlr->consssize = newsize;
80  }
81  assert(num <= conshdlr->consssize);
82 
83  return SCIP_OKAY;
84 }
85 
86 /** resizes initconss array to be able to store at least num constraints */
87 static
89  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
90  SCIP_SET* set, /**< global SCIP settings */
91  int num /**< minimal number of slots in array */
92  )
93 {
94  assert(conshdlr != NULL);
95  assert(set != NULL);
96 
97  if( num > conshdlr->initconsssize )
98  {
99  int newsize;
100 
101  newsize = SCIPsetCalcMemGrowSize(set, num);
102  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->initconss, newsize) );
103  conshdlr->initconsssize = newsize;
104  }
105  assert(num <= conshdlr->initconsssize);
106 
107  return SCIP_OKAY;
108 }
109 
110 /** resizes sepaconss array to be able to store at least num constraints */
111 static
113  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
114  SCIP_SET* set, /**< global SCIP settings */
115  int num /**< minimal number of slots in array */
116  )
117 {
118  assert(conshdlr != NULL);
119  assert(set != NULL);
120 
121  if( num > conshdlr->sepaconsssize )
122  {
123  int newsize;
124 
125  newsize = SCIPsetCalcMemGrowSize(set, num);
126  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->sepaconss, newsize) );
127  conshdlr->sepaconsssize = newsize;
128  }
129  assert(num <= conshdlr->sepaconsssize);
130 
131  return SCIP_OKAY;
132 }
133 
134 /** resizes enfoconss array to be able to store at least num constraints */
135 static
137  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
138  SCIP_SET* set, /**< global SCIP settings */
139  int num /**< minimal number of slots in array */
140  )
141 {
142  assert(conshdlr != NULL);
143  assert(set != NULL);
144 
145  if( num > conshdlr->enfoconsssize )
146  {
147  int newsize;
148 
149  newsize = SCIPsetCalcMemGrowSize(set, num);
150  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->enfoconss, newsize) );
151  conshdlr->enfoconsssize = newsize;
152  }
153  assert(num <= conshdlr->enfoconsssize);
154 
155  return SCIP_OKAY;
156 }
157 
158 /** resizes checkconss array to be able to store at least num constraints */
159 static
161  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
162  SCIP_SET* set, /**< global SCIP settings */
163  int num /**< minimal number of slots in array */
164  )
165 {
166  assert(conshdlr != NULL);
167  assert(set != NULL);
168 
169  if( num > conshdlr->checkconsssize )
170  {
171  int newsize;
172 
173  newsize = SCIPsetCalcMemGrowSize(set, num);
174  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->checkconss, newsize) );
175  conshdlr->checkconsssize = newsize;
176  }
177  assert(num <= conshdlr->checkconsssize);
178 
179  return SCIP_OKAY;
180 }
181 
182 /** resizes propconss array to be able to store at least num constraints */
183 static
185  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
186  SCIP_SET* set, /**< global SCIP settings */
187  int num /**< minimal number of slots in array */
188  )
189 {
190  assert(conshdlr != NULL);
191  assert(set != NULL);
192 
193  if( num > conshdlr->propconsssize )
194  {
195  int newsize;
196 
197  newsize = SCIPsetCalcMemGrowSize(set, num);
198  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->propconss, newsize) );
199  conshdlr->propconsssize = newsize;
200  }
201  assert(num <= conshdlr->propconsssize);
202 
203  return SCIP_OKAY;
204 }
205 
206 /** resizes updateconss array to be able to store at least num constraints */
207 static
209  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
210  SCIP_SET* set, /**< global SCIP settings */
211  int num /**< minimal number of slots in array */
212  )
213 {
214  assert(conshdlr != NULL);
215  assert(set != NULL);
216 
217  if( num > conshdlr->updateconsssize )
218  {
219  int newsize;
220 
221  newsize = SCIPsetCalcMemGrowSize(set, num);
222  SCIP_ALLOC( BMSreallocMemoryArray(&conshdlr->updateconss, newsize) );
223  conshdlr->updateconsssize = newsize;
224  }
225  assert(num <= conshdlr->updateconsssize);
226 
227  return SCIP_OKAY;
228 }
229 
230 
231 
232 
233 /*
234  * Constraint handler methods
235  */
236 
237 #define checkConssArrays(conshdlr) /**/
238 #ifndef NDEBUG
239 #ifdef CHECKCONSARRAYS
240 #undef checkConssArrays
241 /** sanity check for the constraint arrays of the constraint handler (only in debug mode) */
242 static
243 void checkConssArrays(
244  SCIP_CONSHDLR* conshdlr /**< constraint handler */
245  )
246 {
247  int c;
248 
249  assert(conshdlr != NULL);
250  assert(0 <= conshdlr->nactiveconss && conshdlr->nactiveconss <= conshdlr->nconss);
251 
252  for( c = 0; c < conshdlr->nconss; ++c )
253  {
254  assert(conshdlr->conss[c] != NULL);
255  assert(!conshdlr->conss[c]->original);
256  assert(conshdlr->conss[c]->active == (c < conshdlr->nactiveconss));
257  assert(conshdlr->conss[c]->consspos == c);
258  }
259 
260  for( c = 0; c < conshdlr->ninitconss; ++c )
261  {
262  assert(conshdlr->initconss[c] != NULL);
263  assert(!conshdlr->initconss[c]->original);
264  assert(c < conshdlr->ninitconsskept || conshdlr->initconss[c]->active);
265  assert(conshdlr->initconss[c]->initial);
266  }
267 
268  for( c = 0; c < conshdlr->nsepaconss; ++c )
269  {
270  assert(conshdlr->sepaconss[c] != NULL);
271  assert(!conshdlr->sepaconss[c]->original);
272  assert(conshdlr->sepaconss[c]->active);
273  assert(conshdlr->sepaconss[c]->separate);
274  assert(conshdlr->sepaconss[c]->sepaenabled);
275  assert(conshdlr->sepaconss[c]->obsolete == (c >= conshdlr->nusefulsepaconss));
276  }
277 
278  for( c = 0; c < conshdlr->nenfoconss; ++c )
279  {
280  assert(conshdlr->enfoconss[c] != NULL);
281  assert(!conshdlr->enfoconss[c]->original);
282  assert(conshdlr->enfoconss[c]->active);
283  assert(conshdlr->enfoconss[c]->enforce);
284  assert(conshdlr->enfoconss[c]->obsolete == (c >= conshdlr->nusefulenfoconss));
285  }
286 
287  for( c = 0; c < conshdlr->ncheckconss; ++c )
288  {
289  assert(conshdlr->checkconss[c] != NULL);
290  assert(!conshdlr->checkconss[c]->original);
291  assert(conshdlr->checkconss[c]->active);
292  assert(conshdlr->checkconss[c]->check);
293  assert(conshdlr->checkconss[c]->obsolete == (c >= conshdlr->nusefulcheckconss));
294  }
295 
296  for( c = 0; c < conshdlr->npropconss; ++c )
297  {
298  assert(conshdlr->propconss[c] != NULL);
299  assert(!conshdlr->propconss[c]->original);
300  assert(conshdlr->propconss[c]->active);
301  assert(conshdlr->propconss[c]->propagate);
302  assert(conshdlr->propconss[c]->propenabled);
303  assert(conshdlr->propconss[c]->markpropagate == (c < conshdlr->nmarkedpropconss));
304  assert(conshdlr->propconss[c]->markpropagate || (conshdlr->propconss[c]->obsolete == (c >= conshdlr->nusefulpropconss)));
305  }
306 }
307 #endif
308 #endif
309 
310 /** returns whether the constraint updates of the constraint handler are currently delayed */
311 static
313  SCIP_CONSHDLR* conshdlr /**< constraint handler */
314  )
315 {
316  return (conshdlr->delayupdatecount > 0);
317 }
318 
319 /** returns the exponentially decaying weighted age average for age resets */
320 static
322  SCIP_CONSHDLR* conshdlr /**< constraint handler */
323  )
324 {
325  assert(conshdlr != NULL);
326 
327  return MAX(conshdlr->ageresetavg, AGERESETAVG_MIN);
328 }
329 
330 /** updates the exponentially decaying weighted age average for age resets after a constraint age was reset */
331 static
333  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
334  SCIP_Real age /**< age of the constraint that is reset to zero */
335  )
336 {
337  assert(conshdlr != NULL);
338 
339  conshdlr->ageresetavg *= (1.0-AGERESETAVG_DECAY);
340  conshdlr->ageresetavg += AGERESETAVG_DECAY * age;
341 }
342 
343 /** returns whether the constraint's age exceeds the age limit */
344 static
346  SCIP_CONS* cons, /**< constraint to check */
347  SCIP_SET* set /**< global SCIP settings */
348  )
349 {
350  assert(cons != NULL);
351  assert(set != NULL);
352 
353  return (cons->dynamic
354  && ((set->cons_agelimit > 0 && cons->age > set->cons_agelimit)
355  || (set->cons_agelimit == 0 && cons->age > AGERESETAVG_AGELIMIT * conshdlrGetAgeresetavg(cons->conshdlr))));
356 }
357 
358 /** returns whether the constraint's age exceeds the obsolete age limit */
359 static
361  SCIP_CONS* cons, /**< constraint to check */
362  SCIP_SET* set /**< global SCIP settings */
363  )
364 {
365  assert(cons != NULL);
366  assert(set != NULL);
367 
368  return (cons->dynamic
369  && ((set->cons_obsoleteage > 0 && cons->age > set->cons_obsoleteage)
370  || (set->cons_obsoleteage == 0 && cons->age > AGERESETAVG_OBSOLETEAGE * conshdlrGetAgeresetavg(cons->conshdlr))));
371 }
372 
373 /** marks constraint to be obsolete; it will be moved to the last part of the constraint arrays, such that
374  * it is checked, enforced, separated, and propagated after the useful constraints
375  */
376 static
378  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
379  SCIP_CONS* cons /**< constraint to be marked obsolete */
380  )
381 {
382  SCIP_CONS* tmpcons;
383 
384  assert(conshdlr != NULL);
385  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
386  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
387  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
388  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
389  assert(cons != NULL);
390  assert(!cons->original);
391  assert(!cons->obsolete);
392  assert(!conshdlrAreUpdatesDelayed(conshdlr));
393 
394  cons->obsolete = TRUE;
395 
396  if( cons->active )
397  {
398  if( cons->check )
399  {
400  assert(0 <= cons->checkconsspos && cons->checkconsspos < conshdlr->nusefulcheckconss);
401 
402  /* switch the last useful (non-obsolete) check constraint with this constraint */
403  tmpcons = conshdlr->checkconss[conshdlr->nusefulcheckconss-1];
404  assert(tmpcons->checkconsspos == conshdlr->nusefulcheckconss-1);
405 
406  conshdlr->checkconss[conshdlr->nusefulcheckconss-1] = cons;
407  conshdlr->checkconss[cons->checkconsspos] = tmpcons;
408  tmpcons->checkconsspos = cons->checkconsspos;
409  cons->checkconsspos = conshdlr->nusefulcheckconss-1;
410 
411  conshdlr->nusefulcheckconss--;
412  }
413  }
414  if( cons->enabled )
415  {
416  if( cons->separate && cons->sepaenabled )
417  {
418  assert(0 <= cons->sepaconsspos && cons->sepaconsspos < conshdlr->nusefulsepaconss);
419 
420  if( cons->sepaconsspos < conshdlr->lastnusefulsepaconss )
421  conshdlr->lastnusefulsepaconss--;
422 
423  /* switch the last useful (non-obsolete) sepa constraint with this constraint */
424  tmpcons = conshdlr->sepaconss[conshdlr->nusefulsepaconss-1];
425  assert(tmpcons->sepaconsspos == conshdlr->nusefulsepaconss-1);
426 
427  conshdlr->sepaconss[conshdlr->nusefulsepaconss-1] = cons;
428  conshdlr->sepaconss[cons->sepaconsspos] = tmpcons;
429  tmpcons->sepaconsspos = cons->sepaconsspos;
430  cons->sepaconsspos = conshdlr->nusefulsepaconss-1;
431 
432  conshdlr->nusefulsepaconss--;
433  }
434  if( cons->enforce )
435  {
436  assert(0 <= cons->enfoconsspos && cons->enfoconsspos < conshdlr->nusefulenfoconss);
437 
438  if( cons->enfoconsspos < conshdlr->lastnusefulenfoconss )
439  conshdlr->lastnusefulenfoconss--;
440  else
441  {
442  /* the constraint that becomes obsolete is not yet enforced on the current solution:
443  * we have to make sure that it will be enforced the next time; this is not done, if the current
444  * solution was already enforced and only enforcement on the additional constraints is performed
445  * (because in this case, only the new useful constraints are enforced);
446  * thus, we have to reset the enforcement counters in order to enforce all constraints again, especially
447  * the now obsolete one;
448  * this case should occur almost never, because a constraint that was not enforced in the last enforcement
449  * is a newly added one, and it is very unlikely that this constraint will become obsolete before the next
450  * enforcement call;
451  * this reset is not performed for separation and propagation, because they are not vital for correctness
452  */
453  conshdlr->lastenfolplpcount = -1;
454  conshdlr->lastenfolpdomchgcount = -1;
455  conshdlr->lastenfopsdomchgcount = -1;
456  conshdlr->lastenfolpnode = -1;
457  conshdlr->lastenfopsnode = -1;
458  }
459 
460  /* switch the last useful (non-obsolete) enfo constraint with this constraint */
461  tmpcons = conshdlr->enfoconss[conshdlr->nusefulenfoconss-1];
462  assert(tmpcons->enfoconsspos == conshdlr->nusefulenfoconss-1);
463 
464  conshdlr->enfoconss[conshdlr->nusefulenfoconss-1] = cons;
465  conshdlr->enfoconss[cons->enfoconsspos] = tmpcons;
466  tmpcons->enfoconsspos = cons->enfoconsspos;
467  cons->enfoconsspos = conshdlr->nusefulenfoconss-1;
468 
469  conshdlr->nusefulenfoconss--;
470  }
471  /* in case the constraint is marked to be propagated, we do not move it in the propconss array since the first
472  * part of the array contains all marked constraints independently of their age
473  */
474  assert(!cons->markpropagate == (cons->propconsspos < conshdlr->nmarkedpropconss));
475  if( cons->propagate && cons->propenabled && !cons->markpropagate )
476  {
477  assert(0 <= cons->propconsspos && cons->propconsspos < conshdlr->nusefulpropconss);
478 
479  if( cons->propconsspos < conshdlr->lastnusefulpropconss )
480  conshdlr->lastnusefulpropconss--;
481 
482  /* switch the last useful (non-obsolete) prop constraint with this constraint */
483  tmpcons = conshdlr->propconss[conshdlr->nusefulpropconss-1];
484  assert(tmpcons->propconsspos == conshdlr->nusefulpropconss-1);
485 
486  conshdlr->propconss[conshdlr->nusefulpropconss-1] = cons;
487  conshdlr->propconss[cons->propconsspos] = tmpcons;
488  tmpcons->propconsspos = cons->propconsspos;
489  cons->propconsspos = conshdlr->nusefulpropconss-1;
490 
491  conshdlr->nusefulpropconss--;
492  }
493  }
494 
495  checkConssArrays(conshdlr);
496 
497  return SCIP_OKAY;
498 }
499 
500 /** marks obsolete constraint to be not obsolete anymore;
501  * it will be moved to the first part of the constraint arrays, such that it is checked, enforced, separated,
502  * and propagated before the obsolete constraints
503  */
504 static
506  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
507  SCIP_CONS* cons /**< constraint to be marked obsolete */
508  )
509 {
510  SCIP_CONS* tmpcons;
511 
512  assert(conshdlr != NULL);
513  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
514  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
515  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
516  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
517  assert(cons != NULL);
518  assert(!cons->original);
519  assert(cons->obsolete);
520  assert(!conshdlrAreUpdatesDelayed(conshdlr));
521 
522  cons->obsolete = FALSE;
523 
524  if( cons->active )
525  {
526  if( cons->check )
527  {
528  assert(conshdlr->nusefulcheckconss <= cons->checkconsspos && cons->checkconsspos < conshdlr->ncheckconss);
529 
530  /* switch the first obsolete check constraint with this constraint */
531  tmpcons = conshdlr->checkconss[conshdlr->nusefulcheckconss];
532  assert(tmpcons->checkconsspos == conshdlr->nusefulcheckconss);
533 
534  conshdlr->checkconss[conshdlr->nusefulcheckconss] = cons;
535  conshdlr->checkconss[cons->checkconsspos] = tmpcons;
536  tmpcons->checkconsspos = cons->checkconsspos;
537  cons->checkconsspos = conshdlr->nusefulcheckconss;
538 
539  conshdlr->nusefulcheckconss++;
540  }
541  }
542  if( cons->enabled )
543  {
544  if( cons->separate && cons->sepaenabled )
545  {
546  assert(conshdlr->nusefulsepaconss <= cons->sepaconsspos && cons->sepaconsspos < conshdlr->nsepaconss);
547 
548  /* switch the first obsolete sepa constraint with this constraint */
549  tmpcons = conshdlr->sepaconss[conshdlr->nusefulsepaconss];
550  assert(tmpcons->sepaconsspos == conshdlr->nusefulsepaconss);
551 
552  conshdlr->sepaconss[conshdlr->nusefulsepaconss] = cons;
553  conshdlr->sepaconss[cons->sepaconsspos] = tmpcons;
554  tmpcons->sepaconsspos = cons->sepaconsspos;
555  cons->sepaconsspos = conshdlr->nusefulsepaconss;
556 
557  conshdlr->nusefulsepaconss++;
558  }
559  if( cons->enforce )
560  {
561  assert(conshdlr->nusefulenfoconss <= cons->enfoconsspos && cons->enfoconsspos < conshdlr->nenfoconss);
562 
563  /* switch the first obsolete enfo constraint with this constraint */
564  tmpcons = conshdlr->enfoconss[conshdlr->nusefulenfoconss];
565  assert(tmpcons->enfoconsspos == conshdlr->nusefulenfoconss);
566 
567  conshdlr->enfoconss[conshdlr->nusefulenfoconss] = cons;
568  conshdlr->enfoconss[cons->enfoconsspos] = tmpcons;
569  tmpcons->enfoconsspos = cons->enfoconsspos;
570  cons->enfoconsspos = conshdlr->nusefulenfoconss;
571 
572  conshdlr->nusefulenfoconss++;
573  }
574  /* in case the constraint is marked to be propagated, we do not move it in the propconss array since the first
575  * part of the array contains all marked constraints independently of their age
576  */
577  assert(!cons->markpropagate == (cons->propconsspos < conshdlr->nmarkedpropconss));
578  if( cons->propagate && cons->propenabled && !cons->markpropagate)
579  {
580  assert(conshdlr->nusefulpropconss <= cons->propconsspos && cons->propconsspos < conshdlr->npropconss);
581 
582  /* switch the first obsolete prop constraint with this constraint */
583  tmpcons = conshdlr->propconss[conshdlr->nusefulpropconss];
584  assert(tmpcons->propconsspos == conshdlr->nusefulpropconss);
585 
586  conshdlr->propconss[conshdlr->nusefulpropconss] = cons;
587  conshdlr->propconss[cons->propconsspos] = tmpcons;
588  tmpcons->propconsspos = cons->propconsspos;
589  cons->propconsspos = conshdlr->nusefulpropconss;
590 
591  conshdlr->nusefulpropconss++;
592  }
593  }
594 
595  checkConssArrays(conshdlr);
596 
597  return SCIP_OKAY;
598 }
599 
600 /** marks constraint to be propagated in the next propagation round;
601  *
602  * @note the propagation array is divided into three parts in contrast to the other constraint arrays;
603  * the first part contains constraints which were marked to be propagated (independently of its age)
604  * the second part contains the useful (non-obsolete) constraints which are not marked to be propagated
605  * finally, the third part contains obsolete constraints which are not marked to be propagated
606  *
607  * @note if a constraint gets marked for propagation we put it into the first part regardless of its age
608  */
609 static
611  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
612  SCIP_CONS* cons /**< constraint to be marked obsolete */
613  )
614 {
615  SCIP_CONS* tmpcons;
616 
617  assert(conshdlr != NULL);
618  assert(conshdlr->nmarkedpropconss <= conshdlr->nusefulpropconss);
619  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
620  assert(cons != NULL);
621  assert(!cons->original);
622 
623  /* it may happen that the constraint is deleted while updates are delayed: in this case we just return */
624  if( !cons->enabled )
625  return;
626 
627  if( cons->markpropagate )
628  return;
629 
630  cons->markpropagate = TRUE;
631 
632  /* propagation of the constraint is globally or locally disabled, so we do not have to move the constraint in the
633  * propconss array
634  */
635  if( !cons->propagate || !cons->propenabled )
636  {
637  assert(cons->propconsspos == -1);
638  return;
639  }
640  assert(cons->propconsspos >= conshdlr->nmarkedpropconss);
641 
642  /* if the constraint is obsolete, we need to move it first to the non-obsolete part of the array */
643  if( cons->obsolete )
644  {
645  assert(conshdlr->nusefulpropconss <= cons->propconsspos && cons->propconsspos < conshdlr->npropconss);
646 
647  /* switch the first obsolete prop constraint with this constraint */
648  tmpcons = conshdlr->propconss[conshdlr->nusefulpropconss];
649  assert(tmpcons->propconsspos == conshdlr->nusefulpropconss);
650 
651  conshdlr->propconss[conshdlr->nusefulpropconss] = cons;
652  conshdlr->propconss[cons->propconsspos] = tmpcons;
653  tmpcons->propconsspos = cons->propconsspos;
654  cons->propconsspos = conshdlr->nusefulpropconss;
655 
656  conshdlr->nusefulpropconss++;
657  }
658  assert(conshdlr->nmarkedpropconss <= cons->propconsspos && cons->propconsspos < conshdlr->nusefulpropconss);
659 
660  /* switch the first useful prop constraint with this constraint */
661  tmpcons = conshdlr->propconss[conshdlr->nmarkedpropconss];
662  assert(tmpcons->propconsspos == conshdlr->nmarkedpropconss);
663 
664  conshdlr->propconss[conshdlr->nmarkedpropconss] = cons;
665  conshdlr->propconss[cons->propconsspos] = tmpcons;
666  tmpcons->propconsspos = cons->propconsspos;
667  cons->propconsspos = conshdlr->nmarkedpropconss;
668 
669  conshdlr->nmarkedpropconss++;
670 
671  checkConssArrays(conshdlr);
672 }
673 
674 /** unmarks constraint to be propagated in the next propagation round;
675  *
676  * @note the propagation array is divided into three parts in contrast to the other constraint arrays;
677  * the first part contains constraints which were marked to be propagated (independently of its age)
678  * the second part contains the useful (non-obsolete) constraints which are not marked to be propagated
679  * finally, the third part contains obsolete constraints which are not marked to be propagated
680  *
681  * @note if a constraint gets unmarked for propagation, it is put into the right part depending on its age
682  */
683 static
685  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
686  SCIP_CONS* cons /**< constraint to be marked obsolete */
687  )
688 {
689  SCIP_CONS* tmpcons;
690 
691  assert(conshdlr != NULL);
692  assert(conshdlr->nmarkedpropconss <= conshdlr->nusefulpropconss);
693  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
694  assert(cons != NULL);
695  assert(!cons->original);
696 
697  /* it may happen that the constraint is deleted while updates are delayed: in this case we just return */
698  if( !cons->enabled )
699  return;
700 
701  if( !cons->markpropagate )
702  return;
703 
704  cons->markpropagate = FALSE;
705 
706  /* propagation of the constraint is globally or locally disabled, so we do not have to move the constraint in the
707  * propconss array
708  */
709  if( !cons->propagate || !cons->propenabled )
710  {
711  assert(cons->propconsspos == -1);
712  return;
713  }
714  assert(cons->propconsspos >= 0);
715  assert(cons->propconsspos < conshdlr->nmarkedpropconss);
716 
717  /* first, move the constraint out of the first part to the second part of the constraint array */
718  if( cons->propconsspos < conshdlr->nmarkedpropconss - 1 )
719  {
720  conshdlr->nmarkedpropconss--;
721 
722  /* switch the last marked prop constraint with this constraint */
723  tmpcons = conshdlr->propconss[conshdlr->nmarkedpropconss];
724  assert(tmpcons->propconsspos == conshdlr->nmarkedpropconss);
725 
726  conshdlr->propconss[conshdlr->nmarkedpropconss] = cons;
727  conshdlr->propconss[cons->propconsspos] = tmpcons;
728  tmpcons->propconsspos = cons->propconsspos;
729  cons->propconsspos = conshdlr->nmarkedpropconss;
730  }
731  else if( cons->propconsspos == conshdlr->nmarkedpropconss - 1 )
732  conshdlr->nmarkedpropconss--;
733  assert(cons->propconsspos == conshdlr->nmarkedpropconss);
734 
735  /* if the constraint is obsolete, move it to the last part of the constraint array */
736  if( cons->obsolete )
737  {
738  conshdlr->nusefulpropconss--;
739 
740  /* switch the last useful prop constraint with this constraint */
741  tmpcons = conshdlr->propconss[conshdlr->nusefulpropconss];
742  assert(tmpcons->propconsspos == conshdlr->nusefulpropconss);
743 
744  conshdlr->propconss[conshdlr->nusefulpropconss] = cons;
745  conshdlr->propconss[cons->propconsspos] = tmpcons;
746  tmpcons->propconsspos = cons->propconsspos;
747  cons->propconsspos = conshdlr->nusefulpropconss;
748  }
749 
750  checkConssArrays(conshdlr);
751 }
752 
753 
754 /** adds constraint to the conss array of constraint handler */
755 static
757  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
758  SCIP_SET* set, /**< global SCIP settings */
759  SCIP_CONS* cons /**< constraint to add */
760  )
761 {
762  assert(conshdlr != NULL);
763  assert(cons != NULL);
764  assert(cons->conshdlr == conshdlr);
765  assert(!cons->original);
766  assert(!cons->active);
767  assert(cons->consspos == -1);
768  assert(set != NULL);
769  assert(cons->scip == set->scip);
770 
771  /* insert the constraint as inactive constraint into the transformed constraints array */
772  SCIP_CALL( conshdlrEnsureConssMem(conshdlr, set, conshdlr->nconss+1) );
773  conshdlr->conss[conshdlr->nconss] = cons;
774  cons->consspos = conshdlr->nconss;
775  conshdlr->nconss++;
776 
777  return SCIP_OKAY;
778 }
779 
780 /** deletes constraint from the conss array of constraint handler */
781 static
782 void conshdlrDelCons(
783  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
784  SCIP_CONS* cons /**< constraint to remove */
785  )
786 {
787  assert(conshdlr != NULL);
788  assert(cons != NULL);
789  assert(cons->conshdlr == conshdlr);
790  assert(!cons->original);
791  assert(!cons->active);
792  assert(conshdlr->nactiveconss <= cons->consspos && cons->consspos < conshdlr->nconss);
793 
794  conshdlr->conss[cons->consspos] = conshdlr->conss[conshdlr->nconss-1];
795  conshdlr->conss[cons->consspos]->consspos = cons->consspos;
796  conshdlr->nconss--;
797  cons->consspos = -1;
798 }
799 
800 /** adds constraint to the initconss array of constraint handler */
801 static
803  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
804  SCIP_SET* set, /**< global SCIP settings */
805  SCIP_STAT* stat, /**< dynamic problem statistics */
806  SCIP_CONS* cons /**< constraint to add */
807  )
808 {
809  int insertpos;
810 
811  assert(conshdlr != NULL);
812  assert(cons != NULL);
813  assert(cons->conshdlr == conshdlr);
814  assert(!cons->original);
815  assert(cons->active);
816  assert(cons->initial);
817  assert(cons->initconsspos == -1 || cons->initconsspos < conshdlr->ninitconsskept);
818 
819  SCIP_CALL( conshdlrEnsureInitconssMem(conshdlr, set, conshdlr->ninitconss+1) );
820 
821  insertpos = conshdlr->ninitconss;
822 
823  conshdlr->initconss[insertpos] = cons;
824  conshdlr->ninitconss++;
825  stat->ninitconssadded++;
826 
827  /* if the constraint is kept, we keep the stored position at the beginning of the array */
828  if( cons->initconsspos == -1 )
829  cons->initconsspos = insertpos;
830 
831  checkConssArrays(conshdlr);
832 
833  return SCIP_OKAY;
834 }
835 
836 /** deletes constraint from the initconss array of constraint handler */
837 static
839  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
840  SCIP_CONS* cons /**< constraint to remove */
841  )
842 {
843  int delpos;
844 
845  assert(conshdlr != NULL);
846  assert(cons != NULL);
847  assert(cons->conshdlr == conshdlr);
848  assert(!cons->original);
849  assert(0 <= cons->initconsspos && cons->initconsspos < conshdlr->ninitconss);
850 
851  delpos = cons->initconsspos;
852  if( delpos < conshdlr->ninitconsskept )
853  {
854  conshdlr->ninitconsskept--;
855  conshdlr->initconss[delpos] = conshdlr->initconss[conshdlr->ninitconsskept];
856  conshdlr->initconss[delpos]->initconsspos = delpos;
857  delpos = conshdlr->ninitconsskept;
858  }
859 
860  if( delpos < conshdlr->ninitconss-1 )
861  {
862  conshdlr->initconss[delpos] = conshdlr->initconss[conshdlr->ninitconss-1];
863  conshdlr->initconss[delpos]->initconsspos = delpos;
864  }
865  conshdlr->ninitconss--;
866  cons->initconsspos = -1;
867 
868  checkConssArrays(conshdlr);
869 }
870 
871 /** adds constraint to the sepaconss array of constraint handler */
872 static
874  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
875  SCIP_SET* set, /**< global SCIP settings */
876  SCIP_CONS* cons /**< constraint to add */
877  )
878 {
879  int insertpos;
880 
881  assert(conshdlr != NULL);
882  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
883  assert(cons != NULL);
884  assert(cons->conshdlr == conshdlr);
885  assert(!cons->original);
886  assert(cons->active);
887  assert(cons->separate);
888  assert(cons->sepaenabled);
889  assert(cons->sepaconsspos == -1);
890  assert(set != NULL);
891  assert(cons->scip == set->scip);
892  assert(!conshdlrAreUpdatesDelayed(conshdlr) || !conshdlr->duringsepa);
893 
894  SCIP_CALL( conshdlrEnsureSepaconssMem(conshdlr, set, conshdlr->nsepaconss+1) );
895  insertpos = conshdlr->nsepaconss;
896  if( !cons->obsolete )
897  {
898  if( conshdlr->nusefulsepaconss < conshdlr->nsepaconss )
899  {
900  conshdlr->sepaconss[conshdlr->nsepaconss] = conshdlr->sepaconss[conshdlr->nusefulsepaconss];
901  conshdlr->sepaconss[conshdlr->nsepaconss]->sepaconsspos = conshdlr->nsepaconss;
902  insertpos = conshdlr->nusefulsepaconss;
903  }
904  conshdlr->nusefulsepaconss++;
905  }
906  conshdlr->sepaconss[insertpos] = cons;
907  cons->sepaconsspos = insertpos;
908  conshdlr->nsepaconss++;
909 
910  checkConssArrays(conshdlr);
911 
912  return SCIP_OKAY;
913 }
914 
915 /** deletes constraint from the sepaconss array of constraint handler */
916 static
918  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
919  SCIP_CONS* cons /**< constraint to remove */
920  )
921 {
922  int delpos;
923 
924  assert(conshdlr != NULL);
925  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
926  assert(cons != NULL);
927  assert(cons->conshdlr == conshdlr);
928  assert(!cons->original);
929  assert(cons->separate);
930  assert(cons->sepaenabled);
931  assert(cons->sepaconsspos != -1);
932  assert(!conshdlrAreUpdatesDelayed(conshdlr) || !conshdlr->duringsepa);
933 
934  delpos = cons->sepaconsspos;
935  if( !cons->obsolete )
936  {
937  assert(0 <= delpos && delpos < conshdlr->nusefulsepaconss);
938 
939  if( delpos < conshdlr->lastnusefulsepaconss )
940  conshdlr->lastnusefulsepaconss--;
941 
942  conshdlr->sepaconss[delpos] = conshdlr->sepaconss[conshdlr->nusefulsepaconss-1];
943  conshdlr->sepaconss[delpos]->sepaconsspos = delpos;
944  delpos = conshdlr->nusefulsepaconss-1;
945  conshdlr->nusefulsepaconss--;
946  assert(conshdlr->nusefulsepaconss >= 0);
947  assert(conshdlr->lastnusefulsepaconss >= 0);
948  }
949  assert(conshdlr->nusefulsepaconss <= delpos && delpos < conshdlr->nsepaconss);
950  if( delpos < conshdlr->nsepaconss-1 )
951  {
952  conshdlr->sepaconss[delpos] = conshdlr->sepaconss[conshdlr->nsepaconss-1];
953  conshdlr->sepaconss[delpos]->sepaconsspos = delpos;
954  }
955  conshdlr->nsepaconss--;
956  cons->sepaconsspos = -1;
957 
958  checkConssArrays(conshdlr);
959 }
960 
961 /** adds constraint to the enfoconss array of constraint handler */
962 static
964  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
965  SCIP_SET* set, /**< global SCIP settings */
966  SCIP_CONS* cons /**< constraint to add */
967  )
968 {
969  int insertpos;
970 
971  assert(conshdlr != NULL);
972  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
973  assert(cons != NULL);
974  assert(cons->conshdlr == conshdlr);
975  assert(!cons->original);
976  assert(cons->active);
977  assert(cons->enforce);
978  assert(cons->enfoconsspos == -1);
979  assert(set != NULL);
980  assert(cons->scip == set->scip);
981 
982  SCIP_CALL( conshdlrEnsureEnfoconssMem(conshdlr, set, conshdlr->nenfoconss+1) );
983  insertpos = conshdlr->nenfoconss;
984  if( !cons->obsolete )
985  {
986  if( conshdlr->nusefulenfoconss < conshdlr->nenfoconss )
987  {
988  conshdlr->enfoconss[conshdlr->nenfoconss] = conshdlr->enfoconss[conshdlr->nusefulenfoconss];
989  conshdlr->enfoconss[conshdlr->nenfoconss]->enfoconsspos = conshdlr->nenfoconss;
990  insertpos = conshdlr->nusefulenfoconss;
991  }
992  conshdlr->nusefulenfoconss++;
993  }
994  else
995  {
996  /* we have to make sure that even this obsolete constraint is enforced in the next enforcement call;
997  * if the same LP or pseudo solution is enforced again, only the newly added useful constraints are
998  * enforced; thus, we have to reset the enforcement counters and force all constraints to be
999  * enforced again; this is not needed for separation and propagation, because they are not vital for correctness
1000  */
1001  conshdlr->lastenfolplpcount = -1;
1002  conshdlr->lastenfolpdomchgcount = -1;
1003  conshdlr->lastenfopsdomchgcount = -1;
1004  conshdlr->lastenfolpnode = -1;
1005  conshdlr->lastenfopsnode = -1;
1006  }
1007  conshdlr->enfoconss[insertpos] = cons;
1008  cons->enfoconsspos = insertpos;
1009  conshdlr->nenfoconss++;
1010 
1011  checkConssArrays(conshdlr);
1012 
1013  return SCIP_OKAY;
1014 }
1015 
1016 /** deletes constraint from the enfoconss array of constraint handler */
1017 static
1018 void conshdlrDelEnfocons(
1019  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1020  SCIP_CONS* cons /**< constraint to remove */
1021  )
1022 {
1023  int delpos;
1024 
1025  assert(conshdlr != NULL);
1026  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1027  assert(cons != NULL);
1028  assert(cons->conshdlr == conshdlr);
1029  assert(!cons->original);
1030  assert(cons->enforce);
1031  assert(cons->enfoconsspos != -1);
1032 
1033  delpos = cons->enfoconsspos;
1034  if( !cons->obsolete )
1035  {
1036  assert(0 <= delpos && delpos < conshdlr->nusefulenfoconss);
1037 
1038  if( delpos < conshdlr->lastnusefulenfoconss )
1039  conshdlr->lastnusefulenfoconss--;
1040 
1041  conshdlr->enfoconss[delpos] = conshdlr->enfoconss[conshdlr->nusefulenfoconss-1];
1042  conshdlr->enfoconss[delpos]->enfoconsspos = delpos;
1043  delpos = conshdlr->nusefulenfoconss-1;
1044  conshdlr->nusefulenfoconss--;
1045 
1046  /* if the constraint that moved to the free position was a newly added constraint and not enforced in the last
1047  * enforcement, we have to make sure it will be enforced in the next run;
1048  * this check is not performed for separation and propagation, because they are not vital for correctness
1049  */
1050  if( delpos >= conshdlr->lastnusefulenfoconss )
1051  conshdlr->lastnusefulenfoconss = cons->enfoconsspos;
1052 
1053  assert(conshdlr->nusefulenfoconss >= 0);
1054  assert(conshdlr->lastnusefulenfoconss >= 0);
1055  }
1056  assert(conshdlr->nusefulenfoconss <= delpos && delpos < conshdlr->nenfoconss);
1057  if( delpos < conshdlr->nenfoconss-1 )
1058  {
1059  conshdlr->enfoconss[delpos] = conshdlr->enfoconss[conshdlr->nenfoconss-1];
1060  conshdlr->enfoconss[delpos]->enfoconsspos = delpos;
1061  }
1062  conshdlr->nenfoconss--;
1063  cons->enfoconsspos = -1;
1064 
1065  checkConssArrays(conshdlr);
1066 }
1067 
1068 /** adds constraint to the checkconss array of constraint handler */
1069 static
1071  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1072  SCIP_SET* set, /**< global SCIP settings */
1073  SCIP_CONS* cons /**< constraint to add */
1074  )
1075 {
1076  int insertpos;
1077 
1078  assert(conshdlr != NULL);
1079  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1080  assert(cons != NULL);
1081  assert(cons->conshdlr == conshdlr);
1082  assert(!cons->original);
1083  assert(cons->active);
1084  assert(cons->check);
1085  assert(cons->checkconsspos == -1);
1086  assert(set != NULL);
1087  assert(cons->scip == set->scip);
1088 
1089  SCIP_CALL( conshdlrEnsureCheckconssMem(conshdlr, set, conshdlr->ncheckconss+1) );
1090  insertpos = conshdlr->ncheckconss;
1091  if( !cons->obsolete )
1092  {
1093  if( conshdlr->nusefulcheckconss < conshdlr->ncheckconss )
1094  {
1095  assert(conshdlr->checkconss[conshdlr->nusefulcheckconss] != NULL);
1096  conshdlr->checkconss[conshdlr->ncheckconss] = conshdlr->checkconss[conshdlr->nusefulcheckconss];
1097  conshdlr->checkconss[conshdlr->ncheckconss]->checkconsspos = conshdlr->ncheckconss;
1098  insertpos = conshdlr->nusefulcheckconss;
1099  }
1100  conshdlr->nusefulcheckconss++;
1101  }
1102  assert(0 <= insertpos && insertpos <= conshdlr->ncheckconss);
1103  conshdlr->checkconss[insertpos] = cons;
1104  cons->checkconsspos = insertpos;
1105  conshdlr->ncheckconss++;
1106 
1107  checkConssArrays(conshdlr);
1108 
1109  return SCIP_OKAY;
1110 }
1111 
1112 /** deletes constraint from the checkconss array of constraint handler */
1113 static
1115  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1116  SCIP_CONS* cons /**< constraint to add */
1117  )
1118 {
1119  int delpos;
1120 
1121  assert(conshdlr != NULL);
1122  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1123  assert(cons != NULL);
1124  assert(cons->conshdlr == conshdlr);
1125  assert(!cons->original);
1126  assert(cons->active);
1127  assert(cons->check);
1128  assert(cons->checkconsspos != -1);
1129 
1130  delpos = cons->checkconsspos;
1131  if( !cons->obsolete )
1132  {
1133  assert(0 <= delpos && delpos < conshdlr->nusefulcheckconss);
1134  conshdlr->checkconss[delpos] = conshdlr->checkconss[conshdlr->nusefulcheckconss-1];
1135  conshdlr->checkconss[delpos]->checkconsspos = delpos;
1136  delpos = conshdlr->nusefulcheckconss-1;
1137  conshdlr->nusefulcheckconss--;
1138  }
1139  assert(conshdlr->nusefulcheckconss <= delpos && delpos < conshdlr->ncheckconss);
1140  if( delpos < conshdlr->ncheckconss-1 )
1141  {
1142  conshdlr->checkconss[delpos] = conshdlr->checkconss[conshdlr->ncheckconss-1];
1143  conshdlr->checkconss[delpos]->checkconsspos = delpos;
1144  }
1145  conshdlr->ncheckconss--;
1146  cons->checkconsspos = -1;
1147 
1148  checkConssArrays(conshdlr);
1149 }
1150 
1151 /** adds constraint to the propconss array of constraint handler */
1152 static
1154  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1155  SCIP_SET* set, /**< global SCIP settings */
1156  SCIP_CONS* cons /**< constraint to add */
1157  )
1158 {
1159  int insertpos;
1160 
1161  assert(conshdlr != NULL);
1162  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1163  assert(cons != NULL);
1164  assert(cons->conshdlr == conshdlr);
1165  assert(!cons->original);
1166  assert(cons->active);
1167  assert(cons->enabled);
1168  assert(cons->propagate);
1169  assert(cons->propenabled);
1170  assert(cons->propconsspos == -1);
1171  assert(set != NULL);
1172  assert(cons->scip == set->scip);
1173  assert(!conshdlrAreUpdatesDelayed(conshdlr) || !conshdlr->duringprop);
1174 
1175  /* add constraint to the propagation array */
1176  SCIP_CALL( conshdlrEnsurePropconssMem(conshdlr, set, conshdlr->npropconss+1) );
1177  insertpos = conshdlr->npropconss;
1178  if( !cons->obsolete )
1179  {
1180  if( conshdlr->nusefulpropconss < conshdlr->npropconss )
1181  {
1182  conshdlr->propconss[conshdlr->npropconss] = conshdlr->propconss[conshdlr->nusefulpropconss];
1183  conshdlr->propconss[conshdlr->npropconss]->propconsspos = conshdlr->npropconss;
1184  insertpos = conshdlr->nusefulpropconss;
1185  }
1186  conshdlr->nusefulpropconss++;
1187  }
1188  conshdlr->propconss[insertpos] = cons;
1189  cons->propconsspos = insertpos;
1190  conshdlr->npropconss++;
1191 
1192  /* if the constraint is marked to be propagated, we have to move it to the first part of the array */
1193  if( cons->markpropagate )
1194  {
1195  /* temporarily unmark the constraint to be propagated, such that we can use the method below */
1196  cons->markpropagate = FALSE;
1197 
1198  conshdlrMarkConsPropagate(cons->conshdlr, cons);
1199  assert(cons->markpropagate);
1200  }
1201 
1202  checkConssArrays(conshdlr);
1203 
1204  return SCIP_OKAY;
1205 }
1206 
1207 /** deletes constraint from the propconss array of constraint handler */
1208 static
1209 void conshdlrDelPropcons(
1210  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1211  SCIP_CONS* cons /**< constraint to remove */
1212  )
1213 {
1214  int delpos;
1215 
1216  assert(conshdlr != NULL);
1217  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1218  assert(cons != NULL);
1219  assert(cons->conshdlr == conshdlr);
1220  assert(!cons->original);
1221  assert(cons->propagate);
1222  assert(cons->propenabled);
1223  assert(cons->propconsspos != -1);
1224  assert(!conshdlrAreUpdatesDelayed(conshdlr) || !conshdlr->duringprop);
1225 
1226  /* unmark constraint to be propagated; this will move the constraint to the obsolete or non-obsolete part of the
1227  * array, depending on its age
1228  */
1229  if( cons->markpropagate )
1230  {
1232  assert(!cons->markpropagate);
1233  }
1234 
1235  /* delete constraint from the propagation array */
1236  delpos = cons->propconsspos;
1237  assert(delpos >= conshdlr->nmarkedpropconss);
1238  if( !cons->obsolete )
1239  {
1240  assert(0 <= delpos && delpos < conshdlr->nusefulpropconss);
1241 
1242  if( delpos < conshdlr->lastnusefulpropconss )
1243  conshdlr->lastnusefulpropconss--;
1244 
1245  conshdlr->propconss[delpos] = conshdlr->propconss[conshdlr->nusefulpropconss-1];
1246  conshdlr->propconss[delpos]->propconsspos = delpos;
1247  delpos = conshdlr->nusefulpropconss-1;
1248  conshdlr->nusefulpropconss--;
1249  assert(conshdlr->nusefulpropconss >= 0);
1250  assert(conshdlr->lastnusefulpropconss >= 0);
1251  }
1252  assert(conshdlr->nusefulpropconss <= delpos && delpos < conshdlr->npropconss);
1253 
1254  if( delpos < conshdlr->npropconss-1 )
1255  {
1256  conshdlr->propconss[delpos] = conshdlr->propconss[conshdlr->npropconss-1];
1257  conshdlr->propconss[delpos]->propconsspos = delpos;
1258  }
1259  conshdlr->npropconss--;
1260  cons->propconsspos = -1;
1261 
1262  checkConssArrays(conshdlr);
1263 }
1264 
1265 /** enables separation of constraint */
1266 static
1268  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1269  SCIP_SET* set, /**< global SCIP settings */
1270  SCIP_CONS* cons /**< constraint to add */
1271  )
1272 {
1273  assert(conshdlr != NULL);
1274  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1275  assert(cons != NULL);
1276  assert(cons->conshdlr == conshdlr);
1277  assert(!cons->sepaenabled);
1278  assert(cons->sepaconsspos == -1);
1279  assert(set != NULL);
1280  assert(cons->scip == set->scip);
1281 
1282  SCIPdebugMessage("enable separation of constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1283 
1284  /* enable separation of constraint */
1285  cons->sepaenabled = TRUE;
1286 
1287  /* add constraint to the separation array */
1288  if( cons->enabled && cons->separate )
1289  {
1290  SCIP_CALL( conshdlrAddSepacons(conshdlr, set, cons) );
1291  }
1292 
1293  return SCIP_OKAY;
1294 }
1295 
1296 /** disables separation of constraint */
1297 static
1299  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1300  SCIP_CONS* cons /**< constraint to remove */
1301  )
1302 {
1303  assert(conshdlr != NULL);
1304  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1305  assert(cons != NULL);
1306  assert(cons->conshdlr == conshdlr);
1307  assert(cons->sepaenabled);
1308  assert((cons->separate && cons->enabled) == (cons->sepaconsspos != -1));
1309 
1310  SCIPdebugMessage("disable separation of constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1311 
1312  /* delete constraint from the separation array */
1313  if( cons->separate && cons->enabled )
1314  {
1315  conshdlrDelSepacons(conshdlr, cons);
1316  }
1317  assert(cons->sepaconsspos == -1);
1318 
1319  /* disable separation of constraint */
1320  cons->sepaenabled = FALSE;
1321 
1322  return SCIP_OKAY;
1323 }
1324 
1325 /** enables propagation of constraint */
1326 static
1328  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1329  SCIP_SET* set, /**< global SCIP settings */
1330  SCIP_CONS* cons /**< constraint to add */
1331  )
1332 {
1333  assert(conshdlr != NULL);
1334  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1335  assert(cons != NULL);
1336  assert(cons->conshdlr == conshdlr);
1337  assert(!cons->propenabled);
1338  assert(cons->propconsspos == -1);
1339  assert(set != NULL);
1340  assert(cons->scip == set->scip);
1341 
1342  SCIPdebugMessage("enable propagation of constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1343 
1344  /* enable propagation of constraint */
1345  cons->propenabled = TRUE;
1346 
1347  /* add constraint to the propagation array */
1348  if( cons->enabled && cons->propagate )
1349  {
1350  SCIP_CALL( conshdlrAddPropcons(conshdlr, set, cons) );
1351  }
1352 
1353  return SCIP_OKAY;
1354 }
1355 
1356 /** disables propagation of constraint */
1357 static
1359  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1360  SCIP_CONS* cons /**< constraint to remove */
1361  )
1362 {
1363  assert(conshdlr != NULL);
1364  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1365  assert(cons != NULL);
1366  assert(cons->conshdlr == conshdlr);
1367  assert(cons->propenabled);
1368  assert((cons->propagate && cons->enabled) == (cons->propconsspos != -1));
1369 
1370  SCIPdebugMessage("disable propagation of constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1371 
1372  /* delete constraint from the propagation array */
1373  if( cons->propagate && cons->enabled )
1374  {
1375  conshdlrDelPropcons(conshdlr, cons);
1376  }
1377  assert(cons->propconsspos == -1);
1378 
1379  /* disable propagation of constraint */
1380  cons->propenabled = FALSE;
1381 
1382  return SCIP_OKAY;
1383 }
1384 
1385 /** enables separation, enforcement, and propagation of constraint */
1386 static
1388  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1389  SCIP_SET* set, /**< global SCIP settings */
1390  SCIP_STAT* stat, /**< dynamic problem statistics */
1391  SCIP_CONS* cons /**< constraint to add */
1392  )
1393 {
1394  assert(conshdlr != NULL);
1395  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1396  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1397  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1398  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1399  assert(set != NULL);
1400  assert(stat != NULL);
1401  assert(cons != NULL);
1402  assert(cons->scip == set->scip);
1403  assert(cons->conshdlr == conshdlr);
1404  assert(!cons->original);
1405  assert(cons->active);
1406  assert(!cons->enabled);
1407  assert(cons->sepaconsspos == -1);
1408  assert(cons->enfoconsspos == -1);
1409  assert(cons->propconsspos == -1);
1410 
1411  SCIPdebugMessage("enable constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1412 
1413  /* enable constraint */
1414  cons->enabled = TRUE;
1415  conshdlr->nenabledconss++;
1416  stat->nenabledconss++;
1417 
1418  /* add constraint to the separation array */
1419  if( cons->separate && cons->sepaenabled )
1420  {
1421  SCIP_CALL( conshdlrAddSepacons(conshdlr, set, cons) );
1422  }
1423 
1424  /* add constraint to the enforcement array */
1425  if( cons->enforce )
1426  {
1427  SCIP_CALL( conshdlrAddEnfocons(conshdlr, set, cons) );
1428  }
1429 
1430  /* add constraint to the propagation array */
1431  if( cons->propagate && cons->propenabled )
1432  {
1433  SCIP_CALL( conshdlrAddPropcons(conshdlr, set, cons) );
1434  }
1435 
1436  /* call constraint handler's enabling notification method */
1437  if( conshdlr->consenable != NULL )
1438  {
1439  SCIP_CALL( conshdlr->consenable(set->scip, conshdlr, cons) );
1440  }
1441 
1442  checkConssArrays(conshdlr);
1443 
1444  return SCIP_OKAY;
1445 }
1446 
1447 /** disables separation, enforcement, and propagation of constraint */
1448 static
1450  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1451  SCIP_SET* set, /**< global SCIP settings */
1452  SCIP_STAT* stat, /**< dynamic problem statistics */
1453  SCIP_CONS* cons /**< constraint to remove */
1454  )
1455 {
1456  assert(conshdlr != NULL);
1457  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1458  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1459  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1460  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1461  assert(set != NULL);
1462  assert(stat != NULL);
1463  assert(cons != NULL);
1464  assert(cons->scip == set->scip);
1465  assert(cons->conshdlr == conshdlr);
1466  assert(!cons->original);
1467  assert(cons->active);
1468  assert(cons->enabled);
1469  assert((cons->separate && cons->sepaenabled) == (cons->sepaconsspos != -1));
1470  assert(cons->enforce == (cons->enfoconsspos != -1));
1471  assert((cons->propagate && cons->propenabled) == (cons->propconsspos != -1));
1472 
1473  SCIPdebugMessage("disable constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1474 
1475  /* call constraint handler's disabling notification method */
1476  if( conshdlr->consdisable != NULL )
1477  {
1478  SCIP_CALL( conshdlr->consdisable(set->scip, conshdlr, cons) );
1479  }
1480 
1481  /* delete constraint from the separation array */
1482  if( cons->separate && cons->sepaenabled )
1483  {
1484  conshdlrDelSepacons(conshdlr, cons);
1485  }
1486 
1487  /* delete constraint from the enforcement array */
1488  if( cons->enforce )
1489  {
1490  conshdlrDelEnfocons(conshdlr, cons);
1491  }
1492 
1493  /* delete constraint from the propagation array */
1494  if( cons->propagate && cons->propenabled )
1495  {
1496  conshdlrDelPropcons(conshdlr, cons);
1497  }
1498 
1499  assert(cons->sepaconsspos == -1);
1500  assert(cons->enfoconsspos == -1);
1501  assert(cons->propconsspos == -1);
1502 
1503  /* disable constraint */
1504  cons->enabled = FALSE;
1505  conshdlr->nenabledconss--;
1506  stat->nenabledconss--;
1507 
1508  checkConssArrays(conshdlr);
1509 
1510  return SCIP_OKAY;
1511 }
1512 
1513 /** activates and adds constraint to constraint handler's constraint arrays */
1514 static
1516  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1517  SCIP_SET* set, /**< global SCIP settings */
1518  SCIP_STAT* stat, /**< dynamic problem statistics */
1519  SCIP_CONS* cons, /**< constraint to add */
1520  int depth, /**< depth in the tree where the activation takes place, or -1 for global problem */
1521  SCIP_Bool focusnode /**< does the constraint activation take place at the focus node? */
1522  )
1523 {
1524  assert(conshdlr != NULL);
1525  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1526  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1527  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1528  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1529  assert(set != NULL);
1530  assert(stat != NULL);
1531  assert(cons != NULL);
1532  assert(cons->scip == set->scip);
1533  assert(cons->conshdlr == conshdlr);
1534  assert(!cons->original);
1535  assert(!cons->active);
1536  assert(!cons->enabled);
1537  assert(conshdlr->nactiveconss <= cons->consspos && cons->consspos < conshdlr->nconss);
1538  assert(conshdlr->conss[cons->consspos] == cons);
1539  assert(cons->initconsspos < conshdlr->ninitconsskept);
1540  assert(cons->sepaconsspos == -1);
1541  assert(cons->enfoconsspos == -1);
1542  assert(cons->checkconsspos == -1);
1543  assert(cons->propconsspos == -1);
1544  assert(depth >= -1);
1545 
1546  SCIPdebugMessage("activate constraint <%s> in constraint handler <%s> (depth %d, focus=%u)\n",
1547  cons->name, conshdlr->name, depth, focusnode);
1548 
1549  /* activate constraint, switch positions with first inactive constraint */
1550  cons->active = TRUE;
1551  cons->activedepth = depth;
1552  conshdlr->conss[cons->consspos] = conshdlr->conss[conshdlr->nactiveconss];
1553  conshdlr->conss[cons->consspos]->consspos = cons->consspos;
1554  conshdlr->conss[conshdlr->nactiveconss] = cons;
1555  cons->consspos = conshdlr->nactiveconss;
1556  conshdlr->nactiveconss++;
1557  conshdlr->maxnactiveconss = MAX(conshdlr->maxnactiveconss, conshdlr->nactiveconss);
1558  stat->nactiveconss++;
1559 
1560  /* add constraint to the check array */
1561  if( cons->check )
1562  {
1563  SCIP_CALL( conshdlrAddCheckcons(conshdlr, set, cons) );
1564  }
1565 
1566  /* add constraint to the initconss array if the constraint is initial and added to the focus node */
1567  if( cons->initial )
1568  {
1569  SCIP_CALL( conshdlrAddInitcons(conshdlr, set, stat, cons) );
1570  }
1571 
1572  /* call constraint handler's activation notification method */
1573  if( conshdlr->consactive != NULL )
1574  {
1575  SCIP_CALL( conshdlr->consactive(set->scip, conshdlr, cons) );
1576  }
1577 
1578  /* enable separation, enforcement, and propagation of constraint */
1579  SCIP_CALL( conshdlrEnableCons(conshdlr, set, stat, cons) );
1580 
1581  assert(0 <= cons->consspos && cons->consspos < conshdlr->nactiveconss);
1582 
1583  checkConssArrays(conshdlr);
1584 
1585  return SCIP_OKAY;
1586 }
1587 
1588 /** deactivates and removes constraint from constraint handler's conss array */
1589 static
1591  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1592  SCIP_SET* set, /**< global SCIP settings */
1593  SCIP_STAT* stat, /**< dynamic problem statistics */
1594  SCIP_CONS* cons /**< constraint to remove */
1595  )
1596 {
1597  assert(conshdlr != NULL);
1598  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1599  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1600  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1601  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1602  assert(set != NULL);
1603  assert(stat != NULL);
1604  assert(cons != NULL);
1605  assert(cons->scip == set->scip);
1606  assert(cons->conshdlr == conshdlr);
1607  assert(!cons->original);
1608  assert(cons->active);
1609  assert(0 <= cons->consspos && cons->consspos < conshdlr->nactiveconss);
1610  assert(conshdlr->conss[cons->consspos] == cons);
1611  assert(cons->check == (cons->checkconsspos != -1));
1612 
1613  SCIPdebugMessage("deactivate constraint <%s> in constraint handler <%s>\n", cons->name, conshdlr->name);
1614 
1615  /* disable constraint */
1616  if( cons->enabled )
1617  {
1618  SCIP_CALL( conshdlrDisableCons(conshdlr, set, stat, cons) );
1619  }
1620  assert(!cons->enabled);
1621 
1622  /* call constraint handler's deactivation notification method */
1623  if( conshdlr->consdeactive != NULL )
1624  {
1625  SCIP_CALL( conshdlr->consdeactive(set->scip, conshdlr, cons) );
1626  }
1627 
1628  /* delete constraint from the initconss array */
1629  if( cons->initconsspos >= 0 )
1630  {
1631  conshdlrDelInitcons(conshdlr, cons);
1632  }
1633 
1634  /* delete constraint from the check array */
1635  if( cons->check )
1636  {
1637  conshdlrDelCheckcons(conshdlr, cons);
1638  }
1639 
1640  /* switch constraint with the last active constraint in the conss array */
1641  conshdlr->conss[cons->consspos] = conshdlr->conss[conshdlr->nactiveconss-1];
1642  conshdlr->conss[cons->consspos]->consspos = cons->consspos;
1643  conshdlr->conss[conshdlr->nactiveconss-1] = cons;
1644  cons->consspos = conshdlr->nactiveconss-1;
1645  conshdlr->nactiveconss--;
1646  cons->active = FALSE;
1647  cons->activedepth = -2;
1648  stat->nactiveconss--;
1649 
1650  assert(conshdlr->nactiveconss <= cons->consspos && cons->consspos < conshdlr->nconss);
1651  assert(cons->initconsspos == -1);
1652  assert(cons->sepaconsspos == -1);
1653  assert(cons->enfoconsspos == -1);
1654  assert(cons->checkconsspos == -1);
1655  assert(cons->propconsspos == -1);
1656 
1657  checkConssArrays(conshdlr);
1658 
1659  return SCIP_OKAY;
1660 }
1661 
1662 /** processes all delayed updates of constraints:
1663  * recently (de)activated constraints will be (de)activated;
1664  * recently en/disabled constraints will be en/disabled;
1665  * recent obsolete non-check constraints will be globally deleted;
1666  * recent obsolete check constraints will be moved to the last positions in the sepa-, enfo-, check-, and prop-arrays;
1667  * recent useful constraints will be moved to the first positions in the sepa-, enfo-, check-, and prop-arrays;
1668  * constraints which were recently marked to be propagated are moved to the first positions in the prop-array;
1669  * no longer used constraints will be freed and removed from the conss array
1670  */
1671 static
1673  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1674  BMS_BLKMEM* blkmem, /**< block memory */
1675  SCIP_SET* set, /**< global SCIP settings */
1676  SCIP_STAT* stat /**< dynamic problem statistics */
1677  )
1678 {
1679  SCIP_CONS* cons;
1680  int i;
1681 
1682  assert(conshdlr != NULL);
1683  assert(!conshdlrAreUpdatesDelayed(conshdlr));
1684  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
1685  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
1686  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
1687  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
1688 
1689  SCIPdebugMessage("processing %d constraints that have to be updated in constraint handler <%s>\n",
1690  conshdlr->nupdateconss, conshdlr->name);
1691 
1692  for( i = conshdlr->nupdateconss - 1; i >= 0; --i )
1693  {
1694  cons = conshdlr->updateconss[i];
1695  assert(cons != NULL);
1696  assert(cons->conshdlr == conshdlr);
1697  assert(cons->update);
1698  assert(cons->updateinsert || cons->updateactivate || cons->updatedeactivate
1699  || cons->updateenable || cons->updatedisable
1700  || cons->updatesepaenable || cons->updatesepadisable
1701  || cons->updatepropenable || cons->updatepropdisable
1702  || cons->updateobsolete || cons->updatefree
1703  || cons->updatemarkpropagate || cons->updateunmarkpropagate);
1704 
1705  SCIPdebugMessage(" -> constraint <%s>: insert=%u, activate=%u, deactivate=%u, enable=%u, disable=%u, sepaenable=%u, sepadisable=%u, propenable=%u, propdisable=%u, obsolete=%u, free=%u (consdata=%p)\n",
1706  cons->name, cons->updateinsert, cons->updateactivate, cons->updatedeactivate,
1707  cons->updateenable, cons->updatedisable,
1708  cons->updatesepaenable, cons->updatesepadisable,
1709  cons->updatepropenable, cons->updatepropdisable,
1710  cons->updateobsolete, cons->updatefree, (void*)cons->consdata);
1711 
1712  if( cons->updateinsert )
1713  {
1714  SCIP_CALL( conshdlrAddCons(conshdlr, set, cons) );
1715  cons->updateinsert = FALSE;
1716  }
1717 
1718  if( cons->updateactivate )
1719  {
1720  assert(!cons->active);
1721  assert(!cons->updatedeactivate);
1722  assert(!cons->updateenable);
1723  assert(!cons->updatedisable);
1724  assert(!cons->updateobsolete);
1725  assert(!cons->updatefree);
1726 
1727  /* the activation depth was already stored in SCIPconsActivate() */
1728  SCIP_CALL( conshdlrActivateCons(conshdlr, set, stat, cons, cons->activedepth, cons->updateactfocus) );
1729  assert(cons->active);
1730  cons->updateactivate = FALSE;
1731  }
1732  else if( cons->updatedeactivate )
1733  {
1734  assert(cons->active);
1735 
1736  SCIP_CALL( conshdlrDeactivateCons(conshdlr, set, stat, cons) );
1737  assert(!cons->active);
1738  cons->updatedeactivate = FALSE;
1739  cons->updateenable = FALSE;
1740  cons->updatedisable = FALSE;
1741  cons->obsolete = consExceedsObsoleteage(cons, set);
1742  cons->updateobsolete = FALSE;
1743  }
1744  else if( cons->updateenable )
1745  {
1746  assert(!cons->enabled);
1747  assert(!cons->updatedisable);
1748 
1749  SCIP_CALL( conshdlrEnableCons(conshdlr, set, stat, cons) );
1750  assert(cons->enabled);
1751  cons->updateenable = FALSE;
1752  }
1753  else if( cons->updatedisable )
1754  {
1755  assert(cons->enabled);
1756 
1757  SCIP_CALL( conshdlrDisableCons(conshdlr, set, stat, cons) );
1758  assert(!cons->enabled);
1759  cons->updatedisable = FALSE;
1760  }
1761 
1762  if( cons->updatesepaenable )
1763  {
1764  assert(!cons->updatesepadisable);
1765  if( !cons->sepaenabled )
1766  {
1767  SCIP_CALL( conshdlrEnableConsSeparation(conshdlr, set, cons) );
1768  assert(cons->sepaenabled);
1769  }
1770  cons->updatesepaenable = FALSE;
1771  }
1772  else if( cons->updatesepadisable )
1773  {
1774  if( cons->sepaenabled )
1775  {
1776  SCIP_CALL( conshdlrDisableConsSeparation(conshdlr, cons) );
1777  assert(!cons->sepaenabled);
1778  }
1779  cons->updatesepadisable = FALSE;
1780  }
1781 
1782  if( cons->updatepropenable )
1783  {
1784  assert(!cons->updatepropdisable);
1785  if( !cons->propenabled )
1786  {
1787  SCIP_CALL( conshdlrEnableConsPropagation(conshdlr, set, cons) );
1788  assert(cons->propenabled);
1789  }
1790  cons->updatepropenable = FALSE;
1791  }
1792  else if( cons->updatepropdisable )
1793  {
1794  if( cons->propenabled )
1795  {
1796  SCIP_CALL( conshdlrDisableConsPropagation(conshdlr, cons) );
1797  assert(!cons->propenabled);
1798  }
1799  cons->updatepropdisable = FALSE;
1800  }
1801 
1802  if( cons->updatefree )
1803  {
1804  /* nothing to do here: the constraint is freed, when it is released from the updateconss array */
1805  assert(cons->nuses == 1); /* it only exists in the updateconss array */
1806  cons->updatefree = FALSE;
1807  cons->updateobsolete = FALSE;
1808  }
1809  else
1810  {
1811  if( cons->updateobsolete )
1812  {
1813  if( !cons->obsolete && consExceedsObsoleteage(cons, set) )
1814  {
1815  /* the constraint's status must be switched to obsolete */
1816  SCIP_CALL( conshdlrMarkConsObsolete(conshdlr, cons) );
1817  }
1818  else if( cons->obsolete && !consExceedsObsoleteage(cons, set) )
1819  {
1820  /* the constraint's status must be switched to useful */
1821  SCIP_CALL( conshdlrMarkConsUseful(conshdlr, cons) );
1822  }
1823  cons->updateobsolete = FALSE;
1824  }
1825 
1826  if( cons->updatemarkpropagate )
1827  {
1828  /* the constraint must be marked to be propagated */
1829  conshdlrMarkConsPropagate(conshdlr, cons);
1830  cons->updatemarkpropagate = FALSE;
1831  }
1832  else if( cons->updateunmarkpropagate )
1833  {
1834  /* the constraint must be unmarked to be propagated */
1835  conshdlrUnmarkConsPropagate(conshdlr, cons);
1836  cons->updateunmarkpropagate = FALSE;
1837  }
1838  }
1839 
1840  assert(!cons->updateinsert);
1841  assert(!cons->updateactivate);
1842  assert(!cons->updatedeactivate);
1843  assert(!cons->updateenable);
1844  assert(!cons->updatedisable);
1845  assert(!cons->updatesepaenable);
1846  assert(!cons->updatesepadisable);
1847  assert(!cons->updatepropenable);
1848  assert(!cons->updatepropdisable);
1849  assert(!cons->updateobsolete);
1850  assert(!cons->updatemarkpropagate);
1851  assert(!cons->updateunmarkpropagate);
1852  assert(!cons->updatefree);
1853  cons->update = FALSE;
1854 
1855  /* release the constraint */
1856  SCIP_CALL( SCIPconsRelease(&conshdlr->updateconss[i], blkmem, set) );
1857  }
1858 
1859  conshdlr->nupdateconss = 0;
1860 
1861  return SCIP_OKAY;
1862 }
1863 
1864 /** marks constraint handler to delay all constraint updates until the next conshdlrProcessUpdates() call */
1865 static
1867  SCIP_CONSHDLR* conshdlr /**< constraint handler */
1868  )
1869 {
1870  assert(conshdlr != NULL);
1871 
1872  SCIPdebugMessage("constraint updates of constraint handler <%s> will be delayed (count:%d)\n",
1873  conshdlr->name, conshdlr->delayupdatecount+1);
1874 
1875  conshdlr->delayupdatecount++;
1876 }
1877 
1878 /** marks constraint handler to perform all constraint updates immediately;
1879  * all delayed constraint updates will be processed
1880  */
1881 static
1883  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1884  BMS_BLKMEM* blkmem, /**< block memory */
1885  SCIP_SET* set, /**< global SCIP settings */
1886  SCIP_STAT* stat /**< dynamic problem statistics */
1887  )
1888 {
1889  assert(conshdlr != NULL);
1890  assert(conshdlrAreUpdatesDelayed(conshdlr));
1891 
1892  SCIPdebugMessage("constraint updates of constraint handler <%s> will be processed immediately (count:%d)\n",
1893  conshdlr->name, conshdlr->delayupdatecount);
1894  conshdlr->delayupdatecount--;
1895 
1896  /* only run the update if all delays are taken away (reference counting) */
1897  if( !conshdlrAreUpdatesDelayed(conshdlr) )
1898  {
1899  SCIP_CALL( conshdlrProcessUpdates(conshdlr, blkmem, set, stat) );
1900  assert(conshdlr->nupdateconss == 0);
1901  }
1902 
1903  return SCIP_OKAY;
1904 }
1905 
1906 /** adds constraint to constraint handler's update constraint array and captures it */
1907 static
1909  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1910  SCIP_SET* set, /**< global SCIP settings */
1911  SCIP_CONS* cons /**< constraint to add */
1912  )
1913 {
1914  assert(conshdlr != NULL);
1915  assert(set != NULL);
1916  assert(cons != NULL);
1917  assert(cons->conshdlr == conshdlr);
1918 
1919  if( !cons->update )
1920  {
1921  SCIPdebugMessage("constraint <%s> of age %g has to be updated in constraint handler <%s> (consdata=%p)\n",
1922  cons->name, cons->age, conshdlr->name, (void*)cons->consdata);
1923 
1924  /* add constraint to the updateconss array */
1925  SCIP_CALL( conshdlrEnsureUpdateconssMem(conshdlr, set, conshdlr->nupdateconss+1) );
1926  conshdlr->updateconss[conshdlr->nupdateconss] = cons;
1927  conshdlr->nupdateconss++;
1928 
1929  /* capture constraint */
1930  SCIPconsCapture(cons);
1931 
1932  cons->update = TRUE;
1933  }
1934 
1935  return SCIP_OKAY;
1936 }
1937 
1938 /** compares two constraint handlers w. r. to their separation priority */
1939 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompSepa)
1940 { /*lint --e{715}*/
1941  return ((SCIP_CONSHDLR*)elem2)->sepapriority - ((SCIP_CONSHDLR*)elem1)->sepapriority;
1942 }
1943 
1944 /** compares two constraint handlers w. r. to their enforcing priority */
1945 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompEnfo)
1946 { /*lint --e{715}*/
1947  return ((SCIP_CONSHDLR*)elem2)->enfopriority - ((SCIP_CONSHDLR*)elem1)->enfopriority;
1948 }
1949 
1950 /** compares two constraint handlers w. r. to their feasibility check priority */
1951 SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompCheck)
1952 { /*lint --e{715}*/
1953  return ((SCIP_CONSHDLR*)elem2)->checkpriority - ((SCIP_CONSHDLR*)elem1)->checkpriority;
1954 }
1955 
1956 /** copies the given constraint handler to a new scip */
1958  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
1959  SCIP_SET* set, /**< SCIP_SET of SCIP to copy to */
1960  SCIP_Bool* valid /**< was the copying process valid? */
1961  )
1962 {
1963  assert(conshdlr != NULL);
1964  assert(set != NULL);
1965  assert(valid != NULL);
1966  assert(set->scip != NULL);
1967 
1968  if( conshdlr->conshdlrcopy != NULL )
1969  {
1970  SCIPdebugMessage("including constraint handler %s in subscip %p\n", SCIPconshdlrGetName(conshdlr), (void*)set->scip);
1971  SCIP_CALL( conshdlr->conshdlrcopy(set->scip, conshdlr, valid) );
1972  }
1973 
1974  return SCIP_OKAY;
1975 }
1976 
1977 /** creates a constraint handler */
1979  SCIP_CONSHDLR** conshdlr, /**< pointer to constraint handler data structure */
1980  SCIP_SET* set, /**< global SCIP settings */
1981  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1982  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
1983  const char* name, /**< name of constraint handler */
1984  const char* desc, /**< description of constraint handler */
1985  int sepapriority, /**< priority of the constraint handler for separation */
1986  int enfopriority, /**< priority of the constraint handler for constraint enforcing */
1987  int checkpriority, /**< priority of the constraint handler for checking feasibility (and propagation) */
1988  int sepafreq, /**< frequency for separating cuts; zero means to separate only in the root node */
1989  int propfreq, /**< frequency for propagating domains; zero means only preprocessing propagation */
1990  int eagerfreq, /**< frequency for using all instead of only the useful constraints in separation,
1991  * propagation and enforcement, -1 for no eager evaluations, 0 for first only */
1992  int maxprerounds, /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
1993  SCIP_Bool delaysepa, /**< should separation method be delayed, if other separators found cuts? */
1994  SCIP_Bool delayprop, /**< should propagation method be delayed, if other propagators found reductions? */
1995  SCIP_Bool delaypresol, /**< should presolving method be delayed, if other presolvers found reductions? */
1996  SCIP_Bool needscons, /**< should the constraint handler be skipped, if no constraints are available? */
1997  SCIP_PROPTIMING timingmask, /**< positions in the node solving loop where propagation method of constraint handlers should be executed */
1998  SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), /**< copy method of constraint handler or NULL if you don't want to copy your plugin into sub-SCIPs */
1999  SCIP_DECL_CONSFREE ((*consfree)), /**< destructor of constraint handler */
2000  SCIP_DECL_CONSINIT ((*consinit)), /**< initialize constraint handler */
2001  SCIP_DECL_CONSEXIT ((*consexit)), /**< deinitialize constraint handler */
2002  SCIP_DECL_CONSINITPRE ((*consinitpre)), /**< presolving initialization method of constraint handler */
2003  SCIP_DECL_CONSEXITPRE ((*consexitpre)), /**< presolving deinitialization method of constraint handler */
2004  SCIP_DECL_CONSINITSOL ((*consinitsol)), /**< solving process initialization method of constraint handler */
2005  SCIP_DECL_CONSEXITSOL ((*consexitsol)), /**< solving process deinitialization method of constraint handler */
2006  SCIP_DECL_CONSDELETE ((*consdelete)), /**< free specific constraint data */
2007  SCIP_DECL_CONSTRANS ((*constrans)), /**< transform constraint data into data belonging to the transformed problem */
2008  SCIP_DECL_CONSINITLP ((*consinitlp)), /**< initialize LP with relaxations of "initial" constraints */
2009  SCIP_DECL_CONSSEPALP ((*conssepalp)), /**< separate cutting planes for LP solution */
2010  SCIP_DECL_CONSSEPASOL ((*conssepasol)), /**< separate cutting planes for arbitrary primal solution */
2011  SCIP_DECL_CONSENFOLP ((*consenfolp)), /**< enforcing constraints for LP solutions */
2012  SCIP_DECL_CONSENFOPS ((*consenfops)), /**< enforcing constraints for pseudo solutions */
2013  SCIP_DECL_CONSCHECK ((*conscheck)), /**< check feasibility of primal solution */
2014  SCIP_DECL_CONSPROP ((*consprop)), /**< propagate variable domains */
2015  SCIP_DECL_CONSPRESOL ((*conspresol)), /**< presolving method */
2016  SCIP_DECL_CONSRESPROP ((*consresprop)), /**< propagation conflict resolving method */
2017  SCIP_DECL_CONSLOCK ((*conslock)), /**< variable rounding lock method */
2018  SCIP_DECL_CONSACTIVE ((*consactive)), /**< activation notification method */
2019  SCIP_DECL_CONSDEACTIVE((*consdeactive)), /**< deactivation notification method */
2020  SCIP_DECL_CONSENABLE ((*consenable)), /**< enabling notification method */
2021  SCIP_DECL_CONSDISABLE ((*consdisable)), /**< disabling notification method */
2022  SCIP_DECL_CONSDELVARS ((*consdelvars)), /**< variable deletion method */
2023  SCIP_DECL_CONSPRINT ((*consprint)), /**< constraint display method */
2024  SCIP_DECL_CONSCOPY ((*conscopy)), /**< constraint copying method */
2025  SCIP_DECL_CONSPARSE ((*consparse)), /**< constraint parsing method */
2026  SCIP_DECL_CONSGETVARS ((*consgetvars)), /**< constraint get variables method */
2027  SCIP_DECL_CONSGETNVARS((*consgetnvars)), /**< constraint get number of variable method */
2028  SCIP_CONSHDLRDATA* conshdlrdata /**< constraint handler data */
2029  )
2030 {
2031  char paramname[SCIP_MAXSTRLEN];
2032  char paramdesc[SCIP_MAXSTRLEN];
2033 
2034  assert(conshdlr != NULL);
2035  assert(name != NULL);
2036  assert(desc != NULL);
2037  assert(conssepalp != NULL || conssepasol != NULL || sepafreq == -1);
2038  assert(consprop != NULL || propfreq == -1);
2039  assert(eagerfreq >= -1);
2040  assert(!needscons || ((conshdlrcopy == NULL) == (conscopy == NULL)));
2041 
2042  /* both callbacks have to exist or not exist */
2043  assert((consgetvars != NULL) == (consgetnvars != NULL));
2044 
2045  SCIP_ALLOC( BMSallocMemory(conshdlr) );
2046  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conshdlr)->name, name, strlen(name)+1) );
2047  SCIP_ALLOC( BMSduplicateMemoryArray(&(*conshdlr)->desc, desc, strlen(desc)+1) );
2048  (*conshdlr)->sepapriority = sepapriority;
2049  (*conshdlr)->enfopriority = enfopriority;
2050  (*conshdlr)->checkpriority = checkpriority;
2051  (*conshdlr)->sepafreq = sepafreq;
2052  (*conshdlr)->propfreq = propfreq;
2053  (*conshdlr)->eagerfreq = eagerfreq;
2054  (*conshdlr)->maxprerounds = maxprerounds;
2055  (*conshdlr)->conshdlrcopy = conshdlrcopy;
2056  (*conshdlr)->consfree = consfree;
2057  (*conshdlr)->consinit = consinit;
2058  (*conshdlr)->consexit = consexit;
2059  (*conshdlr)->consinitpre = consinitpre;
2060  (*conshdlr)->consexitpre = consexitpre;
2061  (*conshdlr)->consinitsol = consinitsol;
2062  (*conshdlr)->consexitsol = consexitsol;
2063  (*conshdlr)->consdelete = consdelete;
2064  (*conshdlr)->constrans = constrans;
2065  (*conshdlr)->consinitlp = consinitlp;
2066  (*conshdlr)->conssepalp = conssepalp;
2067  (*conshdlr)->conssepasol = conssepasol;
2068  (*conshdlr)->consenfolp = consenfolp;
2069  (*conshdlr)->consenfops = consenfops;
2070  (*conshdlr)->conscheck = conscheck;
2071  (*conshdlr)->consprop = consprop;
2072  (*conshdlr)->conspresol = conspresol;
2073  (*conshdlr)->consresprop = consresprop;
2074  (*conshdlr)->conslock = conslock;
2075  (*conshdlr)->consactive = consactive;
2076  (*conshdlr)->consdeactive = consdeactive;
2077  (*conshdlr)->consenable = consenable;
2078  (*conshdlr)->consdisable = consdisable;
2079  (*conshdlr)->consprint = consprint;
2080  (*conshdlr)->consdelvars = consdelvars;
2081  (*conshdlr)->conscopy = conscopy;
2082  (*conshdlr)->consparse = consparse;
2083  (*conshdlr)->consgetvars = consgetvars;
2084  (*conshdlr)->consgetnvars = consgetnvars;
2085  (*conshdlr)->conshdlrdata = conshdlrdata;
2086  (*conshdlr)->conss = NULL;
2087  (*conshdlr)->consssize = 0;
2088  (*conshdlr)->nconss = 0;
2089  (*conshdlr)->nactiveconss = 0;
2090  (*conshdlr)->maxnactiveconss = 0;
2091  (*conshdlr)->startnactiveconss = 0;
2092  (*conshdlr)->initconss = NULL;
2093  (*conshdlr)->initconsssize = 0;
2094  (*conshdlr)->ninitconss = 0;
2095  (*conshdlr)->ninitconsskept = 0;
2096  (*conshdlr)->sepaconss = NULL;
2097  (*conshdlr)->sepaconsssize = 0;
2098  (*conshdlr)->nsepaconss = 0;
2099  (*conshdlr)->nusefulsepaconss = 0;
2100  (*conshdlr)->enfoconss = NULL;
2101  (*conshdlr)->enfoconsssize = 0;
2102  (*conshdlr)->nenfoconss = 0;
2103  (*conshdlr)->nusefulenfoconss = 0;
2104  (*conshdlr)->checkconss = NULL;
2105  (*conshdlr)->checkconsssize = 0;
2106  (*conshdlr)->ncheckconss = 0;
2107  (*conshdlr)->nusefulcheckconss = 0;
2108  (*conshdlr)->propconss = NULL;
2109  (*conshdlr)->propconsssize = 0;
2110  (*conshdlr)->npropconss = 0;
2111  (*conshdlr)->nusefulpropconss = 0;
2112  (*conshdlr)->nmarkedpropconss = 0;
2113  (*conshdlr)->updateconss = NULL;
2114  (*conshdlr)->updateconsssize = 0;
2115  (*conshdlr)->nupdateconss = 0;
2116  (*conshdlr)->nenabledconss = 0;
2117  (*conshdlr)->lastnusefulpropconss = 0;
2118  (*conshdlr)->lastnusefulsepaconss = 0;
2119  (*conshdlr)->lastnusefulenfoconss = 0;
2120 
2121  (*conshdlr)->storedpropconss = NULL;
2122  (*conshdlr)->storedpropconsssize = 0;
2123  (*conshdlr)->storednmarkedpropconss = 0;
2124  (*conshdlr)->storedpropdomchgcount = 0;
2125 
2126  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
2127  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->presoltime, SCIP_CLOCKTYPE_DEFAULT) );
2128  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->sepatime, SCIP_CLOCKTYPE_DEFAULT) );
2129  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->enfolptime, SCIP_CLOCKTYPE_DEFAULT) );
2130  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->enfopstime, SCIP_CLOCKTYPE_DEFAULT) );
2131  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->proptime, SCIP_CLOCKTYPE_DEFAULT) );
2132  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->sbproptime, SCIP_CLOCKTYPE_DEFAULT) );
2133  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->checktime, SCIP_CLOCKTYPE_DEFAULT) );
2134  SCIP_CALL( SCIPclockCreate(&(*conshdlr)->resproptime, SCIP_CLOCKTYPE_DEFAULT) );
2135 
2136  (*conshdlr)->nsepacalls = 0;
2137  (*conshdlr)->nenfolpcalls = 0;
2138  (*conshdlr)->nenfopscalls = 0;
2139  (*conshdlr)->npropcalls = 0;
2140  (*conshdlr)->ncheckcalls = 0;
2141  (*conshdlr)->nrespropcalls = 0;
2142  (*conshdlr)->ncutoffs = 0;
2143  (*conshdlr)->ncutsfound = 0;
2144  (*conshdlr)->ncutsapplied = 0;
2145  (*conshdlr)->nconssfound = 0;
2146  (*conshdlr)->ndomredsfound = 0;
2147  (*conshdlr)->nchildren = 0;
2148  (*conshdlr)->lastpropdomchgcount = -1;
2149  (*conshdlr)->lastsepalpcount = -1;
2150  (*conshdlr)->lastenfolplpcount = -1;
2151  (*conshdlr)->lastenfolpdomchgcount = -1;
2152  (*conshdlr)->lastenfopsdomchgcount = -1;
2153  (*conshdlr)->lastenfolpnode = -1;
2154  (*conshdlr)->lastenfopsnode = -1;
2155  (*conshdlr)->lastenfolpresult = SCIP_DIDNOTRUN;
2156  (*conshdlr)->lastenfopsresult = SCIP_DIDNOTRUN;
2157  (*conshdlr)->lastnfixedvars = 0;
2158  (*conshdlr)->lastnaggrvars = 0;
2159  (*conshdlr)->lastnchgvartypes = 0;
2160  (*conshdlr)->lastnchgbds = 0;
2161  (*conshdlr)->lastnaddholes = 0;
2162  (*conshdlr)->lastndelconss = 0;
2163  (*conshdlr)->lastnaddconss = 0;
2164  (*conshdlr)->lastnupgdconss = 0;
2165  (*conshdlr)->lastnchgcoefs = 0;
2166  (*conshdlr)->lastnchgsides = 0;
2167  (*conshdlr)->nfixedvars = 0;
2168  (*conshdlr)->naggrvars = 0;
2169  (*conshdlr)->nchgvartypes = 0;
2170  (*conshdlr)->nchgbds = 0;
2171  (*conshdlr)->naddholes = 0;
2172  (*conshdlr)->ndelconss = 0;
2173  (*conshdlr)->naddconss = 0;
2174  (*conshdlr)->nupgdconss = 0;
2175  (*conshdlr)->nchgcoefs = 0;
2176  (*conshdlr)->nchgsides = 0;
2177  (*conshdlr)->npresolcalls = 0;
2178  (*conshdlr)->delayupdatecount = 0;
2179  (*conshdlr)->ageresetavg = AGERESETAVG_INIT;
2180  (*conshdlr)->needscons = needscons;
2181  (*conshdlr)->sepalpwasdelayed = FALSE;
2182  (*conshdlr)->sepasolwasdelayed = FALSE;
2183  (*conshdlr)->propwasdelayed = FALSE;
2184  (*conshdlr)->presolwasdelayed = FALSE;
2185  (*conshdlr)->duringsepa = FALSE;
2186  (*conshdlr)->duringprop = FALSE;
2187  (*conshdlr)->initialized = FALSE;
2188 
2189  (*conshdlr)->pendingconss = NULL;
2190  SCIP_CALL( SCIPqueueCreate( &((*conshdlr)->pendingconss), 100, 1.5 ) );
2191 
2192  /* add parameters */
2193  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/sepafreq", name);
2194  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname,
2195  "frequency for separating cuts (-1: never, 0: only in root node)",
2196  &(*conshdlr)->sepafreq, FALSE, sepafreq, -1, INT_MAX, NULL, NULL) );
2197 
2198  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/propfreq", name);
2199  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname,
2200  "frequency for propagating domains (-1: never, 0: only in root node)",
2201  &(*conshdlr)->propfreq, FALSE, propfreq, -1, INT_MAX, NULL, NULL) );
2202 
2203  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/timingmask", name);
2204  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "timing when constraint propagation should be called (%u:BEFORELP, %u:DURINGLPLOOP, %u:AFTERLPLOOP, %u:ALWAYS)", SCIP_PROPTIMING_BEFORELP, SCIP_PROPTIMING_DURINGLPLOOP, SCIP_PROPTIMING_AFTERLPLOOP, SCIP_PROPTIMING_ALWAYS);
2205  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
2206  (int*)(&(*conshdlr)->timingmask), TRUE, timingmask, (int) SCIP_PROPTIMING_BEFORELP, (int) SCIP_PROPTIMING_ALWAYS, NULL, NULL) ); /*lint !e713*/
2207 
2208  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/eagerfreq", name);
2209  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname,
2210  "frequency for using all instead of only the useful constraints in separation, propagation and enforcement (-1: never, 0: only in first evaluation)",
2211  &(*conshdlr)->eagerfreq, TRUE, eagerfreq, -1, INT_MAX, NULL, NULL) );
2212 
2213  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxprerounds", name);
2214  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname,
2215  "maximal number of presolving rounds the constraint handler participates in (-1: no limit)",
2216  &(*conshdlr)->maxprerounds, TRUE, maxprerounds, -1, INT_MAX, NULL, NULL) );
2217 
2218  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/delaysepa", name);
2219  SCIP_CALL( SCIPsetAddBoolParam(set, messagehdlr, blkmem, paramname,
2220  "should separation method be delayed, if other separators found cuts?",
2221  &(*conshdlr)->delaysepa, TRUE, delaysepa, NULL, NULL) ); /*lint !e740*/
2222 
2223  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/delayprop", name);
2224  SCIP_CALL( SCIPsetAddBoolParam(set, messagehdlr, blkmem, paramname,
2225  "should propagation method be delayed, if other propagators found reductions?",
2226  &(*conshdlr)->delayprop, TRUE, delayprop, NULL, NULL) ); /*lint !e740*/
2227 
2228  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/delaypresol", name);
2229  SCIP_CALL( SCIPsetAddBoolParam(set, messagehdlr, blkmem, paramname,
2230  "should presolving method be delayed, if other presolvers found reductions?",
2231  &(*conshdlr)->delaypresol, TRUE, delaypresol, NULL, NULL) ); /*lint !e740*/
2232 
2233  return SCIP_OKAY;
2234 }
2235 
2236 /** calls destructor and frees memory of constraint handler */
2238  SCIP_CONSHDLR** conshdlr, /**< pointer to constraint handler data structure */
2239  SCIP_SET* set /**< global SCIP settings */
2240  )
2241 {
2242  assert(conshdlr != NULL);
2243  assert(*conshdlr != NULL);
2244  assert(!(*conshdlr)->initialized);
2245  assert((*conshdlr)->nconss == 0);
2246  assert(set != NULL);
2247 
2248  SCIPqueueFree( &((*conshdlr)->pendingconss) );
2249 
2250  /* call destructor of constraint handler */
2251  if( (*conshdlr)->consfree != NULL )
2252  {
2253  SCIP_CALL( (*conshdlr)->consfree(set->scip, *conshdlr) );
2254  }
2255 
2256  SCIPclockFree(&(*conshdlr)->resproptime);
2257  SCIPclockFree(&(*conshdlr)->checktime);
2258  SCIPclockFree(&(*conshdlr)->sbproptime);
2259  SCIPclockFree(&(*conshdlr)->proptime);
2260  SCIPclockFree(&(*conshdlr)->enfopstime);
2261  SCIPclockFree(&(*conshdlr)->enfolptime);
2262  SCIPclockFree(&(*conshdlr)->sepatime);
2263  SCIPclockFree(&(*conshdlr)->presoltime);
2264  SCIPclockFree(&(*conshdlr)->setuptime);
2265 
2266  BMSfreeMemoryArray(&(*conshdlr)->name);
2267  BMSfreeMemoryArray(&(*conshdlr)->desc);
2268  BMSfreeMemoryArrayNull(&(*conshdlr)->conss);
2269  BMSfreeMemoryArrayNull(&(*conshdlr)->initconss);
2270  BMSfreeMemoryArrayNull(&(*conshdlr)->sepaconss);
2271  BMSfreeMemoryArrayNull(&(*conshdlr)->enfoconss);
2272  BMSfreeMemoryArrayNull(&(*conshdlr)->checkconss);
2273  BMSfreeMemoryArrayNull(&(*conshdlr)->propconss);
2274  BMSfreeMemoryArrayNull(&(*conshdlr)->updateconss);
2275  BMSfreeMemoryArrayNull(&(*conshdlr)->storedpropconss);
2276  BMSfreeMemory(conshdlr);
2277 
2278  return SCIP_OKAY;
2279 }
2280 
2281 /** calls initialization method of constraint handler */
2283  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2284  BMS_BLKMEM* blkmem, /**< block memory */
2285  SCIP_SET* set, /**< global SCIP settings */
2286  SCIP_STAT* stat /**< dynamic problem statistics */
2287  )
2288 {
2289  assert(conshdlr != NULL);
2290  assert(set != NULL);
2291 
2292  if( conshdlr->initialized )
2293  {
2294  SCIPerrorMessage("constraint handler <%s> already initialized\n", conshdlr->name);
2295  return SCIP_INVALIDCALL;
2296  }
2297 
2298  if( set->misc_resetstat )
2299  {
2300  SCIPclockReset(conshdlr->setuptime);
2301  SCIPclockReset(conshdlr->presoltime);
2302  SCIPclockReset(conshdlr->sepatime);
2303  SCIPclockReset(conshdlr->enfolptime);
2304  SCIPclockReset(conshdlr->enfopstime);
2305  SCIPclockReset(conshdlr->proptime);
2306  SCIPclockReset(conshdlr->sbproptime);
2307  SCIPclockReset(conshdlr->checktime);
2308  SCIPclockReset(conshdlr->resproptime);
2309 
2310  conshdlr->nsepacalls = 0;
2311  conshdlr->nenfolpcalls = 0;
2312  conshdlr->nenfopscalls = 0;
2313  conshdlr->npropcalls = 0;
2314  conshdlr->ncheckcalls = 0;
2315  conshdlr->nrespropcalls = 0;
2316  conshdlr->ncutoffs = 0;
2317  conshdlr->ncutsfound = 0;
2318  conshdlr->ncutsapplied = 0;
2319  conshdlr->nconssfound = 0;
2320  conshdlr->ndomredsfound = 0;
2321  conshdlr->nchildren = 0;
2322  conshdlr->lastpropdomchgcount = -1;
2323  conshdlr->lastenfolpdomchgcount = -1;
2324  conshdlr->lastenfopsdomchgcount = -1;
2325  conshdlr->lastenfolpnode = -1;
2326  conshdlr->lastenfopsnode = -1;
2327  conshdlr->lastenfolpresult = SCIP_DIDNOTRUN;
2328  conshdlr->lastenfopsresult = SCIP_DIDNOTRUN;
2329  conshdlr->maxnactiveconss = conshdlr->nactiveconss;
2330  conshdlr->startnactiveconss = 0;
2331  conshdlr->lastsepalpcount = -1;
2332  conshdlr->lastenfolplpcount = -1;
2333  conshdlr->lastnusefulpropconss = 0;
2334  conshdlr->lastnusefulsepaconss = 0;
2335  conshdlr->lastnusefulenfoconss = 0;
2336  conshdlr->lastnfixedvars = 0;
2337  conshdlr->lastnaggrvars = 0;
2338  conshdlr->lastnchgvartypes = 0;
2339  conshdlr->lastnchgbds = 0;
2340  conshdlr->lastnaddholes = 0;
2341  conshdlr->lastndelconss = 0;
2342  conshdlr->lastnaddconss = 0;
2343  conshdlr->lastnupgdconss = 0;
2344  conshdlr->lastnchgcoefs = 0;
2345  conshdlr->lastnchgsides = 0;
2346  conshdlr->nfixedvars = 0;
2347  conshdlr->naggrvars = 0;
2348  conshdlr->nchgvartypes = 0;
2349  conshdlr->nchgbds = 0;
2350  conshdlr->naddholes = 0;
2351  conshdlr->ndelconss = 0;
2352  conshdlr->naddconss = 0;
2353  conshdlr->nupgdconss = 0;
2354  conshdlr->nchgcoefs = 0;
2355  conshdlr->nchgsides = 0;
2356  conshdlr->npresolcalls = 0;
2357  conshdlr->ageresetavg = AGERESETAVG_INIT;
2358  conshdlr->sepalpwasdelayed = FALSE;
2359  conshdlr->sepasolwasdelayed = FALSE;
2360  conshdlr->propwasdelayed = FALSE;
2361  conshdlr->presolwasdelayed = FALSE;
2362  }
2363 
2364  /* call initialization method of constraint handler */
2365  if( conshdlr->consinit != NULL )
2366  {
2367  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2368  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2369  * external method; to avoid this, these changes will be buffered and processed after the method call
2370  */
2371  conshdlrDelayUpdates(conshdlr);
2372 
2373  /* start timing */
2374  SCIPclockStart(conshdlr->setuptime, set);
2375 
2376  /* call external method */
2377  SCIP_CALL( conshdlr->consinit(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
2378 
2379  /* stop timing */
2380  SCIPclockStop(conshdlr->setuptime, set);
2381 
2382  /* perform the cached constraint updates */
2383  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2384  }
2385  conshdlr->initialized = TRUE;
2386  assert(!conshdlrAreUpdatesDelayed(conshdlr));
2387 
2388  return SCIP_OKAY;
2389 }
2390 
2391 /** calls exit method of constraint handler */
2393  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2394  BMS_BLKMEM* blkmem, /**< block memory */
2395  SCIP_SET* set, /**< global SCIP settings */
2396  SCIP_STAT* stat /**< dynamic problem statistics */
2397  )
2398 {
2399  assert(conshdlr != NULL);
2400  assert(set != NULL);
2401 
2402  if( !conshdlr->initialized )
2403  {
2404  SCIPerrorMessage("constraint handler <%s> not initialized\n", conshdlr->name);
2405  return SCIP_INVALIDCALL;
2406  }
2407 
2408  while( !SCIPqueueIsEmpty(conshdlr->pendingconss) )
2409  {
2410  SCIP_CALL( SCIPconshdlrPopProp(conshdlr, blkmem, set) );
2411  }
2412 
2413  /* call deinitialization method of constraint handler */
2414  if( conshdlr->consexit != NULL )
2415  {
2416  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2417  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2418  * external method; to avoid this, these changes will be buffered and processed after the method call
2419  */
2420  conshdlrDelayUpdates(conshdlr);
2421 
2422  /* start timing */
2423  SCIPclockStart(conshdlr->setuptime, set);
2424 
2425  /* call external method */
2426  SCIP_CALL( conshdlr->consexit(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
2427 
2428  /* stop timing */
2429  SCIPclockStop(conshdlr->setuptime, set);
2430 
2431  /* perform the cached constraint updates */
2432  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2433  }
2434  conshdlr->initialized = FALSE;
2435 
2436  return SCIP_OKAY;
2437 }
2438 
2439 /** informs constraint handler that the presolving process is being started */
2441  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2442  BMS_BLKMEM* blkmem, /**< block memory */
2443  SCIP_SET* set, /**< global SCIP settings */
2444  SCIP_STAT* stat /**< dynamic problem statistics */
2445  )
2446 {
2447  assert(conshdlr != NULL);
2448  assert(set != NULL);
2449 
2450  /* reset conshdlr last presolved data in case of a restart */
2451  conshdlr->lastpropdomchgcount = -1;
2452  conshdlr->lastenfolpdomchgcount = -1;
2453  conshdlr->lastenfopsdomchgcount = -1;
2454  conshdlr->lastenfolpnode = -1;
2455  conshdlr->lastenfopsnode = -1;
2456  conshdlr->lastenfolpresult = SCIP_DIDNOTRUN;
2457  conshdlr->lastenfopsresult = SCIP_DIDNOTRUN;
2458  conshdlr->maxnactiveconss = conshdlr->nactiveconss;
2459  conshdlr->startnactiveconss = 0;
2460  conshdlr->lastsepalpcount = -1;
2461  conshdlr->lastenfolplpcount = -1;
2462  conshdlr->lastnusefulpropconss = 0;
2463  conshdlr->lastnusefulsepaconss = 0;
2464  conshdlr->lastnusefulenfoconss = 0;
2465  conshdlr->lastnfixedvars = 0;
2466  conshdlr->lastnaggrvars = 0;
2467  conshdlr->lastnchgvartypes = 0;
2468  conshdlr->lastnchgbds = 0;
2469  conshdlr->lastnaddholes = 0;
2470  conshdlr->lastndelconss = 0;
2471  conshdlr->lastnaddconss = 0;
2472  conshdlr->lastnupgdconss = 0;
2473  conshdlr->lastnchgcoefs = 0;
2474  conshdlr->lastnchgsides = 0;
2475  conshdlr->propwasdelayed = FALSE;
2476  conshdlr->presolwasdelayed = FALSE;
2477 
2478  /* call presolving initialization method of constraint handler */
2479  if( conshdlr->consinitpre != NULL )
2480  {
2481  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2482  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2483  * external method; to avoid this, these changes will be buffered and processed after the method call
2484  */
2485  conshdlrDelayUpdates(conshdlr);
2486 
2487  /* start timing */
2488  SCIPclockStart(conshdlr->setuptime, set);
2489 
2490  /* call external method */
2491  SCIP_CALL( conshdlr->consinitpre(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
2492 
2493  /* stop timing */
2494  SCIPclockStop(conshdlr->setuptime, set);
2495 
2496  /* perform the cached constraint updates */
2497  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2498  }
2499 
2500  /* after a restart the LP is empty but the initial constraints are not included in the initialconss array anymore;
2501  * we have to put them back into this array in order to obtain the correct initial root relaxation
2502  */
2503  if( stat->nruns >= 2 )
2504  {
2505  int c;
2506 
2507  for( c = 0; c < conshdlr->nconss; ++c )
2508  {
2509 
2510  /**@todo should only active constraints be added to the initconss array? at least cons->active is asserted in
2511  * conshdlrAddInitcons(conshdlr, set, conshdlr->conss[c])
2512  */
2513  if( conshdlr->conss[c]->addarraypos >= 0 && !conshdlr->conss[c]->deleted &&
2514  conshdlr->conss[c]->initial && conshdlr->conss[c]->initconsspos == -1 )
2515  {
2516  SCIP_CALL( conshdlrAddInitcons(conshdlr, set, stat, conshdlr->conss[c]) );
2517  }
2518  }
2519  }
2520 
2521 #if 0
2522  /* check if all initial constraints are included in the initconss array */
2523  {
2524  int c;
2525 
2526  for( c = 0; c < conshdlr->nconss; ++c )
2527  {
2528  assert(conshdlr->conss[c]->deleted || conshdlr->conss[c]->initial == (conshdlr->conss[c]->initconsspos >= 0));
2529  assert(conshdlr->conss[c]->deleted || !conshdlr->conss[c]->initial
2530  || conshdlr->initconss[conshdlr->conss[c]->initconsspos] == conshdlr->conss[c]);
2531  }
2532  }
2533 #endif
2534 
2535  return SCIP_OKAY;
2536 }
2537 
2538 /** informs constraint handler that the presolving is finished */
2540  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2541  BMS_BLKMEM* blkmem, /**< block memory */
2542  SCIP_SET* set, /**< global SCIP settings */
2543  SCIP_STAT* stat /**< dynamic problem statistics */
2544  )
2545 {
2546  assert(conshdlr != NULL);
2547  assert(set != NULL);
2548 
2549  /* empty the queue: the solving process will use a new one in any case */
2550  while( !SCIPqueueIsEmpty(conshdlr->pendingconss) )
2551  {
2552  SCIP_CALL( SCIPconshdlrPopProp(conshdlr, blkmem, set) );
2553  }
2554 
2555  /* call presolving deinitialization method of constraint handler */
2556  if( conshdlr->consexitpre != NULL )
2557  {
2558  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2559  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2560  * external method; to avoid this, these changes will be buffered and processed after the method call
2561  */
2562  conshdlrDelayUpdates(conshdlr);
2563 
2564  /* start timing */
2565  SCIPclockStart(conshdlr->setuptime, set);
2566 
2567  /* call external method */
2568  SCIP_CALL( conshdlr->consexitpre(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
2569 
2570  /* stop timing */
2571  SCIPclockStop(conshdlr->setuptime, set);
2572 
2573  /* perform the cached constraint updates */
2574  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2575  }
2576 
2577  /* update statistics */
2578  conshdlr->maxnactiveconss = conshdlr->nactiveconss;
2579  conshdlr->startnactiveconss = conshdlr->nactiveconss;
2580 
2581  return SCIP_OKAY;
2582 }
2583 
2584 /** informs constraint handler that the branch and bound process is being started */
2586  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2587  BMS_BLKMEM* blkmem, /**< block memory */
2588  SCIP_SET* set, /**< global SCIP settings */
2589  SCIP_STAT* stat /**< dynamic problem statistics */
2590  )
2591 {
2592  assert(conshdlr != NULL);
2593  assert(set != NULL);
2594  assert(stat != NULL);
2595 
2596  conshdlr->sepalpwasdelayed = FALSE;
2597  conshdlr->sepasolwasdelayed = FALSE;
2598 
2599  /* call solving process initialization method of constraint handler */
2600  if( conshdlr->consinitsol != NULL )
2601  {
2602  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2603  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2604  * external method; to avoid this, these changes will be buffered and processed after the method call
2605  */
2606  conshdlrDelayUpdates(conshdlr);
2607 
2608  /* start timing */
2609  SCIPclockStart(conshdlr->setuptime, set);
2610 
2611  /* call external method */
2612  SCIP_CALL( conshdlr->consinitsol(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
2613 
2614  /* stop timing */
2615  SCIPclockStop(conshdlr->setuptime, set);
2616 
2617  /* perform the cached constraint updates */
2618  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2619  }
2620 
2621  return SCIP_OKAY;
2622 }
2623 
2624 /** informs constraint handler that the branch and bound process data is being freed */
2626  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2627  BMS_BLKMEM* blkmem, /**< block memory */
2628  SCIP_SET* set, /**< global SCIP settings */
2629  SCIP_STAT* stat, /**< dynamic problem statistics */
2630  SCIP_Bool restart /**< was this exit solve call triggered by a restart? */
2631  )
2632 {
2633  assert(conshdlr != NULL);
2634  assert(set != NULL);
2635 
2636  /* call solving process deinitialization method of constraint handler */
2637  if( conshdlr->consexitsol != NULL )
2638  {
2639  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2640  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2641  * external method; to avoid this, these changes will be buffered and processed after the method call
2642  */
2643  conshdlrDelayUpdates(conshdlr);
2644 
2645  /* start timing */
2646  SCIPclockStart(conshdlr->setuptime, set);
2647 
2648  /* call external method */
2649  SCIP_CALL( conshdlr->consexitsol(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss, restart) );
2650 
2651  /* stop timing */
2652  SCIPclockStop(conshdlr->setuptime, set);
2653 
2654  /* perform the cached constraint updates */
2655  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2656  }
2657 
2658  return SCIP_OKAY;
2659 }
2660 
2661 /** calls LP initialization method of constraint handler to separate all initial active constraints */
2663  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2664  BMS_BLKMEM* blkmem, /**< block memory */
2665  SCIP_SET* set, /**< global SCIP settings */
2666  SCIP_STAT* stat, /**< dynamic problem statistics */
2667  SCIP_TREE* tree, /**< branch and bound tree */
2668  SCIP_Bool initkeptconss /**< Also initialize constraints which are valid at a more global node,
2669  * but were not activated there? Should be FALSE for repeated calls at
2670  * one node or if the current focusnode is a child of the former one */
2671  )
2672 {
2673  assert(conshdlr != NULL);
2674 #ifdef MORE_DEBUG
2675  assert(stat->nnodes > 1 || conshdlr->ninitconsskept == 0 || SCIPtreeProbing(tree));
2676 #endif
2677 
2678  if( conshdlr->consinitlp != NULL )
2679  {
2680  int currentdepth;
2681  int oldninitconss;
2682  int c;
2683 
2684  SCIPdebugMessage("initializing LP with %d initial constraints of handler <%s> (ninitconss=%d, kept=%d, initkept=%u)\n",
2685  initkeptconss ? conshdlr->ninitconss : conshdlr->ninitconss - conshdlr->ninitconsskept, conshdlr->name,
2686  conshdlr->ninitconss, conshdlr->ninitconsskept, initkeptconss);
2687 
2688  /* no constraints to initialize (or only kept constraints which do not need to be initialized this time) -> return */
2689  if( conshdlr->ninitconss == 0 || (!initkeptconss && conshdlr->ninitconss == conshdlr->ninitconsskept) )
2690  return SCIP_OKAY;
2691 
2692  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2693  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2694  * external method; to avoid this, these changes will be buffered and processed after the method call
2695  */
2696  conshdlrDelayUpdates(conshdlr);
2697 
2698  oldninitconss = conshdlr->ninitconss;
2699 
2700  /* start timing */
2701  SCIPclockStart(conshdlr->sepatime, set);
2702 
2703  if( initkeptconss )
2704  {
2705  /* add all kept initial constraints which are currently active to the second part of the initconss array */
2706  /* @todo keep track of where a constraint was already initialized (e.g., in the conssetchg)? */
2707  for( c = 0; c < conshdlr->ninitconsskept; ++c )
2708  {
2709  assert(conshdlr->initconss[c]->initconsspos == c);
2710 
2711  if( SCIPconsIsActive(conshdlr->initconss[c]) )
2712  {
2713  SCIP_CALL( conshdlrAddInitcons(conshdlr, set, stat, conshdlr->initconss[c]) );
2714  }
2715  }
2716  }
2717 
2718  /* call external method */
2719  SCIP_CALL( conshdlr->consinitlp(set->scip, conshdlr, &conshdlr->initconss[conshdlr->ninitconsskept],
2720  conshdlr->ninitconss - conshdlr->ninitconsskept) );
2721 
2722  /* stop timing */
2723  SCIPclockStop(conshdlr->sepatime, set);
2724 
2725  /* perform the cached constraint updates */
2726  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2727 
2728  currentdepth = SCIPtreeGetCurrentDepth(tree);
2729  assert(currentdepth >= 0);
2730 
2731  /* clear the initconss array */
2732  for( c = conshdlr->ninitconsskept; c < oldninitconss; ++c )
2733  {
2734  assert(SCIPconsGetActiveDepth(conshdlr->initconss[c]) >= -1);
2735  assert(SCIPconsGetActiveDepth(conshdlr->initconss[c]) <= currentdepth);
2736 
2737  /* if the constraint was not initialized at its valid node, we keep it */
2738  if( currentdepth > 0 ? SCIPconsGetActiveDepth(conshdlr->initconss[c]) != currentdepth :
2739  SCIPconsGetActiveDepth(conshdlr->initconss[c]) > 0 )
2740  {
2741  conshdlr->initconss[conshdlr->ninitconsskept] = conshdlr->initconss[c];
2742  conshdlr->initconss[conshdlr->ninitconsskept]->initconsspos = conshdlr->ninitconsskept;
2743  ++(conshdlr->ninitconsskept);
2744  }
2745  else
2746  conshdlr->initconss[c]->initconsspos = -1;
2747  }
2748 #ifndef NDEBUG
2749  for( ; c < conshdlr->ninitconss; ++c )
2750  assert(conshdlr->initconss[c]->initconsspos < conshdlr->ninitconsskept);
2751 #endif
2752  conshdlr->ninitconss = conshdlr->ninitconsskept;
2753 
2754  if( conshdlr->ninitconss == 0 )
2755  {
2756  BMSfreeMemoryArrayNull(&conshdlr->initconss);
2757  conshdlr->initconsssize = 0;
2758  }
2759  }
2760 
2761  return SCIP_OKAY;
2762 }
2763 
2764 /** calls separator method of constraint handler to separate LP solution */
2766  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2767  BMS_BLKMEM* blkmem, /**< block memory */
2768  SCIP_SET* set, /**< global SCIP settings */
2769  SCIP_STAT* stat, /**< dynamic problem statistics */
2770  SCIP_SEPASTORE* sepastore, /**< separation storage */
2771  int depth, /**< depth of current node */
2772  SCIP_Bool execdelayed, /**< execute separation method even if it is marked to be delayed */
2773  SCIP_RESULT* result /**< pointer to store the result of the callback method */
2774  )
2775 {
2776  assert(conshdlr != NULL);
2777  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
2778  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
2779  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
2780  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
2781  assert(stat != NULL);
2782  assert(conshdlr->lastsepalpcount != stat->lpcount
2783  || (0 <= conshdlr->lastnusefulsepaconss && conshdlr->lastnusefulsepaconss <= conshdlr->nusefulsepaconss));
2784  assert(set != NULL);
2785  assert(result != NULL);
2786 
2787  *result = SCIP_DIDNOTRUN;
2788 
2789  if( conshdlr->conssepalp != NULL
2790  && ((depth == 0 && conshdlr->sepafreq == 0)
2791  || (conshdlr->sepafreq > 0 && depth % conshdlr->sepafreq == 0)
2792  || conshdlr->sepalpwasdelayed) )
2793  {
2794  /* check, if separation method should be delayed */
2795  if( !conshdlr->delaysepa || execdelayed )
2796  {
2797  int nconss;
2798  int nusefulconss;
2799  int firstcons;
2800 
2801  /* check, if this LP solution was already separated */
2802  if( conshdlr->lastsepalpcount == stat->lpcount )
2803  {
2804  /* all constraints that were not yet separated on the new LP solution must be useful constraints, which means,
2805  * that the new constraints are the last constraints of the useful ones
2806  */
2807  nconss = conshdlr->nusefulsepaconss - conshdlr->lastnusefulsepaconss;
2808  nusefulconss = nconss;
2809  firstcons = conshdlr->lastnusefulsepaconss;
2810  }
2811  else
2812  {
2813  /* on a new LP solution, we want to separate all constraints */
2814  nconss = conshdlr->nsepaconss;
2815  nusefulconss = conshdlr->nusefulsepaconss;
2816  firstcons = 0;
2817  }
2818  assert(firstcons >= 0);
2819  assert(firstcons + nconss <= conshdlr->nsepaconss);
2820  assert(nusefulconss <= nconss);
2821 
2822  /* constraint handlers without constraints should only be called once */
2823  if( nconss > 0 || (!conshdlr->needscons && conshdlr->lastsepalpcount != stat->lpcount) )
2824  {
2825  SCIP_CONS** conss;
2826  SCIP_Longint oldndomchgs;
2827  SCIP_Longint oldnprobdomchgs;
2828  SCIP_Longint lastsepalpcount;
2829  int oldncuts;
2830  int oldnactiveconss;
2831  int lastnusefulsepaconss;
2832 
2833  SCIPdebugMessage("separating constraints %d to %d of %d constraints of handler <%s> (%s LP solution)\n",
2834  firstcons, firstcons + nconss - 1, conshdlr->nsepaconss, conshdlr->name,
2835  conshdlr->lastsepalpcount == stat->lpcount ? "old" : "new");
2836 
2837  /* remember the number of processed constraints on the current LP solution */
2838  lastsepalpcount = stat->lpcount;
2839  lastnusefulsepaconss = conshdlr->nusefulsepaconss;
2840 
2841  /* get the array of the constraints to be processed */
2842  conss = &(conshdlr->sepaconss[firstcons]);
2843 
2844  oldndomchgs = stat->nboundchgs + stat->nholechgs;
2845  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
2846  oldncuts = SCIPsepastoreGetNCuts(sepastore);
2847  oldnactiveconss = stat->nactiveconss;
2848 
2849  /* check, if we want to use eager evaluation */
2850  if( (conshdlr->eagerfreq == 0 && conshdlr->nsepacalls == 0)
2851  || (conshdlr->eagerfreq > 0 && conshdlr->nsepacalls % conshdlr->eagerfreq == 0) )
2852  nusefulconss = nconss;
2853 
2854  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2855  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2856  * external method; to avoid this, these changes will be buffered and processed after the method call
2857  */
2858  conshdlrDelayUpdates(conshdlr);
2859  conshdlr->duringsepa = TRUE;
2860 
2861  /* start timing */
2862  SCIPclockStart(conshdlr->sepatime, set);
2863 
2864  /* call external method */
2865  SCIP_CALL( conshdlr->conssepalp(set->scip, conshdlr, conss, nconss, nusefulconss, result) );
2866  SCIPdebugMessage(" -> separating LP returned result <%d>\n", *result);
2867 
2868  /* stop timing */
2869  SCIPclockStop(conshdlr->sepatime, set);
2870 
2871  /* perform the cached constraint updates */
2872  conshdlr->duringsepa = FALSE;
2873  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
2874 
2875  /* update statistics */
2876  if( *result != SCIP_DIDNOTRUN && *result != SCIP_DELAYED )
2877  {
2878  conshdlr->lastsepalpcount = lastsepalpcount;
2879  conshdlr->lastnusefulsepaconss = MIN(lastnusefulsepaconss, conshdlr->nusefulsepaconss);
2880  conshdlr->nsepacalls++;
2881  }
2882  if( *result == SCIP_CUTOFF )
2883  conshdlr->ncutoffs++;
2884  conshdlr->ncutsfound += SCIPsepastoreGetNCuts(sepastore) - oldncuts; /*lint !e776*/
2885  conshdlr->nconssfound += MAX(stat->nactiveconss - oldnactiveconss, 0); /*lint !e776*/
2886 
2887  /* update domain reductions; therefore remove the domain
2888  * reduction counts which were generated in probing mode */
2889  conshdlr->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
2890  conshdlr->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
2891 
2892  /* evaluate result */
2893  if( *result != SCIP_CUTOFF
2894  && *result != SCIP_CONSADDED
2895  && *result != SCIP_REDUCEDDOM
2896  && *result != SCIP_SEPARATED
2897  && *result != SCIP_NEWROUND
2898  && *result != SCIP_DIDNOTFIND
2899  && *result != SCIP_DIDNOTRUN
2900  && *result != SCIP_DELAYED )
2901  {
2902  SCIPerrorMessage("LP separation method of constraint handler <%s> returned invalid result <%d>\n",
2903  conshdlr->name, *result);
2904  return SCIP_INVALIDRESULT;
2905  }
2906  }
2907  }
2908  else
2909  {
2910  SCIPdebugMessage("LP separation method of constraint handler <%s> was delayed\n", conshdlr->name);
2911  *result = SCIP_DELAYED;
2912  }
2913 
2914  /* remember whether separation method was delayed */
2915  conshdlr->sepalpwasdelayed = (*result == SCIP_DELAYED);
2916  }
2917 
2918  return SCIP_OKAY;
2919 }
2920 
2921 /** calls separator method of constraint handler to separate given primal solution */
2923  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
2924  BMS_BLKMEM* blkmem, /**< block memory */
2925  SCIP_SET* set, /**< global SCIP settings */
2926  SCIP_STAT* stat, /**< dynamic problem statistics */
2927  SCIP_SEPASTORE* sepastore, /**< separation storage */
2928  SCIP_SOL* sol, /**< primal solution that should be separated */
2929  int depth, /**< depth of current node */
2930  SCIP_Bool execdelayed, /**< execute separation method even if it is marked to be delayed */
2931  SCIP_RESULT* result /**< pointer to store the result of the callback method */
2932  )
2933 {
2934  assert(conshdlr != NULL);
2935  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
2936  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
2937  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
2938  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
2939  assert(set != NULL);
2940  assert(stat != NULL);
2941  assert(result != NULL);
2942 
2943  *result = SCIP_DIDNOTRUN;
2944 
2945  if( conshdlr->conssepasol != NULL
2946  && ((depth == 0 && conshdlr->sepafreq == 0)
2947  || (conshdlr->sepafreq > 0 && depth % conshdlr->sepafreq == 0)
2948  || conshdlr->sepasolwasdelayed) )
2949  {
2950  /* check, if separation method should be delayed */
2951  if( !conshdlr->delaysepa || execdelayed )
2952  {
2953  int nconss;
2954  int nusefulconss;
2955 
2956  /* always separate all constraints */
2957  nconss = conshdlr->nsepaconss;
2958  nusefulconss = conshdlr->nusefulsepaconss;
2959  assert(nusefulconss <= nconss);
2960 
2961  if( nconss > 0 || !conshdlr->needscons )
2962  {
2963  SCIP_CONS** conss;
2964  SCIP_Longint oldndomchgs;
2965  SCIP_Longint oldnprobdomchgs;
2966  int oldncuts;
2967  int oldnactiveconss;
2968 
2969  SCIPdebugMessage("separating %d constraints of handler <%s> (primal solution %p)\n",
2970  nconss, conshdlr->name, (void*)sol);
2971 
2972  /* get the array of the constraints to be processed */
2973  conss = conshdlr->sepaconss;
2974 
2975  oldndomchgs = stat->nboundchgs + stat->nholechgs;
2976  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
2977  oldncuts = SCIPsepastoreGetNCuts(sepastore);
2978  oldnactiveconss = stat->nactiveconss;
2979 
2980  /* check, if we want to use eager evaluation */
2981  if( (conshdlr->eagerfreq == 0 && conshdlr->nsepacalls == 0)
2982  || (conshdlr->eagerfreq > 0 && conshdlr->nsepacalls % conshdlr->eagerfreq == 0) )
2983  nusefulconss = nconss;
2984 
2985  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
2986  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
2987  * external method; to avoid this, these changes will be buffered and processed after the method call
2988  */
2989  conshdlrDelayUpdates(conshdlr);
2990  conshdlr->duringsepa = TRUE;
2991 
2992  /* start timing */
2993  SCIPclockStart(conshdlr->sepatime, set);
2994 
2995  /* call external method */
2996  SCIP_CALL( conshdlr->conssepasol(set->scip, conshdlr, conss, nconss, nusefulconss, sol, result) );
2997  SCIPdebugMessage(" -> separating sol returned result <%d>\n", *result);
2998 
2999  /* stop timing */
3000  SCIPclockStop(conshdlr->sepatime, set);
3001 
3002  /* perform the cached constraint updates */
3003  conshdlr->duringsepa = FALSE;
3004  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3005 
3006  /* update statistics */
3007  if( *result != SCIP_DIDNOTRUN && *result != SCIP_DELAYED )
3008  conshdlr->nsepacalls++;
3009  if( *result == SCIP_CUTOFF )
3010  conshdlr->ncutoffs++;
3011  conshdlr->ncutsfound += SCIPsepastoreGetNCuts(sepastore) - oldncuts; /*lint !e776*/
3012  conshdlr->nconssfound += MAX(stat->nactiveconss - oldnactiveconss, 0); /*lint !e776*/
3013 
3014  /* update domain reductions; therefore remove the domain
3015  * reduction counts which were generated in probing mode */
3016  conshdlr->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
3017  conshdlr->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
3018 
3019  /* evaluate result */
3020  if( *result != SCIP_CUTOFF
3021  && *result != SCIP_CONSADDED
3022  && *result != SCIP_REDUCEDDOM
3023  && *result != SCIP_SEPARATED
3024  && *result != SCIP_NEWROUND
3025  && *result != SCIP_DIDNOTFIND
3026  && *result != SCIP_DIDNOTRUN
3027  && *result != SCIP_DELAYED )
3028  {
3029  SCIPerrorMessage("SOL separation method of constraint handler <%s> returned invalid result <%d>\n",
3030  conshdlr->name, *result);
3031  return SCIP_INVALIDRESULT;
3032  }
3033  }
3034  }
3035  else
3036  {
3037  SCIPdebugMessage("SOL separation method of constraint handler <%s> was delayed\n", conshdlr->name);
3038  *result = SCIP_DELAYED;
3039  }
3040 
3041  /* remember whether separation method was delayed */
3042  conshdlr->sepasolwasdelayed = (*result == SCIP_DELAYED);
3043  }
3044 
3045  return SCIP_OKAY;
3046 }
3047 
3048 /** calls enforcing method of constraint handler for LP solution for all constraints added after last
3049  * conshdlrResetEnfo() call
3050  */
3052  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3053  BMS_BLKMEM* blkmem, /**< block memory */
3054  SCIP_SET* set, /**< global SCIP settings */
3055  SCIP_STAT* stat, /**< dynamic problem statistics */
3056  SCIP_TREE* tree, /**< branch and bound tree */
3057  SCIP_SEPASTORE* sepastore, /**< separation storage */
3058  SCIP_Bool solinfeasible, /**< was the solution already found out to be infeasible? */
3059  SCIP_RESULT* result /**< pointer to store the result of the callback method */
3060  )
3061 {
3062  assert(conshdlr != NULL);
3063  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
3064  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
3065  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
3066  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
3067  assert(stat != NULL);
3068  assert(conshdlr->lastenfolplpcount != stat->lpcount
3069  || conshdlr->lastenfolpdomchgcount != stat->domchgcount
3070  || conshdlr->lastenfolpnode != stat->nnodes
3071  || (0 <= conshdlr->lastnusefulenfoconss && conshdlr->lastnusefulenfoconss <= conshdlr->nusefulenfoconss));
3072  assert(set != NULL);
3073  assert(tree != NULL);
3074  assert(tree->nchildren == 0);
3075  assert(result != NULL);
3076 
3077  *result = SCIP_FEASIBLE;
3078 
3079  if( conshdlr->consenfolp != NULL )
3080  {
3081  int nconss;
3082  int nusefulconss;
3083  int firstcons;
3084  SCIP_Bool lpchanged;
3085  SCIP_Bool lastinfeasible;
3086 
3087  /* check, if this LP solution was already enforced at this node */
3088  if( conshdlr->lastenfolplpcount == stat->lpcount
3089  && conshdlr->lastenfolpdomchgcount == stat->domchgcount
3090  && conshdlr->lastenfolpnode == stat->nnodes
3091  && conshdlr->lastenfolpresult != SCIP_CONSADDED )
3092  {
3093  assert(conshdlr->lastenfolpresult == SCIP_FEASIBLE || conshdlr->lastenfolpresult == SCIP_INFEASIBLE
3094  || conshdlr->lastenfolpresult == SCIP_SEPARATED );
3095 
3096  /* if we already enforced the same pseudo solution at this node, we will only enforce new constraints in the
3097  * following; however, the result of the last call for the old constraint is still valid and we have to ensure
3098  * that an infeasibility in the last call is not lost because we only enforce new constraints
3099  */
3100  if( conshdlr->lastenfolpresult == SCIP_FEASIBLE )
3101  lastinfeasible = FALSE;
3102  else
3103  {
3104  assert(conshdlr->lastenfolpresult == SCIP_INFEASIBLE || conshdlr->lastenfolpresult == SCIP_SEPARATED);
3105  *result = SCIP_INFEASIBLE;
3106  lastinfeasible = TRUE;
3107  }
3108 
3109  /* all constraints that were not yet enforced on the new LP solution must be useful constraints, which means,
3110  * that the new constraints are the last constraints of the useful ones
3111  */
3112  nconss = conshdlr->nusefulenfoconss - conshdlr->lastnusefulenfoconss;
3113  nusefulconss = nconss;
3114  firstcons = conshdlr->lastnusefulenfoconss;
3115  lpchanged = FALSE;
3116  }
3117  else
3118  {
3119  /* on a new LP solution or a new node, we want to enforce all constraints */
3120  nconss = conshdlr->nenfoconss;
3121  nusefulconss = conshdlr->nusefulenfoconss;
3122  firstcons = 0;
3123  lpchanged = TRUE;
3124  lastinfeasible = FALSE;
3125  }
3126  assert(firstcons >= 0);
3127  assert(firstcons + nconss <= conshdlr->nenfoconss);
3128  assert(nusefulconss <= nconss);
3129 
3130  /* constraint handlers without constraints should only be called once */
3131  if( nconss > 0 || (!conshdlr->needscons && lpchanged) )
3132  {
3133  SCIP_CONS** conss;
3134  SCIP_Longint oldndomchgs;
3135  SCIP_Longint oldnprobdomchgs;
3136  int oldncuts;
3137  int oldnactiveconss;
3138 
3139  SCIPdebugMessage("enforcing constraints %d to %d of %d constraints of handler <%s> (%s LP solution)\n",
3140  firstcons, firstcons + nconss - 1, conshdlr->nenfoconss, conshdlr->name, lpchanged ? "new" : "old");
3141 
3142  /* remember the number of processed constraints on the current LP solution */
3143  conshdlr->lastenfolplpcount = stat->lpcount;
3144  conshdlr->lastenfolpdomchgcount = stat->domchgcount;
3145  conshdlr->lastenfolpnode = stat->nnodes;
3146  conshdlr->lastnusefulenfoconss = conshdlr->nusefulenfoconss;
3147 
3148  /* get the array of the constraints to be processed */
3149  conss = &(conshdlr->enfoconss[firstcons]);
3150 
3151  oldncuts = SCIPsepastoreGetNCuts(sepastore);
3152  oldnactiveconss = stat->nactiveconss;
3153  oldndomchgs = stat->nboundchgs + stat->nholechgs;
3154  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
3155 
3156  /* check, if we want to use eager evaluation */
3157  if( (conshdlr->eagerfreq == 0 && conshdlr->nenfolpcalls == 0)
3158  || (conshdlr->eagerfreq > 0 && conshdlr->nenfolpcalls % conshdlr->eagerfreq == 0) )
3159  nusefulconss = nconss;
3160 
3161  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3162  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3163  * external method; to avoid this, these changes will be buffered and processed after the method call
3164  */
3165  conshdlrDelayUpdates(conshdlr);
3166 
3167  /* start timing */
3168  SCIPclockStart(conshdlr->enfolptime, set);
3169 
3170  /* call external method */
3171  SCIP_CALL( conshdlr->consenfolp(set->scip, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) );
3172  SCIPdebugMessage(" -> enforcing returned result <%d>\n", *result);
3173 
3174  /* stop timing */
3175  SCIPclockStop(conshdlr->enfolptime, set);
3176 
3177  /* perform the cached constraint updates */
3178  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3179 
3180  /* remember the result of the enforcement call */
3181  conshdlr->lastenfolpresult = *result;
3182 
3183  /* update statistics */
3184  if( *result != SCIP_DIDNOTRUN )
3185  conshdlr->nenfolpcalls++;
3186  if( *result == SCIP_CUTOFF )
3187  conshdlr->ncutoffs++;
3188  conshdlr->ncutsfound += SCIPsepastoreGetNCuts(sepastore) - oldncuts; /*lint !e776*/
3189  conshdlr->nconssfound += MAX(stat->nactiveconss - oldnactiveconss, 0); /*lint !e776*/
3190  if( *result != SCIP_BRANCHED )
3191  {
3192  assert(tree->nchildren == 0);
3193 
3194  /* update domain reductions; therefore remove the domain
3195  * reduction counts which were generated in probing mode */
3196  conshdlr->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
3197  conshdlr->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
3198  }
3199  else
3200  conshdlr->nchildren += tree->nchildren;
3201 
3202  /* evaluate result */
3203  if( *result != SCIP_CUTOFF
3204  && *result != SCIP_CONSADDED
3205  && *result != SCIP_REDUCEDDOM
3206  && *result != SCIP_SEPARATED
3207  && *result != SCIP_BRANCHED
3208  && *result != SCIP_INFEASIBLE
3209  && *result != SCIP_FEASIBLE )
3210  {
3211  SCIPerrorMessage("enforcing method of constraint handler <%s> for LP solutions returned invalid result <%d>\n",
3212  conshdlr->name, *result);
3213  return SCIP_INVALIDRESULT;
3214  }
3215 
3216  /* if the same LP solution was already enforced at this node, we only enforced new constraints this time;
3217  * if the enfolp call returns feasible now, the solution is only feasible w.r.t. the new constraints, if the
3218  * last call detected infeasibility for the old constraints, we have to change the result to infeasible
3219  */
3220  if( lastinfeasible && *result == SCIP_FEASIBLE )
3221  *result = SCIP_INFEASIBLE;
3222  }
3223  }
3224 
3225  return SCIP_OKAY;
3226 }
3227 
3228 /** calls enforcing method of constraint handler for pseudo solution for all constraints added after last
3229  * conshdlrResetEnfo() call
3230  */
3232  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3233  BMS_BLKMEM* blkmem, /**< block memory */
3234  SCIP_SET* set, /**< global SCIP settings */
3235  SCIP_STAT* stat, /**< dynamic problem statistics */
3236  SCIP_TREE* tree, /**< branch and bound tree */
3237  SCIP_BRANCHCAND* branchcand, /**< branching candidate storage */
3238  SCIP_Bool solinfeasible, /**< was the solution already found out to be infeasible? */
3239  SCIP_Bool objinfeasible, /**< is the solution infeasible anyway due to violating lower objective bound? */
3240  SCIP_Bool forced, /**< should enforcement of pseudo solution be forced? */
3241  SCIP_RESULT* result /**< pointer to store the result of the callback method */
3242  )
3243 {
3244  assert(conshdlr != NULL);
3245  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
3246  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
3247  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
3248  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
3249  assert(stat != NULL);
3250  assert(conshdlr->lastenfopsdomchgcount != stat->domchgcount
3251  || conshdlr->lastenfopsnode != stat->nnodes
3252  || (0 <= conshdlr->lastnusefulenfoconss && conshdlr->lastnusefulenfoconss <= conshdlr->nusefulenfoconss));
3253  assert(set != NULL);
3254  assert(tree != NULL);
3255  assert(tree->nchildren == 0);
3256  assert(result != NULL);
3257 
3258  /* no enforcing of pseudo solution */
3259  if( set->cons_disableenfops && SCIPbranchcandGetNPseudoCands(branchcand) > 0 )
3260  {
3261  *result = SCIP_INFEASIBLE;
3262  return SCIP_OKAY;
3263  }
3264 
3265  *result = SCIP_FEASIBLE;
3266  if( conshdlr->consenfops != NULL )
3267  {
3268  int nconss;
3269  int nusefulconss;
3270  int firstcons;
3271  SCIP_Bool pschanged;
3272  SCIP_Bool lastinfeasible;
3273 
3274  /* check, if this pseudo solution was already enforced at this node */
3275  if( !forced && conshdlr->lastenfopsdomchgcount == stat->domchgcount
3276  && conshdlr->lastenfopsnode == stat->nnodes
3277  && conshdlr->lastenfopsresult != SCIP_CONSADDED
3278  && conshdlr->lastenfopsresult != SCIP_SOLVELP
3279  )
3280  {
3281  assert(conshdlr->lastenfopsresult != SCIP_CUTOFF);
3282  assert(conshdlr->lastenfopsresult != SCIP_BRANCHED);
3283  assert(conshdlr->lastenfopsresult != SCIP_REDUCEDDOM);
3284  assert(conshdlr->lastenfopsresult != SCIP_DIDNOTRUN || objinfeasible);
3285 
3286  /* if we already enforced the same pseudo solution at this node, we will only enforce new constraints in the
3287  * following; however, the result of the last call for the old constraint is still valid and we have to ensure
3288  * that an infeasibility in the last call is not lost because we only enforce new constraints
3289  */
3290  if( conshdlr->lastenfopsresult == SCIP_INFEASIBLE )
3291  {
3292  *result = SCIP_INFEASIBLE;
3293  lastinfeasible = TRUE;
3294  }
3295  else
3296  lastinfeasible = FALSE;
3297 
3298  /* all constraints that were not yet enforced on the new LP solution must be useful constraints, which means,
3299  * that the new constraints are the last constraints of the useful ones
3300  */
3301  nconss = conshdlr->nusefulenfoconss - conshdlr->lastnusefulenfoconss;
3302  nusefulconss = nconss;
3303  firstcons = conshdlr->lastnusefulenfoconss;
3304  pschanged = FALSE;
3305  }
3306  else
3307  {
3308  /* on a new pseudo solution or a new node, we want to enforce all constraints */
3309  nconss = conshdlr->nenfoconss;
3310  nusefulconss = conshdlr->nusefulenfoconss;
3311  firstcons = 0;
3312  pschanged = TRUE;
3313  lastinfeasible = FALSE;
3314  }
3315  assert(firstcons >= 0);
3316  assert(firstcons + nconss <= conshdlr->nenfoconss);
3317  assert(nusefulconss <= nconss);
3318 
3319  /* constraint handlers without constraints should only be called once */
3320  if( nconss > 0 || (!conshdlr->needscons && pschanged) )
3321  {
3322  SCIP_CONS** conss;
3323  SCIP_Longint oldndomchgs;
3324  SCIP_Longint oldnprobdomchgs;
3325 
3326  SCIPdebugMessage("enforcing constraints %d to %d of %d constraints of handler <%s> (%s pseudo solution, objinfeasible=%u)\n",
3327  firstcons, firstcons + nconss - 1, conshdlr->nenfoconss, conshdlr->name, pschanged ? "new" : "old", objinfeasible);
3328 
3329  /* remember the number of processed constraints on the current pseudo solution */
3330  conshdlr->lastenfopsdomchgcount = stat->domchgcount;
3331  conshdlr->lastenfopsnode = stat->nnodes;
3332  conshdlr->lastnusefulenfoconss = conshdlr->nusefulenfoconss;
3333 
3334  /* get the array of the constraints to be processed */
3335  conss = &(conshdlr->enfoconss[firstcons]);
3336 
3337  oldndomchgs = stat->nboundchgs + stat->nholechgs;
3338  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
3339 
3340  /* check, if we want to use eager evaluation */
3341  if( (conshdlr->eagerfreq == 0 && conshdlr->nenfopscalls == 0)
3342  || (conshdlr->eagerfreq > 0 && conshdlr->nenfopscalls % conshdlr->eagerfreq == 0) )
3343  nusefulconss = nconss;
3344 
3345  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3346  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3347  * external method; to avoid this, these changes will be buffered and processed after the method call
3348  */
3349  conshdlrDelayUpdates(conshdlr);
3350 
3351  /* start timing */
3352  SCIPclockStart(conshdlr->enfopstime, set);
3353 
3354  /* call external method */
3355  SCIP_CALL( conshdlr->consenfops(set->scip, conshdlr, conss, nconss, nusefulconss, solinfeasible, objinfeasible, result) );
3356  SCIPdebugMessage(" -> enforcing returned result <%d>\n", *result);
3357 
3358  /* stop timing */
3359  SCIPclockStop(conshdlr->enfopstime, set);
3360 
3361  /* perform the cached constraint updates */
3362  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3363 
3364  /* update statistics */
3365  if( *result != SCIP_DIDNOTRUN )
3366  conshdlr->nenfopscalls++;
3367  else if( !objinfeasible )
3368  {
3369  SCIPerrorMessage("enforcing method of constraint handler <%s> for pseudo solutions was skipped, even though the solution was not objective-infeasible\n",
3370  conshdlr->name);
3371  conshdlr->lastenfopsresult = *result;
3372 
3373  return SCIP_INVALIDRESULT;
3374  }
3375  /* A constraint handler might return SCIP_DIDNOTRUN and not check any constraints in case objinfeasible was
3376  * TRUE; we change the result pointer to SCIP_INFEASIBLE in this case.
3377  */
3378  else
3379  *result = SCIP_INFEASIBLE;
3380 
3381  if( *result == SCIP_CUTOFF )
3382  conshdlr->ncutoffs++;
3383 
3384  if( *result != SCIP_BRANCHED )
3385  {
3386  assert(tree->nchildren == 0);
3387 
3388  /* update domain reductions; therefore remove the domain
3389  * reduction counts which were generated in probing mode */
3390  conshdlr->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
3391  conshdlr->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
3392  }
3393  else
3394  conshdlr->nchildren += tree->nchildren;
3395 
3396  /* remember the result of the enforcement call */
3397  conshdlr->lastenfopsresult = *result;
3398 
3399  /* evaluate result */
3400  if( *result != SCIP_CUTOFF
3401  && *result != SCIP_CONSADDED
3402  && *result != SCIP_REDUCEDDOM
3403  && *result != SCIP_BRANCHED
3404  && *result != SCIP_SOLVELP
3405  && *result != SCIP_INFEASIBLE
3406  && *result != SCIP_FEASIBLE
3407  && *result != SCIP_DIDNOTRUN )
3408  {
3409  SCIPerrorMessage("enforcing method of constraint handler <%s> for pseudo solutions returned invalid result <%d>\n",
3410  conshdlr->name, *result);
3411  return SCIP_INVALIDRESULT;
3412  }
3413 
3414  /* if the same pseudo solution was already enforced at this node, we only enforced new constraints this time;
3415  * if the enfops call returns feasible now, the solution is only feasible w.r.t. the new constraints, if the
3416  * last call detected infeasibility for the old constraints, we have to change the result to infeasible
3417  */
3418  if( lastinfeasible && *result == SCIP_FEASIBLE )
3419  *result = SCIP_INFEASIBLE;
3420  }
3421  }
3422 
3423  return SCIP_OKAY;
3424 }
3425 
3426 /** calls feasibility check method of constraint handler */
3428  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3429  BMS_BLKMEM* blkmem, /**< block memory */
3430  SCIP_SET* set, /**< global SCIP settings */
3431  SCIP_STAT* stat, /**< dynamic problem statistics */
3432  SCIP_SOL* sol, /**< primal CIP solution */
3433  SCIP_Bool checkintegrality, /**< has integrality to be checked? */
3434  SCIP_Bool checklprows, /**< have current LP rows to be checked? */
3435  SCIP_Bool printreason, /**< should the reason for the violation be printed? */
3436  SCIP_RESULT* result /**< pointer to store the result of the callback method */
3437  )
3438 {
3439  assert(conshdlr != NULL);
3440  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
3441  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
3442  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
3443  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
3444  assert(set != NULL);
3445  assert(result != NULL);
3446 
3447  *result = SCIP_FEASIBLE;
3448 
3449  if( conshdlr->conscheck != NULL && (!conshdlr->needscons || conshdlr->ncheckconss > 0) )
3450  {
3451  SCIPdebugMessage("checking %d constraints of handler <%s>\n", conshdlr->ncheckconss, conshdlr->name);
3452 
3453  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3454  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3455  * external method; to avoid this, these changes will be buffered and processed after the method call
3456  */
3457  conshdlrDelayUpdates(conshdlr);
3458 
3459  /* start timing */
3460  SCIPclockStart(conshdlr->checktime, set);
3461 
3462  /* call external method */
3463  SCIP_CALL( conshdlr->conscheck(set->scip, conshdlr, conshdlr->checkconss, conshdlr->ncheckconss,
3464  sol, checkintegrality, checklprows, printreason, result) );
3465  SCIPdebugMessage(" -> checking returned result <%d>\n", *result);
3466 
3467  /* stop timing */
3468  SCIPclockStop(conshdlr->checktime, set);
3469 
3470  /* update statistics */
3471  conshdlr->ncheckcalls++;
3472 
3473 
3474 
3475  /* perform the cached constraint updates */
3476  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3477 
3478  /* evaluate result */
3479  if( *result != SCIP_INFEASIBLE
3480  && *result != SCIP_FEASIBLE )
3481  {
3482  SCIPerrorMessage("feasibility check of constraint handler <%s> returned invalid result <%d>\n",
3483  conshdlr->name, *result);
3484  return SCIP_INVALIDRESULT;
3485  }
3486  }
3487 
3488  return SCIP_OKAY;
3489 }
3490 
3491 /** calls propagation method of constraint handler */
3493  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3494  BMS_BLKMEM* blkmem, /**< block memory */
3495  SCIP_SET* set, /**< global SCIP settings */
3496  SCIP_STAT* stat, /**< dynamic problem statistics */
3497  int depth, /**< depth of current node */
3498  SCIP_Bool fullpropagation, /**< should all constraints be propagated (or only new ones)? */
3499  SCIP_Bool execdelayed, /**< execute propagation method even if it is marked to be delayed */
3500  SCIP_Bool instrongbranching, /**< are we currently doing strong branching? */
3501  SCIP_PROPTIMING proptiming, /**< current point in the node solving process */
3502  SCIP_RESULT* result /**< pointer to store the result of the callback method */
3503  )
3504 {
3505  assert(conshdlr != NULL);
3506  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
3507  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
3508  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
3509  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
3510  assert(stat != NULL);
3511  assert(conshdlr->lastpropdomchgcount != stat->domchgcount
3512  || (0 <= conshdlr->lastnusefulpropconss && conshdlr->lastnusefulpropconss <= conshdlr->nusefulpropconss));
3513  assert(set != NULL);
3514  assert(depth >= 0);
3515  assert(result != NULL);
3516 
3517  *result = SCIP_DIDNOTRUN;
3518 
3519  if( conshdlr->consprop != NULL
3520  && (!conshdlr->needscons || conshdlr->npropconss > 0)
3521  && ((depth == 0 && conshdlr->propfreq == 0)
3522  || (conshdlr->propfreq > 0 && depth % conshdlr->propfreq == 0)
3523  || conshdlr->propwasdelayed) )
3524  {
3525  /* check, if propagation method should be delayed */
3526  if( !conshdlr->delayprop || execdelayed )
3527  {
3528  int nconss;
3529  int nusefulconss;
3530  int nmarkedpropconss;
3531  int firstcons;
3532 
3533  nmarkedpropconss = conshdlr->nmarkedpropconss;
3534 
3535  /* check, if the current domains were already propagated */
3536  if( !fullpropagation && conshdlr->lastpropdomchgcount == stat->domchgcount )
3537  {
3538  /* all constraints that were not yet propagated on the new domains must be useful constraints, which means,
3539  * that the new constraints are the last constraints of the useful ones
3540  */
3541  nconss = conshdlr->nusefulpropconss - conshdlr->lastnusefulpropconss;
3542  nusefulconss = nconss;
3543  firstcons = conshdlr->lastnusefulpropconss;
3544  }
3545  else
3546  {
3547  /* on new domains, we want to propagate all constraints */
3548  nconss = conshdlr->npropconss;
3549  nusefulconss = conshdlr->nusefulpropconss;
3550  firstcons = 0;
3551  }
3552  assert(firstcons >= 0);
3553  assert(firstcons + nconss <= conshdlr->npropconss);
3554  assert(nusefulconss <= nconss);
3555 
3556  /* constraint handlers without constraints should only be called once */
3557  if( nconss > 0 || fullpropagation
3558  || (!conshdlr->needscons && conshdlr->lastpropdomchgcount != stat->domchgcount) )
3559  {
3560  SCIP_CONS** conss;
3561  SCIP_Longint oldndomchgs;
3562  SCIP_Longint oldnprobdomchgs;
3563  SCIP_Longint lastpropdomchgcount;
3564  int lastnusefulpropconss;
3565 
3566  SCIPdebugMessage("propagating constraints %d to %d of %d constraints of handler <%s> (%s pseudo solution, %d useful)\n",
3567  firstcons, firstcons + nconss - 1, conshdlr->npropconss, conshdlr->name,
3568  !fullpropagation && conshdlr->lastpropdomchgcount == stat->domchgcount ? "old" : "new", nusefulconss);
3569 
3570  /* remember the number of processed constraints on the current domains */
3571  lastpropdomchgcount = stat->domchgcount;
3572  lastnusefulpropconss = conshdlr->nusefulpropconss;
3573 
3574  /* get the array of the constraints to be processed */
3575  conss = &(conshdlr->propconss[firstcons]);
3576 
3577  oldndomchgs = stat->nboundchgs + stat->nholechgs;
3578  oldnprobdomchgs = stat->nprobboundchgs + stat->nprobholechgs;
3579 
3580  /* check, if we want to use eager evaluation */
3581  if( (conshdlr->eagerfreq == 0 && conshdlr->npropcalls == 0)
3582  || (conshdlr->eagerfreq > 0 && conshdlr->npropcalls % conshdlr->eagerfreq == 0) )
3583  nusefulconss = nconss;
3584 
3585  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3586  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3587  * external method; to avoid this, these changes will be buffered and processed after the method call
3588  */
3589  conshdlrDelayUpdates(conshdlr);
3590  conshdlr->duringprop = TRUE;
3591 
3592  /* start timing */
3593  if( instrongbranching )
3594  SCIPclockStart(conshdlr->sbproptime, set);
3595  else
3596  SCIPclockStart(conshdlr->proptime, set);
3597 
3598  /* call external method */
3599  SCIP_CALL( conshdlr->consprop(set->scip, conshdlr, conss, nconss, nusefulconss, nmarkedpropconss, proptiming, result) );
3600  SCIPdebugMessage(" -> propagation returned result <%d>\n", *result);
3601 
3602  /* stop timing */
3603  if( instrongbranching )
3604  SCIPclockStop(conshdlr->sbproptime, set);
3605  else
3606  SCIPclockStop(conshdlr->proptime, set);
3607 
3608  /* perform the cached constraint updates */
3609  conshdlr->duringprop = FALSE;
3610  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3611 
3612  /* update statistics */
3613  if( *result != SCIP_DIDNOTRUN && *result != SCIP_DELAYED )
3614  {
3615  conshdlr->lastpropdomchgcount = lastpropdomchgcount;
3616  conshdlr->lastnusefulpropconss = MIN(conshdlr->nusefulpropconss, lastnusefulpropconss);
3617  conshdlr->npropcalls++;
3618  }
3619  else
3620  {
3621  assert(lastpropdomchgcount == stat->domchgcount);
3622  assert(lastnusefulpropconss == conshdlr->nusefulpropconss);
3623  }
3624  if( *result == SCIP_CUTOFF )
3625  conshdlr->ncutoffs++;
3626 
3627  /* update domain reductions; therefore remove the domain
3628  * reduction counts which were generated in probing mode */
3629  conshdlr->ndomredsfound += stat->nboundchgs + stat->nholechgs - oldndomchgs;
3630  conshdlr->ndomredsfound -= (stat->nprobboundchgs + stat->nprobholechgs - oldnprobdomchgs);
3631 
3632  /* check result code of callback method */
3633  if( *result != SCIP_CUTOFF
3634  && *result != SCIP_REDUCEDDOM
3635  && *result != SCIP_DIDNOTFIND
3636  && *result != SCIP_DIDNOTRUN
3637  && *result != SCIP_DELAYED )
3638  {
3639  SCIPerrorMessage("propagation method of constraint handler <%s> returned invalid result <%d>\n",
3640  conshdlr->name, *result);
3641  return SCIP_INVALIDRESULT;
3642  }
3643  }
3644  }
3645  else
3646  {
3647  SCIPdebugMessage("propagation method of constraint handler <%s> was delayed\n", conshdlr->name);
3648  *result = SCIP_DELAYED;
3649  }
3650 
3651  /* remember whether propagation method was delayed */
3652  conshdlr->propwasdelayed = (*result == SCIP_DELAYED);
3653  }
3654 
3655  return SCIP_OKAY;
3656 }
3657 
3658 /** calls presolving method of constraint handler */
3660  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3661  BMS_BLKMEM* blkmem, /**< block memory */
3662  SCIP_SET* set, /**< global SCIP settings */
3663  SCIP_STAT* stat, /**< dynamic problem statistics */
3664  SCIP_Bool execdelayed, /**< execute presolving method even if it is marked to be delayed */
3665  int nrounds, /**< number of presolving rounds already done */
3666  int* nfixedvars, /**< pointer to total number of variables fixed of all presolvers */
3667  int* naggrvars, /**< pointer to total number of variables aggregated of all presolvers */
3668  int* nchgvartypes, /**< pointer to total number of variable type changes of all presolvers */
3669  int* nchgbds, /**< pointer to total number of variable bounds tightened of all presolvers */
3670  int* naddholes, /**< pointer to total number of domain holes added of all presolvers */
3671  int* ndelconss, /**< pointer to total number of deleted constraints of all presolvers */
3672  int* naddconss, /**< pointer to total number of added constraints of all presolvers */
3673  int* nupgdconss, /**< pointer to total number of upgraded constraints of all presolvers */
3674  int* nchgcoefs, /**< pointer to total number of changed coefficients of all presolvers */
3675  int* nchgsides, /**< pointer to total number of changed left/right hand sides of all presolvers */
3676  SCIP_RESULT* result /**< pointer to store the result of the callback method */
3677  )
3678 {
3679  assert(conshdlr != NULL);
3680  assert(conshdlr->nusefulsepaconss <= conshdlr->nsepaconss);
3681  assert(conshdlr->nusefulenfoconss <= conshdlr->nenfoconss);
3682  assert(conshdlr->nusefulcheckconss <= conshdlr->ncheckconss);
3683  assert(conshdlr->nusefulpropconss <= conshdlr->npropconss);
3684  assert(set != NULL);
3685  assert(nfixedvars != NULL);
3686  assert(naggrvars != NULL);
3687  assert(nchgvartypes != NULL);
3688  assert(nchgbds != NULL);
3689  assert(naddholes != NULL);
3690  assert(ndelconss != NULL);
3691  assert(naddconss != NULL);
3692  assert(nupgdconss != NULL);
3693  assert(nchgcoefs != NULL);
3694  assert(nchgsides != NULL);
3695  assert(result != NULL);
3696 
3697  *result = SCIP_DIDNOTRUN;
3698 
3699  if( conshdlr->conspresol != NULL
3700  && (!conshdlr->needscons || conshdlr->nactiveconss > 0)
3701  && (conshdlr->maxprerounds == -1 || nrounds < conshdlr->maxprerounds || conshdlr->presolwasdelayed) )
3702  {
3703  SCIPdebugMessage("presolving %d constraints of handler <%s>\n", conshdlr->nactiveconss, conshdlr->name);
3704 
3705  /* check, if presolving method should be delayed */
3706  if( !conshdlr->delaypresol || execdelayed )
3707  {
3708  int nnewfixedvars;
3709  int nnewaggrvars;
3710  int nnewchgvartypes;
3711  int nnewchgbds;
3712  int nnewholes;
3713  int nnewdelconss;
3714  int nnewaddconss;
3715  int nnewupgdconss;
3716  int nnewchgcoefs;
3717  int nnewchgsides;
3718 
3719  /* calculate the number of changes since last call */
3720  nnewfixedvars = *nfixedvars - conshdlr->lastnfixedvars;
3721  nnewaggrvars = *naggrvars - conshdlr->lastnaggrvars;
3722  nnewchgvartypes = *nchgvartypes - conshdlr->lastnchgvartypes;
3723  nnewchgbds = *nchgbds - conshdlr->lastnchgbds;
3724  nnewholes = *naddholes - conshdlr->lastnaddholes;
3725  nnewdelconss = *ndelconss - conshdlr->lastndelconss;
3726  nnewaddconss = *naddconss - conshdlr->lastnaddconss;
3727  nnewupgdconss = *nupgdconss - conshdlr->lastnupgdconss;
3728  nnewchgcoefs = *nchgcoefs - conshdlr->lastnchgcoefs;
3729  nnewchgsides = *nchgsides - conshdlr->lastnchgsides;
3730 
3731  /* remember the old number of changes */
3732  conshdlr->lastnfixedvars = *nfixedvars;
3733  conshdlr->lastnaggrvars = *naggrvars;
3734  conshdlr->lastnchgvartypes = *nchgvartypes;
3735  conshdlr->lastnchgbds = *nchgbds;
3736  conshdlr->lastnaddholes = *naddholes;
3737  conshdlr->lastndelconss = *ndelconss;
3738  conshdlr->lastnaddconss = *naddconss;
3739  conshdlr->lastnupgdconss = *nupgdconss;
3740  conshdlr->lastnchgcoefs = *nchgcoefs;
3741  conshdlr->lastnchgsides = *nchgsides;
3742 
3743  /* because during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3744  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3745  * external method; to avoid this, these changes will be buffered and processed after the method call
3746  */
3747  conshdlrDelayUpdates(conshdlr);
3748 
3749  /* start timing */
3750  SCIPclockStart(conshdlr->presoltime, set);
3751 
3752  /* call external method */
3753  SCIP_CALL( conshdlr->conspresol(set->scip, conshdlr, conshdlr->conss, conshdlr->nactiveconss, nrounds,
3754  nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes,
3755  nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides,
3756  nfixedvars, naggrvars, nchgvartypes, nchgbds, naddholes,
3757  ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) );
3758 
3759  /* stop timing */
3760  SCIPclockStop(conshdlr->presoltime, set);
3761 
3762  /* perform the cached constraint updates */
3763  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3764 
3765  /* count the new changes */
3766  conshdlr->nfixedvars += *nfixedvars - conshdlr->lastnfixedvars;
3767  conshdlr->naggrvars += *naggrvars - conshdlr->lastnaggrvars;
3768  conshdlr->nchgvartypes += *nchgvartypes - conshdlr->lastnchgvartypes;
3769  conshdlr->nchgbds += *nchgbds - conshdlr->lastnchgbds;
3770  conshdlr->naddholes += *naddholes - conshdlr->lastnaddholes;
3771  conshdlr->ndelconss += *ndelconss - conshdlr->lastndelconss;
3772  conshdlr->naddconss += *naddconss - conshdlr->lastnaddconss;
3773  conshdlr->nupgdconss += *nupgdconss - conshdlr->lastnupgdconss;
3774  conshdlr->nchgcoefs += *nchgcoefs - conshdlr->lastnchgcoefs;
3775  conshdlr->nchgsides += *nchgsides - conshdlr->lastnchgsides;
3776 
3777  /* check result code of callback method */
3778  if( *result != SCIP_CUTOFF
3779  && *result != SCIP_UNBOUNDED
3780  && *result != SCIP_SUCCESS
3781  && *result != SCIP_DIDNOTFIND
3782  && *result != SCIP_DIDNOTRUN
3783  && *result != SCIP_DELAYED )
3784  {
3785  SCIPerrorMessage("presolving method of constraint handler <%s> returned invalid result <%d>\n",
3786  conshdlr->name, *result);
3787  return SCIP_INVALIDRESULT;
3788  }
3789 
3790  /* increase the number of calls, if the presolving method tried to find reductions */
3791  if( *result != SCIP_DIDNOTRUN && *result != SCIP_DELAYED )
3792  ++(conshdlr->npresolcalls);
3793  }
3794  else
3795  {
3796  SCIPdebugMessage("presolving method of constraint handler <%s> was delayed\n", conshdlr->name);
3797  *result = SCIP_DELAYED;
3798  }
3799 
3800  SCIPdebugMessage("after presolving %d constraints left of handler <%s>\n", conshdlr->nactiveconss, conshdlr->name);
3801 
3802  /* remember whether presolving method was delayed */
3803  conshdlr->presolwasdelayed = (*result == SCIP_DELAYED);
3804  }
3805 
3806  return SCIP_OKAY;
3807 }
3808 
3809 /** calls variable deletion method of constraint handler */
3811  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3812  BMS_BLKMEM* blkmem, /**< block memory */
3813  SCIP_SET* set, /**< global SCIP settings */
3814  SCIP_STAT* stat /**< dynamic problem statistics */
3815  )
3816 {
3817  assert(conshdlr != NULL);
3818  assert(set != NULL);
3819 
3820  if( conshdlr->consdelvars != NULL )
3821  {
3822  SCIPdebugMessage("deleting variables in constraints of handler <%s>\n", conshdlr->name);
3823 
3824  /* during constraint processing, constraints of this handler may be deleted, activated, deactivated,
3825  * enabled, disabled, marked obsolete or useful, which would change the conss array given to the
3826  * external method; to avoid this, these changes will be buffered and processed after the method call
3827  */
3828  conshdlrDelayUpdates(conshdlr);
3829 
3830  /* call external method */
3831  SCIP_CALL( conshdlr->consdelvars(set->scip, conshdlr, conshdlr->conss, conshdlr->nconss) );
3832 
3833  /* perform the cached constraint updates */
3834  SCIP_CALL( conshdlrForceUpdates(conshdlr, blkmem, set, stat) );
3835  }
3836 
3837  return SCIP_OKAY;
3838 }
3839 
3840 /** locks rounding of variables involved in the given constraint constraint handler that doesn't need constraints */
3842  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3843  SCIP_SET* set /**< global SCIP settings */
3844  )
3845 {
3846  assert(conshdlr != NULL);
3847  assert(conshdlr->conslock != NULL);
3848  assert(!conshdlr->needscons);
3849 
3850  SCIP_CALL( conshdlr->conslock(set->scip, conshdlr, NULL, +1, 0) );
3851 
3852  return SCIP_OKAY;
3853 }
3854 
3855 /** unlocks rounding of variables involved in the given constraint constraint handler that doesn't need constraints */
3857  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3858  SCIP_SET* set /**< global SCIP settings */
3859  )
3860 {
3861  assert(conshdlr != NULL);
3862  assert(conshdlr->conslock != NULL);
3863  assert(!conshdlr->needscons);
3864 
3865  SCIP_CALL( conshdlr->conslock(set->scip, conshdlr, NULL, -1, 0) );
3866 
3867  return SCIP_OKAY;
3868 }
3869 
3870 /** gets name of constraint handler */
3871 const char* SCIPconshdlrGetName(
3872  SCIP_CONSHDLR* conshdlr /**< constraint handler */
3873  )
3874 {
3875  assert(conshdlr != NULL);
3876 
3877  return conshdlr->name;
3878 }
3879 
3880 /** gets description of constraint handler */
3881 const char* SCIPconshdlrGetDesc(
3882  SCIP_CONSHDLR* conshdlr /**< constraint handler */
3883  )
3884 {
3885  assert(conshdlr != NULL);
3886 
3887  return conshdlr->desc;
3888 }
3889 
3890 /** gets user data of constraint handler */
3892  SCIP_CONSHDLR* conshdlr /**< constraint handler */
3893  )
3894 {
3895  assert(conshdlr != NULL);
3896 
3897  return conshdlr->conshdlrdata;
3898 }
3899 
3900 /** sets user data of constraint handler; user has to free old data in advance! */
3901 void SCIPconshdlrSetData(
3902  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3903  SCIP_CONSHDLRDATA* conshdlrdata /**< new constraint handler user data */
3904  )
3905 {
3906  assert(conshdlr != NULL);
3907 
3908  conshdlr->conshdlrdata = conshdlrdata;
3909 }
3910 
3911 /** sets all separation related callbacks of the constraint handler */
3912 void SCIPconshdlrSetSepa(
3913  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3914  SCIP_DECL_CONSSEPALP ((*conssepalp)), /**< separate cutting planes for LP solution */
3915  SCIP_DECL_CONSSEPASOL ((*conssepasol)), /**< separate cutting planes for arbitrary primal solution */
3916  int sepafreq, /**< frequency for separating cuts; zero means to separate only in the root node */
3917  int sepapriority, /**< priority of the constraint handler for separation */
3918  SCIP_Bool delaysepa /**< should separation method be delayed, if other separators found cuts? */
3919  )
3920 {
3921  assert(conshdlr != NULL);
3922 
3923  assert(conssepalp != NULL || conssepasol != NULL || sepafreq == -1);
3924 
3925  conshdlr->conssepalp = conssepalp;
3926  conshdlr->conssepasol = conssepasol;
3927  conshdlr->sepafreq = sepafreq;
3928  conshdlr->sepapriority = sepapriority;
3929  conshdlr->delaysepa = delaysepa;
3930 }
3931 
3932 /** sets both the propagation callback and the propagation frequency of the constraint handler */
3933 void SCIPconshdlrSetProp(
3934  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3935  SCIP_DECL_CONSPROP ((*consprop)), /**< propagate variable domains */
3936  int propfreq, /**< frequency for propagating domains; zero means only preprocessing propagation */
3937  SCIP_Bool delayprop, /**< should propagation method be delayed, if other propagators found reductions? */
3938  SCIP_PROPTIMING timingmask /**< positions in the node solving loop where propagators should be executed */
3939  )
3940 {
3941  assert(conshdlr != NULL);
3942 
3943  assert(consprop != NULL || propfreq == -1);
3944 
3945  conshdlr->consprop = consprop;
3946  conshdlr->propfreq = propfreq;
3947  conshdlr->delayprop = delayprop;
3948  conshdlr->timingmask = timingmask;
3949 }
3950 
3951 /** sets copy method of both the constraint handler and each associated constraint */
3952 void SCIPconshdlrSetCopy(
3953  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3954  SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), /**< copy method of constraint handler or NULL if you don't want to copy your plugin into sub-SCIPs */
3955  SCIP_DECL_CONSCOPY ((*conscopy)) /**< constraint copying method */
3956  )
3957 {
3958  assert(conshdlr != NULL);
3959 
3960  assert(!conshdlr->needscons || (conshdlrcopy == NULL) == (conscopy == NULL));
3961 
3962  conshdlr->conshdlrcopy = conshdlrcopy;
3963  conshdlr->conscopy = conscopy;
3964 }
3965 
3966 /** sets destructor method of constraint handler */
3967 void SCIPconshdlrSetFree(
3968  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3969  SCIP_DECL_CONSFREE ((*consfree)) /**< destructor of constraint handler */
3970  )
3971 {
3972  assert(conshdlr != NULL);
3973 
3974  conshdlr->consfree = consfree;
3975 }
3976 
3977 /** sets initialization method of constraint handler */
3978 void SCIPconshdlrSetInit(
3979  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3980  SCIP_DECL_CONSINIT ((*consinit)) /**< initialize constraint handler */
3981  )
3982 {
3983  assert(conshdlr != NULL);
3984 
3985  conshdlr->consinit = consinit;
3986 }
3987 
3988 /** sets deinitialization method of constraint handler */
3989 void SCIPconshdlrSetExit(
3990  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
3991  SCIP_DECL_CONSEXIT ((*consexit)) /**< deinitialize constraint handler */
3992  )
3993 {
3994  assert(conshdlr != NULL);
3995 
3996  conshdlr->consexit = consexit;
3997 }
3998 
3999 /** sets solving process initialization method of constraint handler */
4001  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4002  SCIP_DECL_CONSINITSOL((*consinitsol)) /**< solving process initialization method of constraint handler */
4003  )
4004 {
4005  assert(conshdlr != NULL);
4006 
4007  conshdlr->consinitsol = consinitsol;
4008 }
4009 
4010 /** sets solving process deinitialization method of constraint handler */
4012  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4013  SCIP_DECL_CONSEXITSOL ((*consexitsol)) /**< solving process deinitialization method of constraint handler */
4014  )
4015 {
4016  assert(conshdlr != NULL);
4017 
4018  conshdlr->consexitsol = consexitsol;
4019 }
4020 
4021 /** sets preprocessing initialization method of constraint handler */
4023  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4024  SCIP_DECL_CONSINITPRE((*consinitpre)) /**< preprocessing initialization method of constraint handler */
4025  )
4026 {
4027  assert(conshdlr != NULL);
4028 
4029  conshdlr->consinitpre = consinitpre;
4030 }
4031 
4032 /** sets preprocessing deinitialization method of constraint handler */
4034  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4035  SCIP_DECL_CONSEXITPRE((*consexitpre)) /**< preprocessing deinitialization method of constraint handler */
4036  )
4037 {
4038  assert(conshdlr != NULL);
4039 
4040  conshdlr->consexitpre = consexitpre;
4041 }
4042 
4043 /** sets presolving method of constraint handler */
4045  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4046  SCIP_DECL_CONSPRESOL ((*conspresol)), /**< presolving method of constraint handler */
4047  int maxprerounds, /**< maximal number of presolving rounds the constraint handler participates in (-1: no limit) */
4048  SCIP_Bool delaypresol /**< should presolving method be delayed, if other presolvers found reductions? */
4049  )
4050 {
4051  assert(conshdlr != NULL);
4052 
4053  conshdlr->conspresol = conspresol;
4054  conshdlr->maxprerounds = maxprerounds;
4055  conshdlr->delaypresol = delaypresol;
4056 }
4057 
4058 /** sets method of constraint handler to free specific constraint data */
4060  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4061  SCIP_DECL_CONSDELETE ((*consdelete)) /**< free specific constraint data */
4062  )
4063 {
4064  assert(conshdlr != NULL);
4065 
4066  conshdlr->consdelete = consdelete;
4067 }
4068 
4069 /** sets method of constraint handler to transform constraint data into data belonging to the transformed problem */
4071  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4072  SCIP_DECL_CONSTRANS ((*constrans)) /**< transform constraint data into data belonging to the transformed problem */
4073  )
4074 {
4075  assert(conshdlr != NULL);
4076 
4077  conshdlr->constrans = constrans;
4078 }
4079 
4080 /** sets method of constraint handler to initialize LP with relaxations of "initial" constraints */
4082  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4083  SCIP_DECL_CONSINITLP ((*consinitlp)) /**< initialize LP with relaxations of "initial" constraints */
4084  )
4085 {
4086  assert(conshdlr != NULL);
4087 
4088  conshdlr->consinitlp = consinitlp;
4089 }
4090 
4091 /** sets propagation conflict resolving method of constraint handler */
4093  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4094  SCIP_DECL_CONSRESPROP ((*consresprop)) /**< propagation conflict resolving method */
4095  )
4096 {
4097  assert(conshdlr != NULL);
4098 
4099  conshdlr->consresprop = consresprop;
4100 }
4101 
4102 /** sets activation notification method of constraint handler */
4104  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4105  SCIP_DECL_CONSACTIVE ((*consactive)) /**< activation notification method */
4106  )
4107 {
4108  assert(conshdlr != NULL);
4109 
4110  conshdlr->consactive = consactive;
4111 }
4112 
4113 /** sets deactivation notification method of constraint handler */
4115  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4116  SCIP_DECL_CONSDEACTIVE((*consdeactive)) /**< deactivation notification method */
4117  )
4118 {
4119  assert(conshdlr != NULL);
4120 
4121  conshdlr->consdeactive = consdeactive;
4122 }
4123 
4124 /** sets enabling notification method of constraint handler */
4126  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4127  SCIP_DECL_CONSENABLE ((*consenable)) /**< enabling notification method */
4128  )
4129 {
4130  assert(conshdlr != NULL);
4131 
4132  conshdlr->consenable = consenable;
4133 }
4134 
4135 /** sets disabling notification method of constraint handler */
4137  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4138  SCIP_DECL_CONSDISABLE ((*consdisable)) /**< disabling notification method */
4139  )
4140 {
4141  assert(conshdlr != NULL);
4142 
4143  conshdlr->consdisable = consdisable;
4144 }
4145 
4146 /** sets variable deletion method of constraint handler */
4148  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4149  SCIP_DECL_CONSDELVARS ((*consdelvars)) /**< variable deletion method */
4150  )
4151 {
4152  assert(conshdlr != NULL);
4153 
4154  conshdlr->consdelvars = consdelvars;
4155 }
4156 
4157 /** sets constraint display method of constraint handler */
4159  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4160  SCIP_DECL_CONSPRINT ((*consprint)) /**< constraint display method */
4161  )
4162 {
4163  assert(conshdlr != NULL);
4164 
4165  conshdlr->consprint = consprint;
4166 }
4167 
4168 /** sets constraint parsing method of constraint handler */
4170  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4171  SCIP_DECL_CONSPARSE ((*consparse)) /**< constraint parsing method */
4172  )
4173 {
4174  assert(conshdlr != NULL);
4175 
4176  conshdlr->consparse = consparse;
4177 }
4178 
4179 /** sets constraint variable getter method of constraint handler */
4181  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4182  SCIP_DECL_CONSGETVARS ((*consgetvars)) /**< constraint variable getter method */
4183  )
4184 {
4185  assert(conshdlr != NULL);
4186 
4187  conshdlr->consgetvars = consgetvars;
4188 }
4189 
4190 /** sets constraint variable number getter method of constraint handler */
4192  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
4193  SCIP_DECL_CONSGETNVARS((*consgetnvars)) /**< constraint variable number getter method */
4194  )
4195 {
4196  assert(conshdlr != NULL);
4197 
4198  conshdlr->consgetnvars = consgetnvars;
4199 }
4200 
4201 /** gets array with constraints of constraint handler; the first SCIPconshdlrGetNActiveConss() entries are the active
4202  * constraints, the last SCIPconshdlrGetNConss() - SCIPconshdlrGetNActiveConss() constraints are deactivated
4203  *
4204  * @note A constraint is active if it is global and was not removed or it was added locally (in that case the local
4205  * flag is TRUE) and the current node belongs to the corresponding sub tree.
4206  */
4208  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4209  )
4210 {
4211  assert(conshdlr != NULL);
4212 
4213  return conshdlr->conss;
4214 }
4215 
4216 /** gets array with enforced constraints of constraint handler; this is local information */
4218  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4219  )
4220 {
4221  assert(conshdlr != NULL);
4222 
4223  return conshdlr->enfoconss;
4224 }
4225 
4226 /** gets array with checked constraints of constraint handler; this is local information */
4228  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4229  )
4230 {
4231  assert(conshdlr != NULL);
4232 
4233  return conshdlr->checkconss;
4234 }
4235 
4236 /** gets total number of existing transformed constraints of constraint handler */
4238  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4239  )
4240 {
4241  assert(conshdlr != NULL);
4242 
4243  return conshdlr->nconss;
4244 }
4245 
4246 /** gets number of enforced constraints of constraint handler; this is local information */
4248  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4249  )
4250 {
4251  assert(conshdlr != NULL);
4252 
4253  return conshdlr->nenfoconss;
4254 }
4255 
4256 /** gets number of checked constraints of constraint handler; this is local information */
4258  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4259  )
4260 {
4261  assert(conshdlr != NULL);
4262 
4263  return conshdlr->ncheckconss;
4264 }
4265 
4266 /** gets number of active constraints of constraint handler
4267  *
4268  * @note A constraint is active if it is global and was not removed or it was added locally (in that case the local
4269  * flag is TRUE) and the current node belongs to the corresponding sub tree.
4270  */
4272  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4273  )
4274 {
4275  assert(conshdlr != NULL);
4276 
4277  return conshdlr->nactiveconss;
4278 }
4279 
4280 /** gets number of enabled constraints of constraint handler */
4282  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4283  )
4284 {
4285  assert(conshdlr != NULL);
4286 
4287  return conshdlr->nenabledconss;
4288 }
4289 
4290 /** enables or disables all clocks of \p conshdlr, depending on the value of the flag */
4292  SCIP_CONSHDLR* conshdlr, /**< the constraint handler for which all clocks should be enabled or disabled */
4293  SCIP_Bool enable /**< should the clocks of the constraint handler be enabled? */
4294  )
4295 {
4296  assert(conshdlr != NULL);
4297 
4298  SCIPclockEnableOrDisable(conshdlr->setuptime, enable);
4299  SCIPclockEnableOrDisable(conshdlr->checktime, enable);
4300  SCIPclockEnableOrDisable(conshdlr->enfolptime, enable);
4301  SCIPclockEnableOrDisable(conshdlr->enfopstime, enable);
4302  SCIPclockEnableOrDisable(conshdlr->presoltime, enable);
4303  SCIPclockEnableOrDisable(conshdlr->proptime, enable);
4304  SCIPclockEnableOrDisable(conshdlr->resproptime, enable);
4305  SCIPclockEnableOrDisable(conshdlr->sbproptime, enable);
4306  SCIPclockEnableOrDisable(conshdlr->sepatime, enable);
4307 }
4308 
4309 /** gets time in seconds used for setting up this constraint handler for new stages */
4311  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4312  )
4313 {
4314  assert(conshdlr != NULL);
4315 
4316  return SCIPclockGetTime(conshdlr->setuptime);
4317 }
4318 
4319 /** gets time in seconds used for presolving in this constraint handler */
4321  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4322  )
4323 {
4324  assert(conshdlr != NULL);
4325 
4326  return SCIPclockGetTime(conshdlr->presoltime);
4327 }
4328 
4329 /** gets time in seconds used for separation in this constraint handler */
4331  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4332  )
4333 {
4334  assert(conshdlr != NULL);
4335 
4336  return SCIPclockGetTime(conshdlr->sepatime);
4337 }
4338 
4339 /** gets time in seconds used for LP enforcement in this constraint handler */
4341  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4342  )
4343 {
4344  assert(conshdlr != NULL);
4345 
4346  return SCIPclockGetTime(conshdlr->enfolptime);
4347 }
4348 
4349 /** gets time in seconds used for pseudo enforcement in this constraint handler */
4351  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4352  )
4353 {
4354  assert(conshdlr != NULL);
4355 
4356  return SCIPclockGetTime(conshdlr->enfopstime);
4357 }
4358 
4359 /** gets time in seconds used for propagation in this constraint handler */
4361  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4362  )
4363 {
4364  assert(conshdlr != NULL);
4365 
4366  return SCIPclockGetTime(conshdlr->proptime);
4367 }
4368 
4369 /** gets time in seconds used for propagation in this constraint handler during strong branching */
4371  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4372  )
4373 {
4374  assert(conshdlr != NULL);
4375 
4376  return SCIPclockGetTime(conshdlr->sbproptime);
4377 }
4378 
4379 /** gets time in seconds used for feasibility checking in this constraint handler */
4381  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4382  )
4383 {
4384  assert(conshdlr != NULL);
4385 
4386  return SCIPclockGetTime(conshdlr->checktime);
4387 }
4388 
4389 /** gets time in seconds used for resolving propagation in this constraint handler */
4391  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4392  )
4393 {
4394  assert(conshdlr != NULL);
4395 
4396  return SCIPclockGetTime(conshdlr->resproptime);
4397 }
4398 
4399 /** gets number of calls to the constraint handler's separation method */
4401  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4402  )
4403 {
4404  assert(conshdlr != NULL);
4405 
4406  return conshdlr->nsepacalls;
4407 }
4408 
4409 /** gets number of calls to the constraint handler's LP enforcing method */
4411  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4412  )
4413 {
4414  assert(conshdlr != NULL);
4415 
4416  return conshdlr->nenfolpcalls;
4417 }
4418 
4419 /** gets number of calls to the constraint handler's pseudo enforcing method */
4421  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4422  )
4423 {
4424  assert(conshdlr != NULL);
4425 
4426  return conshdlr->nenfopscalls;
4427 }
4428 
4429 /** gets number of calls to the constraint handler's propagation method */
4431  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4432  )
4433 {
4434  assert(conshdlr != NULL);
4435 
4436  return conshdlr->npropcalls;
4437 }
4438 
4439 /** gets number of calls to the constraint handler's checking method */
4441  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4442  )
4443 {
4444  assert(conshdlr != NULL);
4445 
4446  return conshdlr->ncheckcalls;
4447 }
4448 
4449 /** gets number of calls to the constraint handler's resolve propagation method */
4451  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4452  )
4453 {
4454  assert(conshdlr != NULL);
4455 
4456  return conshdlr->nrespropcalls;
4457 }
4458 
4459 /** gets total number of times, this constraint handler detected a cutoff */
4461  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4462  )
4463 {
4464  assert(conshdlr != NULL);
4465 
4466  return conshdlr->ncutoffs;
4467 }
4468 
4469 /** gets total number of cuts found by this constraint handler */
4471  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4472  )
4473 {
4474  assert(conshdlr != NULL);
4475 
4476  return conshdlr->ncutsfound;
4477 }
4478 
4479 /** gets total number of cuts found by this constraint handler applied to lp */
4481  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4482  )
4483 {
4484  assert(conshdlr != NULL);
4485 
4486  return conshdlr->ncutsapplied;
4487 }
4488 
4489 /** increase count of applied cuts */
4491  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4492  )
4493 {
4494  assert(conshdlr != NULL);
4495 
4496  ++conshdlr->ncutsapplied;
4497 }
4498 
4499 /** increase count of found cuts */
4501  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4502  )
4503 {
4504  assert(conshdlr != NULL);
4505 
4506  ++conshdlr->ncutsfound;
4507 }
4508 
4509 /** gets total number of additional constraints added by this constraint handler */
4511  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4512  )
4513 {
4514  assert(conshdlr != NULL);
4515 
4516  return conshdlr->nconssfound;
4517 }
4518 
4519 /** gets total number of domain reductions found by this constraint handler */
4521  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4522  )
4523 {
4524  assert(conshdlr != NULL);
4525 
4526  return conshdlr->ndomredsfound;
4527 }
4528 
4529 /** gets number of children created by this constraint handler */
4531  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4532  )
4533 {
4534  assert(conshdlr != NULL);
4535 
4536  return conshdlr->nchildren;
4537 }
4538 
4539 /** gets maximum number of active constraints of constraint handler existing at the same time */
4541  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4542  )
4543 {
4544  assert(conshdlr != NULL);
4545 
4546  return conshdlr->maxnactiveconss;
4547 }
4548 
4549 /** gets initial number of active constraints of constraint handler */
4551  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4552  )
4553 {
4554  assert(conshdlr != NULL);
4555 
4556  return conshdlr->startnactiveconss;
4557 }
4558 
4559 /** gets number of variables fixed in presolving method of constraint handler */
4561  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4562  )
4563 {
4564  assert(conshdlr != NULL);
4565 
4566  return conshdlr->nfixedvars;
4567 }
4568 
4569 /** gets number of variables aggregated in presolving method of constraint handler */
4571  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4572  )
4573 {
4574  assert(conshdlr != NULL);
4575 
4576  return conshdlr->naggrvars;
4577 }
4578 
4579 /** gets number of variable types changed in presolving method of constraint handler */
4581  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4582  )
4583 {
4584  assert(conshdlr != NULL);
4585 
4586  return conshdlr->nchgvartypes;
4587 }
4588 
4589 /** gets number of bounds changed in presolving method of constraint handler */
4591  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4592  )
4593 {
4594  assert(conshdlr != NULL);
4595 
4596  return conshdlr->nchgbds;
4597 }
4598 
4599 /** gets number of holes added to domains of variables in presolving method of constraint handler */
4601  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4602  )
4603 {
4604  assert(conshdlr != NULL);
4605 
4606  return conshdlr->naddholes;
4607 }
4608 
4609 /** gets number of constraints deleted in presolving method of constraint handler */
4611  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4612  )
4613 {
4614  assert(conshdlr != NULL);
4615 
4616  return conshdlr->ndelconss;
4617 }
4618 
4619 /** gets number of constraints added in presolving method of constraint handler */
4621  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4622  )
4623 {
4624  assert(conshdlr != NULL);
4625 
4626  return conshdlr->naddconss;
4627 }
4628 
4629 /** gets number of constraints upgraded in presolving method of constraint handler */
4631  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4632  )
4633 {
4634  assert(conshdlr != NULL);
4635 
4636  return conshdlr->nupgdconss;
4637 }
4638 
4639 /** gets number of coefficients changed in presolving method of constraint handler */
4641  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4642  )
4643 {
4644  assert(conshdlr != NULL);
4645 
4646  return conshdlr->nchgcoefs;
4647 }
4648 
4649 /** gets number of constraint sides changed in presolving method of constraint handler */
4651  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4652  )
4653 {
4654  assert(conshdlr != NULL);
4655 
4656  return conshdlr->nchgsides;
4657 }
4658 
4659 /** gets number of times the presolving method of the constraint handler was called and tried to find reductions */
4661  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4662  )
4663 {
4664  assert(conshdlr != NULL);
4665 
4666  return conshdlr->npresolcalls;
4667 }
4668 
4669 /** gets separation priority of constraint handler */
4671  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4672  )
4673 {
4674  assert(conshdlr != NULL);
4675 
4676  return conshdlr->sepapriority;
4677 }
4678 
4679 /** gets enforcing priority of constraint handler */
4681  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4682  )
4683 {
4684  assert(conshdlr != NULL);
4685 
4686  return conshdlr->enfopriority;
4687 }
4688 
4689 /** gets checking priority of constraint handler */
4691  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4692  )
4693 {
4694  assert(conshdlr != NULL);
4695 
4696  return conshdlr->checkpriority;
4697 }
4698 
4699 /** gets separation frequency of constraint handler */
4701  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4702  )
4703 {
4704  assert(conshdlr != NULL);
4705 
4706  return conshdlr->sepafreq;
4707 }
4708 
4709 /** gets propagation frequency of constraint handler */
4711  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4712  )
4713 {
4714  assert(conshdlr != NULL);
4715 
4716  return conshdlr->propfreq;
4717 }
4718 
4719 /** gets frequency of constraint handler for eager evaluations in separation, propagation and enforcement */
4721  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4722  )
4723 {
4724  assert(conshdlr != NULL);
4725 
4726  return conshdlr->eagerfreq;
4727 }
4728 
4729 /** needs constraint handler a constraint to be called? */
4731  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4732  )
4733 {
4734  assert(conshdlr != NULL);
4735 
4736  return conshdlr->needscons;
4737 }
4738 
4739 /** does the constraint handler perform presolving? */
4741  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4742  )
4743 {
4744  assert(conshdlr != NULL);
4745 
4746  return (conshdlr->conspresol != NULL);
4747 }
4748 
4749 /** should separation method be delayed, if other separators found cuts? */
4751  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4752  )
4753 {
4754  assert(conshdlr != NULL);
4755 
4756  return conshdlr->delaysepa;
4757 }
4758 
4759 /** should propagation method be delayed, if other propagators found reductions? */
4761  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4762  )
4763 {
4764  assert(conshdlr != NULL);
4765 
4766  return conshdlr->delayprop;
4767 }
4768 
4769 /** should presolving method be delayed, if other presolvers found reductions? */
4771  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4772  )
4773 {
4774  assert(conshdlr != NULL);
4775 
4776  return conshdlr->delaypresol;
4777 }
4778 
4779 /** was LP separation method delayed at the last call? */
4781  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4782  )
4783 {
4784  assert(conshdlr != NULL);
4785 
4786  return conshdlr->sepalpwasdelayed;
4787 }
4788 
4789 /** was primal solution separation method delayed at the last call? */
4791  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4792  )
4793 {
4794  assert(conshdlr != NULL);
4795 
4796  return conshdlr->sepasolwasdelayed;
4797 }
4798 
4799 /** was propagation method delayed at the last call? */
4801  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4802  )
4803 {
4804  assert(conshdlr != NULL);
4805 
4806  return conshdlr->propwasdelayed;
4807 }
4808 
4809 /** was presolving method delayed at the last call? */
4811  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4812  )
4813 {
4814  assert(conshdlr != NULL);
4815 
4816  return conshdlr->presolwasdelayed;
4817 }
4818 
4819 /** is constraint handler initialized? */
4821  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4822  )
4823 {
4824  assert(conshdlr != NULL);
4825 
4826  return conshdlr->initialized;
4827 }
4828 
4829 /** does the constraint handler have a copy function? */
4831  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4832  )
4833 {
4834  assert(conshdlr != NULL);
4835 
4836  return (conshdlr->conshdlrcopy != NULL);
4837 }
4838 
4839 /** returns the timing mask of the propagation method of the constraint handler */
4841  SCIP_CONSHDLR* conshdlr /**< constraint handler */
4842  )
4843 {
4844  assert(conshdlr != NULL);
4845 
4846  return conshdlr->timingmask;
4847 }
4848 
4849 
4850 
4851 /*
4852  * Constraint set change methods
4853  */
4854 
4855 /** creates empty constraint set change data */
4856 static
4858  SCIP_CONSSETCHG** conssetchg, /**< pointer to constraint set change data */
4859  BMS_BLKMEM* blkmem /**< block memory */
4860  )
4861 {
4862  assert(conssetchg != NULL);
4863  assert(blkmem != NULL);
4864 
4865  SCIP_ALLOC( BMSallocBlockMemory(blkmem, conssetchg) );
4866  (*conssetchg)->addedconss = NULL;
4867  (*conssetchg)->disabledconss = NULL;
4868  (*conssetchg)->addedconsssize = 0;
4869  (*conssetchg)->naddedconss = 0;
4870  (*conssetchg)->disabledconsssize = 0;
4871  (*conssetchg)->ndisabledconss = 0;
4872 
4873  return SCIP_OKAY;
4874 }
4875 
4876 /** releases all constraints of the constraint set change data */
4877 static
4879  SCIP_CONSSETCHG* conssetchg, /**< constraint set change data */
4880  BMS_BLKMEM* blkmem, /**< block memory */
4881  SCIP_SET* set /**< global SCIP settings */
4882  )
4883 {
4884  int i;
4885 
4886  assert(conssetchg != NULL);
4887 
4888  /* release constraints */
4889  for( i = 0; i < conssetchg->naddedconss; ++i )
4890  {
4891  if( conssetchg->addedconss[i] != NULL )
4892  {
4893  SCIP_CALL( SCIPconsRelease(&conssetchg->addedconss[i], blkmem, set) );
4894  }
4895  }
4896  for( i = 0; i < conssetchg->ndisabledconss; ++i )
4897  {
4898  if( conssetchg->disabledconss[i] != NULL )
4899  {
4900  SCIP_CALL( SCIPconsRelease(&conssetchg->disabledconss[i], blkmem, set) );
4901  }
4902  }
4903 
4904  return SCIP_OKAY;
4905 }
4906 
4907 /** frees constraint set change data and releases all included constraints */
4909  SCIP_CONSSETCHG** conssetchg, /**< pointer to constraint set change */
4910  BMS_BLKMEM* blkmem, /**< block memory */
4911  SCIP_SET* set /**< global SCIP settings */
4912  )
4913 {
4914  assert(conssetchg != NULL);
4915  assert(blkmem != NULL);
4916 
4917  if( *conssetchg != NULL )
4918  {
4919  /* release constraints */
4920  SCIP_CALL( conssetchgRelease(*conssetchg, blkmem, set) );
4921 
4922  /* free memory */
4923  BMSfreeBlockMemoryArrayNull(blkmem, &(*conssetchg)->addedconss, (*conssetchg)->addedconsssize);
4924  BMSfreeBlockMemoryArrayNull(blkmem, &(*conssetchg)->disabledconss, (*conssetchg)->disabledconsssize);
4925  BMSfreeBlockMemory(blkmem, conssetchg);
4926  }
4927 
4928  return SCIP_OKAY;
4929 }
4930 
4931 /** ensures, that addedconss array can store at least num entries */
4932 static
4934  SCIP_CONSSETCHG* conssetchg, /**< constraint set change data structure */
4935  BMS_BLKMEM* blkmem, /**< block memory */
4936  SCIP_SET* set, /**< global SCIP settings */
4937  int num /**< minimum number of entries to store */
4938  )
4939 {
4940  assert(conssetchg != NULL);
4941 
4942  if( num > conssetchg->addedconsssize )
4943  {
4944  int newsize;
4945 
4946  newsize = SCIPsetCalcMemGrowSize(set, num);
4947  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conssetchg->addedconss, conssetchg->addedconsssize, newsize) );
4948  conssetchg->addedconsssize = newsize;
4949  }
4950  assert(num <= conssetchg->addedconsssize);
4951 
4952  return SCIP_OKAY;
4953 }
4954 
4955 /** ensures, that disabledconss array can store at least num entries */
4956 static
4958  SCIP_CONSSETCHG* conssetchg, /**< constraint set change data structure */
4959  BMS_BLKMEM* blkmem, /**< block memory */
4960  SCIP_SET* set, /**< global SCIP settings */
4961  int num /**< minimum number of entries to store */
4962  )
4963 {
4964  assert(conssetchg != NULL);
4965 
4966  if( num > conssetchg->disabledconsssize )
4967  {
4968  int newsize;
4969 
4970  newsize = SCIPsetCalcMemGrowSize(set, num);
4971  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conssetchg->disabledconss, conssetchg->disabledconsssize, newsize) );
4972  conssetchg->disabledconsssize = newsize;
4973  }
4974  assert(num <= conssetchg->disabledconsssize);
4975 
4976  return SCIP_OKAY;
4977 }
4978 
4979 /** adds constraint addition to constraint set changes, and captures constraint; activates constraint if the
4980  * constraint set change data is currently active
4981  */
4983  SCIP_CONSSETCHG** conssetchg, /**< pointer to constraint set change data structure */
4984  BMS_BLKMEM* blkmem, /**< block memory */
4985  SCIP_SET* set, /**< global SCIP settings */
4986  SCIP_STAT* stat, /**< dynamic problem statistics */
4987  SCIP_CONS* cons, /**< added constraint */
4988  int depth, /**< depth of constraint set change's node */
4989  SCIP_Bool focusnode, /**< does the constraint set change belong to the focus node? */
4990  SCIP_Bool active /**< is the constraint set change currently active? */
4991  )
4992 {
4993  assert(conssetchg != NULL);
4994  assert(cons != NULL);
4995 
4996  /* if constraint set change doesn't exist, create it */
4997  if( *conssetchg == NULL )
4998  {
4999  SCIP_CALL( conssetchgCreate(conssetchg, blkmem) );
5000  }
5001 
5002  /* add constraint to the addedconss array */
5003  SCIP_CALL( conssetchgEnsureAddedconssSize(*conssetchg, blkmem, set, (*conssetchg)->naddedconss+1) );
5004  (*conssetchg)->addedconss[(*conssetchg)->naddedconss] = cons;
5005  (*conssetchg)->naddedconss++;
5006 
5007  /* undelete constraint, if it was globally deleted in the past */
5008  cons->deleted = FALSE;
5009 
5010  /* capture constraint */
5011  SCIPconsCapture(cons);
5012 
5013  /* activate constraint, if node is active */
5014  if( active && !SCIPconsIsActive(cons) )
5015  {
5016  SCIP_CALL( SCIPconsActivate(cons, set, stat, depth, focusnode) );
5017  assert(SCIPconsIsActive(cons));
5018 
5019  /* remember, that this constraint set change data was responsible for the constraint's addition */
5020  cons->addconssetchg = *conssetchg;
5021  cons->addarraypos = (*conssetchg)->naddedconss-1;
5022  }
5023 
5024  return SCIP_OKAY;
5025 }
5026 
5027 /** adds constraint disabling to constraint set changes, and captures constraint */
5029  SCIP_CONSSETCHG** conssetchg, /**< pointer to constraint set change data structure */
5030  BMS_BLKMEM* blkmem, /**< block memory */
5031  SCIP_SET* set, /**< global SCIP settings */
5032  SCIP_CONS* cons /**< disabled constraint */
5033  )
5034 {
5035  assert(conssetchg != NULL);
5036  assert(cons != NULL);
5037 
5038  /* if constraint set change doesn't exist, create it */
5039  if( *conssetchg == NULL )
5040  {
5041  SCIP_CALL( conssetchgCreate(conssetchg, blkmem) );
5042  }
5043 
5044  /* add constraint to the disabledconss array */
5045  SCIP_CALL( conssetchgEnsureDisabledconssSize(*conssetchg, blkmem, set, (*conssetchg)->ndisabledconss+1) );
5046  (*conssetchg)->disabledconss[(*conssetchg)->ndisabledconss] = cons;
5047  (*conssetchg)->ndisabledconss++;
5048 
5049  /* capture constraint */
5050  SCIPconsCapture(cons);
5051 
5052  return SCIP_OKAY;
5053 }
5054 
5055 /** deactivates, deletes, and releases constraint from the addedconss array of the constraint set change data */
5056 static
5058  SCIP_CONSSETCHG* conssetchg, /**< constraint set change to delete constraint from */
5059  BMS_BLKMEM* blkmem, /**< block memory */
5060  SCIP_SET* set, /**< global SCIP settings */
5061  int arraypos /**< position of constraint in disabledconss array */
5062  )
5063 {
5064  SCIP_CONS* cons;
5065 
5066  assert(conssetchg != NULL);
5067  assert(conssetchg->addedconss != NULL);
5068  assert(0 <= arraypos && arraypos < conssetchg->naddedconss);
5069 
5070  cons = conssetchg->addedconss[arraypos];
5071  assert(cons != NULL);
5072 
5073  SCIPdebugMessage("delete added constraint <%s> at position %d from constraint set change data\n", cons->name, arraypos);
5074 
5075  /* remove the link to the constraint set change data */
5076  if( cons->addconssetchg == conssetchg )
5077  {
5078  cons->addconssetchg = NULL;
5079  cons->addarraypos = -1;
5080  }
5081 
5082  /* release constraint */
5083  SCIP_CALL( SCIPconsRelease(&conssetchg->addedconss[arraypos], blkmem, set) );
5084 
5085  /* we want to keep the order of the constraint additions: move all subsequent constraints one slot to the front */
5086  for( ; arraypos < conssetchg->naddedconss-1; ++arraypos )
5087  {
5088  conssetchg->addedconss[arraypos] = conssetchg->addedconss[arraypos+1];
5089  assert(conssetchg->addedconss[arraypos] != NULL);
5090  if( conssetchg->addedconss[arraypos]->addconssetchg == conssetchg )
5091  {
5092  assert(conssetchg->addedconss[arraypos]->addarraypos == arraypos+1);
5093  conssetchg->addedconss[arraypos]->addarraypos = arraypos;
5094  }
5095  }
5096  conssetchg->naddedconss--;
5097 
5098  return SCIP_OKAY;
5099 }
5100 
5101 /** deletes and releases deactivated constraint from the disabledconss array of the constraint set change data */
5102 static
5104  SCIP_CONSSETCHG* conssetchg, /**< constraint set change to apply */
5105  BMS_BLKMEM* blkmem, /**< block memory */
5106  SCIP_SET* set, /**< global SCIP settings */
5107  int arraypos /**< position of constraint in disabledconss array */
5108  )
5109 {
5110  assert(conssetchg != NULL);
5111  assert(0 <= arraypos && arraypos < conssetchg->ndisabledconss);
5112  assert(conssetchg->disabledconss[arraypos] != NULL);
5113 
5114  SCIPdebugMessage("delete disabled constraint <%s> at position %d from constraint set change data\n",
5115  conssetchg->disabledconss[arraypos]->name, arraypos);
5116 
5117  /* release constraint */
5118  SCIP_CALL( SCIPconsRelease(&conssetchg->disabledconss[arraypos], blkmem, set) );
5119 
5120  /* we want to keep the order of the constraint disablings: move all subsequent constraints one slot to the front */
5121  for( ; arraypos < conssetchg->ndisabledconss-1; ++arraypos )
5122  {
5123  conssetchg->disabledconss[arraypos] = conssetchg->disabledconss[arraypos+1];
5124  assert(conssetchg->disabledconss[arraypos] != NULL);
5125  }
5126  conssetchg->ndisabledconss--;
5127 
5128  return SCIP_OKAY;
5129 }
5130 
5131 /** applies constraint set change */
5133  SCIP_CONSSETCHG* conssetchg, /**< constraint set change to apply */
5134  BMS_BLKMEM* blkmem, /**< block memory */
5135  SCIP_SET* set, /**< global SCIP settings */
5136  SCIP_STAT* stat, /**< dynamic problem statistics */
5137  int depth, /**< depth of constraint set change's node */
5138  SCIP_Bool focusnode /**< does the constraint set change belong to the focus node? */
5139  )
5140 {
5141  SCIP_CONS* cons;
5142  int i;
5143 
5144  if( conssetchg == NULL )
5145  return SCIP_OKAY;
5146 
5147  SCIPdebugMessage("applying constraint set changes at %p: %d constraint additions, %d constraint disablings\n",
5148  (void*)conssetchg, conssetchg->naddedconss, conssetchg->ndisabledconss);
5149 
5150  /* apply constraint additions */
5151  i = 0;
5152  while( i < conssetchg->naddedconss )
5153  {
5154  cons = conssetchg->addedconss[i];
5155  assert(cons != NULL);
5156  assert(!cons->update);
5157 
5158  /* if constraint is already active, or if constraint is globally deleted, it can be removed from addedconss array */
5159  if( cons->active || cons->deleted )
5160  {
5161  /* delete constraint from addedcons array, the empty slot is now used by the next constraint,
5162  * and naddedconss was decreased, so do not increase i
5163  */
5164  SCIP_CALL( conssetchgDelAddedCons(conssetchg, blkmem, set, i) );
5165  }
5166  else
5167  {
5168  assert(cons->addconssetchg == NULL);
5169  assert(cons->addarraypos == -1);
5170 
5171  /* activate constraint */
5172  SCIP_CALL( SCIPconsActivate(cons, set, stat, depth, focusnode) );
5173  assert(cons->active);
5174  assert(!cons->update);
5175 
5176  /* remember, that this constraint set change data was responsible for the constraint's addition */
5177  cons->addconssetchg = conssetchg;
5178  cons->addarraypos = i;
5179 
5180  ++i; /* handle the next constraint */
5181  }
5182  }
5183 
5184  /* apply constraint disablings */
5185  i = 0;
5186  while( i < conssetchg->ndisabledconss )
5187  {
5188  cons = conssetchg->disabledconss[i];
5189  assert(cons != NULL);
5190  assert(!cons->update);
5191 
5192  /* if the constraint is disabled, we can permanently remove it from the disabledconss array */
5193  if( !cons->enabled )
5194  {
5195  SCIPdebugMessage("constraint <%s> of handler <%s> was deactivated -> remove it from disabledconss array\n",
5196  cons->name, cons->conshdlr->name);
5197 
5198  /* release and remove constraint from the disabledconss array, the empty slot is now used by the next constraint
5199  * and ndisabledconss was decreased, so do not increase i
5200  */
5201  SCIP_CALL( conssetchgDelDisabledCons(conssetchg, blkmem, set, i) );
5202  }
5203  else
5204  {
5205  assert(cons->addarraypos >= 0);
5206  assert(!cons->deleted); /* deleted constraints must not be enabled! */
5207  SCIP_CALL( SCIPconsDisable(conssetchg->disabledconss[i], set, stat) );
5208  assert(!cons->update);
5209  assert(!cons->enabled);
5210 
5211  ++i; /* handle the next constraint */
5212  }
5213  }
5214 
5215  return SCIP_OKAY;
5216 }
5217 
5218 /** undoes constraint set change */
5220  SCIP_CONSSETCHG* conssetchg, /**< constraint set change to undo */
5221  BMS_BLKMEM* blkmem, /**< block memory */
5222  SCIP_SET* set, /**< global SCIP settings */
5223  SCIP_STAT* stat /**< dynamic problem statistics */
5224  )
5225 {
5226  SCIP_CONS* cons;
5227  int i;
5228 
5229  if( conssetchg == NULL )
5230  return SCIP_OKAY;
5231 
5232  SCIPdebugMessage("undoing constraint set changes at %p: %d constraint additions, %d constraint disablings\n",
5233  (void*)conssetchg, conssetchg->naddedconss, conssetchg->ndisabledconss);
5234 
5235  /* undo constraint disablings */
5236  for( i = conssetchg->ndisabledconss-1; i >= 0; --i )
5237  {
5238  cons = conssetchg->disabledconss[i];
5239  assert(cons != NULL);
5240  assert(!cons->update);
5241 
5242  /* If the constraint is inactive, we can permanently remove it from the disabledconss array. It was deactivated
5243  * in the subtree of the current node but not reactivated on the switching way back to the current node, which
5244  * means, the deactivation was more global (i.e. valid on a higher level node) than the current node and the
5245  * disabling at the current node doesn't have any effect anymore.
5246  * If the constraint is already enabled, we need not to do anything. This may happen on a path A -> B,
5247  * if the constraint is disabled at node B, and while processing the subtree of B, it is also disabled at
5248  * the more global node A. Then on the switching path back to A, the constraint is enabled at node B (which is
5249  * actually wrong, since it now should be disabled in the whole subtree of A, but we cannot know this), and
5250  * again enabled at node A (where enabling is ignored). If afterwards, a subnode of B is processed, the
5251  * switching disables the constraint in node A, and the disabling is then removed from node B.
5252  */
5253  if( !cons->active )
5254  {
5255  SCIPdebugMessage("constraint <%s> of handler <%s> was deactivated -> remove it from disabledconss array\n",
5256  cons->name, cons->conshdlr->name);
5257 
5258  /* release and remove constraint from the disabledconss array */
5259  SCIP_CALL( conssetchgDelDisabledCons(conssetchg, blkmem, set, i) );
5260  }
5261  else if( !cons->enabled )
5262  {
5263  assert(cons->addarraypos >= 0);
5264  assert(!cons->deleted); /* deleted constraints must not be active! */
5265  SCIP_CALL( SCIPconsEnable(cons, set, stat) );
5266  }
5267  assert(!cons->update);
5268  assert(!cons->active || cons->enabled);
5269  }
5270 
5271  /* undo constraint additions */
5272  for( i = conssetchg->naddedconss-1; i >= 0; --i )
5273  {
5274  cons = conssetchg->addedconss[i];
5275  assert(cons != NULL);
5276  assert(!cons->update);
5277 
5278  /* If the constraint is already deactivated, we need not to do anything. This may happen on a path A -> B,
5279  * if the constraint is added at node B, and while processing the subtree of B, it is also added at
5280  * the more global node A. Then on the switching path back to A, the node is deactivated at node B (which is
5281  * actually wrong, since it now should be active in the whole subtree of A, but we cannot know this), and
5282  * again deactivated at node A (where deactivation is ignored). If afterwards, a subnode of B is processed, the
5283  * switching activates the constraint in node A, and the activation is then removed from node B.
5284  */
5285  if( cons->active )
5286  {
5287  assert(cons->addconssetchg == conssetchg);
5288  assert(cons->addarraypos == i);
5289 
5290  /* deactivate constraint */
5291  SCIP_CALL( SCIPconsDeactivate(cons, set, stat) );
5292 
5293  /* unlink the constraint and the constraint set change */
5294  cons->addconssetchg = NULL;
5295  cons->addarraypos = -1;
5296  }
5297  assert(!cons->active);
5298  assert(!cons->update);
5299  }
5300 
5301  return SCIP_OKAY;
5302 }
5303 
5304 /** applies constraint set change to the global problem and deletes the constraint set change data */
5306  SCIP_CONSSETCHG** conssetchg, /**< pointer to constraint set change data */
5307  BMS_BLKMEM* blkmem, /**< block memory */
5308  SCIP_SET* set, /**< global SCIP settings */
5309  SCIP_STAT* stat, /**< dynamic problem statistics */
5310  SCIP_PROB* prob /**< problem data */
5311  )
5312 {
5313  SCIP_CONS* cons;
5314  int i;
5315 
5316  assert(conssetchg != NULL);
5317 
5318  /* nothing to do on empty constraint set change data */
5319  if( *conssetchg == NULL )
5320  return SCIP_OKAY;
5321 
5322  SCIPdebugMessage("moving constraint set changes at %p to global problem: %d constraint additions, %d constraint disablings\n",
5323  (void*)*conssetchg, (*conssetchg)->naddedconss, (*conssetchg)->ndisabledconss);
5324 
5325  /* apply constraint additions to the global problem (loop backwards, because then conssetchgDelAddedCons() is
5326  * more efficient)
5327  */
5328  for( i = (*conssetchg)->naddedconss-1; i >= 0; --i )
5329  {
5330  cons = (*conssetchg)->addedconss[i];
5331  assert(cons != NULL);
5332  assert(!cons->update);
5333 
5334  /* only move constraints that are not sticking at the current node */
5335  if( !SCIPconsIsStickingAtNode(cons) )
5336  {
5337  /* because we first have to delete the constraint, we have to capture it in order to not loose it */
5338  SCIPconsCapture(cons);
5339 
5340  /* delete constraint addition from constraint set change data */
5341  SCIP_CALL( conssetchgDelAddedCons(*conssetchg, blkmem, set, i) );
5342 
5343  /* don't move deleted constraints to the global problem */
5344  if( !cons->deleted )
5345  {
5346  SCIP_CALL( SCIPprobAddCons(prob, set, stat, cons) );
5347  }
5348 
5349  /* release constraint */
5350  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
5351  }
5352  }
5353 
5354  /* apply constraint disablings to the global problem (loop backwards, because then conssetchgDelDisabledCons() is
5355  * more efficient)
5356  */
5357  for( i = (*conssetchg)->ndisabledconss-1; i >= 0; --i )
5358  {
5359  cons = (*conssetchg)->disabledconss[i];
5360  assert(cons != NULL);
5361  assert(!cons->update);
5362 
5363  /* only delete constraints that are not sticking at the current node */
5364  if( !SCIPconsIsStickingAtNode(cons) )
5365  {
5366  /* globally delete constraint */
5367  if( !cons->deleted )
5368  {
5369  SCIP_CALL( SCIPconsDelete(cons, blkmem, set, stat, prob) );
5370  }
5371 
5372  /* release and remove constraint from the disabledconss array */
5373  SCIP_CALL( conssetchgDelDisabledCons(*conssetchg, blkmem, set, i) );
5374  }
5375  }
5376 
5377  if( (*conssetchg)->naddedconss == 0 && (*conssetchg)->ndisabledconss == 0 )
5378  {
5379  /* free empty constraint set change data */
5380  SCIP_CALL( SCIPconssetchgFree(conssetchg, blkmem, set) );
5381  }
5382 
5383  return SCIP_OKAY;
5384 }
5385 
5386 
5387 
5388 
5389 /*
5390  * Constraint methods
5391  */
5392 
5393 /** creates and captures a constraint, and inserts it into the conss array of its constraint handler
5394  *
5395  * @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution
5396  * may be declared feasible even if it violates this particular constraint.
5397  * This constellation should only be used, if no LP or pseudo solution can violate the constraint -- e.g. if a
5398  * local constraint is redundant due to the variable's local bounds.
5399  */
5401  SCIP_CONS** cons, /**< pointer to constraint */
5402  BMS_BLKMEM* blkmem, /**< block memory */
5403  SCIP_SET* set, /**< global SCIP settings */
5404  const char* name, /**< name of constraint */
5405  SCIP_CONSHDLR* conshdlr, /**< constraint handler for this constraint */
5406  SCIP_CONSDATA* consdata, /**< data for this specific constraint */
5407  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
5408  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
5409  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
5410  * Usually set to TRUE. */
5411  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
5412  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5413  SCIP_Bool check, /**< should the constraint be checked for feasibility?
5414  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5415  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
5416  * Usually set to TRUE. */
5417  SCIP_Bool local, /**< is constraint only valid locally?
5418  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
5419  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
5420  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
5421  * adds coefficients to this constraint. */
5422  SCIP_Bool dynamic, /**< is constraint subject to aging?
5423  * Usually set to FALSE. Set to TRUE for own cuts which
5424  * are separated as constraints. */
5425  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
5426  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
5427  SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
5428  * if it may be moved to a more global node?
5429  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
5430  SCIP_Bool original, /**< is constraint belonging to the original problem? */
5431  SCIP_Bool deleteconsdata /**< has the constraint data to be deleted if constraint is freed? */
5432  )
5433 {
5434  assert(cons != NULL);
5435  assert(blkmem != NULL);
5436  assert(set != NULL);
5437  assert(name != NULL);
5438  assert(conshdlr != NULL);
5439  assert(!original || deleteconsdata);
5440 
5441  /* constraints of constraint handlers that don't need constraints cannot be created */
5442  if( !conshdlr->needscons )
5443  {
5444  SCIPerrorMessage("cannot create constraint <%s> of type [%s] - constraint handler does not need constraints\n",
5445  name, conshdlr->name);
5446  return SCIP_INVALIDCALL;
5447  }
5448 
5449  /* create constraint data */
5450  SCIP_ALLOC( BMSallocBlockMemory(blkmem, cons) );
5451  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &(*cons)->name, name, strlen(name)+1) );
5452 #ifndef NDEBUG
5453  (*cons)->scip = set->scip;
5454 #endif
5455  (*cons)->conshdlr = conshdlr;
5456  (*cons)->consdata = consdata;
5457  (*cons)->transorigcons = NULL;
5458  (*cons)->addconssetchg = NULL;
5459  (*cons)->addarraypos = -1;
5460  (*cons)->consspos = -1;
5461  (*cons)->initconsspos = -1;
5462  (*cons)->sepaconsspos = -1;
5463  (*cons)->enfoconsspos = -1;
5464  (*cons)->checkconsspos = -1;
5465  (*cons)->propconsspos = -1;
5466  (*cons)->activedepth = -2;
5467  (*cons)->validdepth = (local ? -1 : 0);
5468  (*cons)->age = 0.0;
5469  (*cons)->nlockspos = 0;
5470  (*cons)->nlocksneg = 0;
5471  (*cons)->markedprop = FALSE;
5472  (*cons)->nuses = 0;
5473  (*cons)->nupgradelocks = 0;
5474  (*cons)->initial = initial;
5475  (*cons)->separate = separate;
5476  (*cons)->enforce = enforce;
5477  (*cons)->check = check;
5478  (*cons)->propagate = propagate;
5479  (*cons)->sepaenabled = separate;
5480  (*cons)->propenabled = propagate;
5481  (*cons)->local = local;
5482  (*cons)->modifiable = modifiable;
5483  (*cons)->dynamic = dynamic;
5484  (*cons)->removable = removable;
5485  (*cons)->stickingatnode = stickingatnode;
5486  (*cons)->original = original;
5487  (*cons)->deleteconsdata = deleteconsdata;
5488  (*cons)->active = FALSE;
5489  (*cons)->enabled = FALSE;
5490  (*cons)->obsolete = FALSE;
5491  (*cons)->markpropagate = FALSE;
5492  (*cons)->deleted = FALSE;
5493  (*cons)->update = FALSE;
5494  (*cons)->updateinsert = FALSE;
5495  (*cons)->updateactivate = FALSE;
5496  (*cons)->updatedeactivate = FALSE;
5497  (*cons)->updateenable = FALSE;
5498  (*cons)->updatedisable = FALSE;
5499  (*cons)->updatesepaenable = FALSE;
5500  (*cons)->updatesepadisable = FALSE;
5501  (*cons)->updatepropenable = FALSE;
5502  (*cons)->updatepropdisable = FALSE;
5503  (*cons)->updateobsolete = FALSE;
5504  (*cons)->updatemarkpropagate = FALSE;
5505  (*cons)->updateunmarkpropagate = FALSE;
5506  (*cons)->updatefree = FALSE;
5507  (*cons)->updateactfocus = FALSE;
5508 
5509  /* capture constraint */
5510  SCIPconsCapture(*cons);
5511 
5512  /* insert the constraint as inactive constraint into the transformed constraints array */
5513  if( !original )
5514  {
5515  /* check, if inserting constraint should be delayed */
5516  if( conshdlrAreUpdatesDelayed(conshdlr) )
5517  {
5518  SCIPdebugMessage(" -> delaying insertion of constraint <%s>\n", (*cons)->name);
5519  (*cons)->updateinsert = TRUE;
5520  SCIP_CALL( conshdlrAddUpdateCons((*cons)->conshdlr, set, *cons) );
5521  assert((*cons)->update);
5522  assert((*cons)->nuses == 2);
5523  }
5524  else
5525  {
5526  SCIP_CALL( conshdlrAddCons(conshdlr, set, *cons) );
5527  }
5528  }
5529 
5530  checkConssArrays(conshdlr);
5531 
5532  return SCIP_OKAY;
5533 }
5534 
5535 /** copies source constraint of source SCIP into the target constraint for the target SCIP, using the variable map for
5536  * mapping the variables of the source SCIP to the variables of the target SCIP; if the copying process was successful
5537  * a constraint is created and captured;
5538  *
5539  * @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution
5540  * may be declared feasible even if it violates this particular constraint.
5541  * This constellation should only be used, if no LP or pseudo solution can violate the constraint -- e.g. if a
5542  * local constraint is redundant due to the variable's local bounds.
5543  */
5545  SCIP_CONS** cons, /**< pointer to store the created target constraint */
5546  SCIP_SET* set, /**< global SCIP settings of the target SCIP */
5547  const char* name, /**< name of constraint, or NULL if the name of the source constraint should be used */
5548  SCIP* sourcescip, /**< source SCIP data structure */
5549  SCIP_CONSHDLR* sourceconshdlr, /**< source constraint handler for this constraint */
5550  SCIP_CONS* sourcecons, /**< source constraint of the source SCIP */
5551  SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to corresponding
5552  * variables of the target SCIP */
5553  SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
5554  * target constraints, must not be NULL! */
5555  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
5556  SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
5557  SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
5558  SCIP_Bool check, /**< should the constraint be checked for feasibility? */
5559  SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
5560  SCIP_Bool local, /**< is constraint only valid locally? */
5561  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
5562  SCIP_Bool dynamic, /**< is constraint subject to aging? */
5563  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
5564  SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
5565  * if it may be moved to a more global node? */
5566  SCIP_Bool global, /**< create a global or a local copy? */
5567  SCIP_Bool* success /**< pointer to store whether the copying was successful or not */
5568  )
5569 {
5570  assert(cons != NULL);
5571  assert(set != NULL);
5572  assert(sourcescip != NULL);
5573  assert(sourceconshdlr != NULL);
5574  assert(sourcecons != NULL);
5575  assert(varmap != NULL);
5576  assert(consmap != NULL);
5577  assert(success != NULL);
5578 
5579  /* if constraint handler does not support copying, success will return false. Constraints handlers have to actively set this to true. */
5580  (*success) = FALSE;
5581 
5582  if( sourceconshdlr->conscopy != NULL )
5583  {
5584  SCIP_CALL( sourceconshdlr->conscopy(set->scip, cons, name, sourcescip, sourceconshdlr, sourcecons, varmap, consmap,
5585  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, success) );
5586  }
5587 
5588  return SCIP_OKAY;
5589 }
5590 
5591 
5592 /** parses constraint information (in cip format) out of a string; if the parsing process was successful a constraint is
5593  * created, captured, and inserted into the conss array of its constraint handler.
5594  *
5595  * @warning If a constraint is marked to be checked for feasibility but not to be enforced, an LP or pseudo solution
5596  * may be declared feasible even if it violates this particular constraint.
5597  * This constellation should only be used, if no LP or pseudo solution can violate the constraint -- e.g. if a
5598  * local constraint is redundant due to the variable's local bounds.
5599  */
5601  SCIP_CONS** cons, /**< pointer to constraint */
5602  SCIP_SET* set, /**< global SCIP settings */
5603  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler of target SCIP */
5604  const char* str, /**< string to parse for constraint */
5605  SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
5606  * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
5607  SCIP_Bool separate, /**< should the constraint be separated during LP processing?
5608  * Usually set to TRUE. */
5609  SCIP_Bool enforce, /**< should the constraint be enforced during node processing?
5610  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5611  SCIP_Bool check, /**< should the constraint be checked for feasibility?
5612  * TRUE for model constraints, FALSE for additional, redundant constraints. */
5613  SCIP_Bool propagate, /**< should the constraint be propagated during node processing?
5614  * Usually set to TRUE. */
5615  SCIP_Bool local, /**< is constraint only valid locally?
5616  * Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints. */
5617  SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)?
5618  * Usually set to FALSE. In column generation applications, set to TRUE if pricing
5619  * adds coefficients to this constraint. */
5620  SCIP_Bool dynamic, /**< is constraint subject to aging?
5621  * Usually set to FALSE. Set to TRUE for own cuts which
5622  * are separated as constraints. */
5623  SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup?
5624  * Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'. */
5625  SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
5626  * if it may be moved to a more global node?
5627  * Usually set to FALSE. Set to TRUE to for constraints that represent node data. */
5628  SCIP_Bool* success /**< pointer store if the paring process was successful */
5629  )
5630 {
5631  SCIP_CONSHDLR* conshdlr;
5632  char conshdlrname[SCIP_MAXSTRLEN];
5633  char consname[SCIP_MAXSTRLEN];
5634  char* endptr;
5635 
5636  assert(cons != NULL);
5637  assert(set != NULL);
5638 
5639  (*success) = FALSE;
5640 
5641  /* scan constraint handler name */
5642  assert(str != NULL);
5643  SCIPstrCopySection(str, '[', ']', conshdlrname, SCIP_MAXSTRLEN, &endptr);
5644  if ( endptr == NULL || endptr == str )
5645  {
5646  SCIPmessagePrintWarning(messagehdlr, "Syntax error: Could not find constraint handler name.\n");
5647  return SCIP_OKAY;
5648  }
5649  assert(endptr != NULL);
5650  SCIPdebugMessage("constraint handler name <%s>\n", conshdlrname);
5651 
5652  /* scan constraint name */
5653  SCIPstrCopySection(endptr, '<', '>', consname, SCIP_MAXSTRLEN, &endptr);
5654  if ( endptr == NULL || endptr == str )
5655  {
5656  SCIPmessagePrintWarning(messagehdlr, "Syntax error: Could not find constraint name.\n");
5657  return SCIP_OKAY;
5658  }
5659  assert(endptr != NULL);
5660  SCIPdebugMessage("constraint name <%s>\n", consname);
5661 
5662  str = endptr;
5663 
5664  /* skip white space */
5665  while ( isspace((unsigned char)* str) )
5666  ++str;
5667 
5668  /* check for colon */
5669  if( *str != ':' )
5670  {
5671  SCIPmessagePrintWarning(messagehdlr, "Syntax error: Could not find colon ':' after constraint name.\n");
5672  return SCIP_OKAY;
5673  }
5674 
5675  /* skip colon */
5676  ++str;
5677 
5678  /* skip white space */
5679  while ( isspace((unsigned char)* str) )
5680  ++str;
5681 
5682  /* check if a constraint handler with parsed name exists */
5683  conshdlr = SCIPsetFindConshdlr(set, conshdlrname);
5684 
5685  if( conshdlr == NULL )
5686  {
5687  SCIPmessagePrintWarning(messagehdlr, "constraint handler <%s> doesn't exist in SCIP data structure\n", conshdlrname);
5688  }
5689  else
5690  {
5691  assert( conshdlr != NULL );
5692  if ( conshdlr->consparse == NULL )
5693  {
5694  SCIPmessagePrintWarning(messagehdlr, "constraint handler <%s> does not support parsing constraints\n", conshdlrname);
5695  }
5696  else
5697  {
5698  SCIP_CALL( conshdlr->consparse(set->scip, conshdlr, cons, consname, str,
5699  initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) );
5700  }
5701  }
5702 
5703  return SCIP_OKAY;
5704 }
5705 
5706 /** change name of given constraint */
5708  SCIP_CONS* cons, /**< problem constraint */
5709  BMS_BLKMEM* blkmem, /**< block memory buffer */
5710  const char* name /**< new name of constraint */
5711  )
5712 {
5713  assert(cons != NULL);
5714  assert(cons->name != NULL);
5715 
5716  /* free old constraint name */
5717  BMSfreeBlockMemoryArray(blkmem, &cons->name, strlen(cons->name)+1);
5718 
5719  /* copy new constraint name */
5720  SCIP_ALLOC( BMSduplicateBlockMemoryArray(blkmem, &cons->name, name, strlen(name)+1) );
5721 
5722  return SCIP_OKAY;
5723 }
5724 
5725 
5726 /** frees a constraint and removes it from the conss array of its constraint handler */
5728  SCIP_CONS** cons, /**< constraint to free */
5729  BMS_BLKMEM* blkmem, /**< block memory buffer */
5730  SCIP_SET* set /**< global SCIP settings */
5731  )
5732 {
5733  assert(cons != NULL);
5734  assert(*cons != NULL);
5735  assert((*cons)->conshdlr != NULL);
5736  assert((*cons)->nuses == 0);
5737  assert(!(*cons)->active);
5738  assert(!(*cons)->update);
5739  assert(!(*cons)->original || (*cons)->transorigcons == NULL);
5740  assert(blkmem != NULL);
5741  assert(set != NULL);
5742  assert((*cons)->scip == set->scip);
5743 
5744  SCIPdebugMessage("freeing constraint <%s> at conss pos %d of handler <%s>\n",
5745  (*cons)->name, (*cons)->consspos, (*cons)->conshdlr->name);
5746 
5747  /* free constraint data */
5748  if( (*cons)->conshdlr->consdelete != NULL && (*cons)->consdata != NULL && (*cons)->deleteconsdata )
5749  {
5750  SCIP_CALL( (*cons)->conshdlr->consdelete(set->scip, (*cons)->conshdlr, *cons, &(*cons)->consdata) );
5751  }
5752  else if( !(*cons)->deleteconsdata )
5753  (*cons)->consdata = NULL;
5754  assert((*cons)->consdata == NULL);
5755 
5756  /* unlink transformed and original constraint */
5757  if( (*cons)->transorigcons != NULL )
5758  {
5759  assert(!(*cons)->original);
5760  assert((*cons)->transorigcons->original);
5761  assert((*cons)->transorigcons->transorigcons == *cons);
5762 
5763  (*cons)->transorigcons->transorigcons = NULL;
5764  }
5765 
5766  /* remove constraint from the transformed constraints array */
5767  if( !(*cons)->original )
5768  {
5769  conshdlrDelCons((*cons)->conshdlr, *cons);
5770  checkConssArrays((*cons)->conshdlr);
5771  }
5772  assert((*cons)->consspos == -1);
5773 
5774  /* free constraint */
5775  BMSfreeBlockMemoryArray(blkmem, &(*cons)->name, strlen((*cons)->name)+1);
5776  BMSfreeBlockMemory(blkmem, cons);
5777 
5778  return SCIP_OKAY;
5779 }
5780 
5781 /** increases usage counter of constraint */
5782 void SCIPconsCapture(
5783  SCIP_CONS* cons /**< constraint */
5784  )
5785 {
5786  assert(cons != NULL);
5787  assert(cons->nuses >= 0);
5788 
5789  SCIPdebugMessage("capture constraint <%s> with nuses=%d, cons pointer %p\n", cons->name, cons->nuses, (void*)cons);
5790  cons->nuses++;
5791 }
5792 
5793 /** decreases usage counter of constraint, and frees memory if necessary */
5795  SCIP_CONS** cons, /**< pointer to constraint */
5796  BMS_BLKMEM* blkmem, /**< block memory */
5797  SCIP_SET* set /**< global SCIP settings */
5798  )
5799 {
5800  assert(blkmem != NULL);
5801  assert(cons != NULL);
5802  assert(*cons != NULL);
5803  assert((*cons)->conshdlr != NULL);
5804  assert((*cons)->nuses >= 1);
5805  assert(set != NULL);
5806  assert((*cons)->scip == set->scip);
5807 
5808  SCIPdebugMessage("release constraint <%s> with nuses=%d, cons pointer %p\n", (*cons)->name, (*cons)->nuses, (void*)(*cons));
5809  (*cons)->nuses--;
5810  if( (*cons)->nuses == 0 )
5811  {
5812  assert(!(*cons)->active || (*cons)->updatedeactivate);
5813 
5814  /* check, if freeing constraint should be delayed */
5815  if( conshdlrAreUpdatesDelayed((*cons)->conshdlr) )
5816  {
5817  SCIPdebugMessage(" -> delaying freeing constraint <%s>\n", (*cons)->name);
5818  (*cons)->updatefree = TRUE;
5819  SCIP_CALL( conshdlrAddUpdateCons((*cons)->conshdlr, set, *cons) );
5820  assert((*cons)->update);
5821  assert((*cons)->nuses == 1);
5822  }
5823  else
5824  {
5825  SCIP_CALL( SCIPconsFree(cons, blkmem, set) );
5826  }
5827  }
5828  *cons = NULL;
5829 
5830  return SCIP_OKAY;
5831 }
5832 
5833 /** outputs constraint information to file stream */
5835  SCIP_CONS* cons, /**< constraint to print */
5836  SCIP_SET* set, /**< global SCIP settings */
5837  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
5838  FILE* file /**< output file (or NULL for standard output) */
5839  )
5840 {
5841  SCIP_CONSHDLR* conshdlr;
5842 
5843  assert(cons != NULL);
5844  assert(set != NULL);
5845  assert(cons->scip == set->scip);
5846 
5847  conshdlr = cons->conshdlr;
5848  assert(conshdlr != NULL);
5849 
5850  SCIPmessageFPrintInfo(messagehdlr, file, " [%s] <%s>: ", conshdlr->name, cons->name);
5851 
5852  if( conshdlr->consprint != NULL )
5853  {
5854  SCIP_CALL( conshdlr->consprint(set->scip, conshdlr, cons, file) );
5855  }
5856  else
5857  SCIPmessageFPrintInfo(messagehdlr, file, "constraint handler <%s> doesn't support printing constraint", conshdlr->name);
5858 
5859  return SCIP_OKAY;
5860 }
5861 
5862 /** method to collect the variables of a constraint
5863  *
5864  * If the number of variables is greater than the available slots in the variable array, nothing happens except that
5865  * the success point is set to FALSE. With the method SCIPconsGetNVars() it is possible to get the number of variables
5866  * a constraint has in its scope.
5867  *
5868  * @note The success pointer indicates if all variables were copied into the vars arrray.
5869  *
5870  * @note It might be that a constraint handler does not support this functionality, in that case the success pointer is
5871  * set to FALSE.
5872  */
5874  SCIP_CONS* cons, /**< constraint to print */
5875  SCIP_SET* set, /**< global SCIP settings */
5876  SCIP_VAR** vars, /**< array to store the involved variable of the constraint */
5877  int varssize, /**< available slots in vars array which is needed to check if the array is large enough */
5878  SCIP_Bool* success /**< pointer to store whether the variables are successfully copied */
5879  )
5880 {
5881  SCIP_CONSHDLR* conshdlr;
5882 
5883  assert(cons != NULL);
5884  assert(set != NULL);
5885  assert(cons->scip == set->scip);
5886 
5887  conshdlr = cons->conshdlr;
5888  assert(conshdlr != NULL);
5889 
5890  if( conshdlr->consgetvars != NULL )
5891  {
5892  SCIP_CALL( conshdlr->consgetvars(set->scip, conshdlr, cons, vars, varssize, success) );
5893  }
5894  else
5895  {
5896  (*success) = FALSE;
5897  }
5898 
5899  return SCIP_OKAY;
5900 }
5901 
5902 /** methed to collect the number of variables of a constraint
5903  *
5904  * @note The success pointer indicates if the contraint handler was able to return the number of variables
5905  *
5906  * @note It might be that a constraint handler does not support this functionality, in that case the success pointer is
5907  * set to FALSE
5908  */
5910  SCIP_CONS* cons, /**< constraint to print */
5911  SCIP_SET* set, /**< global SCIP settings */
5912  int* nvars, /**< pointer to store the number of variables */
5913  SCIP_Bool* success /**< pointer to store whether the constraint successfully returned the number of variables */
5914  )
5915 {
5916  SCIP_CONSHDLR* conshdlr;
5917 
5918  assert(cons != NULL);
5919  assert(set != NULL);
5920  assert(cons->scip == set->scip);
5921 
5922  conshdlr = cons->conshdlr;
5923  assert(conshdlr != NULL);
5924 
5925  if( conshdlr->consgetnvars != NULL )
5926  {
5927  SCIP_CALL( conshdlr->consgetnvars(set->scip, conshdlr, cons, nvars, success) );
5928  }
5929  else
5930  {
5931  (*nvars) = 0;
5932  (*success) = FALSE;
5933  }
5934 
5935  return SCIP_OKAY;
5936 }
5937 
5938 /** globally removes constraint from all subproblems; removes constraint from the constraint set change data of the
5939  * node, where it was created, or from the problem, if it was a problem constraint
5940  */
5942  SCIP_CONS* cons, /**< constraint to delete */
5943  BMS_BLKMEM* blkmem, /**< block memory */
5944  SCIP_SET* set, /**< global SCIP settings */
5945  SCIP_STAT* stat, /**< dynamic problem statistics */
5946  SCIP_PROB* prob /**< problem data */
5947  )
5948 {
5949  assert(cons != NULL);
5950  assert(cons->conshdlr != NULL);
5951  assert(!cons->active || cons->updatedeactivate || cons->addarraypos >= 0);
5952  assert(set != NULL);
5953  assert(cons->scip == set->scip);
5954 
5955  SCIPdebugMessage("globally deleting constraint <%s> (delay updates: %d)\n",
5956  cons->name, cons->conshdlr->delayupdatecount);
5957 
5958  /* deactivate constraint, if it is currently active */
5959  if( cons->active && !cons->updatedeactivate )
5960  {
5961  SCIP_CALL( SCIPconsDeactivate(cons, set, stat) );
5962  }
5963  else
5964  cons->updateactivate = FALSE;
5965 
5966  assert(!cons->active || cons->updatedeactivate);
5967  assert(!cons->enabled || cons->updatedeactivate);
5968 
5969  /* mark constraint deleted */
5970  cons->deleted = TRUE;
5971 
5972  /* remove formerly active constraint from the conssetchg's addedconss / prob's conss array */
5973  if( cons->addarraypos >= 0 )
5974  {
5975  if( cons->addconssetchg == NULL )
5976  {
5977  /* remove problem constraint from the problem */
5978  SCIP_CALL( SCIPprobDelCons(prob, blkmem, set, stat, cons) );
5979  }
5980  else
5981  {
5982  assert(cons->addconssetchg->addedconss != NULL);
5983  assert(0 <= cons->addarraypos && cons->addarraypos < cons->addconssetchg->naddedconss);
5984  assert(cons->addconssetchg->addedconss[cons->addarraypos] == cons);
5985 
5986  /* remove constraint from the constraint set change addedconss array */
5987  SCIP_CALL( conssetchgDelAddedCons(cons->addconssetchg, blkmem, set, cons->addarraypos) );
5988  }
5989  }
5990 
5991  return SCIP_OKAY;
5992 }
5993 
5994 /** gets and captures transformed constraint of a given original constraint; if the constraint is not yet transformed,
5995  * a new transformed constraint for this constraint is created
5996  */
5998  SCIP_CONS* origcons, /**< original constraint */
5999  BMS_BLKMEM* blkmem, /**< block memory buffer */
6000  SCIP_SET* set, /**< global SCIP settings */
6001  SCIP_CONS** transcons /**< pointer to store the transformed constraint */
6002  )
6003 {
6004  assert(origcons != NULL);
6005  assert(set != NULL);
6006  assert(origcons->scip == set->scip);
6007  assert(origcons->conshdlr != NULL);
6008  assert(origcons->original);
6009  assert(transcons != NULL);
6010 
6011  /* check, if the constraint is already transformed */
6012  if( origcons->transorigcons != NULL )
6013  {
6014  *transcons = origcons->transorigcons;
6015  SCIPconsCapture(*transcons);
6016  }
6017  else
6018  {
6019  /* create transformed constraint */
6020  if( origcons->conshdlr->constrans != NULL )
6021  {
6022  /* use constraint handler's own method to transform constraint */
6023  SCIP_CALL( origcons->conshdlr->constrans(set->scip, origcons->conshdlr, origcons, transcons) );
6024  }
6025  else
6026  {
6027  /* create new constraint with a pointer copy of the constraint data */
6028  SCIP_CALL( SCIPconsCreate(transcons, blkmem, set, origcons->name, origcons->conshdlr, origcons->consdata, origcons->initial,
6029  origcons->separate, origcons->enforce, origcons->check, origcons->propagate,
6030  origcons->local, origcons->modifiable, origcons->dynamic, origcons->removable, origcons->stickingatnode,
6031  FALSE, FALSE) );
6032  }
6033 
6034  /* link original and transformed constraint */
6035  origcons->transorigcons = *transcons;
6036  (*transcons)->transorigcons = origcons;
6037 
6038  /* copy the number of upgradelocks */
6039  (*transcons)->nupgradelocks = origcons->nupgradelocks; /*lint !e732*/
6040  }
6041  assert(*transcons != NULL);
6042 
6043  return SCIP_OKAY;
6044 }
6045 
6046 /** sets the initial flag of the given constraint */
6048  SCIP_CONS* cons, /**< constraint */
6049  SCIP_SET* set, /**< global SCIP settings */
6050  SCIP_STAT* stat, /**< dynamic problem statistics */
6051  SCIP_Bool initial /**< new value */
6052  )
6053 {
6054  assert(cons != NULL);
6055  assert(set != NULL);
6056  assert(cons->scip == set->scip);
6057 
6058  if( cons->initial != initial )
6059  {
6060  cons->initial = initial;
6061  if( !cons->original )
6062  {
6063  if( cons->initial )
6064  {
6065  SCIP_CALL( conshdlrAddInitcons(SCIPconsGetHdlr(cons), set, stat, cons) );
6066  }
6067  else
6068  {
6069  if( cons->initconsspos >= 0 )
6070  {
6071  conshdlrDelInitcons(SCIPconsGetHdlr(cons), cons);
6072  }
6073  }
6074  }
6075  }
6076 
6077  return SCIP_OKAY;
6078 }
6079 
6080 /** sets the separate flag of the given constraint */
6082  SCIP_CONS* cons, /**< constraint */
6083  SCIP_SET* set, /**< global SCIP settings */
6084  SCIP_Bool separate /**< new value */
6085  )
6086 {
6087  assert(cons != NULL);
6088  assert(set != NULL);
6089  assert(cons->scip == set->scip);
6090 
6091  if( cons->separate != separate )
6092  {
6093  if( SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM )
6094  {
6095  cons->separate = separate;
6096  }
6097  else if( cons->enabled && cons->sepaenabled )
6098  {
6099  if( separate )
6100  {
6101  cons->separate = separate;
6102  SCIP_CALL( conshdlrAddSepacons(cons->conshdlr, set, cons) );
6103  }
6104  else
6105  {
6106  conshdlrDelSepacons(cons->conshdlr, cons);
6107  cons->separate = separate;
6108  }
6109  }
6110  }
6111 
6112  return SCIP_OKAY;
6113 }
6114 
6115 /** sets the enforce flag of the given constraint */
6117  SCIP_CONS* cons, /**< constraint */
6118  SCIP_SET* set, /**< global SCIP settings */
6119  SCIP_Bool enforce /**< new value */
6120  )
6121 {
6122  assert(cons != NULL);
6123  assert(set != NULL);
6124  assert(cons->scip == set->scip);
6125 
6126  if( cons->enforce != enforce )
6127  {
6128  if( SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM )
6129  {
6130  cons->enforce = enforce;
6131  }
6132  else if( cons->enabled )
6133  {
6134  if( enforce )
6135  {
6136  cons->enforce = enforce;
6137  SCIP_CALL( conshdlrAddEnfocons(cons->conshdlr, set, cons) );
6138  }
6139  else
6140  {
6141  conshdlrDelEnfocons(cons->conshdlr, cons);
6142  cons->enforce = enforce;
6143  }
6144  }
6145  }
6146 
6147  return SCIP_OKAY;
6148 }
6149 
6150 /** sets the check flag of the given constraint */
6152  SCIP_CONS* cons, /**< constraint */
6153  SCIP_SET* set, /**< global SCIP settings */
6154  SCIP_Bool check /**< new value */
6155  )
6156 {
6157  assert(cons != NULL);
6158  assert(set != NULL);
6159  assert(cons->scip == set->scip);
6160 
6161  if( cons->check != check )
6162  {
6163  cons->check = check;
6164 
6165  if( !cons->original )
6166  {
6167  /* if constraint is a problem constraint, update variable roundings locks */
6168  if( cons->addconssetchg == NULL && cons->addarraypos >= 0 )
6169  {
6170  if( cons->check )
6171  {
6172  SCIP_CALL( SCIPconsAddLocks(cons, set, +1, 0) );
6173  }
6174  else
6175  {
6176  SCIP_CALL( SCIPconsAddLocks(cons, set, -1, 0) );
6177  }
6178  }
6179 
6180  /* if constraint is active, update the checkconss array of the constraint handler */
6181  if( cons->active )
6182  {
6183  if( cons->check )
6184  {
6185  SCIP_CALL( conshdlrAddCheckcons(cons->conshdlr, set, cons) );
6186  }
6187  else
6188  {
6189  conshdlrDelCheckcons(cons->conshdlr, cons);
6190  }
6191  }
6192  }
6193  }
6194 
6195  return SCIP_OKAY;
6196 }
6197 
6198 /** sets the propagate flag of the given constraint */
6200  SCIP_CONS* cons, /**< constraint */
6201  SCIP_SET* set, /**< global SCIP settings */
6202  SCIP_Bool propagate /**< new value */
6203  )
6204 {
6205  assert(cons != NULL);
6206  assert(set != NULL);
6207  assert(cons->scip == set->scip);
6208 
6209  if( cons->propagate != propagate )
6210  {
6211  if( SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM )
6212  {
6213  cons->propagate = propagate;
6214  }
6215  else if( cons->enabled && cons->propenabled )
6216  {
6217  if( propagate )
6218  {
6219  cons->propagate = propagate;
6220  SCIP_CALL( conshdlrAddPropcons(cons->conshdlr, set, cons) );
6221  }
6222  else
6223  {
6224  conshdlrDelPropcons(cons->conshdlr, cons);
6225  cons->propagate = propagate;
6226  }
6227  }
6228  }
6229 
6230  return SCIP_OKAY;
6231 }
6232 
6233 /** sets the local flag of the given constraint */
6234 void SCIPconsSetLocal(
6235  SCIP_CONS* cons, /**< constraint */
6236  SCIP_Bool local /**< new value */
6237  )
6238 {
6239  assert(cons != NULL);
6240 
6241  cons->local = local;
6242  if( !local )
6243  cons->validdepth = 0;
6244 }
6245 
6246 /** sets the modifiable flag of the given constraint */
6248  SCIP_CONS* cons, /**< constraint */
6249  SCIP_Bool modifiable /**< new value */
6250  )
6251 {
6252  assert(cons != NULL);
6253 
6254  cons->modifiable = modifiable;
6255 }
6256 
6257 /** sets the dynamic flag of the given constraint */
6258 void SCIPconsSetDynamic(
6259  SCIP_CONS* cons, /**< constraint */
6260  SCIP_Bool dynamic /**< new value */
6261  )
6262 {
6263  assert(cons != NULL);
6264 
6265  cons->dynamic = dynamic;
6266 }
6267 
6268 /** sets the removable flag of the given constraint */
6270  SCIP_CONS* cons, /**< constraint */
6271  SCIP_Bool removable /**< new value */
6272  )
6273 {
6274  assert(cons != NULL);
6275 
6276  cons->removable = removable;
6277 }
6278 
6279 /** sets the stickingatnode flag of the given constraint */
6281  SCIP_CONS* cons, /**< constraint */
6282  SCIP_Bool stickingatnode /**< new value */
6283  )
6284 {
6285  assert(cons != NULL);
6286 
6287  cons->stickingatnode = stickingatnode;
6288 }
6289 
6290 /** gives the constraint a new name; ATTENTION: to old pointer is over written that might
6291  * result in a memory leakage */
6293  SCIP_CONS* cons, /**< constraint */
6294  const char* name /**< new name of constraint */
6295  )
6296 {
6297  assert( cons != NULL );
6298  assert( name != NULL );
6299 
6300  cons->name = (char*)name;
6301 }
6302 
6303 /** gets associated transformed constraint of an original constraint, or NULL if no associated transformed constraint
6304  * exists
6305  */
6307  SCIP_CONS* cons /**< constraint */
6308  )
6309 {
6310  assert(cons->original);
6311 
6312  return cons->transorigcons;
6313 }
6314 
6315 /** activates constraint or marks constraint to be activated in next update */
6317  SCIP_CONS* cons, /**< constraint */
6318  SCIP_SET* set, /**< global SCIP settings */
6319  SCIP_STAT* stat, /**< dynamic problem statistics */
6320  int depth, /**< depth in the tree where the constraint activation takes place, or -1 for global problem */
6321  SCIP_Bool focusnode /**< does the constraint activation take place at the focus node? */
6322  )
6323 {
6324  assert(cons != NULL);
6325  assert(!cons->original);
6326  assert(!cons->active);
6327  assert(!cons->updateactivate);
6328  assert(!cons->updatedeactivate);
6329  assert(!cons->updateenable);
6330  assert(!cons->updatedisable);
6331  assert(!cons->updateobsolete);
6332  assert(!cons->updatefree);
6333  assert(cons->activedepth == -2);
6334  assert(cons->conshdlr != NULL);
6335  assert(set != NULL);
6336  assert(cons->scip == set->scip);
6337 
6338  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6339  {
6340  SCIPdebugMessage("delayed activation of constraint <%s> in constraint handler <%s> (depth %d)\n",
6341  cons->name, cons->conshdlr->name, depth);
6342  cons->updateactivate = TRUE;
6343  cons->activedepth = depth;
6344  cons->updateactfocus = focusnode;
6345  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6346  assert(cons->update);
6347  }
6348  else
6349  {
6350  SCIP_CALL( conshdlrActivateCons(cons->conshdlr, set, stat, cons, depth, focusnode) );
6351  assert(cons->active);
6352  }
6353 
6354  return SCIP_OKAY;
6355 }
6356 
6357 /** deactivates constraint or marks constraint to be deactivated in next update */
6359  SCIP_CONS* cons, /**< constraint */
6360  SCIP_SET* set, /**< global SCIP settings */
6361  SCIP_STAT* stat /**< dynamic problem statistics */
6362  )
6363 {
6364  assert(cons != NULL);
6365  assert(!cons->original);
6366  assert(cons->active);
6367  assert(!cons->updateactivate);
6368  assert(!cons->updatedeactivate);
6369  assert(cons->activedepth >= -1);
6370  assert(cons->conshdlr != NULL);
6371  assert(set != NULL);
6372  assert(cons->scip == set->scip);
6373 
6374  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6375  {
6376  SCIPdebugMessage("delayed deactivation of constraint <%s> in constraint handler <%s>\n",
6377  cons->name, cons->conshdlr->name);
6378  cons->updatedeactivate = TRUE;
6379  cons->activedepth = -2;
6380  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6381  assert(cons->update);
6382  }
6383  else
6384  {
6385  SCIP_CALL( conshdlrDeactivateCons(cons->conshdlr, set, stat, cons) );
6386  assert(!cons->active);
6387  }
6388 
6389  return SCIP_OKAY;
6390 }
6391 
6392 /** enables constraint's separation, enforcing, and propagation capabilities or marks them to be enabled in next update */
6394  SCIP_CONS* cons, /**< constraint */
6395  SCIP_SET* set, /**< global SCIP settings */
6396  SCIP_STAT* stat /**< dynamic problem statistics */
6397  )
6398 {
6399  assert(cons != NULL);
6400  assert(!cons->original);
6401  assert(cons->conshdlr != NULL);
6402  assert(set != NULL);
6403  assert(cons->scip == set->scip);
6404 
6405  if( !cons->active || cons->updatedeactivate || cons->updateenable || (cons->enabled && !cons->updatedisable) )
6406  return SCIP_OKAY;
6407 
6408  assert(!cons->updateactivate);
6409 
6410  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6411  {
6412  cons->updateenable = TRUE;
6413  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6414  assert(cons->update);
6415  }
6416  else
6417  {
6418  SCIP_CALL( conshdlrEnableCons(cons->conshdlr, set, stat, cons) );
6419  assert(cons->enabled);
6420  }
6421 
6422  return SCIP_OKAY;
6423 }
6424 
6425 /** disables constraint's separation, enforcing, and propagation capabilities or marks them to be disabled in next update */
6427  SCIP_CONS* cons, /**< constraint */
6428  SCIP_SET* set, /**< global SCIP settings */
6429  SCIP_STAT* stat /**< dynamic problem statistics */
6430  )
6431 {
6432  assert(cons != NULL);
6433  assert(!cons->original);
6434  assert(cons->conshdlr != NULL);
6435  assert(set != NULL);
6436  assert(cons->scip == set->scip);
6437 
6438  if( cons->updatedisable || (!cons->enabled && !cons->updateenable) )
6439  return SCIP_OKAY;
6440 
6441  assert(cons->active);
6442  assert(!cons->updateactivate);
6443 
6444  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6445  {
6446  cons->updatedisable = TRUE;
6447  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6448  assert(cons->update);
6449  }
6450  else
6451  {
6452  SCIP_CALL( conshdlrDisableCons(cons->conshdlr, set, stat, cons) );
6453  assert(!cons->enabled);
6454  }
6455 
6456  return SCIP_OKAY;
6457 }
6458 
6459 /** enables constraint's separation capabilities or marks them to be enabled in next update */
6461  SCIP_CONS* cons, /**< constraint */
6462  SCIP_SET* set /**< global SCIP settings */
6463  )
6464 {
6465  assert(cons != NULL);
6466  assert(cons->conshdlr != NULL);
6467  assert(set != NULL);
6468  assert(cons->scip == set->scip);
6469 
6470  if( cons->updatesepaenable || (cons->sepaenabled && !cons->updatesepadisable) )
6471  return SCIP_OKAY;
6472 
6473  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6474  {
6475  cons->updatesepadisable = FALSE;
6476  cons->updatesepaenable = TRUE;
6477  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6478  assert(cons->update);
6479  }
6480  else
6481  {
6482  SCIP_CALL( conshdlrEnableConsSeparation(cons->conshdlr, set, cons) );
6483  assert(cons->sepaenabled);
6484  }
6485 
6486  return SCIP_OKAY;
6487 }
6488 
6489 /** disables constraint's separation capabilities or marks them to be disabled in next update */
6491  SCIP_CONS* cons, /**< constraint */
6492  SCIP_SET* set /**< global SCIP settings */
6493  )
6494 {
6495  assert(cons != NULL);
6496  assert(cons->conshdlr != NULL);
6497 
6498  if( cons->updatesepadisable || (!cons->sepaenabled && !cons->updatesepaenable) )
6499  return SCIP_OKAY;
6500 
6501  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6502  {
6503  cons->updatesepaenable = FALSE;
6504  cons->updatesepadisable = TRUE;
6505  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6506  assert(cons->update);
6507  }
6508  else
6509  {
6511  assert(!cons->sepaenabled);
6512  }
6513 
6514  return SCIP_OKAY;
6515 }
6516 
6517 /** enables constraint's propagation capabilities or marks them to be enabled in next update */
6519  SCIP_CONS* cons, /**< constraint */
6520  SCIP_SET* set /**< global SCIP settings */
6521  )
6522 {
6523  assert(cons != NULL);
6524  assert(cons->conshdlr != NULL);
6525  assert(set != NULL);
6526  assert(cons->scip == set->scip);
6527 
6528  if( cons->updatepropenable || (cons->propenabled && !cons->updatepropdisable) )
6529  return SCIP_OKAY;
6530 
6531  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6532  {
6533  cons->updatepropdisable = FALSE;
6534  cons->updatepropenable = TRUE;
6535  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6536  assert(cons->update);
6537  }
6538  else
6539  {
6540  SCIP_CALL( conshdlrEnableConsPropagation(cons->conshdlr, set, cons) );
6541  assert(cons->propenabled);
6542  }
6543 
6544  return SCIP_OKAY;
6545 }
6546 
6547 /** disables constraint's propagation capabilities or marks them to be disabled in next update */
6549  SCIP_CONS* cons, /**< constraint */
6550  SCIP_SET* set /**< global SCIP settings */
6551  )
6552 {
6553  assert(cons != NULL);
6554  assert(cons->conshdlr != NULL);
6555  assert(set != NULL);
6556  assert(cons->scip == set->scip);
6557 
6558  if( cons->updatepropdisable || (!cons->propenabled && !cons->updatepropenable) )
6559  return SCIP_OKAY;
6560 
6561  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6562  {
6563  cons->updatepropenable = FALSE;
6564  cons->updatepropdisable = TRUE;
6565  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6566  assert(cons->update);
6567  }
6568  else
6569  {
6571  assert(!cons->propenabled);
6572  }
6573 
6574  return SCIP_OKAY;
6575 }
6576 
6577 /** marks the constraint to be propagated (update might be delayed) */
6579  SCIP_CONS* cons, /**< constraint */
6580  SCIP_SET* set /**< global SCIP settings */
6581  )
6582 {
6583  assert(cons != NULL);
6584  assert(cons->conshdlr != NULL);
6585  assert(set != NULL);
6586  assert(cons->scip == set->scip);
6587 
6588  if( cons->updatemarkpropagate || (cons->markpropagate && !cons->updateunmarkpropagate) )
6589  return SCIP_OKAY;
6590 
6591  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6592  {
6593  cons->updateunmarkpropagate = FALSE;
6594  cons->updatemarkpropagate = TRUE;
6595  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6596  assert(cons->update);
6597  }
6598  else
6599  {
6600  conshdlrMarkConsPropagate(cons->conshdlr, cons);
6601  assert(cons->markpropagate || !cons->enabled);
6602  }
6603 
6604  return SCIP_OKAY;
6605 }
6606 
6607 /** unmarks the constraint to be propagated (update might be delayed) */
6609  SCIP_CONS* cons, /**< constraint */
6610  SCIP_SET* set /**< global SCIP settings */
6611  )
6612 {
6613  assert(cons != NULL);
6614  assert(cons->conshdlr != NULL);
6615  assert(set != NULL);
6616  assert(cons->scip == set->scip);
6617 
6618  if( cons->updateunmarkpropagate || (!cons->markpropagate && !cons->updatemarkpropagate) )
6619  return SCIP_OKAY;
6620 
6621  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6622  {
6623  cons->updatemarkpropagate = FALSE;
6624  cons->updateunmarkpropagate = TRUE;
6625  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6626  assert(cons->update);
6627  }
6628  else
6629  {
6631  assert(!cons->markpropagate || !cons->enabled);
6632  }
6633 
6634  return SCIP_OKAY;
6635 
6636 }
6637 
6638 /** adds given value to age of constraint, but age can never become negative;
6639  * should be called
6640  * - in constraint separation, if no cut was found for this constraint,
6641  * - in constraint enforcing, if constraint was feasible, and
6642  * - in constraint propagation, if no domain reduction was deduced;
6643  * if it's age exceeds the constraint age limit, makes constraint obsolete or marks constraint to be made obsolete
6644  * in next update
6645  */
6647  SCIP_CONS* cons, /**< constraint */
6648  BMS_BLKMEM* blkmem, /**< block memory */
6649  SCIP_SET* set, /**< global SCIP settings */
6650  SCIP_STAT* stat, /**< dynamic problem statistics */
6651  SCIP_PROB* prob, /**< problem data */
6652  SCIP_Real deltaage /**< value to add to the constraint's age */
6653  )
6654 {
6655  assert(cons != NULL);
6656  assert(cons->conshdlr != NULL);
6657  assert(!cons->updateactivate);
6658  assert(set != NULL);
6659  assert(cons->scip == set->scip);
6660 
6661  /* no aging in presolving */
6662  if( set->stage == SCIP_STAGE_PRESOLVING )
6663  return SCIP_OKAY;
6664 
6665  SCIPdebugMessage("adding %g to age (%g) of constraint <%s> of handler <%s>\n",
6666  deltaage, cons->age, cons->name, cons->conshdlr->name);
6667 
6668  cons->age += deltaage;
6669  cons->age = MAX(cons->age, 0.0);
6670 
6671  if( !cons->original )
6672  {
6673  if( !cons->check && consExceedsAgelimit(cons, set) )
6674  {
6675  SCIP_CALL( SCIPconsDelete(cons, blkmem, set, stat, prob) );
6676  }
6677  else if( !cons->obsolete && consExceedsObsoleteage(cons, set) )
6678  {
6679  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6680  {
6681  cons->updateobsolete = TRUE;
6682  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6683  assert(cons->update);
6684  }
6685  else
6686  {
6688  assert(cons->obsolete);
6689  }
6690  }
6691  }
6692 
6693  return SCIP_OKAY;
6694 }
6695 
6696 /** increases age of constraint by 1.0;
6697  * should be called
6698  * - in constraint separation, if no cut was found for this constraint,
6699  * - in constraint enforcing, if constraint was feasible, and
6700  * - in constraint propagation, if no domain reduction was deduced;
6701  * if it's age exceeds the constraint age limit, makes constraint obsolete or marks constraint to be made obsolete
6702  * in next update
6703  */
6705  SCIP_CONS* cons, /**< constraint */
6706  BMS_BLKMEM* blkmem, /**< block memory */
6707  SCIP_SET* set, /**< global SCIP settings */
6708  SCIP_STAT* stat, /**< dynamic problem statistics */
6709  SCIP_PROB* prob /**< problem data */
6710  )
6711 {
6712  SCIP_CALL( SCIPconsAddAge(cons, blkmem, set, stat, prob, 1.0) );
6713 
6714  return SCIP_OKAY;
6715 }
6716 
6717 /** resets age of constraint to zero;
6718  * should be called
6719  * - in constraint separation, if a cut was found for this constraint,
6720  * - in constraint enforcing, if the constraint was violated, and
6721  * - in constraint propagation, if a domain reduction was deduced;
6722  * if it was obsolete, makes constraint useful again or marks constraint to be made useful again in next update
6723  */
6725  SCIP_CONS* cons, /**< constraint */
6726  SCIP_SET* set /**< global SCIP settings */
6727  )
6728 {
6729  assert(cons != NULL);
6730  assert(cons->conshdlr != NULL);
6731  assert(!cons->updateactivate);
6732  assert(set != NULL);
6733  assert(cons->scip == set->scip);
6734 
6735  SCIPdebugMessage("resetting age %g of constraint <%s> of handler <%s>\n", cons->age, cons->name, cons->conshdlr->name);
6736 
6737  conshdlrUpdateAgeresetavg(cons->conshdlr, cons->age);
6738  cons->age = 0.0;
6739 
6740  if( cons->obsolete )
6741  {
6742  assert(!cons->original);
6743  if( conshdlrAreUpdatesDelayed(cons->conshdlr) )
6744  {
6745  cons->updateobsolete = TRUE;
6746  SCIP_CALL( conshdlrAddUpdateCons(cons->conshdlr, set, cons) );
6747  assert(cons->update);
6748  }
6749  else
6750  {
6751  SCIP_CALL( conshdlrMarkConsUseful(cons->conshdlr, cons) );
6752  assert(!cons->obsolete);
6753  }
6754  }
6755 
6756  return SCIP_OKAY;
6757 }
6758 
6759 /** adds an active constraint to the propagation queue(if not already marked for propagation) of corresponding
6760  * constraint handler and marks the constraint to be propagated in the next propagation round
6761  *
6762  * @note if constraint is added to the queue it will be captured
6763  */
6765  SCIP_CONS* cons /**< constraint */
6766  )
6767 {
6768  assert(cons != NULL);
6769  assert(cons->conshdlr != NULL);
6770 
6771  if( !SCIPconsIsActive(cons) )
6772  return SCIP_OKAY;
6773 
6774  if( !cons->markedprop )
6775  {
6776  SCIP_CALL( SCIPqueueInsert(cons->conshdlr->pendingconss, (void*)cons) );
6777  SCIPconsCapture(cons);
6778  cons->markedprop = TRUE;
6779  }
6780  assert(cons->markedprop);
6781 
6782  return SCIP_OKAY;
6783 }
6784 
6785 /** returns first constraint from propagation queue(if not empty) of given constraint handler */
6787  SCIP_CONSHDLR* conshdlr /**< constraint handler */
6788  )
6789 {
6790  if( SCIPqueueIsEmpty(conshdlr->pendingconss) )
6791  return NULL;
6792 
6793  return (SCIP_CONS*)SCIPqueueFirst(conshdlr->pendingconss);
6794 }
6795 
6796 /** removes constraint from propagation queue(if not empty) of given constraint handler and unmarks constraint to be
6797  * propagated in the next propagation round
6798  *
6799  * @note if constraint is removed from the queue it will be released
6800  */
6802  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
6803  BMS_BLKMEM* blkmem, /**< block memory */
6804  SCIP_SET* set /**< global SCIP settings */
6805  )
6806 {
6807  SCIP_CONS* cons;
6808 
6809  if( SCIPqueueIsEmpty(conshdlr->pendingconss) )
6810  return SCIP_OKAY;
6811 
6812  cons = (SCIP_CONS*)SCIPqueueRemove(conshdlr->pendingconss);
6813  assert(cons != NULL);
6814 
6815  cons->markedprop = FALSE;
6816  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
6817 
6818  return SCIP_OKAY;
6819 }
6820 
6821 /** resolves the given conflicting bound, that was deduced by the given constraint, by putting all "reason" bounds
6822  * leading to the deduction into the conflict queue with calls to SCIPaddConflictLb(), SCIPaddConflictUb(), SCIPaddConflictBd(),
6823  * SCIPaddConflictRelaxedLb(), SCIPaddConflictRelaxedUb(), SCIPaddConflictRelaxedBd(), or SCIPaddConflictBinvar();
6824  *
6825  * @note it is sufficient to explain the relaxed bound change
6826  */
6828  SCIP_CONS* cons, /**< constraint that deduced the assignment */
6829  SCIP_SET* set, /**< global SCIP settings */
6830  SCIP_VAR* infervar, /**< variable whose bound was deduced by the constraint */
6831  int inferinfo, /**< user inference information attached to the bound change */
6832  SCIP_BOUNDTYPE inferboundtype, /**< bound that was deduced (lower or upper bound) */
6833  SCIP_BDCHGIDX* bdchgidx, /**< bound change index, representing the point of time where change took place */
6834  SCIP_Real relaxedbd, /**< the relaxed bound */
6835  SCIP_RESULT* result /**< pointer to store the result of the callback method */
6836  )
6837 {
6838  SCIP_CONSHDLR* conshdlr;
6839 
6840  assert(cons != NULL);
6841  assert((inferboundtype == SCIP_BOUNDTYPE_LOWER
6842  && SCIPvarGetLbAtIndex(infervar, bdchgidx, TRUE) > SCIPvarGetLbGlobal(infervar))
6843  || (inferboundtype == SCIP_BOUNDTYPE_UPPER
6844  && SCIPvarGetUbAtIndex(infervar, bdchgidx, TRUE) < SCIPvarGetUbGlobal(infervar)));
6845  assert(result != NULL);
6846  assert(set != NULL);
6847  assert(cons->scip == set->scip);
6848 
6849  *result = SCIP_DIDNOTRUN;
6850 
6851  conshdlr = cons->conshdlr;
6852  assert(conshdlr != NULL);
6853 
6854  if( conshdlr->consresprop != NULL )
6855  {
6856  /* start timing */
6857  SCIPclockStart(conshdlr->resproptime, set);
6858 
6859  SCIP_CALL( conshdlr->consresprop(set->scip, conshdlr, cons, infervar, inferinfo, inferboundtype, bdchgidx,
6860  relaxedbd, result) );
6861 
6862  /* stop timing */
6863  SCIPclockStop(conshdlr->resproptime, set);
6864 
6865  /* update statistics */
6866  conshdlr->nrespropcalls++;
6867 
6868  /* check result code */
6869  if( *result != SCIP_SUCCESS && *result != SCIP_DIDNOTFIND )
6870  {
6871  SCIPerrorMessage("propagation conflict resolving method of constraint handler <%s> returned invalid result <%d>\n",
6872  conshdlr->name, *result);
6873  return SCIP_INVALIDRESULT;
6874  }
6875  }
6876  else
6877  {
6878  SCIPerrorMessage("propagation conflict resolving method of constraint handler <%s> is not implemented\n",
6879  conshdlr->name);
6880  return SCIP_PLUGINNOTFOUND;
6881  }
6882 
6883  return SCIP_OKAY;
6884 }
6885 
6886 /** adds given values to lock status of the constraint and updates the rounding locks of the involved variables */
6888  SCIP_CONS* cons, /**< constraint */
6889  SCIP_SET* set, /**< global SCIP settings */
6890  int nlockspos, /**< increase in number of rounding locks for constraint */
6891  int nlocksneg /**< increase in number of rounding locks for constraint's negation */
6892  )
6893 {
6894  int oldnlockspos;
6895  int oldnlocksneg;
6896  int updlockpos;
6897  int updlockneg;
6898 
6899  assert(cons != NULL);
6900  assert(cons->conshdlr != NULL);
6901  assert(cons->conshdlr->conslock != NULL);
6902  assert(cons->nlockspos >= 0);
6903  assert(cons->nlocksneg >= 0);
6904  assert(-2 <= nlockspos && nlockspos <= 2);
6905  assert(-2 <= nlocksneg && nlocksneg <= 2);
6906  assert(set != NULL);
6907  assert(cons->scip == set->scip);
6908 
6909  /* update the rounding locks */
6910  oldnlockspos = cons->nlockspos;
6911  oldnlocksneg = cons->nlocksneg;
6912  cons->nlockspos += nlockspos;
6913  cons->nlocksneg += nlocksneg;
6914  assert(cons->nlockspos >= 0);
6915  assert(cons->nlocksneg >= 0);
6916 
6917  /* check, if the constraint switched from unlocked to locked, or from locked to unlocked */
6918  updlockpos = (int)(cons->nlockspos > 0) - (int)(oldnlockspos > 0);
6919  updlockneg = (int)(cons->nlocksneg > 0) - (int)(oldnlocksneg > 0);
6920 
6921  /* lock the variables, if the constraint switched from unlocked to locked or from locked to unlocked */
6922  if( updlockpos != 0 || updlockneg != 0 )
6923  {
6924  SCIP_CALL( cons->conshdlr->conslock(set->scip, cons->conshdlr, cons, updlockpos, updlockneg) );
6925  }
6926 
6927  return SCIP_OKAY;
6928 }
6929 
6930 /** checks single constraint for feasibility of the given solution */
6932  SCIP_CONS* cons, /**< constraint to check */
6933  SCIP_SET* set, /**< global SCIP settings */
6934  SCIP_SOL* sol, /**< primal CIP solution */
6935  SCIP_Bool checkintegrality, /**< has integrality to be checked? */
6936  SCIP_Bool checklprows, /**< have current LP rows to be checked? */
6937  SCIP_Bool printreason, /**< should the reason for the violation be printed? */
6938  SCIP_RESULT* result /**< pointer to store the result of the callback method */
6939  )
6940 {
6941  SCIP_CONSHDLR* conshdlr;
6942 
6943  assert(cons != NULL);
6944  assert(set != NULL);
6945  assert(cons->scip == set->scip);
6946  assert(result != NULL);
6947 
6948  conshdlr = cons->conshdlr;
6949  assert(conshdlr != NULL);
6950 
6951  /* call external method */
6952  assert(conshdlr->conscheck != NULL);
6953 
6954  SCIP_CALL( conshdlr->conscheck(set->scip, conshdlr, &cons, 1, sol, checkintegrality, checklprows, printreason, result) );
6955  SCIPdebugMessage(" -> checking returned result <%d>\n", *result);
6956 
6957  if( *result != SCIP_INFEASIBLE && *result != SCIP_FEASIBLE )
6958  {
6959  SCIPerrorMessage("feasibility check of constraint handler <%s> on constraint <%s> returned invalid result <%d>\n",
6960  conshdlr->name, cons->name, *result);
6961  return SCIP_INVALIDRESULT;
6962  }
6963 
6964  return SCIP_OKAY;
6965 }
6966 
6967 /** enforces single constraint for a given pseudo solution */
6969  SCIP_CONS* cons, /**< constraint to enforce */
6970  SCIP_SET* set, /**< global SCIP settings */
6971  SCIP_Bool solinfeasible, /**< was the solution already declared infeasible by a constraint handler? */
6972  SCIP_Bool objinfeasible, /**< is the solution infeasible anyway due to violating lower objective bound? */
6973  SCIP_RESULT* result /**< pointer to store the result of the callback method */
6974  )
6975 {
6976  SCIP_CONSHDLR* conshdlr;
6977 
6978  assert(cons != NULL);
6979  assert(set != NULL);
6980  assert(cons->scip == set->scip);
6981  assert(result != NULL);
6982 
6983  conshdlr = cons->conshdlr;
6984  assert(conshdlr != NULL);
6985 
6986  /* call external method */
6987  assert(conshdlr->consenfops != NULL);
6988 
6989  SCIP_CALL( conshdlr->consenfops(set->scip, conshdlr, &cons, 1, 1, solinfeasible, objinfeasible, result) );
6990  SCIPdebugMessage(" -> enfops returned result <%d>\n", *result);
6991 
6992  if( *result != SCIP_CUTOFF
6993  && *result != SCIP_CONSADDED
6994  && *result != SCIP_REDUCEDDOM
6995  && *result != SCIP_BRANCHED
6996  && *result != SCIP_SOLVELP
6997  && *result != SCIP_INFEASIBLE
6998  && *result != SCIP_FEASIBLE
6999  && *result != SCIP_DIDNOTRUN )
7000  {
7001  SCIPerrorMessage("enforcing method of constraint handler <%s> for pseudo solutions returned invalid result <%d>\n",
7002  conshdlr->name, *result);
7003  return SCIP_INVALIDRESULT;
7004  }
7005 
7006  /* do not update statistics */
7007 
7008  return SCIP_OKAY;
7009 }
7010 
7011 /** enforces single constraint for a given LP solution */
7013  SCIP_CONS* cons, /**< constraint to enforce */
7014  SCIP_SET* set, /**< global SCIP settings */
7015  SCIP_Bool solinfeasible, /**< was the solution already declared infeasible by a constraint handler? */
7016  SCIP_RESULT* result /**< pointer to store the result of the callback method */
7017  )
7018 {
7019  SCIP_CONSHDLR* conshdlr;
7020 
7021  assert(cons != NULL);
7022  assert(set != NULL);
7023  assert(cons->scip == set->scip);
7024  assert(result != NULL);
7025 
7026  conshdlr = cons->conshdlr;
7027  assert(conshdlr != NULL);
7028 
7029  /* call external method */
7030  assert(conshdlr->consenfolp != NULL);
7031 
7032  SCIP_CALL( conshdlr->consenfolp(set->scip, conshdlr, &cons, 1, 1, solinfeasible, result) );
7033  SCIPdebugMessage(" -> enfolp returned result <%d>\n", *result);
7034 
7035  if( *result != SCIP_CUTOFF
7036  && *result != SCIP_CONSADDED
7037  && *result != SCIP_REDUCEDDOM
7038  && *result != SCIP_BRANCHED
7039  && *result != SCIP_SEPARATED
7040  && *result != SCIP_INFEASIBLE
7041  && *result != SCIP_FEASIBLE)
7042  {
7043  SCIPerrorMessage("enforcing method of constraint handler <%s> for LP returned invalid result <%d>\n",
7044  conshdlr->name, *result);
7045  return SCIP_INVALIDRESULT;
7046  }
7047 
7048  /* do not update statistics */
7049 
7050  return SCIP_OKAY;
7051 }
7052 
7053 
7054 /** calls LP initialization method for single constraint */
7056  SCIP_CONS* cons, /**< constraint to initialize */
7057  SCIP_SET* set /**< global SCIP settings */
7058  )
7059 {
7060  SCIP_CONSHDLR* conshdlr;
7061 
7062  assert(cons != NULL);
7063  assert(set != NULL);
7064  assert(cons->scip == set->scip);
7065 
7066  conshdlr = cons->conshdlr;
7067  assert(conshdlr != NULL);
7068 
7069  /* call external method */
7070  if( conshdlr->consinitlp != NULL )
7071  {
7072  SCIP_CALL( conshdlr->consinitlp(set->scip, conshdlr, &cons, 1) );
7073  }
7074 
7075  return SCIP_OKAY;
7076 }
7077 
7078 /** calls separation method of single constraint for LP solution */
7080  SCIP_CONS* cons, /**< constraint to separate */
7081  SCIP_SET* set, /**< global SCIP settings */
7082  SCIP_RESULT* result /**< pointer to store the result of the separation call */
7083  )
7084 {
7085  SCIP_CONSHDLR* conshdlr;
7086 
7087  assert(cons != NULL);
7088  assert(set != NULL);
7089  assert(cons->scip == set->scip);
7090  assert(result != NULL);
7091 
7092  conshdlr = cons->conshdlr;
7093  assert(conshdlr != NULL);
7094 
7095  /* call external method */
7096  if( conshdlr->conssepalp != NULL )
7097  {
7098  SCIP_CALL( conshdlr->conssepalp(set->scip, conshdlr, &cons, 1, 1, result) );
7099  SCIPdebugMessage(" -> sepalp returned result <%d>\n", *result);
7100 
7101  if( *result != SCIP_CUTOFF
7102  && *result != SCIP_CONSADDED
7103  && *result != SCIP_REDUCEDDOM
7104  && *result != SCIP_SEPARATED
7105  && *result != SCIP_NEWROUND
7106  && *result != SCIP_DIDNOTFIND
7107  && *result != SCIP_DIDNOTRUN
7108  && *result != SCIP_DELAYED )
7109  {
7110  SCIPerrorMessage("separation method of constraint handler <%s> returned invalid result <%d>\n", conshdlr->name,
7111  *result);
7112  return SCIP_INVALIDRESULT;
7113  }
7114  }
7115 
7116  return SCIP_OKAY;
7117 }
7118 
7119 /** calls separation method of single constraint for given primal solution */
7121  SCIP_CONS* cons, /**< constraint to separate */
7122  SCIP_SET* set, /**< global SCIP settings */
7123  SCIP_SOL* sol, /**< primal solution that should be separated */
7124  SCIP_RESULT* result /**< pointer to store the result of the separation call */
7125  )
7126 {
7127  SCIP_CONSHDLR* conshdlr;
7128 
7129  assert(cons != NULL);
7130  assert(set != NULL);
7131  assert(cons->scip == set->scip);
7132  assert(sol != NULL);
7133  assert(result != NULL);
7134 
7135  conshdlr = cons->conshdlr;
7136  assert(conshdlr != NULL);
7137 
7138  /* call external method */
7139  if( conshdlr->conssepasol != NULL )
7140  {
7141  SCIP_CALL( conshdlr->conssepasol(set->scip, conshdlr, &cons, 1, 1, sol, result) );
7142  SCIPdebugMessage(" -> sepasol returned result <%d>\n", *result);
7143 
7144  if( *result != SCIP_CUTOFF
7145  && *result != SCIP_CONSADDED
7146  && *result != SCIP_REDUCEDDOM
7147  && *result != SCIP_SEPARATED
7148  && *result != SCIP_NEWROUND
7149  && *result != SCIP_DIDNOTFIND
7150  && *result != SCIP_DIDNOTRUN
7151  && *result != SCIP_DELAYED )
7152  {
7153  SCIPerrorMessage("separation method of constraint handler for arbitrary primal solution <%s> returned invalid result <%d>\n",
7154  conshdlr->name, *result);
7155  return SCIP_INVALIDRESULT;
7156  }
7157  }
7158 
7159  return SCIP_OKAY;
7160 }
7161 
7162 /** calls domain propagation method of single constraint */
7164  SCIP_CONS* cons, /**< constraint to propagate */
7165  SCIP_SET* set, /**< global SCIP settings */
7166  SCIP_PROPTIMING proptiming, /**< current point in the node solving loop */
7167  SCIP_RESULT* result /**< pointer to store the result of the callback method */
7168  )
7169 {
7170  SCIP_CONSHDLR* conshdlr;
7171 
7172  assert(cons != NULL);
7173  assert(set != NULL);
7174  assert(cons->scip == set->scip);
7175  assert(result != NULL);
7176 
7177  conshdlr = cons->conshdlr;
7178  assert(conshdlr != NULL);
7179 
7180  /* call external method */
7181  if( conshdlr->consprop != NULL )
7182  {
7183  SCIP_CALL( conshdlr->consprop(set->scip, conshdlr, &cons, 1, 1, 1, proptiming, result) );
7184  SCIPdebugMessage(" -> prop returned result <%d>\n", *result);
7185 
7186  if( *result != SCIP_CUTOFF
7187  && *result != SCIP_CONSADDED
7188  && *result != SCIP_REDUCEDDOM
7189  && *result != SCIP_DIDNOTFIND
7190  && *result != SCIP_DIDNOTRUN
7191  && *result != SCIP_DELAYED )
7192  {
7193  SCIPerrorMessage("propagation method of constraint handler <%s> returned invalid result <%d>\n",
7194  conshdlr->name, *result);
7195  return SCIP_INVALIDRESULT;
7196  }
7197  }
7198 
7199  return SCIP_OKAY;
7200 }
7201 
7202 /** resolves propagation conflict of single constraint */
7204  SCIP_CONS* cons, /**< constraint to resolve conflict for */
7205  SCIP_SET* set, /**< global SCIP settings */
7206  SCIP_VAR* infervar, /**< the conflict variable whose bound change has to be resolved */
7207  int inferinfo, /**< the user information passed to the corresponding SCIPinferVarLbCons() or SCIPinferVarUbCons() call */
7208  SCIP_BOUNDTYPE boundtype, /**< the type of the changed bound (lower or upper bound) */
7209  SCIP_BDCHGIDX* bdchgidx, /**< the index of the bound change, representing the point of time where the change took place */
7210  SCIP_Real relaxedbd, /**< the relaxed bound which is sufficient to be explained */
7211  SCIP_RESULT* result /**< pointer to store the result of the callback method */
7212  )
7213 {
7214  SCIP_CONSHDLR* conshdlr;
7215 
7216  assert(cons != NULL);
7217  assert(set != NULL);
7218  assert(cons->scip == set->scip);
7219  assert(result != NULL);
7220  assert(infervar != NULL);
7221  assert(bdchgidx != NULL);
7222 
7223  conshdlr = cons->conshdlr;
7224  assert(conshdlr != NULL);
7225 
7226  /* call external method */
7227  if( conshdlr->consresprop != NULL )
7228  {
7229  SCIP_CALL( conshdlr->consresprop(set->scip, conshdlr, cons, infervar, inferinfo, boundtype, bdchgidx, relaxedbd, result) );
7230  SCIPdebugMessage(" -> resprop returned result <%d>\n", *result);
7231 
7232  if( *result != SCIP_SUCCESS
7233  && *result != SCIP_DIDNOTFIND )
7234  {
7235  SCIPerrorMessage("propagation conflict resolving method of constraint handler <%s> returned invalid result <%d>\n",
7236  conshdlr->name, *result);
7237  return SCIP_INVALIDRESULT;
7238  }
7239  }
7240 
7241  return SCIP_OKAY;
7242 }
7243 
7244 /** presolves single constraint */
7246  SCIP_CONS* cons, /**< constraint to presolve */
7247  SCIP_SET* set, /**< global SCIP settings */
7248  int nrounds, /**< number of presolving rounds already done */
7249  int nnewfixedvars, /**< number of variables fixed since the last call to the presolving method */
7250  int nnewaggrvars, /**< number of variables aggregated since the last call to the presolving method */
7251  int nnewchgvartypes, /**< number of variable type changes since the last call to the presolving method */
7252  int nnewchgbds, /**< number of variable bounds tightened since the last call to the presolving method */
7253  int nnewholes, /**< number of domain holes added since the last call to the presolving method */
7254  int nnewdelconss, /**< number of deleted constraints since the last call to the presolving method */
7255  int nnewaddconss, /**< number of added constraints since the last call to the presolving method */
7256  int nnewupgdconss, /**< number of upgraded constraints since the last call to the presolving method */
7257  int nnewchgcoefs, /**< number of changed coefficients since the last call to the presolving method */
7258  int nnewchgsides, /**< number of changed left or right hand sides since the last call to the presolving method */
7259  int* nfixedvars, /**< pointer to count total number of variables fixed of all presolvers */
7260  int* naggrvars, /**< pointer to count total number of variables aggregated of all presolvers */
7261  int* nchgvartypes, /**< pointer to count total number of variable type changes of all presolvers */
7262  int* nchgbds, /**< pointer to count total number of variable bounds tightened of all presolvers */
7263  int* naddholes, /**< pointer to count total number of domain holes added of all presolvers */
7264  int* ndelconss, /**< pointer to count total number of deleted constraints of all presolvers */
7265  int* naddconss, /**< pointer to count total number of added constraints of all presolvers */
7266  int* nupgdconss, /**< pointer to count total number of upgraded constraints of all presolvers */
7267  int* nchgcoefs, /**< pointer to count total number of changed coefficients of all presolvers */
7268  int* nchgsides, /**< pointer to count total number of changed left/right hand sides of all presolvers */
7269  SCIP_RESULT* result /**< pointer to store the result of the callback method */
7270  )
7271 {
7272  SCIP_CONSHDLR* conshdlr;
7273 
7274  assert(cons != NULL);
7275  assert(set != NULL);
7276  assert(cons->scip == set->scip);
7277  assert(nfixedvars != NULL);
7278  assert(naggrvars != NULL);
7279  assert(nchgvartypes != NULL);
7280  assert(nchgbds != NULL);
7281  assert(naddholes != NULL);
7282  assert(ndelconss != NULL);
7283  assert(naddconss != NULL);
7284  assert(nupgdconss != NULL);
7285  assert(nchgcoefs != NULL);
7286  assert(nchgsides != NULL);
7287  assert(result != NULL);
7288 
7289  conshdlr = cons->conshdlr;
7290  assert(conshdlr != NULL);
7291 
7292  /* call external method */
7293  if( conshdlr->conspresol != NULL )
7294  {
7295  SCIP_CALL( conshdlr->conspresol(set->scip, conshdlr, &cons, 1, nrounds, nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds,
7296  nnewholes, nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, nfixedvars, naggrvars, nchgvartypes,
7297  nchgbds, naddholes, ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) );
7298  SCIPdebugMessage(" -> presol returned result <%d>\n", *result);
7299 
7300  if( *result != SCIP_UNBOUNDED
7301  && *result != SCIP_CUTOFF
7302  && *result != SCIP_SUCCESS
7303  && *result != SCIP_DIDNOTFIND
7304  && *result != SCIP_DIDNOTRUN
7305  && *result != SCIP_DELAYED )
7306  {
7307  SCIPerrorMessage("presolving method of constraint handler <%s> returned invalid result <%d>\n",
7308  conshdlr->name, *result);
7309  return SCIP_INVALIDRESULT;
7310  }
7311  }
7312 
7313  return SCIP_OKAY;
7314 }
7315 
7316 /** calls constraint activation notification method of single constraint */
7318  SCIP_CONS* cons, /**< constraint to notify */
7319  SCIP_SET* set /**< global SCIP settings */
7320  )
7321 {
7322  SCIP_CONSHDLR* conshdlr;
7323 
7324  assert(cons != NULL);
7325  assert(set != NULL);
7326  assert(cons->scip == set->scip);
7327 
7328  conshdlr = cons->conshdlr;
7329  assert(conshdlr != NULL);
7330 
7331  /* call external method */
7332  if( conshdlr->consactive != NULL )
7333  {
7334  SCIP_CALL( conshdlr->consactive(set->scip, conshdlr, cons) );
7335  }
7336 
7337  return SCIP_OKAY;
7338 }
7339 
7340 /** calls constraint deactivation notification method of single constraint */
7342  SCIP_CONS* cons, /**< constraint to notify */
7343  SCIP_SET* set /**< global SCIP settings */
7344  )
7345 {
7346  SCIP_CONSHDLR* conshdlr;
7347 
7348  assert(cons != NULL);
7349  assert(set != NULL);
7350  assert(cons->scip == set->scip);
7351 
7352  conshdlr = cons->conshdlr;
7353  assert(conshdlr != NULL);
7354 
7355  /* call external method */
7356  if( conshdlr->consdeactive != NULL )
7357  {
7358  SCIP_CALL( conshdlr->consdeactive(set->scip, conshdlr, cons) );
7359  }
7360 
7361  return SCIP_OKAY;
7362 }
7363 
7364 
7365 
7366 /*
7367  * Hash functions
7368  */
7369 
7370 /** gets the key (i.e. the name) of the given constraint */
7371 SCIP_DECL_HASHGETKEY(SCIPhashGetKeyCons)
7372 { /*lint --e{715}*/
7373  SCIP_CONS* cons = (SCIP_CONS*)elem;
7374 
7375  assert(cons != NULL);
7376  return cons->name;
7377 }
7378 
7379 
7380 /*
7381  * method for arrays of contraint handlers
7382  */
7383 
7384 /** ensures size of storage for propagable constraints with a minimum size of num */
7385 static
7387  SCIP_SET* set, /**< global SCIP settings */
7388  SCIP_CONSHDLR* conshdlr, /**< constraint handler */
7389  int num /**< minimum number of entries to store */
7390  )
7391 {
7392  assert(set != NULL);
7393  assert(conshdlr != NULL);
7394 
7395  if( num > conshdlr->storedpropconsssize )
7396  {
7397  int newsize;
7398 
7399  newsize = SCIPsetCalcMemGrowSize(set, num);
7400  SCIP_ALLOC( BMSreallocMemoryArray(&(conshdlr->storedpropconss), newsize) );
7401 
7402  conshdlr->storedpropconsssize = newsize;
7403  }
7404  assert(num <= conshdlr->storedpropconsssize);
7405 
7406  return SCIP_OKAY;
7407 }
7408 
7409 /** stores all constraints marked for propagation away when probing is started */
7411  SCIP_SET* set, /**< global SCIP settings */
7412  SCIP_CONSHDLR** conshdlrs, /**< all constraint handlers */
7413  int nconshdlrs /**< number of contraint handlers */
7414  )
7415 {
7416  SCIP_CONSHDLR* conshdlr;
7417  int c;
7418 
7419  assert(set != NULL);
7420  assert(conshdlrs != NULL || nconshdlrs == 0);
7421 
7422  for( c = nconshdlrs - 1; c >= 0; --c )
7423  {
7424  conshdlr = conshdlrs[c]; /*lint !e613*/
7425  assert(conshdlr != NULL);
7426  assert(conshdlr->storednmarkedpropconss == 0);
7427 
7428  if( conshdlr->nmarkedpropconss > 0 )
7429  {
7430  int v;
7431 
7432  SCIP_CALL( ensurePropagationStorage(set, conshdlr, conshdlr->nmarkedpropconss) );
7433  BMScopyMemoryArray(conshdlr->storedpropconss, conshdlr->propconss, conshdlr->nmarkedpropconss);
7434 
7435  conshdlr->storednmarkedpropconss = conshdlr->nmarkedpropconss;
7436  conshdlr->storedpropdomchgcount = conshdlr->lastpropdomchgcount;
7437 
7438  for( v = conshdlr->storednmarkedpropconss - 1; v >= 0; --v )
7439  {
7440  SCIPconsCapture(conshdlr->storedpropconss[v]);
7441  SCIP_CALL( SCIPconsUnmarkPropagate(conshdlr->storedpropconss[v], set) );
7442  }
7443  assert(conshdlr->nmarkedpropconss == 0);
7444  }
7445  }
7446 
7447  return SCIP_OKAY;
7448 }
7449 
7450 /** reset all constraints marked for propagation when probing was finished */
7452  SCIP_SET* set, /**< global SCIP settings */
7453  BMS_BLKMEM* blkmem, /**< block memory */
7454  SCIP_CONSHDLR** conshdlrs, /**< all constraint handlers */
7455  int nconshdlrs /**< number of contraint handlers */
7456  )
7457 {
7458  SCIP_CONSHDLR* conshdlr;
7459  int c;
7460 
7461  assert(set != NULL);
7462  assert(blkmem != NULL);
7463  assert(conshdlrs != NULL || nconshdlrs == 0);
7464 
7465  for( c = nconshdlrs - 1; c >= 0; --c )
7466  {
7467  conshdlr = conshdlrs[c]; /*lint !e613*/
7468  assert(conshdlr != NULL);
7469 
7470  if( conshdlr->storednmarkedpropconss > 0 )
7471  {
7472 #ifndef NDEBUG
7473  int ndisabled = 0;
7474 #endif
7475  int v;
7476 
7477  /* mark all previously marked constraint, which were marked before probing */
7478  for( v = conshdlr->storednmarkedpropconss - 1; v >= 0; --v )
7479  {
7480  SCIP_CONS* cons = conshdlr->storedpropconss[v];
7481  assert(cons != NULL);
7482 
7483  if( cons->enabled && cons->propagate && cons->propenabled )
7484  {
7485  SCIP_CALL( SCIPconsMarkPropagate(cons, set) );
7486  }
7487 #ifndef NDEBUG
7488  else
7489  ++ndisabled;
7490 #endif
7491  SCIP_CALL( SCIPconsRelease(&cons, blkmem, set) );
7492  }
7493  assert(conshdlr->storednmarkedpropconss - ndisabled <= conshdlr->npropconss);
7494  assert(conshdlr->nmarkedpropconss + ndisabled >= conshdlr->storednmarkedpropconss || (conshdlrAreUpdatesDelayed(conshdlr) && conshdlr->nupdateconss + ndisabled >= conshdlr->storednmarkedpropconss));
7495 
7496  conshdlr->lastpropdomchgcount = conshdlr->storedpropdomchgcount;
7497  conshdlr->storednmarkedpropconss = 0;
7498  }
7499  }
7500 
7501  return SCIP_OKAY;
7502 }
7503 
7504 /*
7505  * simple functions implemented as defines
7506  */
7507 
7508 /* In debug mode, the following methods are implemented as function calls to ensure
7509  * type validity.
7510  * In optimized mode, the methods are implemented as defines to improve performance.
7511  * However, we want to have them in the library anyways, so we have to undef the defines.
7512  */
7513 
7514 #undef SCIPconsGetName
7515 #undef SCIPconsGetPos
7516 #undef SCIPconsGetHdlr
7517 #undef SCIPconsGetData
7518 #undef SCIPconsGetNUses
7519 #undef SCIPconsGetActiveDepth
7520 #undef SCIPconsGetValidDepth
7521 #undef SCIPconsIsActive
7522 #undef SCIPconsIsEnabled
7523 #undef SCIPconsIsSeparationEnabled
7524 #undef SCIPconsIsPropagationEnabled
7525 #undef SCIPconsIsDeleted
7526 #undef SCIPconsIsObsolete
7527 #undef SCIPconsGetAge
7528 #undef SCIPconsIsInitial
7529 #undef SCIPconsIsSeparated
7530 #undef SCIPconsIsEnforced
7531 #undef SCIPconsIsChecked
7532 #undef SCIPconsIsMarkedPropagate
7533 #undef SCIPconsIsPropagated
7534 #undef SCIPconsIsGlobal
7535 #undef SCIPconsIsLocal
7536 #undef SCIPconsIsModifiable
7537 #undef SCIPconsIsDynamic
7538 #undef SCIPconsIsRemovable
7539 #undef SCIPconsIsStickingAtNode
7540 #undef SCIPconsIsInProb
7541 #undef SCIPconsIsOriginal
7542 #undef SCIPconsIsTransformed
7543 #undef SCIPconsIsLockedPos
7544 #undef SCIPconsIsLockedNeg
7545 #undef SCIPconsIsLocked
7546 #undef SCIPconsGetNLocksPos
7547 #undef SCIPconsGetNLocksNeg
7548 #undef SCIPconsIsAdded
7549 #undef SCIPconsGetNUpgradeLocks
7550 
7551 /** returns the name of the constraint
7552  *
7553  * @note to change the name of a constraint, use SCIPchgConsName() from scip.h
7554  */
7555 const char* SCIPconsGetName(
7556  SCIP_CONS* cons /**< constraint */
7557  )
7558 {
7559  assert(cons != NULL);
7560 
7561  return cons->name;
7562 }
7563 
7564 /** returns the position of constraint in the corresponding handler's conss array */
7565 int SCIPconsGetPos(
7566  SCIP_CONS* cons /**< constraint */
7567  )
7568 {
7569  assert(cons != NULL);
7570 
7571  return cons->consspos;
7572 }
7573 
7574 /** returns the constraint handler of the constraint */
7576  SCIP_CONS* cons /**< constraint */
7577  )
7578 {
7579  assert(cons != NULL);
7580 
7581  return cons->conshdlr;
7582 }
7583 
7584 /** returns the constraint data field of the constraint */
7586  SCIP_CONS* cons /**< constraint */
7587  )
7588 {
7589  assert(cons != NULL);
7590 
7591  return cons->consdata;
7592 }
7593 
7594 /** gets number of times, the constraint is currently captured */
7595 int SCIPconsGetNUses(
7596  SCIP_CONS* cons /**< constraint */
7597  )
7598 {
7599  assert(cons != NULL);
7600 
7601  return cons->nuses;
7602 }
7603 
7604 /** for an active constraint, returns the depth in the tree at which the constraint was activated */
7606  SCIP_CONS* cons /**< constraint */
7607  )
7608 {
7609  assert(cons != NULL);
7610  assert(SCIPconsIsActive(cons));
7611 
7612  return cons->activedepth;
7613 }
7614 
7615 /** returns TRUE iff constraint is active in the current node */
7617  SCIP_CONS* cons /**< constraint */
7618  )
7619 {
7620  assert(cons != NULL);
7621 
7622  return cons->updateactivate || (cons->active && !cons->updatedeactivate);
7623 }
7624 
7625 /** returns the depth in the tree at which the constraint is valid; returns INT_MAX, if the constraint is local
7626  * and currently not active
7627  */
7629  SCIP_CONS* cons /**< constraint */
7630  )
7631 {
7632  assert(cons != NULL);
7633  assert(cons->validdepth == 0 || cons->local);
7634 
7635  return (!cons->local ? 0
7636  : !SCIPconsIsActive(cons) ? INT_MAX
7637  : cons->validdepth == -1 ? SCIPconsGetActiveDepth(cons)
7638  : cons->validdepth);
7639 }
7640 
7641 /** returns TRUE iff constraint is enabled in the current node */
7643  SCIP_CONS* cons /**< constraint */
7644  )
7645 {
7646  assert(cons != NULL);
7647 
7648  return cons->updateenable || (cons->enabled && !cons->updatedisable);
7649 }
7650 
7651 /** returns TRUE iff constraint's separation is enabled in the current node */
7653  SCIP_CONS* cons /**< constraint */
7654  )
7655 {
7656  assert(cons != NULL);
7657 
7658  return SCIPconsIsEnabled(cons)
7659  && (cons->updatesepaenable || (cons->sepaenabled && !cons->updatesepadisable));
7660 }
7661 
7662 /** returns TRUE iff constraint's propagation is enabled in the current node */
7664  SCIP_CONS* cons /**< constraint */
7665  )
7666 {
7667  assert(cons != NULL);
7668 
7669  return SCIPconsIsEnabled(cons)
7670  && (cons->updatepropenable || (cons->propenabled && !cons->updatepropdisable));
7671 }
7672 
7673 /** returns TRUE iff constraint is deleted or marked to be deleted */
7675  SCIP_CONS* cons /**< constraint */
7676  )
7677 {
7678  assert(cons != NULL);
7679 
7680  return cons->deleted;
7681 }
7682 
7683 /** returns TRUE iff constraint is marked obsolete */
7685  SCIP_CONS* cons /**< constraint */
7686  )
7687 {
7688  assert(cons != NULL);
7689 
7690  return cons->updateobsolete || cons->obsolete;
7691 }
7692 
7693 /** gets age of constraint */
7695  SCIP_CONS* cons /**< constraint */
7696  )
7697 {
7698  assert(cons != NULL);
7699 
7700  return cons->age;
7701 }
7702 
7703 /** returns TRUE iff the LP relaxation of constraint should be in the initial LP */
7705  SCIP_CONS* cons /**< constraint */
7706  )
7707 {
7708  assert(cons != NULL);
7709 
7710  return cons->initial;
7711 }
7712 
7713 /** returns TRUE iff constraint should be separated during LP processing */
7715  SCIP_CONS* cons /**< constraint */
7716  )
7717 {
7718  assert(cons != NULL);
7719 
7720  return cons->separate;
7721 }
7722 
7723 /** returns TRUE iff constraint should be enforced during node processing */
7725  SCIP_CONS* cons /**< constraint */
7726  )
7727 {
7728  assert(cons != NULL);
7729 
7730  return cons->enforce;
7731 }
7732 
7733 /** returns TRUE iff constraint should be checked for feasibility */
7735  SCIP_CONS* cons /**< constraint */
7736  )
7737 {
7738  assert(cons != NULL);
7739 
7740  return cons->check;
7741 }
7742 
7743 /** returns whether the constraint is marked for propagation */
7745  SCIP_CONS* cons /**< constraint */
7746  )
7747 {
7748  assert(cons != NULL);
7749 
7750  return cons->markpropagate;
7751 }
7752 
7753 /** returns TRUE iff constraint should be propagated during node processing */
7755  SCIP_CONS* cons /**< constraint */
7756  )
7757 {
7758  assert(cons != NULL);
7759 
7760  return cons->propagate;
7761 }
7762 
7763 /** returns TRUE iff constraint is globally valid */
7765  SCIP_CONS* cons /**< constraint */
7766  )
7767 {
7768  assert(cons != NULL);
7769 
7770  return !cons->local;
7771 }
7772 
7773 /** returns TRUE iff constraint is only locally valid or not added to any (sub)problem */
7775  SCIP_CONS* cons /**< constraint */
7776  )
7777 {
7778  assert(cons != NULL);
7779 
7780  return cons->local;
7781 }
7782 
7783 /** returns TRUE iff constraint is modifiable (subject to column generation) */
7785  SCIP_CONS* cons /**< constraint */
7786  )
7787 {
7788  assert(cons != NULL);
7789 
7790  return cons->modifiable;
7791 }
7792 
7793 /** returns TRUE iff constraint is subject to aging */
7795  SCIP_CONS* cons /**< constraint */
7796  )
7797 {
7798  assert(cons != NULL);
7799 
7800  return cons->dynamic;
7801 }
7802 
7803 /** returns TRUE iff constraint's relaxation should be removed from the LP due to aging or cleanup */
7805  SCIP_CONS* cons /**< constraint */
7806  )
7807 {
7808  assert(cons != NULL);
7809 
7810  return cons->removable;
7811 }
7812 
7813 /** returns TRUE iff constraint's relaxation should be removed from the LP due to aging or cleanup */
7815  SCIP_CONS* cons /**< constraint */
7816  )
7817 {
7818  assert(cons != NULL);
7819 
7820  return cons->stickingatnode;
7821 }
7822 
7823 /** returns TRUE iff constraint belongs to the global problem */
7825  SCIP_CONS* cons /**< constraint */
7826  )
7827 {
7828  assert(cons != NULL);
7829 
7830  return (cons->addconssetchg == NULL && cons->addarraypos >= 0);
7831 }
7832 
7833 /** returns TRUE iff constraint is belonging to original space */
7835  SCIP_CONS* cons /**< constraint */
7836  )
7837 {
7838  assert(cons != NULL);
7839 
7840  return cons->original;
7841 }
7842 
7843 /** returns TRUE iff constraint is belonging to transformed space */
7845  SCIP_CONS* cons /**< constraint */
7846  )
7847 {
7848  assert(cons != NULL);
7849 
7850  return !cons->original;
7851 }
7852 
7853 /** returns TRUE iff roundings for variables in constraint are locked */
7855  SCIP_CONS* cons /**< constraint */
7856  )
7857 {
7858  assert(cons != NULL);
7859 
7860  return (cons->nlockspos > 0);
7861 }
7862 
7863 /** returns TRUE iff roundings for variables in constraint's negation are locked */
7865  SCIP_CONS* cons /**< constraint */
7866  )
7867 {
7868  assert(cons != NULL);
7869 
7870  return (cons->nlocksneg > 0);
7871 }
7872 
7873 /** returns TRUE iff roundings for variables in constraint or in constraint's negation are locked */
7875  SCIP_CONS* cons /**< constraint */
7876  )
7877 {
7878  assert(cons != NULL);
7879 
7880  return (cons->nlockspos > 0 || cons->nlocksneg > 0);
7881 }
7882 
7883 /** get number of times the roundings for variables in constraint are locked */
7885  SCIP_CONS* cons /**< constraint */
7886  )
7887 {
7888  assert(cons != NULL);
7889 
7890  return cons->nlockspos;
7891 }
7892 
7893 /** get number of times the roundings for variables in constraint's negation are locked */
7895  SCIP_CONS* cons /**< constraint */
7896  )
7897 {
7898  assert(cons != NULL);
7899 
7900  return cons->nlocksneg;
7901 }
7902 
7903 /** returns if the constraint was already added to a SCIP instance */
7905  SCIP_CONS* cons /**< constraint */
7906  )
7907 {
7908  assert(cons != NULL);
7909 
7910  return (cons->addarraypos >= 0);
7911 }
7912 
7913 /** adds locks to (dis-)allow upgrading of constraint */
7915  SCIP_CONS* cons, /**< constraint to add locks */
7916  int nlocks /**< number of locks to add */
7917  )
7918 {
7919  assert(cons != NULL);
7920 
7921  assert(cons->nupgradelocks < (1 << 29) - nlocks); /*lint !e574*/
7922  cons->nupgradelocks += (unsigned int) nlocks;
7923 }
7924 
7925 /** gets number of locks against upgrading the constraint, 0 means this constraint can be upgraded */
7927  SCIP_CONS* cons /**< constraint */
7928  )
7929 {
7930  assert(cons != NULL);
7931 
7932  return cons->nupgradelocks;
7933 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:51
SCIP_Longint SCIPconshdlrGetNChildren(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4532
SCIP_CONS * SCIPconshdlrFrontProp(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:6788
SCIP_CONS ** updateconss
Definition: struct_cons.h:184
SCIP_RETCODE SCIPconsSetChecked(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool check)
Definition: cons.c:6153
SCIP_Bool SCIPconshdlrIsPresolvingDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4772
int SCIPconshdlrGetNAddHoles(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4602
enum SCIP_BoundType SCIP_BOUNDTYPE
Definition: type_lp.h:50
SCIP_Bool delaypresol
Definition: struct_cons.h:259
int SCIPconshdlrGetNChgBds(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4592
SCIP_PROPTIMING timingmask
Definition: struct_cons.h:268
SCIP_RETCODE SCIPconsUnmarkPropagate(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6610
SCIP_RETCODE SCIPconshdlrEnforcePseudoSol(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_BRANCHCAND *branchcand, SCIP_Bool solinfeasible, SCIP_Bool objinfeasible, SCIP_Bool forced, SCIP_RESULT *result)
Definition: cons.c:3233
int lastnchgvartypes
Definition: struct_cons.h:237
SCIP_Bool SCIPconsIsLockedPos(SCIP_CONS *cons)
Definition: cons.c:7856
SCIP_Longint nenfolpcalls
Definition: struct_cons.h:119
SCIP_Bool SCIPconsIsLocked(SCIP_CONS *cons)
Definition: cons.c:7876
int initconsspos
Definition: struct_cons.h:51
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:424
SCIP_Longint nsepacalls
Definition: struct_cons.h:118
SCIP_Longint lastsepalpcount
Definition: struct_cons.h:194
unsigned int updatemarkpropagate
Definition: struct_cons.h:98
static void conshdlrDelEnfocons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:1020
SCIP_RETCODE SCIPconshdlrEnforceLPSol(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_SEPASTORE *sepastore, SCIP_Bool solinfeasible, SCIP_RESULT *result)
Definition: cons.c:3053
unsigned int propenabled
Definition: struct_cons.h:68
static SCIP_RETCODE conshdlrEnsureInitconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:90
static SCIP_RETCODE ensurePropagationStorage(SCIP_SET *set, SCIP_CONSHDLR *conshdlr, int num)
Definition: cons.c:7388
unsigned int updatepropdisable
Definition: struct_cons.h:94
int nusefulenfoconss
Definition: struct_cons.h:219
SCIP_Longint ncutoffs
Definition: struct_cons.h:124
SCIP_RETCODE SCIPconsIncAge(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: cons.c:6706
SCIP_RETCODE SCIPconssetchgFree(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:4910
SCIP_RETCODE SCIPconsActivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:6318
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:122
SCIP_Bool SCIPconshdlrWasPropagationDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4802
static SCIP_RETCODE conshdlrEnsureCheckconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:162
SCIP_Bool sepasolwasdelayed
Definition: struct_cons.h:262
SCIP_CONS ** enfoconss
Definition: struct_cons.h:178
unsigned int active
Definition: struct_cons.h:76
internal methods for branch and bound tree
SCIP_RETCODE SCIPconshdlrExit(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:2394
unsigned int dynamic
Definition: struct_cons.h:71
SCIP_RETCODE SCIPconsDelete(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: cons.c:5943
#define SCIP_DECL_CONSLOCK(x)
Definition: type_cons.h:582
static SCIP_RETCODE conssetchgDelAddedCons(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int arraypos)
Definition: cons.c:5059
static SCIP_RETCODE conshdlrDisableConsSeparation(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:1300
SCIP_Longint SCIPconshdlrGetNSepaCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4402
void SCIPconshdlrSetPrint(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
Definition: cons.c:4160
#define AGERESETAVG_INIT
Definition: cons.c:45
SCIP_CONS ** conss
Definition: struct_cons.h:172
SCIP_CONS ** addedconss
Definition: struct_cons.h:107
void SCIPconsSetDynamic(SCIP_CONS *cons, SCIP_Bool dynamic)
Definition: cons.c:6260
void SCIPconsSetStickingAtNode(SCIP_CONS *cons, SCIP_Bool stickingatnode)
Definition: cons.c:6282
SCIP_CLOCK * setuptime
Definition: struct_cons.h:185
SCIP_Longint lastenfopsdomchgcount
Definition: struct_cons.h:133
static void conshdlrDelCons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:784
SCIP_RETCODE SCIPconsSepasol(SCIP_CONS *cons, SCIP_SET *set, SCIP_SOL *sol, SCIP_RESULT *result)
Definition: cons.c:7122
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
Definition: cons.c:7836
static SCIP_Bool consExceedsAgelimit(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:347
#define SCIP_DECL_CONSDELETE(x)
Definition: type_cons.h:186
unsigned int updatesepaenable
Definition: struct_cons.h:91
SCIP_Longint ninitconssadded
Definition: struct_stat.h:92
int lastnusefulenfoconss
Definition: struct_cons.h:234
#define SCIP_MAXSTRLEN
Definition: def.h:196
SCIP_Bool presolwasdelayed
Definition: struct_cons.h:264
#define SCIP_DECL_CONSINITPRE(x)
Definition: type_cons.h:113
int storedpropconsssize
Definition: struct_cons.h:227
SCIP_Bool SCIPconsIsInProb(SCIP_CONS *cons)
Definition: cons.c:7826
int validdepth
Definition: struct_cons.h:59
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4239
internal methods for clocks and timing issues
int SCIPbranchcandGetNPseudoCands(SCIP_BRANCHCAND *branchcand)
Definition: branch.c:802
int nusefulsepaconss
Definition: struct_cons.h:216
#define SCIP_DECL_CONSPRESOL(x)
Definition: type_cons.h:470
void SCIPconshdlrSetDeactive(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
Definition: cons.c:4116
#define NULL
Definition: lpi_spx.cpp:129
static SCIP_RETCODE conshdlrEnsureEnfoconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:138
void SCIPconshdlrSetInitpre(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITPRE((*consinitpre)))
Definition: cons.c:4024
SCIP_Bool SCIPconshdlrIsPropagationDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4762
SCIP_Bool SCIPconshdlrWasPresolvingDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4812
SCIP_RETCODE SCIPconsParse(SCIP_CONS **cons, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, const char *str, 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, SCIP_Bool *success)
Definition: cons.c:5602
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4209
static SCIP_RETCODE conshdlrDeactivateCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: cons.c:1592
#define SCIP_DECL_CONSCHECK(x)
Definition: type_cons.h:390
#define SCIP_DECL_CONSTRANS(x)
Definition: type_cons.h:196
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:7786
void SCIPconshdlrSetInitsol(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITSOL((*consinitsol)))
Definition: cons.c:4002
SCIP_Longint ndomredsfound
Definition: struct_cons.h:128
int SCIPconshdlrGetSepaPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4672
SCIP_Bool duringprop
Definition: struct_cons.h:267
SCIP_Longint SCIPconshdlrGetNConssFound(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4512
SCIP_RETCODE SCIPqueueInsert(SCIP_QUEUE *queue, void *elem)
Definition: misc.c:595
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:7618
static SCIP_RETCODE conshdlrAddSepacons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:875
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:16380
SCIP_Longint lastenfopsnode
Definition: struct_cons.h:135
unsigned int update
Definition: struct_cons.h:85
int lastnusefulsepaconss
Definition: struct_cons.h:233
int propconsspos
Definition: struct_cons.h:55
static SCIP_RETCODE conshdlrActivateCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons, int depth, SCIP_Bool focusnode)
Definition: cons.c:1517
SCIP_Bool SCIPconshdlrIsSeparationDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4752
SCIP_PROPTIMING SCIPconshdlrGetPropTimingmask(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4842
int SCIPconshdlrGetNChgCoefs(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4642
int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4273
SCIP_Longint lastpropdomchgcount
Definition: struct_cons.h:130
SCIP_Longint nholechgs
Definition: struct_stat.h:86
#define SCIP_PROPTIMING_DURINGLPLOOP
Definition: type_timing.h:39
#define SCIP_DECL_CONSRESPROP(x)
Definition: type_cons.h:521
SCIP_Real SCIPconshdlrGetSepaTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4332
int SCIPconsGetActiveDepth(SCIP_CONS *cons)
Definition: cons.c:7607
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:350
SCIP_RETCODE SCIPconsGetVars(SCIP_CONS *cons, SCIP_SET *set, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
Definition: cons.c:5875
datastructures for constraints and constraint handlers
SCIP_CLOCK * resproptime
Definition: struct_cons.h:193
unsigned int check
Definition: struct_cons.h:65
static void conshdlrDelCheckcons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:1116
SCIP_RETCODE SCIPconshdlrCreate(SCIP_CONSHDLR **conshdlr, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int sepapriority, int enfopriority, int checkpriority, int sepafreq, int propfreq, int eagerfreq, int maxprerounds, SCIP_Bool delaysepa, SCIP_Bool delayprop, SCIP_Bool delaypresol, SCIP_Bool needscons, SCIP_PROPTIMING timingmask, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSFREE((*consfree)), SCIP_DECL_CONSINIT((*consinit)), SCIP_DECL_CONSEXIT((*consexit)), SCIP_DECL_CONSINITPRE((*consinitpre)), SCIP_DECL_CONSEXITPRE((*consexitpre)), SCIP_DECL_CONSINITSOL((*consinitsol)), SCIP_DECL_CONSEXITSOL((*consexitsol)), SCIP_DECL_CONSDELETE((*consdelete)), SCIP_DECL_CONSTRANS((*constrans)), SCIP_DECL_CONSINITLP((*consinitlp)), SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSPROP((*consprop)), SCIP_DECL_CONSPRESOL((*conspresol)), SCIP_DECL_CONSRESPROP((*consresprop)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_DECL_CONSACTIVE((*consactive)), SCIP_DECL_CONSDEACTIVE((*consdeactive)), SCIP_DECL_CONSENABLE((*consenable)), SCIP_DECL_CONSDISABLE((*consdisable)), SCIP_DECL_CONSDELVARS((*consdelvars)), SCIP_DECL_CONSPRINT((*consprint)), SCIP_DECL_CONSCOPY((*conscopy)), SCIP_DECL_CONSPARSE((*consparse)), SCIP_DECL_CONSGETVARS((*consgetvars)), SCIP_DECL_CONSGETNVARS((*consgetnvars)), SCIP_CONSHDLRDATA *conshdlrdata)
Definition: cons.c:1980
SCIP_CONS ** SCIPconshdlrGetEnfoConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4219
SCIP_RETCODE SCIPconsSetSeparated(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool separate)
Definition: cons.c:6083
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:7846
SCIP_CONSDATA * consdata
Definition: struct_cons.h:44
#define FALSE
Definition: def.h:52
SCIP_Bool SCIPconshdlrDoesPresolve(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4742
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:280
static SCIP_RETCODE conssetchgRelease(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:4880
unsigned int removable
Definition: struct_cons.h:72
SCIP_RETCODE SCIPconshdlrInitsol(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:2587
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:7579
SCIP_Bool SCIPconsIsMarkedPropagate(SCIP_CONS *cons)
Definition: cons.c:7746
SCIP_STAGE stage
Definition: struct_set.h:57
SCIP_RESULT lastenfolpresult
Definition: struct_cons.h:136
#define TRUE
Definition: def.h:51
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:7577
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define AGERESETAVG_OBSOLETEAGE
Definition: cons.c:51
#define SCIP_DECL_CONSGETNVARS(x)
Definition: type_cons.h:789
int nenabledconss
Definition: struct_stat.h:180
void SCIPconshdlrSetFree(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSFREE((*consfree)))
Definition: cons.c:3969
unsigned int enabled
Definition: struct_cons.h:81
int SCIPtreeGetCurrentDepth(SCIP_TREE *tree)
Definition: tree.c:7213
static SCIP_RETCODE conshdlrEnsurePropconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:186
internal methods for branching rules and branching candidate storage
SCIP_Bool delayprop
Definition: struct_cons.h:258
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:4264
SCIP_Longint SCIPconshdlrGetNPropCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4432
int SCIPconshdlrGetNAddConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4622
SCIP_RETCODE SCIPconsEnableSeparation(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6462
int SCIPconsGetNUpgradeLocks(SCIP_CONS *cons)
Definition: cons.c:7928
#define SCIP_DECL_CONSEXITSOL(x)
Definition: type_cons.h:173
void SCIPconshdlrSetCopy(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSHDLRCOPY((*conshdlrcopy)), SCIP_DECL_CONSCOPY((*conscopy)))
Definition: cons.c:3954
SCIP_Longint nconssfound
Definition: struct_cons.h:127
SCIP_RETCODE SCIPconsSetPropagated(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool propagate)
Definition: cons.c:6201
SCIP_Longint nchildren
Definition: struct_cons.h:129
SCIP_Real SCIPvarGetLbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:15141
SCIP_RETCODE SCIPconshdlrInit(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:2284
#define SCIPdebugMessage
Definition: pub_message.h:77
static void conshdlrUnmarkConsPropagate(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:686
SCIP_RETCODE SCIPconshdlrSeparateLP(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SEPASTORE *sepastore, int depth, SCIP_Bool execdelayed, SCIP_RESULT *result)
Definition: cons.c:2767
void SCIPconsSetNamePointer(SCIP_CONS *cons, const char *name)
Definition: cons.c:6294
unsigned int updateunmarkpropagate
Definition: struct_cons.h:99
int SCIPconshdlrGetStartNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4552
int enfoconsspos
Definition: struct_cons.h:53
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:250
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4732
SCIP_CLOCK * sepatime
Definition: struct_cons.h:187
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:7776
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:7716
SCIP_Bool SCIPqueueIsEmpty(SCIP_QUEUE *queue)
Definition: misc.c:691
#define BMSfreeMemory(ptr)
Definition: memory.h:117
SCIP_Bool sepalpwasdelayed
Definition: struct_cons.h:261
SCIP_Bool duringsepa
Definition: struct_cons.h:266
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition: cons.c:6308
SCIP_CONS ** disabledconss
Definition: struct_cons.h:108
static void conshdlrDelSepacons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:919
SCIP_Bool cons_disableenfops
Definition: struct_set.h:207
#define SCIP_DECL_CONSINITLP(x)
Definition: type_cons.h:209
int nusefulcheckconss
Definition: struct_cons.h:222
static SCIP_Bool conshdlrAreUpdatesDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:314
SCIP_Real SCIPconshdlrGetRespropTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4392
SCIP_Bool SCIPconshdlrIsInitialized(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4822
SCIP_CONS * transorigcons
Definition: struct_cons.h:45
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:7706
SCIP_Longint SCIPconshdlrGetNEnfoPSCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4422
SCIP_Real SCIPconshdlrGetStrongBranchPropTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4372
SCIP_RETCODE SCIPconsResetAge(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6726
SCIP_RETCODE SCIPconsActive(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:7319
int sepaconsspos
Definition: struct_cons.h:52
SCIP_Longint lastenfolpnode
Definition: struct_cons.h:134
SCIP_Real SCIPconshdlrGetEnfoLPTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4342
SCIP * scip
Definition: struct_set.h:58
SCIP_CONSSETCHG * addconssetchg
Definition: struct_cons.h:47
SCIP_Longint ncheckcalls
Definition: struct_cons.h:122
int activedepth
Definition: struct_cons.h:58
static SCIP_RETCODE conshdlrEnsureUpdateconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:210
static void conshdlrDelayUpdates(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:1868
unsigned int stickingatnode
Definition: struct_cons.h:73
#define AGERESETAVG_MIN
Definition: cons.c:46
SCIP_Longint SCIPconshdlrGetNDomredsFound(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4522
static SCIP_RETCODE conshdlrForceUpdates(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:1884
#define SCIP_DECL_CONSINITSOL(x)
Definition: type_cons.h:158
SCIP_CONSHDLRDATA * SCIPconshdlrGetData(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:3893
unsigned int updateinsert
Definition: struct_cons.h:86
SCIP_RETCODE SCIPconsDisableSeparation(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6492
unsigned int deleted
Definition: struct_cons.h:84
static SCIP_RETCODE conssetchgDelDisabledCons(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int arraypos)
Definition: cons.c:5105
SCIP_RETCODE SCIPconshdlrCopyInclude(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_Bool *valid)
Definition: cons.c:1959
int SCIPconshdlrGetNDelConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4612
SCIP_CONSHDLR * SCIPsetFindConshdlr(SCIP_SET *set, const char *name)
Definition: set.c:2965
SCIP_Bool SCIPtreeProbing(SCIP_TREE *tree)
Definition: tree.c:7095
int storednmarkedpropconss
Definition: struct_cons.h:228
void SCIPconshdlrSetExitsol(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITSOL((*consexitsol)))
Definition: cons.c:4013
#define SCIP_DECL_CONSPRINT(x)
Definition: type_cons.h:673
SCIP_Longint SCIPconshdlrGetNCutoffs(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4462
SCIP_RETCODE SCIPconsEnablePropagation(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6520
int SCIPconshdlrGetNChgSides(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4652
#define BMSduplicateBlockMemoryArray(mem, ptr, source, num)
Definition: memory.h:414
SCIP_RETCODE SCIPconssetchgApply(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool focusnode)
Definition: cons.c:5134
unsigned int sepaenabled
Definition: struct_cons.h:67
void SCIPconshdlrEnableOrDisableClocks(SCIP_CONSHDLR *conshdlr, SCIP_Bool enable)
Definition: cons.c:4293
#define SCIP_DECL_CONSDELVARS(x)
Definition: type_cons.h:659
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
Definition: cons.c:7816
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:120
unsigned int updatepropenable
Definition: struct_cons.h:93
SCIP_CLOCK * presoltime
Definition: struct_cons.h:186
static SCIP_RETCODE conshdlrAddCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:758
internal methods for storing and manipulating the main problem
SCIP_RETCODE SCIPconsResprop(SCIP_CONS *cons, SCIP_SET *set, SCIP_VAR *infervar, int inferinfo, SCIP_BOUNDTYPE boundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT *result)
Definition: cons.c:7205
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPconsTransform(SCIP_CONS *origcons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS **transcons)
Definition: cons.c:5999
SCIP_QUEUE * pendingconss
Definition: struct_cons.h:270
int SCIPconsGetNUses(SCIP_CONS *cons)
Definition: cons.c:7597
SCIP_Longint lpcount
Definition: struct_stat.h:137
unsigned int obsolete
Definition: struct_cons.h:82
SCIP_Bool misc_resetstat
Definition: struct_set.h:307
#define SCIP_DECL_CONSPARSE(x)
Definition: type_cons.h:749
static SCIP_RETCODE conshdlrEnableConsPropagation(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:1329
static SCIP_Real conshdlrGetAgeresetavg(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:323
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:199
static void conshdlrMarkConsPropagate(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:612
#define SCIP_DECL_CONSDEACTIVE(x)
Definition: type_cons.h:612
static SCIP_RETCODE conshdlrAddUpdateCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:1910
SCIP_RETCODE SCIPconsProp(SCIP_CONS *cons, SCIP_SET *set, SCIP_PROPTIMING proptiming, SCIP_RESULT *result)
Definition: cons.c:7165
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:3873
SCIP_Real SCIPvarGetUbAtIndex(SCIP_VAR *var, SCIP_BDCHGIDX *bdchgidx, SCIP_Bool after)
Definition: var.c:15233
int SCIPconshdlrGetEnfoPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4682
SCIP_RETCODE SCIPconsDeactive(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:7343
SCIP_CONS ** storedpropconss
Definition: struct_cons.h:181
SCIP_RETCODE SCIPconshdlrDelVars(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:3812
SCIP_CLOCK * enfopstime
Definition: struct_cons.h:189
static SCIP_Bool consExceedsObsoleteage(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:362
void SCIPstrCopySection(const char *str, char startchar, char endchar, char *token, int size, char **endptr)
Definition: misc.c:7680
SCIP_Longint SCIPconshdlrGetNCheckCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4442
SCIP_Real SCIPconshdlrGetCheckTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4382
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:7557
int SCIPsepastoreGetNCuts(SCIP_SEPASTORE *sepastore)
Definition: sepastore.c:1344
int cons_agelimit
Definition: struct_set.h:203
SCIP_RETCODE SCIPconshdlrInitpre(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:2442
int SCIPconshdlrGetCheckPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4692
SCIP_CONS ** initconss
Definition: struct_cons.h:176
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:428
unsigned int modifiable
Definition: struct_cons.h:70
void SCIPmessagePrintWarning(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:411
void SCIPconshdlrSetEnable(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSENABLE((*consenable)))
Definition: cons.c:4127
SCIP_RETCODE SCIPconsChgName(SCIP_CONS *cons, BMS_BLKMEM *blkmem, const char *name)
Definition: cons.c:5709
SCIP_RETCODE SCIPconsCopy(SCIP_CONS **cons, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_CONSHDLR *sourceconshdlr, SCIP_CONS *sourcecons, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, 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, SCIP_Bool global, SCIP_Bool *success)
Definition: cons.c:5546
SCIP_Bool SCIPconsIsGlobal(SCIP_CONS *cons)
Definition: cons.c:7766
SCIP_RETCODE SCIPconsInitlp(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:7057
#define SCIP_DECL_CONSDISABLE(x)
Definition: type_cons.h:642
SCIP_Bool SCIPconshdlrIsClonable(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4832
unsigned int markedprop
Definition: struct_cons.h:61
void SCIPconshdlrSetExit(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXIT((*consexit)))
Definition: cons.c:3991
#define SCIP_PROPTIMING_ALWAYS
Definition: type_timing.h:46
SCIP_Real SCIPconsGetAge(SCIP_CONS *cons)
Definition: cons.c:7696
SCIP_Longint npropcalls
Definition: struct_cons.h:121
SCIP_Bool SCIPconshdlrWasLPSeparationDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4782
static SCIP_RETCODE conshdlrProcessUpdates(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:1674
SCIP_Bool SCIPconsIsSeparationEnabled(SCIP_CONS *cons)
Definition: cons.c:7654
#define SCIP_PROPTIMING_AFTERLPLOOP
Definition: type_timing.h:40
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:258
SCIP * scip
Definition: struct_cons.h:39
SCIP_RETCODE SCIPconshdlrInitLP(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_Bool initkeptconss)
Definition: cons.c:2664
SCIP_RETCODE SCIPconsPresol(SCIP_CONS *cons, SCIP_SET *set, int nrounds, int nnewfixedvars, int nnewaggrvars, int nnewchgvartypes, int nnewchgbds, int nnewholes, int nnewdelconss, int nnewaddconss, int nnewupgdconss, int nnewchgcoefs, int nnewchgsides, int *nfixedvars, int *naggrvars, int *nchgvartypes, int *nchgbds, int *naddholes, int *ndelconss, int *naddconss, int *nupgdconss, int *nchgcoefs, int *nchgsides, SCIP_RESULT *result)
Definition: cons.c:7247
SCIP_Bool needscons
Definition: struct_cons.h:260
SCIP_Bool SCIPconsIsPropagationEnabled(SCIP_CONS *cons)
Definition: cons.c:7665
SCIP_Bool SCIPconsIsObsolete(SCIP_CONS *cons)
Definition: cons.c:7686
SCIP_Real SCIPconshdlrGetSetupTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4312
#define SCIP_DECL_CONSENABLE(x)
Definition: type_cons.h:627
unsigned int updatesepadisable
Definition: struct_cons.h:92
SCIP_RETCODE SCIPconsAddLocks(SCIP_CONS *cons, SCIP_SET *set, int nlockspos, int nlocksneg)
Definition: cons.c:6889
int SCIPconsGetValidDepth(SCIP_CONS *cons)
Definition: cons.c:7630
SCIP_RETCODE SCIPconsDisable(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6428
#define AGERESETAVG_AGELIMIT
Definition: cons.c:48
static SCIP_RETCODE conssetchgCreate(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem)
Definition: cons.c:4859
static void conshdlrDelPropcons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:1211
SCIP_RETCODE SCIPsetAddIntParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2039
void SCIPconsAddUpgradeLocks(SCIP_CONS *cons, int nlocks)
Definition: cons.c:7916
#define AGERESETAVG_DECAY
Definition: cons.c:47
void SCIPqueueFree(SCIP_QUEUE **queue)
Definition: misc.c:573
#define SCIP_DECL_CONSENFOLP(x)
Definition: type_cons.h:312
int SCIPconshdlrGetPropFreq(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4712
SCIP_RESULT lastenfopsresult
Definition: struct_cons.h:137
void SCIPconshdlrSetActive(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
Definition: cons.c:4105
struct SCIP_ConsData SCIP_CONSDATA
Definition: type_cons.h:49
internal methods for storing separated cuts
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
Definition: cons.c:7587
static SCIP_RETCODE conshdlrEnableCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: cons.c:1389
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:111
SCIP_Longint nprobboundchgs
Definition: struct_stat.h:87
SCIP_RETCODE SCIPconshdlrUnlockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:3858
#define SCIP_DECL_CONSSEPALP(x)
Definition: type_cons.h:238
#define checkConssArrays(conshdlr)
Definition: cons.c:239
int startnactiveconss
Definition: struct_cons.h:208
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:160
void SCIPconshdlrIncNCutsFound(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4502
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:417
internal methods for problem variables
int SCIPconshdlrGetSepaFreq(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4702
#define SCIP_DECL_CONSGETVARS(x)
Definition: type_cons.h:771
#define SCIP_DECL_CONSEXIT(x)
Definition: type_cons.h:93
int lastnusefulpropconss
Definition: struct_cons.h:232
public data structures and miscellaneous methods
static void conshdlrDelInitcons(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:840
SCIP_Bool delaysepa
Definition: struct_cons.h:257
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition: cons.c:5911
static SCIP_RETCODE conshdlrMarkConsUseful(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:507
SCIP_Longint ncutsfound
Definition: struct_cons.h:125
#define SCIP_Bool
Definition: def.h:49
char * name
Definition: struct_cons.h:42
SCIP_RETCODE SCIPconsEnfops(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool solinfeasible, SCIP_Bool objinfeasible, SCIP_RESULT *result)
Definition: cons.c:6970
SCIP_Longint SCIPconshdlrGetNEnfoLPCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4412
static const char * paramname[]
Definition: lpi_msk.c:4129
void SCIPconsSetModifiable(SCIP_CONS *cons, SCIP_Bool modifiable)
Definition: cons.c:6249
SCIP_Longint SCIPconshdlrGetNRespropCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4452
SCIP_CONS ** propconss
Definition: struct_cons.h:180
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:7796
unsigned int initial
Definition: struct_cons.h:62
SCIP_DECL_HASHGETKEY(SCIPhashGetKeyCons)
Definition: cons.c:7373
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:5796
SCIP_CONSHDLR * conshdlr
Definition: struct_cons.h:43
void SCIPconshdlrSetDelete(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
Definition: cons.c:4061
int nlocksneg
Definition: struct_cons.h:57
void SCIPconshdlrSetInit(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINIT((*consinit)))
Definition: cons.c:3980
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:175
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:421
unsigned int updatefree
Definition: struct_cons.h:96
#define SCIP_DECL_CONSEXITPRE(x)
Definition: type_cons.h:137
#define MAX(x, y)
Definition: tclique_def.h:75
void SCIPconshdlrIncNAppliedCuts(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4492
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:7806
SCIP_Bool SCIPconsIsAdded(SCIP_CONS *cons)
Definition: cons.c:7906
unsigned int separate
Definition: struct_cons.h:63
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
Definition: cons.c:7676
void SCIPconsSetRemovable(SCIP_CONS *cons, SCIP_Bool removable)
Definition: cons.c:6271
SCIP_RETCODE SCIPconshdlrsResetPropagationStatus(SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7453
SCIP_RETCODE SCIPconshdlrPropagate(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, int depth, SCIP_Bool fullpropagation, SCIP_Bool execdelayed, SCIP_Bool instrongbranching, SCIP_PROPTIMING proptiming, SCIP_RESULT *result)
Definition: cons.c:3494
SCIP_CONS ** checkconss
Definition: struct_cons.h:179
int nusefulpropconss
Definition: struct_cons.h:226
unsigned int updateactivate
Definition: struct_cons.h:87
int SCIPconsGetPos(SCIP_CONS *cons)
Definition: cons.c:7567
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:102
unsigned int updateenable
Definition: struct_cons.h:89
static SCIP_RETCODE conshdlrEnableConsSeparation(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:1269
int delayupdatecount
Definition: struct_cons.h:256
static SCIP_RETCODE conshdlrEnsureSepaconssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:114
#define SCIP_PROPTIMING_BEFORELP
Definition: type_timing.h:38
int SCIPconshdlrGetMaxNActiveConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4542
int consspos
Definition: struct_cons.h:50
int SCIPconshdlrGetNUpgdConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4632
SCIP_RETCODE SCIPprobDelCons(SCIP_PROB *prob, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1283
#define SCIP_DECL_CONSENFOPS(x)
Definition: type_cons.h:355
void SCIPconshdlrSetGetNVars(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETNVARS((*consgetnvars)))
Definition: cons.c:4193
void SCIPconshdlrSetParse(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPARSE((*consparse)))
Definition: cons.c:4171
SCIP_Real age
Definition: struct_cons.h:41
int SCIPconshdlrGetNPresolCalls(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4662
SCIP_RETCODE SCIPconshdlrExitpre(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:2541
static SCIP_RETCODE conshdlrAddEnfocons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:965
SCIP_Bool propwasdelayed
Definition: struct_cons.h:263
SCIP_Real SCIPconshdlrGetPropTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4362
unsigned int updateactfocus
Definition: struct_cons.h:97
int cons_obsoleteage
Definition: struct_set.h:205
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:16370
int nactiveconss
Definition: struct_stat.h:179
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:5784
unsigned int SCIP_PROPTIMING
Definition: type_timing.h:48
SCIP_RETCODE SCIPqueueCreate(SCIP_QUEUE **queue, int initsize, SCIP_Real sizefac)
Definition: misc.c:549
static SCIP_RETCODE conshdlrAddCheckcons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:1072
SCIP_Longint nenfopscalls
Definition: struct_cons.h:120
SCIP_RETCODE SCIPconshdlrPresolve(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool execdelayed, int nrounds, int *nfixedvars, int *naggrvars, int *nchgvartypes, int *nchgbds, int *naddholes, int *ndelconss, int *naddconss, int *nupgdconss, int *nchgcoefs, int *nchgsides, SCIP_RESULT *result)
Definition: cons.c:3661
SCIP_RETCODE SCIPconssetchgUndo(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:5221
SCIP_Longint domchgcount
Definition: struct_stat.h:84
SCIP_Bool SCIPconsIsLockedNeg(SCIP_CONS *cons)
Definition: cons.c:7866
SCIP_Longint lastenfolplpcount
Definition: struct_cons.h:195
SCIP_Longint SCIPconshdlrGetNCutsFound(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4472
SCIP_Longint ncutsapplied
Definition: struct_cons.h:126
SCIP_RETCODE SCIPconssetchgAddAddedCons(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons, int depth, SCIP_Bool focusnode, SCIP_Bool active)
Definition: cons.c:4984
#define SCIP_DECL_CONSFREE(x)
Definition: type_cons.h:73
SCIP_Bool SCIPconshdlrWasSolSeparationDelayed(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4792
SCIP_CLOCK * enfolptime
Definition: struct_cons.h:188
int SCIPconshdlrGetNEnfoConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4249
void SCIPconshdlrSetDisable(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDISABLE((*consdisable)))
Definition: cons.c:4138
SCIP_RETCODE SCIPconshdlrCheck(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: cons.c:3429
SCIP_RETCODE SCIPconssetchgMakeGlobal(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: cons.c:5307
int SCIPconshdlrGetEagerFreq(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4722
unsigned int updatedisable
Definition: struct_cons.h:90
static SCIP_RETCODE conshdlrEnsureConssMem(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, int num)
Definition: cons.c:66
#define SCIP_DECL_CONSINIT(x)
Definition: type_cons.h:83
unsigned int original
Definition: struct_cons.h:74
static SCIP_RETCODE conshdlrDisableConsPropagation(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:1360
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:602
unsigned int updateobsolete
Definition: struct_cons.h:95
SCIP_Longint nrespropcalls
Definition: struct_cons.h:123
SCIP_Longint nboundchgs
Definition: struct_stat.h:85
SCIP_DECL_SORTPTRCOMP(SCIPconshdlrCompSepa)
Definition: cons.c:1941
unsigned int local
Definition: struct_cons.h:69
int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4259
SCIP_RETCODE SCIPconsAddAge(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Real deltaage)
Definition: cons.c:6648
SCIP_RETCODE SCIPconsSetInitial(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool initial)
Definition: cons.c:6049
void SCIPconshdlrSetResprop(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSRESPROP((*consresprop)))
Definition: cons.c:4094
#define SCIP_Real
Definition: def.h:123
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:7736
internal methods for problem statistics
static void conshdlrUpdateAgeresetavg(SCIP_CONSHDLR *conshdlr, SCIP_Real age)
Definition: cons.c:334
void SCIPconshdlrSetPresol(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRESOL((*conspresol)), int maxprerounds, SCIP_Bool delaypresol)
Definition: cons.c:4046
SCIP_RETCODE SCIPconshdlrExitsol(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_Bool restart)
Definition: cons.c:2627
void SCIPconshdlrSetProp(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING timingmask)
Definition: cons.c:3935
#define MIN(x, y)
Definition: memory.c:59
SCIP_CLOCK * sbproptime
Definition: struct_cons.h:191
SCIP_Real SCIPconshdlrGetEnfoPSTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4352
#define SCIP_DECL_CONSSEPASOL(x)
Definition: type_cons.h:270
void SCIPconshdlrSetDelvars(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELVARS((*consdelvars)))
Definition: cons.c:4149
#define SCIP_DECL_CONSPROP(x)
Definition: type_cons.h:416
#define BMSallocMemory(ptr)
Definition: memory.h:92
SCIP_RETCODE SCIPconsPrint(SCIP_CONS *cons, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: cons.c:5836
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:80
SCIP_Real SCIPconshdlrGetPresolTime(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4322
internal methods for constraints and constraint handlers
SCIP_Longint storedpropdomchgcount
Definition: struct_cons.h:131
#define SCIP_DECL_CONSACTIVE(x)
Definition: type_cons.h:597
static SCIP_RETCODE conssetchgEnsureDisabledconssSize(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: cons.c:4959
int SCIPconshdlrGetNChgVarTypes(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4582
void SCIPconshdlrSetGetVars(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSGETVARS((*consgetvars)))
Definition: cons.c:4182
#define SCIP_Longint
Definition: def.h:107
int nlockspos
Definition: struct_cons.h:56
static SCIP_RETCODE conshdlrAddInitcons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: cons.c:804
unsigned int markpropagate
Definition: struct_cons.h:83
SCIP_RETCODE SCIPconsFree(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:5729
void * SCIPqueueRemove(SCIP_QUEUE *queue)
Definition: misc.c:639
void SCIPconshdlrSetTrans(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
Definition: cons.c:4072
SCIP_Real ageresetavg
Definition: struct_cons.h:138
SCIP_RETCODE SCIPconsMarkPropagate(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6580
SCIP_RETCODE SCIPconssetchgAddDisabledCons(SCIP_CONSSETCHG **conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:5030
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2007
SCIP_RETCODE SCIPconsEnable(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6395
SCIP_CLOCK * proptime
Definition: struct_cons.h:190
unsigned int updatedeactivate
Definition: struct_cons.h:88
#define SCIP_DECL_CONSHDLRCOPY(x)
Definition: type_cons.h:65
static SCIP_RETCODE conshdlrDisableCons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: cons.c:1451
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:48
int SCIPconshdlrGetNFixedVars(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4562
int nchildren
Definition: struct_tree.h:190
SCIP_RETCODE SCIPconshdlrSeparateSol(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SEPASTORE *sepastore, SCIP_SOL *sol, int depth, SCIP_Bool execdelayed, SCIP_RESULT *result)
Definition: cons.c:2924
SCIP_Longint SCIPconshdlrGetNCutsApplied(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4482
SCIP_RETCODE SCIPconshdlrPopProp(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6803
SCIP_RETCODE SCIPprobAddCons(SCIP_PROB *prob, SCIP_SET *set, SCIP_STAT *stat, SCIP_CONS *cons)
Definition: prob.c:1216
void SCIPconshdlrSetExitpre(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSEXITPRE((*consexitpre)))
Definition: cons.c:4035
SCIP_RETCODE SCIPconsEnfolp(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool solinfeasible, SCIP_RESULT *result)
Definition: cons.c:7014
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:404
int addarraypos
Definition: struct_cons.h:49
SCIP_RETCODE SCIPconsDeactivate(SCIP_CONS *cons, SCIP_SET *set, SCIP_STAT *stat)
Definition: cons.c:6360
SCIP_RETCODE SCIPconsDisablePropagation(SCIP_CONS *cons, SCIP_SET *set)
Definition: cons.c:6550
void SCIPconsSetLocal(SCIP_CONS *cons, SCIP_Bool local)
Definition: cons.c:6236
#define SCIP_DECL_CONSCOPY(x)
Definition: type_cons.h:714
common defines and data types used in all packages of SCIP
SCIP_Longint nnodes
Definition: struct_stat.h:63
void * SCIPqueueFirst(SCIP_QUEUE *queue)
Definition: misc.c:673
const char * SCIPconshdlrGetDesc(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:3883
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:371
int checkconsspos
Definition: struct_cons.h:54
SCIP_RETCODE SCIPconshdlrFree(SCIP_CONSHDLR **conshdlr, SCIP_SET *set)
Definition: cons.c:2239
void SCIPconshdlrSetSepa(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSSEPALP((*conssepalp)), SCIP_DECL_CONSSEPASOL((*conssepasol)), int sepafreq, int sepapriority, SCIP_Bool delaysepa)
Definition: cons.c:3914
SCIP_RETCODE SCIPconshdlrsStorePropagationStatus(SCIP_SET *set, SCIP_CONSHDLR **conshdlrs, int nconshdlrs)
Definition: cons.c:7412
SCIP_Bool initialized
Definition: struct_cons.h:265
unsigned int enforce
Definition: struct_cons.h:64
SCIP_Bool SCIPconsIsEnabled(SCIP_CONS *cons)
Definition: cons.c:7644
#define SCIP_ALLOC(x)
Definition: def.h:269
unsigned int propagate
Definition: struct_cons.h:66
SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4229
int nmarkedpropconss
Definition: struct_cons.h:225
SCIP_RETCODE SCIPsetAddBoolParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:2017
SCIP_Longint nprobholechgs
Definition: struct_stat.h:88
SCIP_RETCODE SCIPconshdlrLockVars(SCIP_CONSHDLR *conshdlr, SCIP_SET *set)
Definition: cons.c:3843
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:7726
static SCIP_RETCODE conshdlrMarkConsObsolete(SCIP_CONSHDLR *conshdlr, SCIP_CONS *cons)
Definition: cons.c:379
int SCIPconshdlrGetNEnabledConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4283
int SCIPconsGetNLocksPos(SCIP_CONS *cons)
Definition: cons.c:7886
unsigned int nupgradelocks
Definition: struct_cons.h:100
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:7756
static SCIP_RETCODE conshdlrAddPropcons(SCIP_CONSHDLR *conshdlr, SCIP_SET *set, SCIP_CONS *cons)
Definition: cons.c:1155
int SCIPconsGetNLocksNeg(SCIP_CONS *cons)
Definition: cons.c:7896
void SCIPconshdlrSetInitlp(SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSINITLP((*consinitlp)))
Definition: cons.c:4083
void SCIPconshdlrSetData(SCIP_CONSHDLR *conshdlr, SCIP_CONSHDLRDATA *conshdlrdata)
Definition: cons.c:3903
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:390
SCIP_RETCODE SCIPconsCreate(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set, 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, SCIP_Bool original, SCIP_Bool deleteconsdata)
Definition: cons.c:5402
SCIP_CONS ** sepaconss
Definition: struct_cons.h:177
SCIP_RETCODE SCIPconsCheck(SCIP_CONS *cons, SCIP_SET *set, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: cons.c:6933
SCIP_RETCODE SCIPconsSepalp(SCIP_CONS *cons, SCIP_SET *set, SCIP_RESULT *result)
Definition: cons.c:7081
static SCIP_RETCODE conssetchgEnsureAddedconssSize(SCIP_CONSSETCHG *conssetchg, BMS_BLKMEM *blkmem, SCIP_SET *set, int num)
Definition: cons.c:4935
SCIP_CONSHDLRDATA * conshdlrdata
Definition: struct_cons.h:171
int SCIPconshdlrGetNAggrVars(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4572
SCIP_CLOCK * checktime
Definition: struct_cons.h:192
SCIP_Longint lastenfolpdomchgcount
Definition: struct_cons.h:132
SCIP_RETCODE SCIPconsSetEnforced(SCIP_CONS *cons, SCIP_SET *set, SCIP_Bool enforce)
Definition: cons.c:6118
SCIP_RETCODE SCIPconsResolvePropagation(SCIP_CONS *cons, SCIP_SET *set, SCIP_VAR *infervar, int inferinfo, SCIP_BOUNDTYPE inferboundtype, SCIP_BDCHGIDX *bdchgidx, SCIP_Real relaxedbd, SCIP_RESULT *result)
Definition: cons.c:6829
SCIP_RETCODE SCIPconsPushProp(SCIP_CONS *cons)
Definition: cons.c:6766