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