Scippy

SCIP

Solving Constraint Integer Programs

conflictstore.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-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file conflictstore.c
17  * @brief methods for storing conflicts
18  * @author Jakob Witzig
19  */
20 
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
22 
23 #include <assert.h>
24 #include <string.h>
25 
26 #include "scip/conflictstore.h"
27 #include "scip/cons.h"
28 #include "scip/event.h"
29 #include "scip/set.h"
30 #include "scip/tree.h"
31 #include "scip/misc.h"
32 #include "scip/prob.h"
33 #include "scip/reopt.h"
34 #include "scip/scip.h"
35 #include "scip/def.h"
36 #include "scip/cons_linear.h"
38 
39 
40 #define CONFLICTSTORE_DUALSIZE 100 /* default size of conflict store */
41 #define CONFLICTSTORE_MINSIZE 2000 /* default minimal size of a dynamic conflict store */
42 #define CONFLICTSTORE_MAXSIZE 60000 /* maximal size of a dynamic conflict store (multiplied by 3) */
43 #define CONFLICTSTORE_SIZE 10000 /* default size of conflict store */
44 #define CONFLICTSTORE_SORTFREQ 20 /* frequency to resort the conflict array */
45 
46 /* event handler properties */
47 #define EVENTHDLR_NAME "ConflictStore"
48 #define EVENTHDLR_DESC "Solution event handler for conflict store."
49 
50 
51 /* exec the event handler */
52 static
53 SCIP_DECL_EVENTEXEC(eventExecConflictstore)
54 {/*lint --e{715}*/
55  assert(eventhdlr != NULL);
56  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
57  assert(event != NULL);
59 
61  {
63  }
64 
65  return SCIP_OKAY;
66 }
67 
68 /** solving process initialization method of event handler (called when branch and bound process is about to begin) */
69 static
70 SCIP_DECL_EVENTINITSOL(eventInitsolConflictstore)
71 {
72  SCIP_Bool cleanboundexceeding;
73 
74  assert(scip != NULL);
75  assert(eventhdlr != NULL);
76  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
77 
78  SCIP_CALL( SCIPgetBoolParam(scip, "conflict/cleanboundexceedings", &cleanboundexceeding) );
79 
80  if( !cleanboundexceeding )
81  return SCIP_OKAY;
82 
84 
85  return SCIP_OKAY;
86 }
87 
88 /** solving process deinitialization method of event handler (called before branch and bound process data is freed) */
89 static
90 SCIP_DECL_EVENTEXITSOL(eventExitsolConflictstore)
91 {
92  SCIP_Bool cleanboundexceeding;
93 
94  assert(scip != NULL);
95  assert(eventhdlr != NULL);
96  assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
97 
98  SCIP_CALL( SCIPgetBoolParam(scip, "conflict/cleanboundexceedings", &cleanboundexceeding) );
99 
100  if( !cleanboundexceeding )
101  return SCIP_OKAY;
102 
104 
105  return SCIP_OKAY;
106 }
107 
108 /* comparison method for constraints */
109 static
111 {
112  /*lint --e{715}*/
113  SCIP_CONS* cons1 = (SCIP_CONS*)elem1;
114  SCIP_CONS* cons2 = (SCIP_CONS*)elem2;
115 
116  assert(cons1 != NULL);
117  assert(cons2 != NULL);
118 
119  if( SCIPconsGetAge(cons1) > SCIPconsGetAge(cons2) )
120  return -1;
121  else if ( SCIPconsGetAge(cons1) < SCIPconsGetAge(cons2) )
122  return +1;
123  else
124 #ifdef SCIP_DISABLED_CODE
125  /* @todo if both constraints have the same age we prefere the constraint with more non-zeros
126  * this requires a larges change of the callback, passing void-pointer (i.e. a scip
127  * object) would necessary.
128  */
129  {
130  SCIP_Bool success;
131  int nvars1;
132  int nvars2;
133 
134  SCIP_CALL( SCIPgetConsNVars(scip, cons1, &nvars1, &success) );
135  assert(success)
136 
137  SCIP_CALL( SCIPgetConsNVars(scip, cons2, &nvars2, &success) );
138  assert(success)
139 
140  if( nvars1 >= nvars2 )
141  return -1;
142  else
143  return +1;
144  }
145 #else
146  return 0;
147 #endif
148 }
149 
150 /* initializes the conflict store */
151 static
153  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
154  SCIP_SET* set, /**< global SCIP settings */
155  SCIP_PROB* transprob /**< transformed problem */
156  )
157 {
158  assert(conflictstore != NULL);
159 
160  /* calculate the maximal size of the conflict store */
161  if( conflictstore->maxstoresize == -1 )
162  {
163  SCIP_CALL( SCIPsetGetIntParam(set, "conflict/maxstoresize", &conflictstore->maxstoresize) );
164 
165  /* the size should be dynamic wrt number of variables after presolving */
166  if( conflictstore->maxstoresize == -1 )
167  {
168  int nconss;
169  int nvars;
170 
171  nconss = SCIPprobGetNConss(transprob);
172  nvars = SCIPprobGetNVars(transprob);
173 
174  conflictstore->initstoresize = CONFLICTSTORE_MINSIZE;
175  conflictstore->initstoresize += 2*nconss;
176 
177  if( nvars/2 <= 500 )
178  conflictstore->initstoresize += (int) CONFLICTSTORE_MAXSIZE/100;
179  else if( nvars/2 <= 5000 )
180  conflictstore->initstoresize += (int) CONFLICTSTORE_MAXSIZE/10;
181  else
182  conflictstore->initstoresize += CONFLICTSTORE_MAXSIZE/2;
183 
184  conflictstore->initstoresize = MIN(conflictstore->initstoresize, CONFLICTSTORE_MAXSIZE);
185  conflictstore->storesize = conflictstore->initstoresize;
186  conflictstore->maxstoresize = (int)(MIN(3.0 * conflictstore->initstoresize, CONFLICTSTORE_MAXSIZE));
187  }
188  else
189  {
190  conflictstore->initstoresize = conflictstore->maxstoresize;
191  conflictstore->storesize = conflictstore->maxstoresize;
192  }
193 
194 #ifdef NDEBUG
195  if( conflictstore->maxstoresize == 0 )
196  SCIPsetDebugMsg(set, "usage of conflict pool is disabled.\n");
197  else
198  SCIPsetDebugMsg(set, "[init,max] size of conflict pool is [%d,%d].\n",
199  conflictstore->initstoresize, conflictstore->maxstoresize);
200 #endif
201  }
202 
203  return SCIP_OKAY;
204 }
205 
206 /** resizes conflict and primal bound arrays to be able to store at least num entries */
207 static
209  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
210  SCIP_SET* set, /**< global SCIP settings */
211  BMS_BLKMEM* blkmem, /**< block memory */
212  int num /**< minimal number of slots in array */
213  )
214 {
215  assert(conflictstore != NULL);
216  assert(set != NULL);
217 
218  /* we do not allocate more memory as allowed */
219  if( conflictstore->conflictsize == conflictstore->maxstoresize )
220  return SCIP_OKAY;
221 
222  if( num > conflictstore->conflictsize )
223  {
224  int newsize;
225 #ifndef NDEBUG
226  int i;
227 #endif
228  /* initialize the complete data structure */
229  if( conflictstore->conflictsize == 0 )
230  {
231  newsize = MIN(conflictstore->storesize, CONFLICTSTORE_SIZE);
232  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &conflictstore->conflicts, newsize) );
233  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &conflictstore->primalbounds, newsize) );
234  }
235  else
236  {
237  newsize = SCIPsetCalcMemGrowSize(set, num);
238  newsize = MIN(conflictstore->maxstoresize, newsize);
239  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->conflicts, conflictstore->conflictsize,
240  newsize) );
241  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->primalbounds, conflictstore->conflictsize,
242  newsize) );
243  }
244 
245 #ifndef NDEBUG
246  for( i = conflictstore->nconflicts; i < newsize; i++ )
247  {
248  conflictstore->conflicts[i] = NULL;
249  conflictstore->primalbounds[i] = -SCIPsetInfinity(set);
250  }
251 #endif
252  conflictstore->conflictsize = newsize;
253  }
254  assert(num <= conflictstore->conflictsize || conflictstore->conflictsize == conflictstore->maxstoresize);
255 
256  return SCIP_OKAY;
257 }
258 
259 /* increase the dynamic storage if we could not delete enough conflicts
260  *
261  * we want to have at least set->conf_maxconss free slots in the conflict array, because this is the maximal number
262  * of conflicts generated at a node. we increase the size by the minimum of set->conf_maxconss and 1% of the current
263  * store size. nevertheless, we don't exceed conflictstore->maxstoresize.
264  */
265 static
267  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
268  SCIP_SET* set /**< global SCIP settings */
269  )
270 {
271  assert(conflictstore != NULL);
272 
273  /* increase storage */
274  if( conflictstore->storesize - conflictstore->nconflicts <= set->conf_maxconss
275  && conflictstore->storesize < conflictstore->maxstoresize )
276  {
277  SCIP_Real increase = ceil(0.01 * conflictstore->storesize);
278  conflictstore->storesize += MIN(set->conf_maxconss, (int)(increase));
279  conflictstore->storesize = MIN(conflictstore->storesize, conflictstore->maxstoresize);
280  }
281 
282  return;
283 }
284 
285 /* removes conflict at position pos */
286 static
288  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
289  SCIP_SET* set, /**< global SCIP settings */
290  SCIP_STAT* stat, /**< dynamic SCIP statistics */
291  SCIP_PROB* transprob, /**< transformed problem, or NULL if delete = FALSE */
292  BMS_BLKMEM* blkmem, /**< block memory */
293  SCIP_REOPT* reopt, /**< reoptimization data */
294  int pos, /**< position to remove */
295  SCIP_Bool deleteconflict /**< should the conflict be deleted? */
296  )
297 {
298  SCIP_CONS* conflict;
299  int lastpos;
300 
301  assert(conflictstore != NULL);
302  assert(pos >= 0 && pos < conflictstore->nconflicts);
303 
304  lastpos = conflictstore->nconflicts-1;
305  conflict = conflictstore->conflicts[pos];
306  assert(conflict != NULL);
307 
308  /* decrease number of conflicts depending an a cutoff bound */
309  conflictstore->ncbconflicts -= (SCIPsetIsInfinity(set, REALABS(conflictstore->primalbounds[pos])) ? 0 : 1);
310 
311 #ifdef SCIP_PRINT_DETAILS
312  SCIPsetDebugMsg(set, "-> remove conflict at pos=%d with age=%g\n", pos, SCIPconsGetAge(conflict));
313 #endif
314 
315  /* mark the constraint as deleted */
316  if( deleteconflict && !SCIPconsIsDeleted(conflict) )
317  {
318  assert(transprob != NULL);
319  SCIP_CALL( SCIPconsDelete(conflictstore->conflicts[pos], blkmem, set, stat, transprob, reopt) );
320  }
321  SCIP_CALL( SCIPconsRelease(&conflictstore->conflicts[pos], blkmem, set) );
322 
323  /* replace with conflict at the last position */
324  if( pos < lastpos )
325  {
326  conflictstore->conflicts[pos] = conflictstore->conflicts[lastpos];
327  conflictstore->primalbounds[pos] = conflictstore->primalbounds[lastpos];
328  }
329 
330 #ifndef NDEBUG
331  conflictstore->conflicts[lastpos] = NULL;
332  conflictstore->primalbounds[lastpos] = -SCIPsetInfinity(set);
333 #endif
334 
335  /* decrease number of conflicts */
336  --conflictstore->nconflicts;
337 
338  return SCIP_OKAY;
339 }
340 
341 /* removes dual ray at position pos */
342 static
344  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
345  SCIP_SET* set, /**< global SCIP settings */
346  SCIP_STAT* stat, /**< dynamic SCIP statistics */
347  SCIP_PROB* transprob, /**< transformed problem, or NULL if delete = FALSE */
348  BMS_BLKMEM* blkmem, /**< block memory */
349  SCIP_REOPT* reopt, /**< reoptimization data */
350  int pos, /**< position to remove */
351  SCIP_Bool deleteconflict /**< should the dual ray be deleted? */
352  )
353 {
354  SCIP_CONS* dualray;
355  SCIP_Bool success;
356  int lastpos;
357  int nvars;
358 
359  assert(conflictstore != NULL);
360 
361  lastpos = conflictstore->ndualrayconfs-1;
362  dualray = conflictstore->dualrayconfs[pos];
363  assert(dualray != NULL);
364 
365  /* decrease the number of non-zeros */
366  SCIP_CALL( SCIPconsGetNVars(dualray, set, &nvars, &success) );
367  assert(success);
368  conflictstore->nnzdualrays -= nvars;
369 
370 #ifdef SCIP_PRINT_DETAILS
371  SCIPsetDebugMsg(set, "-> remove dual ray at pos=%d age=%g nvars=%d\n", pos, SCIPconsGetAge(dualray), nvars);
372 #endif
373 
374  /* mark the constraint as deleted */
375  if( deleteconflict && !SCIPconsIsDeleted(dualray) )
376  {
377  assert(transprob != NULL);
378  SCIP_CALL( SCIPconsDelete(dualray, blkmem, set, stat, transprob, reopt) );
379  }
380  SCIP_CALL( SCIPconsRelease(&dualray, blkmem, set) );
381 
382  /* replace with dual ray at the last position */
383  if( pos < lastpos )
384  {
385  conflictstore->dualrayconfs[pos] = conflictstore->dualrayconfs[lastpos];
386 
387 #ifndef NDEBUG
388  conflictstore->dualrayconfs[lastpos] = NULL;
389 #endif
390  }
391 
392  /* decrease number of dual rays */
393  --conflictstore->ndualrayconfs;
394 
395  return SCIP_OKAY;
396 }
397 
398 /** removes all deleted conflicts from the storage */
399 static
401  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
402  SCIP_SET* set, /**< global SCIP settings */
403  SCIP_STAT* stat, /**< dynamic SCIP statistics */
404  BMS_BLKMEM* blkmem, /**< block memory */
405  SCIP_REOPT* reopt, /**< reoptimization data */
406  int* ndelconfs /**< pointer to store the number of deleted conflicts */
407  )
408 {
409  int i;
410 
411  assert(conflictstore != NULL);
412 
413  (*ndelconfs) = 0;
414 
415  for( i = 0; i < conflictstore->nconflicts; )
416  {
417  assert(conflictstore->conflicts[i] != NULL);
418 
419  /* check whether the constraint is already marked as deleted */
420  if( SCIPconsIsDeleted(conflictstore->conflicts[i]) )
421  {
422  /* remove conflict at current position
423  *
424  * don't increase i because delPosConflict will swap the last pointer to the i-th position
425  */
426  SCIP_CALL( delPosConflict(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
427 
428  ++(*ndelconfs);
429  }
430  else
431  /* increase i */
432  i++;
433  }
434 
435  SCIPsetDebugMsg(set, "removed %d/%d as deleted marked conflicts.\n", *ndelconfs, conflictstore->nconflicts);
436 
437  return SCIP_OKAY;
438 }
439 
440 /** cleans up the storage */
441 static
443  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
444  SCIP_SET* set, /**< global SCIP settings */
445  SCIP_STAT* stat, /**< dynamic SCIP statistics */
446  SCIP_PROB* transprob, /**< transformed problem */
447  BMS_BLKMEM* blkmem, /**< block memory */
448  SCIP_REOPT* reopt /**< reoptimization data */
449  )
450 {
451  int ndelconfs;
452 
453  assert(conflictstore != NULL);
454  assert(blkmem != NULL);
455  assert(set != NULL);
456  assert(stat != NULL);
457  assert(transprob != NULL);
458 
459  /* the storage is empty */
460  if( conflictstore->nconflicts == 0 )
461  return SCIP_OKAY;
462  assert(conflictstore->nconflicts >= 1);
463 
464  ndelconfs = 0;
465 
466  /* remove all as deleted marked conflicts */
467  SCIP_CALL( cleanDeletedConflicts(conflictstore, set, stat, blkmem, reopt, &ndelconfs) );
468 
469  /* return if at least one conflict could be deleted */
470  if( ndelconfs > 0 )
471  goto TERMINATE;
472 
473  /* only clean up the storage if it is filled enough */
474  if( conflictstore->nconflicts < conflictstore->conflictsize )
475  goto TERMINATE;
476 
477  /* resort the array regularly */
478  if( conflictstore->ncleanups % CONFLICTSTORE_SORTFREQ == 0 )
479  {
480  /* sort conflict */
481  SCIPsortPtrReal((void**)conflictstore->conflicts, conflictstore->primalbounds, compareConss, conflictstore->nconflicts);
482  assert(SCIPsetIsGE(set, SCIPconsGetAge(conflictstore->conflicts[0]),
483  SCIPconsGetAge(conflictstore->conflicts[conflictstore->nconflicts-1])));
484  }
485  assert(conflictstore->nconflicts > 0);
486 
487  if( conflictstore->ncleanups % CONFLICTSTORE_SORTFREQ == 0 )
488  {
489  /* remove conflict at first position (array is sorted) */
490  SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, 0, TRUE) );
491  }
492  else
493  {
494  SCIP_Real maxage;
495  int oldest_i;
496  int i;
497 
498  assert(!SCIPconsIsDeleted(conflictstore->conflicts[0]));
499 
500  maxage = SCIPconsGetAge(conflictstore->conflicts[0]);
501  oldest_i = 0;
502 
503  /* check the first 10% of conflicts and find the oldest */
504  for( i = 1; i < 0.1 * conflictstore->nconflicts; i++ )
505  {
506  assert(!SCIPconsIsDeleted(conflictstore->conflicts[i]));
507 
508  if( SCIPconsGetAge(conflictstore->conflicts[i]) > maxage )
509  {
510  maxage = SCIPconsGetAge(conflictstore->conflicts[i]);
511  oldest_i = i;
512  }
513  }
514 
515  /* remove conflict at position oldest_i */
516  SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, oldest_i, TRUE) );
517  }
518  ++ndelconfs;
519 
520  /* adjust size of the storage if we use a dynamic store */
521  if( set->conf_maxstoresize == -1 )
522  adjustStorageSize(conflictstore, set);
523  assert(conflictstore->initstoresize <= conflictstore->storesize);
524  assert(conflictstore->storesize <= conflictstore->maxstoresize);
525 
526  TERMINATE:
527 
528  /* increase the number of clean ups */
529  ++conflictstore->ncleanups;
530 
531  SCIPsetDebugMsg(set, "clean-up #%lld: removed %d/%d conflicts, %d depending on cutoff bound\n",
532  conflictstore->ncleanups, ndelconfs, conflictstore->nconflicts+ndelconfs, conflictstore->ncbconflicts);
533 
534  return SCIP_OKAY;
535 }
536 
537 /** adds an original conflict constraint to the store
538  *
539  * @note the constraint will be only transfered to the storage of the transformed problem after calling
540  * SCIPconflictstoreTransform()
541  */
542 static
544  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
545  SCIP_SET* set, /**< global SCIP settings */
546  BMS_BLKMEM* blkmem, /**< block memory */
547  SCIP_CONS* cons /**< conflict constraint */
548  )
549 {
550  assert(conflictstore != NULL);
551  assert(cons != NULL);
552 
553  if( conflictstore->origconfs == NULL )
554  {
556  conflictstore->origconflictsize = CONFLICTSTORE_MINSIZE;
557  }
558  else if( conflictstore->norigconfs == conflictstore->origconflictsize )
559  {
560  int newsize = SCIPsetCalcMemGrowSize(set, conflictstore->origconflictsize+1);
561  SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->origconfs, conflictstore->origconflictsize, newsize) );
562  conflictstore->origconflictsize = newsize;
563  }
564 
565  SCIPconsCapture(cons);
566  conflictstore->origconfs[conflictstore->norigconfs] = cons;
567  ++conflictstore->norigconfs;
568 
569  return SCIP_OKAY;
570 }
571 
572 
573 /** creates conflict store */
575  SCIP_CONFLICTSTORE** conflictstore, /**< pointer to store conflict store */
576  SCIP_SET* set /**< global SCIP settings */
577  )
578 {
579  assert(conflictstore != NULL);
580 
581  SCIP_ALLOC( BMSallocMemory(conflictstore) );
582 
583  (*conflictstore)->conflicts = NULL;
584  (*conflictstore)->primalbounds = NULL;
585  (*conflictstore)->dualrayconfs = NULL;
586  (*conflictstore)->origconfs = NULL;
587  (*conflictstore)->nnzdualrays = 0;
588  (*conflictstore)->conflictsize = 0;
589  (*conflictstore)->origconflictsize = 0;
590  (*conflictstore)->nconflicts = 0;
591  (*conflictstore)->ndualrayconfs = 0;
592  (*conflictstore)->norigconfs = 0;
593  (*conflictstore)->ncbconflicts = 0;
594  (*conflictstore)->nconflictsfound = 0;
595  (*conflictstore)->initstoresize = -1;
596  (*conflictstore)->storesize = -1;
597  (*conflictstore)->maxstoresize = -1;
598  (*conflictstore)->ncleanups = 0;
599  (*conflictstore)->lastnodenum = -1;
600  (*conflictstore)->eventhdlr = SCIPsetFindEventhdlr(set, EVENTHDLR_NAME);
601 
602  /* create event handler for LP events */
603  if( (*conflictstore)->eventhdlr == NULL )
604  {
605  SCIP_CALL( SCIPeventhdlrCreate(&(*conflictstore)->eventhdlr, EVENTHDLR_NAME, EVENTHDLR_DESC, NULL, NULL,
606  NULL, NULL, eventInitsolConflictstore, eventExitsolConflictstore, NULL, eventExecConflictstore, NULL) );
607  SCIP_CALL( SCIPsetIncludeEventhdlr(set, (*conflictstore)->eventhdlr) );
608  }
609  assert((*conflictstore)->eventhdlr != NULL);
610 
611  return SCIP_OKAY;
612 }
613 
614 /** frees conflict store */
616  SCIP_CONFLICTSTORE** conflictstore, /**< pointer to store conflict store */
617  BMS_BLKMEM* blkmem, /**< block memory */
618  SCIP_SET* set, /**< global SCIP settings */
619  SCIP_STAT* stat, /**< dynamic SCIP statistics */
620  SCIP_REOPT* reopt /**< reoptimization data */
621  )
622 {
623  assert(conflictstore != NULL);
624  assert(*conflictstore != NULL);
625 
626  /* clear the storage */
627  SCIP_CALL( SCIPconflictstoreClean(*conflictstore, blkmem, set, stat, reopt) );
628 
629  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->origconfs, (*conflictstore)->origconflictsize);
630  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->conflicts, (*conflictstore)->conflictsize);
631  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->primalbounds, (*conflictstore)->conflictsize);
632  BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->dualrayconfs, CONFLICTSTORE_DUALSIZE);
633  BMSfreeMemoryNull(conflictstore);
634 
635  return SCIP_OKAY;
636 }
637 
638 /** cleans conflict store */
640  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
641  BMS_BLKMEM* blkmem, /**< block memory */
642  SCIP_SET* set, /**< global SCIP settings */
643  SCIP_STAT* stat, /**< dynamic SCIP statistics */
644  SCIP_REOPT* reopt /**< reoptimization data */
645  )
646 {
647  int i;
648 
649  assert(conflictstore != NULL);
650 
651  SCIPsetDebugMsg(set, "cleaning conflict store: %d origconfs, %d conflicts, %d dual rays\n",
652  conflictstore->norigconfs, conflictstore->nconflicts, conflictstore->ndualrayconfs);
653 
654  /* remove original constraints if present */
655  if( conflictstore->origconfs != NULL )
656  {
657  for( i = 0; i < conflictstore->norigconfs; i++ )
658  {
659  SCIP_CONS* conflict = conflictstore->origconfs[i];
660  SCIP_CALL( SCIPconsRelease(&conflict, blkmem, set) );
661  }
662  conflictstore->norigconfs = 0;
663  }
664 
665  if( conflictstore->conflicts != NULL )
666  {
667  /* we travers in reverse order to avoid swapping of pointers */
668  for( i = conflictstore->nconflicts-1; i >= 0; i--)
669  {
670  SCIP_CALL( delPosConflict(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
671  }
672  assert(conflictstore->nconflicts == 0);
673  }
674 
675  if( conflictstore->dualrayconfs != NULL )
676  {
677  /* we travers in reverse order to avoid swapping of pointers */
678  for( i = conflictstore->ndualrayconfs-1; i >= 0 ; i-- )
679  {
680  SCIP_CALL( delPosDualray(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
681  }
682  assert(conflictstore->ndualrayconfs == 0);
683  }
684 
685  return SCIP_OKAY;
686 }
687 
688 /** adds a constraint to the pool of dual rays
689  *
690  * @note this methods captures the constraint
691  */
693  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
694  SCIP_CONS* dualraycons, /**< constraint based on a dual ray */
695  BMS_BLKMEM* blkmem, /**< block memory */
696  SCIP_SET* set, /**< global SCIP settings */
697  SCIP_STAT* stat, /**< dynamic SCIP statistics */
698  SCIP_PROB* transprob, /**< transformed problem */
699  SCIP_REOPT* reopt /**< reoptimization data */
700  )
701 {
702  int nvars;
703  SCIP_Bool success;
704 
705  assert(conflictstore != NULL);
706  assert(conflictstore->ndualrayconfs <= CONFLICTSTORE_DUALSIZE);
707 
708  /* mark the constraint to be a conflict */
709  SCIPconsMarkConflict(dualraycons);
710 
711  /* create an array to stre constraints based on dual rays */
712  if( conflictstore->dualrayconfs == NULL )
713  {
715  }
716 
717  /* the store is full, we proceed as follows
718  *
719  * 1. check whether some constraints are marked as deleted and remove those
720  * 2. if no constraint is marked as deleted: remove the oldest
721  */
722  if( conflictstore->ndualrayconfs == CONFLICTSTORE_DUALSIZE )
723  {
724  int ndeleted;
725  int i;
726 
727  ndeleted = 0;
728  for( i = 0; i < conflictstore->ndualrayconfs; )
729  {
730  if( SCIPconsIsDeleted(conflictstore->dualrayconfs[i]) )
731  {
732  /* remove dual ray at current position
733  *
734  * don't increase i because delPosDualray will swap the last pointer to the i-th position
735  */
736  SCIP_CALL( delPosDualray(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
737 
738  ++ndeleted;
739  }
740  else
741  ++i;
742  }
743 
744  /* if we could not remove a dual ray that is already marked as deleted we need to remove the oldest active one */
745  if( ndeleted == 0 )
746  {
747  /* sort dual rays */
748  SCIPsortPtr((void**)conflictstore->dualrayconfs, compareConss, conflictstore->ndualrayconfs);
749  assert(SCIPsetIsGE(set, SCIPconsGetAge(conflictstore->dualrayconfs[0]),
750  SCIPconsGetAge(conflictstore->dualrayconfs[conflictstore->ndualrayconfs-1])));
751 
752  SCIP_CALL( delPosDualray(conflictstore, set, stat, transprob, blkmem, reopt, 0, TRUE) );
753  }
754  }
755 
756  /* add the new constraint based on a dual ray at the last position */
757  SCIPconsCapture(dualraycons);
758  conflictstore->dualrayconfs[conflictstore->ndualrayconfs] = dualraycons;
759  ++conflictstore->ndualrayconfs;
760 
761  /* increase the number of non-zeros */
762  SCIP_CALL( SCIPconsGetNVars(dualraycons, set, &nvars, &success) );
763  assert(success);
764  conflictstore->nnzdualrays += nvars;
765 
766  return SCIP_OKAY;
767 }
768 
769 /** adds a conflict to the conflict store
770  *
771  * @note this method captures the constraint
772  */
774  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
775  BMS_BLKMEM* blkmem, /**< block memory */
776  SCIP_SET* set, /**< global SCIP settings */
777  SCIP_STAT* stat, /**< dynamic SCIP statistics */
778  SCIP_TREE* tree, /**< branch and bound tree (or NULL for an original constraint) */
779  SCIP_PROB* transprob, /**< transformed problem (or NULL for an original constraint) */
780  SCIP_REOPT* reopt, /**< reoptimization data */
781  SCIP_CONS* cons, /**< constraint representing the conflict */
782  SCIP_CONFTYPE conftype, /**< type of the conflict */
783  SCIP_Bool cutoffinvolved, /**< is a cutoff bound involved in this conflict */
784  SCIP_Real primalbound /**< primal bound the conflict depend on (or -SCIPinfinity) */
785  )
786 {
787  SCIP_Longint curnodenum;
788  int nconflicts;
789 
790  assert(conflictstore != NULL);
791  assert(blkmem != NULL);
792  assert(set != NULL);
793  assert(stat != NULL);
794  assert(tree != NULL || SCIPconsIsOriginal(cons));
795  assert(transprob != NULL || SCIPconsIsOriginal(cons));
796  assert(cons != NULL);
797  assert(conftype != SCIP_CONFTYPE_BNDEXCEEDING || cutoffinvolved);
798  assert(!cutoffinvolved || !SCIPsetIsInfinity(set, REALABS(primalbound)));
799 
800  /* mark the constraint to be a conflict */
801  SCIPconsMarkConflict(cons);
802 
803  /* add the constraint to a special store */
804  if( SCIPconsIsOriginal(cons) )
805  {
806  assert(SCIPsetGetStage(set) == SCIP_STAGE_PROBLEM);
807  SCIP_CALL( conflictstoreAddOrigConflict(conflictstore, set, blkmem, cons) );
808  return SCIP_OKAY;
809  }
810 
811  nconflicts = conflictstore->nconflicts;
812 
813  /* initialize the storage */
814  if( conflictstore->maxstoresize == -1 )
815  {
816  SCIP_CALL( initConflictstore(conflictstore, set, transprob) );
817  }
818  assert(conflictstore->initstoresize >= 0);
819  assert(conflictstore->initstoresize <= conflictstore->maxstoresize);
820 
821  /* return if conflict pool is disabled */
822  if( conflictstore->maxstoresize == 0 )
823  return SCIP_OKAY;
824 
825  SCIP_CALL( conflictstoreEnsureMem(conflictstore, set, blkmem, nconflicts+1) );
826 
827  /* return if the store has size zero */
828  if( conflictstore->conflictsize == 0 )
829  {
830  assert(conflictstore->maxstoresize == 0);
831  return SCIP_OKAY;
832  }
833 
834  assert(tree != NULL);
835  curnodenum = (SCIPtreeGetFocusNode(tree) == NULL ? -1 : SCIPnodeGetNumber(SCIPtreeGetFocusNode(tree)));
836 
837  /* clean up the storage if we are at a new node or the storage is full */
838  if( conflictstore->lastnodenum != curnodenum || conflictstore->nconflicts == conflictstore->conflictsize )
839  {
840  SCIP_CALL( conflictstoreCleanUpStorage(conflictstore, set, stat, transprob, blkmem, reopt) );
841  }
842 
843  /* update the last seen node */
844  conflictstore->lastnodenum = curnodenum;
845 
846  SCIPconsCapture(cons);
847  conflictstore->conflicts[conflictstore->nconflicts] = cons;
848  conflictstore->primalbounds[conflictstore->nconflicts] = primalbound;
849  conflictstore->ncbconflicts += (SCIPsetIsInfinity(set, REALABS(primalbound)) ? 0 : 1);
850 
851  ++conflictstore->nconflicts;
852  ++conflictstore->nconflictsfound;
853 
854 #ifdef SCIP_PRINT_DETAILS
855  SCIPsetDebugMsg(set, "add conflict <%s> to conflict store at position %d\n", SCIPconsGetName(cons), conflictstore->nconflicts-1);
856  SCIPsetDebugMsg(set, " -> conflict type: %d, cutoff involved = %u\n", conftype, cutoffinvolved);
857  if( cutoffinvolved )
858  SCIPsetDebugMsg(set, " -> current primal bound: %g\n", primalbound);
859 #endif
860 
861  return SCIP_OKAY;
862 }
863 
864 /** deletes all conflicts depending on a cutoff bound larger than the given bound */
866  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
867  SCIP_SET* set, /**< global SCIP settings */
868  SCIP_STAT* stat, /**< dynamic SCIP statistics */
869  BMS_BLKMEM* blkmem, /**< block memory */
870  SCIP_PROB* transprob, /**< transformed problem*/
871  SCIP_REOPT* reopt, /**< reoptimization data */
872  SCIP_Real cutoffbound /**< current cutoff bound */
873  )
874 {
875  SCIP_Real improvement;
876  int ndelconfs;
877  int i;
878 
879  assert(conflictstore != NULL);
880  assert(set != NULL);
881  assert(stat != NULL);
882  assert(blkmem != NULL);
883  assert(transprob != NULL);
884 
885  ndelconfs = 0;
886 
887  /* return if we do not want to use the storage */
888  if( set->conf_maxstoresize == 0 )
889  return SCIP_OKAY;
890 
891  /* return if we do not want to remove conflicts related to an older cutoff bound */
892  if( !set->conf_cleanbnddepend )
893  return SCIP_OKAY;
894 
895  /* calculate scalar to determine whether the old primal bound is worse enough to remove the conflict */
896  if( SCIPsetIsPositive(set, cutoffbound) )
897  improvement = (1 - set->conf_minimprove);
898  else
899  improvement = (1 + set->conf_minimprove);
900 
901  /* remove all conflicts depending on a primalbound*improvement > cutoffbound
902  *
903  * note: we cannot remove conflicts that are marked as deleted because at this point in time we would destroy
904  * the internal data structure
905  */
906  for( i = 0; i < conflictstore->nconflicts; )
907  {
908  assert(conflictstore->conflicts[i] != NULL);
909 
910  /* check if the conflict depends on the cutoff bound */
911  if( SCIPsetIsGT(set, improvement * conflictstore->primalbounds[i], cutoffbound) )
912  {
913  /* remove conflict at current position
914  *
915  * don't increase i because delPosConflict will swap the last pointer to the i-th position
916  */
917  SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
918  ++ndelconfs;
919  }
920  else
921  /* increase i */
922  ++i;
923  }
924  assert(conflictstore->ncbconflicts >= 0);
925  assert(conflictstore->nconflicts >= 0);
926 
927  SCIPsetDebugMsg(set, "-> removed %d/%d conflicts, %d depending on cutoff bound\n", ndelconfs,
928  conflictstore->nconflicts+ndelconfs, ndelconfs);
929 
930  return SCIP_OKAY;
931 }
932 
933 /** returns the maximal size of the conflict pool */
935  SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
936  )
937 {
938  assert(conflictstore != NULL);
939 
940  return MIN(conflictstore->storesize, conflictstore->maxstoresize);
941 }
942 
943 /** returns the initial size of the conflict pool */
945  SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
946  )
947 {
948  assert(conflictstore != NULL);
949 
950  return conflictstore->initstoresize;
951 }
952 
953 /** returns the number of stored conflicts on the conflict pool
954  *
955  * @note the number of active conflicts can be less
956  */
958  SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
959  )
960 {
961  assert(conflictstore != NULL);
962 
963  return conflictstore->nconflicts;
964 }
965 
966 /** returns all active conflicts stored in the conflict store */
968  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
969  SCIP_CONS** conflicts, /**< array to store conflicts */
970  int conflictsize, /**< size of the conflict array */
971  int* nconflicts /**< pointer to store the number of conflicts */
972  )
973 {
974  int i;
975 
976  assert(conflictstore != NULL);
977 
978  /* return if the allocated memory is obviously to small */
979  if( conflictstore->nconflicts > conflictsize )
980  {
981  (*nconflicts) = conflictstore->nconflicts;
982  return SCIP_OKAY;
983  }
984 
985  (*nconflicts) = 0;
986  for( i = 0; i < conflictstore->nconflicts; i++ )
987  {
988  SCIP_CONS* conflict;
989 
990  conflict = conflictstore->conflicts[i];
991  assert(conflict != NULL);
992 
993  /* skip deactivated and deleted constraints */
994  if( !SCIPconsIsActive(conflict) || SCIPconsIsDeleted(conflict) )
995  continue;
996 
997  /* count exact number conflicts */
998  if( *nconflicts > conflictsize )
999  ++(*nconflicts);
1000  else
1001  {
1002  conflicts[*nconflicts] = conflict;
1003  ++(*nconflicts);
1004  }
1005  }
1006 
1007  return SCIP_OKAY;
1008 }
1009 
1010 /** transformes all original conflicts into transformed conflicts */
1012  SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1013  BMS_BLKMEM* blkmem, /**< block memory */
1014  SCIP_SET* set, /**< global SCIP settings */
1015  SCIP_STAT* stat, /**< dynamic SCIP statistics */
1016  SCIP_TREE* tree, /**< branch and bound tree */
1017  SCIP_PROB* transprob, /**< transformed problem */
1018  SCIP_REOPT* reopt /**< reoptimization data */
1019  )
1020 {
1021  int ntransconss;
1022  int i;
1023 
1024  assert(conflictstore != NULL);
1025  assert(set != NULL);
1026  assert(SCIPsetGetStage(set) == SCIP_STAGE_TRANSFORMING);
1027 
1028  /* return if no original constraints are stored */
1029  if( conflictstore->norigconfs == 0 )
1030  return SCIP_OKAY;
1031 
1032  ntransconss = 0;
1033 
1034  for( i = 0; i < conflictstore->norigconfs; i++ )
1035  {
1036  SCIP_CONS* transcons;
1037 
1038  assert(conflictstore->origconfs[i] != NULL);
1039  assert(SCIPconsIsOriginal(conflictstore->origconfs[i]));
1040 
1041  transcons = SCIPconsGetTransformed(conflictstore->origconfs[i]);
1042 
1043  if( transcons != NULL )
1044  {
1045  SCIP_CALL( SCIPconflictstoreAddConflict(conflictstore, blkmem, set, stat, tree, transprob, reopt, transcons,
1047 
1048  ++ntransconss;
1049  }
1050 
1051  SCIP_CALL( SCIPconsRelease(&conflictstore->origconfs[i], blkmem, set) );
1052  }
1053 
1054  SCIPsetDebugMsg(set, "-> transform %d/%d conflicts into transformed space\n", ntransconss, conflictstore->norigconfs);
1055 
1056  conflictstore->norigconfs = 0;
1057 
1058  return SCIP_OKAY;
1059 }
1060 
1061 /** returns the average number of non-zeros over all stored dual ray constraints */
1063  SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1064  )
1065 {
1066  assert(conflictstore != NULL);
1067 
1068  if( conflictstore->ndualrayconfs == 0 )
1069  return 0.0;
1070  else
1071  return (SCIP_Real) conflictstore->nnzdualrays / ((SCIP_Real) conflictstore->ndualrayconfs);
1072 }
1073 
1074 /** returns the number of all stored dual ray constraints */
1076  SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1077  )
1078 {
1079  assert(conflictstore != NULL);
1080 
1081  return conflictstore->ndualrayconfs;
1082 }
1083 
SCIP_RETCODE SCIPclearConflictStore(SCIP *scip, SCIP_EVENT *event)
Definition: scip.c:12923
SCIP_RETCODE SCIPconsDelete(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_REOPT *reopt)
Definition: cons.c:6259
SCIP_RETCODE SCIPsetIncludeEventhdlr(SCIP_SET *set, SCIP_EVENTHDLR *eventhdlr)
Definition: set.c:4274
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5522
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:422
internal methods for managing events
static SCIP_DECL_SORTPTRCOMP(compareConss)
#define EVENTHDLR_NAME
Definition: conflictstore.c:47
#define CONFLICTSTORE_SORTFREQ
Definition: conflictstore.c:44
SCIP_RETCODE SCIPeventhdlrCreate(SCIP_EVENTHDLR **eventhdlr, const char *name, const char *desc, SCIP_DECL_EVENTCOPY((*eventcopy)), SCIP_DECL_EVENTFREE((*eventfree)), SCIP_DECL_EVENTINIT((*eventinit)), SCIP_DECL_EVENTEXIT((*eventexit)), SCIP_DECL_EVENTINITSOL((*eventinitsol)), SCIP_DECL_EVENTEXITSOL((*eventexitsol)), SCIP_DECL_EVENTDELETE((*eventdelete)), SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
Definition: event.c:64
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip.c:814
int SCIPprobGetNConss(SCIP_PROB *prob)
Definition: prob.c:2297
internal methods for branch and bound tree
static SCIP_DECL_EVENTEXITSOL(eventExitsolConflictstore)
Definition: conflictstore.c:90
int SCIPconflictstoreGetNConflictsInStore(SCIP_CONFLICTSTORE *conflictstore)
SCIP_RETCODE SCIPconflictstoreTransform(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt)
#define CONFLICTSTORE_MINSIZE
Definition: conflictstore.c:41
SCIP_RETCODE SCIPconflictstoreCleanNewIncumbent(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Real cutoffbound)
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:5645
SCIP_EVENTHDLR * SCIPsetFindEventhdlr(SCIP_SET *set, const char *name)
Definition: set.c:4297
static SCIP_RETCODE cleanDeletedConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int *ndelconfs)
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:5384
SCIP_RETCODE SCIPconflictstoreAddDualraycons(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS *dualraycons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt)
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2243
void SCIPconsMarkConflict(SCIP_CONS *cons)
Definition: cons.c:6900
#define FALSE
Definition: def.h:64
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:278
static SCIP_RETCODE conflictstoreEnsureMem(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, BMS_BLKMEM *blkmem, int num)
int SCIPconflictstoreGetNDualrays(SCIP_CONFLICTSTORE *conflictstore)
#define TRUE
Definition: def.h:63
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5096
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
Definition: tree.c:8011
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition: cons.c:6628
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:7942
SCIP_RETCODE SCIPconflictstoreClean(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt)
SCIP_RETCODE SCIPconflictstoreCreate(SCIP_CONFLICTSTORE **conflictstore, SCIP_SET *set)
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
Definition: cons.c:8180
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5616
static SCIP_DECL_EVENTEXEC(eventExecConflictstore)
Definition: conflictstore.c:53
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7143
static SCIP_RETCODE delPosDualray(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int pos, SCIP_Bool deleteconflict)
SCIP_Real SCIPconsGetAge(SCIP_CONS *cons)
Definition: cons.c:8040
internal methods for storing and manipulating the main problem
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
Definition: scip.c:28737
static SCIP_RETCODE conflictstoreAddOrigConflict(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONS *cons)
SCIP_RETCODE SCIPconflictstoreFree(SCIP_CONFLICTSTORE **conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt)
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:7881
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip.c:4369
internal miscellaneous methods
#define NULL
Definition: lpi_spx1.cpp:137
#define CONFLICTSTORE_DUALSIZE
Definition: conflictstore.c:40
#define REALABS(x)
Definition: def.h:159
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:306
int SCIPconflictstoreGetInitPoolSize(SCIP_CONFLICTSTORE *conflictstore)
SCIP_Real SCIPconflictstoreGetAvgNnzDualray(SCIP_CONFLICTSTORE *conflictstore)
#define CONFLICTSTORE_MAXSIZE
Definition: conflictstore.c:42
static SCIP_RETCODE initConflictstore(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_PROB *transprob)
static SCIP_RETCODE delPosConflict(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int pos, SCIP_Bool deleteconflict)
data structures and methods for collecting reoptimization information
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition: cons.c:6227
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip.c:40207
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:408
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:959
static SCIP_RETCODE conflictstoreCleanUpStorage(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt)
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6112
SCIP_RETCODE SCIPsetGetIntParam(SCIP_SET *set, const char *name, int *value)
Definition: set.c:2854
#define CONFLICTSTORE_SIZE
Definition: conflictstore.c:43
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
Definition: cons.c:8010
#define SCIPsetDebugMsg
Definition: set.h:1870
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip.c:40241
#define EVENTHDLR_DESC
Definition: conflictstore.c:48
Constraint handler for linear constraints in their most general form, .
int SCIPconflictstoreGetMaxPoolSize(SCIP_CONFLICTSTORE *conflictstore)
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition: type_event.h:88
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:6100
#define BMSfreeMemoryNull(ptr)
Definition: memory.h:101
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5598
#define SCIP_Real
Definition: def.h:135
enum SCIP_ConflictType SCIP_CONFTYPE
Definition: type_conflict.h:53
#define MIN(x, y)
Definition: memory.c:75
SCIP_RETCODE SCIPconflictstoreAddConflict(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_CONS *cons, SCIP_CONFTYPE conftype, SCIP_Bool cutoffinvolved, SCIP_Real primalbound)
#define BMSallocMemory(ptr)
Definition: memory.h:74
internal methods for constraints and constraint handlers
void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
#define SCIP_Longint
Definition: def.h:120
static SCIP_DECL_EVENTINITSOL(eventInitsolConflictstore)
Definition: conflictstore.c:70
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:2669
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:392
#define SCIP_ALLOC(x)
Definition: def.h:317
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:412
SCIP_RETCODE SCIPconflictstoreGetConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS **conflicts, int conflictsize, int *nconflicts)
SCIP callable library.
static void adjustStorageSize(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set)