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-2025 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 conflictstore.c
26 * @ingroup OTHER_CFILES
27 * @brief methods for storing conflicts
28 * @author Jakob Witzig
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include <assert.h>
34#include <string.h>
35
36#include "scip/certificate.h"
37#include "scip/conflictstore.h"
38#include "scip/cons.h"
39#include "scip/event.h"
40#include "scip/set.h"
41#include "scip/tree.h"
42#include "scip/misc.h"
43#include "scip/prob.h"
44#include "scip/reopt.h"
45#include "scip/scip.h"
47#include "scip/def.h"
48#include "scip/cons_linear.h"
51
52
53#define CONFLICTSTORE_DUALRAYSIZE 100 /* default size of conflict store */
54#define CONFLICTSTORE_DUALSOLSIZE 75 /* default size of conflict store */
55#define CONFLICTSTORE_MINSIZE 2000 /* default minimal size of a dynamic conflict store */
56#define CONFLICTSTORE_MAXSIZE 60000 /* maximal size of a dynamic conflict store (multiplied by 3) */
57#define CONFLICTSTORE_SIZE 10000 /* default size of conflict store */
58#define CONFLICTSTORE_SORTFREQ 20 /* frequency to resort the conflict array */
59
60/* event handler properties */
61#define EVENTHDLR_NAME "ConflictStore"
62#define EVENTHDLR_DESC "Solution event handler for conflict store."
63
64
65/* exec the event handler */
66static
67SCIP_DECL_EVENTEXEC(eventExecConflictstore)
68{/*lint --e{715}*/
69 assert(eventhdlr != NULL);
70 assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
71 assert(event != NULL);
73
75 {
77 }
78
79 return SCIP_OKAY;
80}
81
82/** solving process initialization method of event handler (called when branch and bound process is about to begin) */
83static
84SCIP_DECL_EVENTINITSOL(eventInitsolConflictstore)
85{
86 SCIP_Bool cleanboundexceeding;
87
88 assert(scip != NULL);
89 assert(eventhdlr != NULL);
90 assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
91
92 SCIP_CALL( SCIPgetBoolParam(scip, "conflict/cleanboundexceedings", &cleanboundexceeding) );
93
94 if( !cleanboundexceeding )
95 return SCIP_OKAY;
96
98
99 return SCIP_OKAY;
100}
101
102/** solving process deinitialization method of event handler (called before branch and bound process data is freed) */
103static
104SCIP_DECL_EVENTEXITSOL(eventExitsolConflictstore)
105{
106 SCIP_Bool cleanboundexceeding;
107
108 assert(scip != NULL);
109 assert(eventhdlr != NULL);
110 assert(strcmp(SCIPeventhdlrGetName(eventhdlr), EVENTHDLR_NAME) == 0);
111
112 SCIP_CALL( SCIPgetBoolParam(scip, "conflict/cleanboundexceedings", &cleanboundexceeding) );
113
114 if( !cleanboundexceeding )
115 return SCIP_OKAY;
116
118
119 return SCIP_OKAY;
120}
121
122/* comparison method for constraints */
123static
125{
126 /*lint --e{715}*/
127 SCIP_CONS* cons1 = (SCIP_CONS*)elem1;
128 SCIP_CONS* cons2 = (SCIP_CONS*)elem2;
129
130 assert(cons1 != NULL);
131 assert(cons2 != NULL);
132
133 if( SCIPconsGetAge(cons1) > SCIPconsGetAge(cons2) + 1e-09 )
134 return -1;
135 else if ( SCIPconsGetAge(cons1) < SCIPconsGetAge(cons2) - 1e-09 )
136 return +1;
137 else
138#ifdef SCIP_DISABLED_CODE
139 /* @todo if both constraints have the same age we prefere the constraint with more non-zeros
140 * this requires a larges change of the callback, passing void-pointer (i.e. a scip
141 * object) would necessary.
142 */
143 {
144 SCIP_Bool success;
145 int nvars1;
146 int nvars2;
147
148 SCIP_CALL( SCIPgetConsNVars(scip, cons1, &nvars1, &success) );
149 assert(success);
150
151 SCIP_CALL( SCIPgetConsNVars(scip, cons2, &nvars2, &success) );
152 assert(success);
153
154 if( nvars1 >= nvars2 )
155 return -1;
156 else
157 return +1;
158 }
159#else
160 return 0;
161#endif
162}
163
164/* initializes the conflict store */
165static
167 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
168 SCIP_SET* set, /**< global SCIP settings */
169 SCIP_PROB* transprob /**< transformed problem */
170 )
171{
172 assert(conflictstore != NULL);
173
174 /* calculate the maximal size of the conflict store */
175 if( conflictstore->maxstoresize == -1 )
176 {
177 SCIP_CALL( SCIPsetGetIntParam(set, "conflict/maxstoresize", &conflictstore->maxstoresize) );
178
179 /* the size should be dynamic wrt number of variables after presolving */
180 if( conflictstore->maxstoresize == -1 )
181 {
182 int nconss;
183 int nvars;
184
185 nconss = SCIPprobGetNConss(transprob);
186 nvars = SCIPprobGetNVars(transprob);
187
188 conflictstore->initstoresize = CONFLICTSTORE_MINSIZE;
189 conflictstore->initstoresize += 2*nconss;
190
191 if( nvars/2 <= 500 )
192 conflictstore->initstoresize += (int) CONFLICTSTORE_MAXSIZE/100;
193 else if( nvars/2 <= 5000 )
194 conflictstore->initstoresize += (int) CONFLICTSTORE_MAXSIZE/10;
195 else
196 conflictstore->initstoresize += CONFLICTSTORE_MAXSIZE/2;
197
198 conflictstore->initstoresize = MIN(conflictstore->initstoresize, CONFLICTSTORE_MAXSIZE);
199 conflictstore->storesize = conflictstore->initstoresize;
200 conflictstore->maxstoresize = (int)(MIN(3.0 * conflictstore->initstoresize, CONFLICTSTORE_MAXSIZE));
201 }
202 else
203 {
204 conflictstore->initstoresize = conflictstore->maxstoresize;
205 conflictstore->storesize = conflictstore->maxstoresize;
206 }
207
208#ifdef NDEBUG
209 if( conflictstore->maxstoresize == 0 )
210 SCIPsetDebugMsg(set, "usage of conflict pool is disabled.\n");
211 else
212 SCIPsetDebugMsg(set, "[init,max] size of conflict pool is [%d,%d].\n",
213 conflictstore->initstoresize, conflictstore->maxstoresize);
214#endif
215 }
216
217 return SCIP_OKAY;
218}
219
220/** resizes conflict and primal bound arrays to be able to store at least num entries */
221static
223 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
224 SCIP_SET* set, /**< global SCIP settings */
225 BMS_BLKMEM* blkmem, /**< block memory */
226 int num /**< minimal number of slots in array */
227 )
228{
229 assert(conflictstore != NULL);
230 assert(set != NULL);
231
232 /* we do not allocate more memory as allowed */
233 if( conflictstore->conflictsize == conflictstore->maxstoresize )
234 return SCIP_OKAY;
235
236 if( num > conflictstore->conflictsize )
237 {
238 int newsize;
239
240 /* initialize the complete data structure */
241 if( conflictstore->conflictsize == 0 )
242 {
243 assert(conflictstore->storesize > 0);
244
245 newsize = MIN(conflictstore->storesize, CONFLICTSTORE_SIZE);
246 newsize = MAX(newsize, num);
247 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &conflictstore->conflicts, newsize) );
248 SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &conflictstore->confprimalbnds, newsize) );
249 }
250 else
251 {
252 newsize = SCIPsetCalcMemGrowSize(set, num);
253 newsize = MIN(conflictstore->maxstoresize, newsize);
254 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->conflicts, conflictstore->conflictsize, \
255 newsize) );
256 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->confprimalbnds, conflictstore->conflictsize, \
257 newsize) );
258 }
259
260 conflictstore->conflictsize = newsize;
261 }
262 assert(num <= conflictstore->conflictsize || conflictstore->conflictsize == conflictstore->maxstoresize);
263
264 return SCIP_OKAY;
265}
266
267/* increase the dynamic storage if we could not delete enough conflicts
268 *
269 * we want to have at least set->conf_maxconss free slots in the conflict array, because this is the maximal number
270 * of conflicts generated at a node. we increase the size by the minimum of set->conf_maxconss and 1% of the current
271 * store size. nevertheless, we don't exceed conflictstore->maxstoresize.
272 */
273static
275 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
276 SCIP_SET* set /**< global SCIP settings */
277 )
278{
279 assert(conflictstore != NULL);
280
281 /* increase storage */
282 if( conflictstore->storesize - conflictstore->nconflicts <= set->conf_maxconss
283 && conflictstore->storesize < conflictstore->maxstoresize )
284 {
285 SCIP_Real increase = ceil(0.01 * conflictstore->storesize);
286 conflictstore->storesize += MIN(set->conf_maxconss, (int)(increase));
287 conflictstore->storesize = MIN(conflictstore->storesize, conflictstore->maxstoresize);
288 }
289
290 return;
291}
292
293/** removes an exact conflict constraint from the certificate hashmap
294 *
295 * @todo consider moving this to SCIPconsDelete()
296 */
297static
299 SCIP_SET* set, /**< global SCIP settings */
300 SCIP_CONS* cons /**< conflict constraint */
301 )
302{
303 SCIP_CERTIFICATE* certificate;
304
305 assert(set != NULL);
306 assert(set->scip != NULL);
307 assert(cons != NULL);
308
309 if( !SCIPisExact(set->scip) || !SCIPisCertified(set->scip) || !SCIPconshdlrIsExact((SCIPconsGetHdlr(cons))) )
310 return SCIP_OKAY;
311
312 certificate = SCIPgetCertificate(set->scip);
313 assert(certificate != NULL);
314
315 if( certificate->rowdatahash != NULL && SCIPhashmapExists(certificate->rowdatahash, (void*) cons) )
316 {
317 SCIP_CALL( SCIPhashmapRemove(certificate->rowdatahash, (void*) cons) );
318 }
319
320 return SCIP_OKAY;
321}
322
323/* removes conflict at position pos */
324static
326 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
327 SCIP_SET* set, /**< global SCIP settings */
328 SCIP_STAT* stat, /**< dynamic SCIP statistics */
329 SCIP_PROB* transprob, /**< transformed problem, or NULL if delete = FALSE */
330 BMS_BLKMEM* blkmem, /**< block memory */
331 SCIP_REOPT* reopt, /**< reoptimization data */
332 int pos, /**< position to remove */
333 SCIP_Bool deleteconflict /**< should the conflict be deleted? */
334 )
335{
336 SCIP_CONS* conflict;
337 int lastpos;
338
339 assert(conflictstore != NULL);
340 assert(pos >= 0 && pos < conflictstore->nconflicts);
341
342 lastpos = conflictstore->nconflicts-1;
343 conflict = conflictstore->conflicts[pos];
344 assert(conflict != NULL);
345
346 /* decrease number of conflicts depending an a cutoff bound */
347 conflictstore->ncbconflicts -= (SCIPsetIsInfinity(set, REALABS(conflictstore->confprimalbnds[pos])) ? 0 : 1);
348
349#ifdef SCIP_PRINT_DETAILS
350 SCIPsetDebugMsg(set, "-> remove conflict <%s> at pos=%d with age=%g\n", SCIPconsGetName(conflict), pos, SCIPconsGetAge(conflict));
351#endif
352
353 /* remove conflict locks */
355
356 /* invalidate conflict position */
357 assert(conflictstore->conflicts[pos]->confconsspos == pos);
358 conflictstore->conflicts[pos]->confconsspos = -1;
359
360 /* mark the constraint as deleted */
361 if( deleteconflict && !SCIPconsIsDeleted(conflict) )
362 {
363 assert(transprob != NULL);
364 SCIP_CALL( SCIPconsDelete(conflictstore->conflicts[pos], blkmem, set, stat, transprob, reopt) );
366 }
367 SCIP_CALL( SCIPconsRelease(&conflictstore->conflicts[pos], blkmem, set) );
368
369 /* replace with conflict at the last position */
370 if( pos < lastpos )
371 {
372 assert(conflictstore->conflicts[lastpos] != NULL);
373 conflictstore->conflicts[pos] = conflictstore->conflicts[lastpos];
374 conflictstore->conflicts[pos]->confconsspos = pos;
375 conflictstore->confprimalbnds[pos] = conflictstore->confprimalbnds[lastpos];
376 }
377
378 /* decrease number of conflicts */
379 --conflictstore->nconflicts;
380
381 return SCIP_OKAY;
382}
383
384/* removes proof based on a dual ray at position pos */
385static
387 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
388 SCIP_SET* set, /**< global SCIP settings */
389 SCIP_STAT* stat, /**< dynamic SCIP statistics */
390 SCIP_PROB* transprob, /**< transformed problem, or NULL if delete = FALSE */
391 BMS_BLKMEM* blkmem, /**< block memory */
392 SCIP_REOPT* reopt, /**< reoptimization data */
393 int pos, /**< position to remove */
394 SCIP_Bool deleteconflict /**< should the dual ray be deleted? */
395 )
396{
397 SCIP_CONS* dualproof;
398 SCIP_Bool success;
399 int lastpos;
400 int nvars;
401
402 assert(conflictstore != NULL);
403
404 lastpos = conflictstore->ndualrayconfs-1;
405 dualproof = conflictstore->dualrayconfs[pos];
406 assert(dualproof != NULL);
407
408 /* decrease the number of non-zeros */
409 SCIP_CALL( SCIPconsGetNVars(dualproof, set, &nvars, &success) );
410 assert(success);
411 conflictstore->nnzdualrays -= nvars;
412
413#ifdef SCIP_PRINT_DETAILS
414 SCIPsetDebugMsg(set, "-> remove dual proof (ray) at pos=%d age=%g nvars=%d\n", pos, SCIPconsGetAge(dualproof), nvars);
415#endif
416
417 /**@todo implement dualraycons upgrade */
418 SCIPconsAddUpgradeLocks(dualproof, -1);
419
420 /* remove conflict locks */
422
423 /* mark the constraint as deleted */
424 if( deleteconflict && !SCIPconsIsDeleted(dualproof) )
425 {
426 assert(transprob != NULL);
427 SCIP_CALL( SCIPconsDelete(dualproof, blkmem, set, stat, transprob, reopt) );
428 }
430 SCIP_CALL( SCIPconsRelease(&dualproof, blkmem, set) );
431
432 /* replace with dual ray at the last position */
433 if( pos < lastpos )
434 {
435 conflictstore->dualrayconfs[pos] = conflictstore->dualrayconfs[lastpos];
436 conflictstore->drayrelaxonly[pos] = conflictstore->drayrelaxonly[lastpos];
437 }
438
439 /* decrease number of dual rays */
440 --conflictstore->ndualrayconfs;
441
442 return SCIP_OKAY;
443}
444
445/* removes proof based on a dual solution at position pos */
446static
448 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
449 SCIP_SET* set, /**< global SCIP settings */
450 SCIP_STAT* stat, /**< dynamic SCIP statistics */
451 SCIP_PROB* transprob, /**< transformed problem, or NULL if delete = FALSE */
452 BMS_BLKMEM* blkmem, /**< block memory */
453 SCIP_REOPT* reopt, /**< reoptimization data */
454 int pos, /**< position to remove */
455 SCIP_Bool deleteconflict /**< should the dual ray be deleted? */
456 )
457{
458 SCIP_CONS* dualproof;
459 SCIP_Bool success;
460 int lastpos;
461 int nvars;
462
463 assert(conflictstore != NULL);
464 assert(pos >= 0 && pos < conflictstore->ndualsolconfs);
465
466 lastpos = conflictstore->ndualsolconfs-1;
467 dualproof = conflictstore->dualsolconfs[pos];
468 assert(dualproof != NULL);
469
470 /* decrease the number of non-zeros */
471 SCIP_CALL( SCIPconsGetNVars(dualproof, set, &nvars, &success) );
472 assert(success);
473 conflictstore->nnzdualsols -= nvars;
474
475#ifdef SCIP_PRINT_DETAILS
476 SCIPsetDebugMsg(set, "-> remove dual proof (sol) at pos=%d age=%g nvars=%d\n", pos, SCIPconsGetAge(dualproof), nvars);
477#endif
478
479 /**@todo implement dualsolcons upgrade */
480 SCIPconsAddUpgradeLocks(dualproof, -1);
481
482 /* remove conflict locks */
484
485 /* mark the constraint as deleted */
486 if( deleteconflict && !SCIPconsIsDeleted(dualproof) )
487 {
488 assert(transprob != NULL);
489 SCIP_CALL( SCIPconsDelete(dualproof, blkmem, set, stat, transprob, reopt) );
491 }
492 SCIP_CALL( SCIPconsRelease(&dualproof, blkmem, set) );
493
494 /* replace with dual ray at the last position */
495 if( pos < lastpos )
496 {
497 conflictstore->dualsolconfs[pos] = conflictstore->dualsolconfs[lastpos];
498 conflictstore->dualprimalbnds[pos] = conflictstore->dualprimalbnds[lastpos];
499 conflictstore->scalefactors[pos] = conflictstore->scalefactors[lastpos];
500 conflictstore->updateside[pos] = conflictstore->updateside[lastpos];
501 conflictstore->dsolrelaxonly[pos] = conflictstore->dsolrelaxonly[lastpos];
502 }
503
504 /* decrease number of dual rays */
505 --conflictstore->ndualsolconfs;
506
507 return SCIP_OKAY;
508}
509
510/** removes all deleted conflicts from the storage */
511static
513 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
514 SCIP_SET* set, /**< global SCIP settings */
515 SCIP_STAT* stat, /**< dynamic SCIP statistics */
516 BMS_BLKMEM* blkmem, /**< block memory */
517 SCIP_REOPT* reopt, /**< reoptimization data */
518 int* ndelconfs /**< pointer to store the number of deleted conflicts */
519 )
520{
521 int i;
522
523 assert(conflictstore != NULL);
524
525 (*ndelconfs) = 0;
526
527 /* we traverse backwards to avoid swapping of pointers */
528 for( i = conflictstore->nconflicts-1; i >= 0; i-- )
529 {
530 assert(conflictstore->conflicts[i] != NULL);
531
532 /* check whether the constraint is already marked as deleted */
533 if( SCIPconsIsDeleted(conflictstore->conflicts[i]) || SCIPconsIsChecked(conflictstore->conflicts[i]) )
534 {
535 /* remove conflict at current position */
536 SCIP_CALL( delPosConflict(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
537
538 ++(*ndelconfs);
539 }
540 }
541 SCIPsetDebugMsg(set, "> removed %d/%d as deleted marked conflicts.\n", *ndelconfs, conflictstore->nconflicts + (*ndelconfs));
542
543 return SCIP_OKAY;
544}
545
546/** removes all deleted dual proofs of infeasible LP relaxations from the storage */
547static
549 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
550 SCIP_SET* set, /**< global SCIP settings */
551 SCIP_STAT* stat, /**< dynamic SCIP statistics */
552 BMS_BLKMEM* blkmem, /**< block memory */
553 SCIP_REOPT* reopt, /**< reoptimization data */
554 int* ndelproofs /**< pointer to store the number of deleted conflicts */
555 )
556{
557 int i;
558
559 assert(conflictstore != NULL);
560
561 (*ndelproofs) = 0;
562
563 /* we traverse backwards to avoid swapping of pointers */
564 for( i = conflictstore->ndualrayconfs-1; i >= 0; i-- )
565 {
566 assert(conflictstore->dualrayconfs[i] != NULL);
567
568 /* check whether the constraint is already marked as deleted */
569 if( SCIPconsIsDeleted(conflictstore->dualrayconfs[i]) || SCIPconsIsChecked(conflictstore->dualrayconfs[i]) )
570 {
571 /* remove proof at current position */
572 SCIP_CALL( delPosDualray(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
573
574 ++(*ndelproofs);
575 }
576 }
577
578 SCIPsetDebugMsg(set, "> removed %d/%d as deleted marked dual infeasibility proofs.\n",
579 *ndelproofs, conflictstore->ndualrayconfs + (*ndelproofs));
580
581 return SCIP_OKAY;
582}
583
584/** removes all deleted dual proofs of bound exceeding LP relaxations from the storage */
585static
587 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
588 SCIP_SET* set, /**< global SCIP settings */
589 SCIP_STAT* stat, /**< dynamic SCIP statistics */
590 BMS_BLKMEM* blkmem, /**< block memory */
591 SCIP_REOPT* reopt, /**< reoptimization data */
592 int* ndelproofs /**< pointer to store the number of deleted conflicts */
593 )
594{
595 int i;
596
597 assert(conflictstore != NULL);
598
599 (*ndelproofs) = 0;
600
601 /* we traverse backwards to avoid swapping of pointers */
602 for( i = conflictstore->ndualsolconfs-1; i >= 0; i-- )
603 {
604 assert(conflictstore->dualsolconfs[i] != NULL);
605
606 /* check whether the constraint is already marked as deleted */
607 if( SCIPconsIsDeleted(conflictstore->dualsolconfs[i]) || SCIPconsIsChecked(conflictstore->dualsolconfs[i]) )
608 {
609 /* remove proof at current position */
610 SCIP_CALL( delPosDualsol(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
611
612 ++(*ndelproofs);
613 }
614 }
615
616 SCIPsetDebugMsg(set, "> removed %d/%d as deleted marked dual boundexceeding proofs.\n",
617 *ndelproofs, conflictstore->ndualrayconfs + (*ndelproofs));
618
619 return SCIP_OKAY;
620}
621
622/** cleans up the storage */
623static
625 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
626 SCIP_SET* set, /**< global SCIP settings */
627 SCIP_STAT* stat, /**< dynamic SCIP statistics */
628 SCIP_PROB* transprob, /**< transformed problem */
629 BMS_BLKMEM* blkmem, /**< block memory */
630 SCIP_REOPT* reopt /**< reoptimization data */
631 )
632{
633 int ndelconfs;
634 int i;
635
636 assert(conflictstore != NULL);
637 assert(blkmem != NULL);
638 assert(set != NULL);
639 assert(stat != NULL);
640 assert(transprob != NULL);
641
642 /* the storage is empty */
643 if( conflictstore->nconflicts == 0 )
644 return SCIP_OKAY;
645 assert(conflictstore->nconflicts >= 1);
646 assert(conflictstore->conflicts != NULL);
647
648 ndelconfs = 0;
649
650 /* remove all as deleted marked conflicts */
651 SCIP_CALL( cleanDeletedAndCheckedConflicts(conflictstore, set, stat, blkmem, reopt, &ndelconfs) );
652
653 /* return if at least one conflict could be deleted */
654 if( ndelconfs > 0 )
655 goto TERMINATE;
656
657 /* only clean up the storage if it is filled enough */
658 if( conflictstore->nconflicts < conflictstore->conflictsize )
659 goto TERMINATE;
660
661 /* resort the array regularly */
662 if( conflictstore->ncleanups % CONFLICTSTORE_SORTFREQ == 0 )
663 {
664#ifndef NDEBUG
665 /* check conflict positions */
666 for( i = 0; i < conflictstore->nconflicts; ++i )
667 {
668 assert(conflictstore->conflicts[i] != NULL);
669 assert(conflictstore->conflicts[i]->confconsspos == i);
670 }
671#endif
672
673 /* sort conflict constraints */
674 SCIPsortPtrReal((void**)conflictstore->conflicts, conflictstore->confprimalbnds, compareConss, conflictstore->nconflicts);
675 assert(SCIPsetIsGE(set, SCIPconsGetAge(conflictstore->conflicts[0]),
676 SCIPconsGetAge(conflictstore->conflicts[conflictstore->nconflicts-1])));
677
678 /* update conflict positions */
679 for( i = 0; i < conflictstore->nconflicts; ++i )
680 conflictstore->conflicts[i]->confconsspos = i;
681 }
682 assert(conflictstore->nconflicts > 0);
683
684 if( conflictstore->ncleanups % CONFLICTSTORE_SORTFREQ == 0 )
685 {
686 /* remove conflict at first position (array is sorted) */
687 SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, 0, TRUE) );
688 }
689 else
690 {
691 SCIP_Real maxage;
692 int oldest_i;
693
694 assert(!SCIPconsIsDeleted(conflictstore->conflicts[0]));
695
696 maxage = SCIPconsGetAge(conflictstore->conflicts[0]);
697 oldest_i = 0;
698
699 /* check the first 10% of conflicts and find the oldest */
700 for( i = 1; i < 0.1 * conflictstore->nconflicts; ++i )
701 {
702 assert(!SCIPconsIsDeleted(conflictstore->conflicts[i]));
703
704 if( SCIPconsGetAge(conflictstore->conflicts[i]) > maxage )
705 {
706 maxage = SCIPconsGetAge(conflictstore->conflicts[i]);
707 oldest_i = i;
708 }
709 }
710
711 /* remove conflict at position oldest_i */
712 SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, oldest_i, TRUE) );
713 }
714 ++ndelconfs;
715
716 /* adjust size of the storage if we use a dynamic store */
717 if( set->conf_maxstoresize == -1 )
718 adjustStorageSize(conflictstore, set);
719 assert(conflictstore->initstoresize <= conflictstore->storesize);
720 assert(conflictstore->storesize <= conflictstore->maxstoresize);
721
722 TERMINATE:
723
724 /* increase the number of clean ups */
725 ++conflictstore->ncleanups;
726
727 SCIPsetDebugMsg(set, "clean-up #%lld: removed %d/%d conflicts, %d depending on cutoff bound\n",
728 conflictstore->ncleanups, ndelconfs, conflictstore->nconflicts+ndelconfs, conflictstore->ncbconflicts);
729
730 return SCIP_OKAY; /*lint !e438*/
731}
732
733/** adds an original conflict constraint to the store
734 *
735 * @note the constraint will be only transfered to the storage of the transformed problem after calling
736 * SCIPconflictstoreTransform()
737 */
738static
740 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
741 SCIP_SET* set, /**< global SCIP settings */
742 BMS_BLKMEM* blkmem, /**< block memory */
743 SCIP_CONS* cons /**< conflict constraint */
744 )
745{
746 assert(conflictstore != NULL);
747 assert(cons != NULL);
748
749 if( conflictstore->origconfs == NULL )
750 {
753 }
754 else if( conflictstore->norigconfs == conflictstore->origconflictsize )
755 {
756 int newsize = SCIPsetCalcMemGrowSize(set, conflictstore->origconflictsize+1);
757 SCIP_ALLOC( BMSreallocBlockMemoryArray(blkmem, &conflictstore->origconfs, conflictstore->origconflictsize, newsize) );
758 conflictstore->origconflictsize = newsize;
759 }
760
761 SCIPconsCapture(cons);
762 conflictstore->origconfs[conflictstore->norigconfs] = cons;
763 ++conflictstore->norigconfs;
764
765 return SCIP_OKAY;
766}
767
768
769/** creates conflict store */
771 SCIP_CONFLICTSTORE** conflictstore, /**< pointer to store conflict store */
772 SCIP_SET* set /**< global SCIP settings */
773 )
774{
775 assert(conflictstore != NULL);
776
777 SCIP_ALLOC( BMSallocMemory(conflictstore) );
778
779 (*conflictstore)->conflicts = NULL;
780 (*conflictstore)->confprimalbnds = NULL;
781 (*conflictstore)->dualprimalbnds = NULL;
782 (*conflictstore)->scalefactors = NULL;
783 (*conflictstore)->updateside = NULL;
784 (*conflictstore)->drayrelaxonly = NULL;
785 (*conflictstore)->dsolrelaxonly = NULL;
786 (*conflictstore)->dualrayconfs = NULL;
787 (*conflictstore)->dualsolconfs = NULL;
788 (*conflictstore)->origconfs = NULL;
789 (*conflictstore)->nnzdualrays = 0;
790 (*conflictstore)->nnzdualsols = 0;
791 (*conflictstore)->conflictsize = 0;
792 (*conflictstore)->origconflictsize = 0;
793 (*conflictstore)->nconflicts = 0;
794 (*conflictstore)->ndualrayconfs = 0;
795 (*conflictstore)->ndualsolconfs = 0;
796 (*conflictstore)->norigconfs = 0;
797 (*conflictstore)->ncbconflicts = 0;
798 (*conflictstore)->nconflictsfound = 0;
799 (*conflictstore)->initstoresize = -1;
800 (*conflictstore)->storesize = -1;
801 (*conflictstore)->maxstoresize = -1;
802 (*conflictstore)->ncleanups = 0;
803 (*conflictstore)->lastcutoffbound = SCIP_INVALID;
804 (*conflictstore)->lastnodenum = -1;
805 (*conflictstore)->eventhdlr = SCIPsetFindEventhdlr(set, EVENTHDLR_NAME);
806
807 /* create event handler for LP events */
808 if( (*conflictstore)->eventhdlr == NULL )
809 {
810 SCIP_CALL( SCIPeventhdlrCreate(&(*conflictstore)->eventhdlr, set, EVENTHDLR_NAME, EVENTHDLR_DESC, NULL, NULL,
811 NULL, NULL, eventInitsolConflictstore, eventExitsolConflictstore, NULL, eventExecConflictstore, NULL) );
812 SCIP_CALL( SCIPsetIncludeEventhdlr(set, (*conflictstore)->eventhdlr) );
813 }
814 assert((*conflictstore)->eventhdlr != NULL);
815
816 return SCIP_OKAY;
817}
818
819/** frees conflict store */
821 SCIP_CONFLICTSTORE** conflictstore, /**< pointer to store conflict store */
822 BMS_BLKMEM* blkmem, /**< block memory */
823 SCIP_SET* set, /**< global SCIP settings */
824 SCIP_STAT* stat, /**< dynamic SCIP statistics */
825 SCIP_REOPT* reopt /**< reoptimization data */
826 )
827{
828 assert(conflictstore != NULL);
829 assert(*conflictstore != NULL);
830
831 /* clear the storage */
832 SCIP_CALL( SCIPconflictstoreClear(*conflictstore, blkmem, set, stat, reopt) );
833
834 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->origconfs, (*conflictstore)->origconflictsize);
835 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->conflicts, (*conflictstore)->conflictsize);
836 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->confprimalbnds, (*conflictstore)->conflictsize);
837 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->dualrayconfs, CONFLICTSTORE_DUALRAYSIZE);
838 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->drayrelaxonly, CONFLICTSTORE_DUALRAYSIZE);
839 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->dualsolconfs, CONFLICTSTORE_DUALSOLSIZE);
840 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->dualprimalbnds, CONFLICTSTORE_DUALSOLSIZE);
841 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->scalefactors, CONFLICTSTORE_DUALSOLSIZE);
842 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->updateside, CONFLICTSTORE_DUALSOLSIZE);
843 BMSfreeBlockMemoryArrayNull(blkmem, &(*conflictstore)->dsolrelaxonly, CONFLICTSTORE_DUALSOLSIZE);
844 BMSfreeMemoryNull(conflictstore);
845
846 return SCIP_OKAY;
847}
848
849/** clears conflict store */
851 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
852 BMS_BLKMEM* blkmem, /**< block memory */
853 SCIP_SET* set, /**< global SCIP settings */
854 SCIP_STAT* stat, /**< dynamic SCIP statistics */
855 SCIP_REOPT* reopt /**< reoptimization data */
856 )
857{
858 int i;
859
860 assert(conflictstore != NULL);
861
862 SCIPsetDebugMsg(set, "clearing conflict store: %d origconfs, %d conflicts, %d dual proofs\n",
863 conflictstore->norigconfs, conflictstore->nconflicts, conflictstore->ndualrayconfs + conflictstore->ndualsolconfs);
864
865 /* remove original constraints (if present) */
866 if( conflictstore->origconfs != NULL )
867 {
868 for( i = 0; i < conflictstore->norigconfs; i++ )
869 {
870 SCIP_CONS* conflict = conflictstore->origconfs[i];
871 SCIP_CALL( SCIPconsRelease(&conflict, blkmem, set) );
872 }
873 conflictstore->norigconfs = 0;
874 }
875
876 /* clean up storage of conflict constraints */
877 if( conflictstore->conflicts != NULL )
878 {
879 /* we traverse in reverse order to avoid swapping of pointers */
880 for( i = conflictstore->nconflicts-1; i >= 0; i--)
881 {
882 SCIP_CALL( delPosConflict(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
883 }
884 assert(conflictstore->nconflicts == 0);
885 }
886
887 /* clean up storage of proof constraints based on dual rays */
888 if( conflictstore->dualrayconfs != NULL )
889 {
890 /* we traverse in reverse order to avoid swapping of pointers */
891 for( i = conflictstore->ndualrayconfs-1; i >= 0; i-- )
892 {
893 SCIP_CALL( delPosDualray(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
894 }
895 assert(conflictstore->ndualrayconfs == 0);
896 }
897
898 /* clean up storage of proof constraints based on dual solutions */
899 if( conflictstore->dualsolconfs != NULL )
900 {
901 /* we traverse in reverse order to avoid swapping of pointers */
902 for( i = conflictstore->ndualsolconfs-1; i >= 0; i-- )
903 {
904 SCIP_CALL( delPosDualsol(conflictstore, set, stat, NULL, blkmem, reopt, i, FALSE) );
905 }
906 assert(conflictstore->ndualsolconfs == 0);
907 }
908
909 return SCIP_OKAY;
910}
911
912/** cleans up conflict store */
914 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
915 BMS_BLKMEM* blkmem, /**< block memory */
916 SCIP_SET* set, /**< global SCIP settings */
917 SCIP_STAT* stat, /**< dynamic SCIP statistics */
918 SCIP_PROB* transprob, /**< transformed problem */
919 SCIP_REOPT* reopt /**< reoptimization data */
920 )
921{
922 int ndelconfs;
923 int ndeldualray;
924 int ndeldualsol;
925
926 assert(conflictstore != NULL);
927
928 SCIPsetDebugMsg(set, "cleaning conflict store: %d conflicts, %d dual proofs\n",
929 conflictstore->nconflicts, conflictstore->ndualrayconfs + conflictstore->ndualsolconfs);
930
931 ndelconfs = 0;
932 ndeldualray = 0;
933 ndeldualsol = 0;
934
935 /* remove all conflicts that are marked as deleted or where the check flag has changed to TRUE.
936 *
937 * the latter case might happen during processing parallel constraints, e.g., cons_knapsack.c:detectRedundantConstraints().
938 * in that case, the conflict constraint should stay, e.g., it has the stricter capacity, and replaces a model
939 * constraint. hence, the conflict is now a constraint that is needed to stay correct. therefore, the conflictpool
940 * is not allowed to delete this constraint from the entire problem.
941 */
942 SCIP_CALL( cleanDeletedAndCheckedConflicts(conflictstore, set, stat, blkmem, reopt, &ndelconfs) );
943
944 /* remove all dual infeasibility proofs that are marked as deleted or where the check flag has changed to TRUE. */
945 SCIP_CALL( cleanDeletedAndCheckedDualrayCons(conflictstore, set, stat, blkmem, reopt, &ndeldualray) );
946
947 /* remove all dual bound exceeding proofs that are marked as deleted or where the check flag has changed to TRUE. */
948 SCIP_CALL( cleanDeletedAndCheckedDualsolCons(conflictstore, set, stat, blkmem, reopt, &ndeldualsol) );
949
950 /* don't update bound exceeding proofs after a restart
951 *
952 * TODO: check whether we want to delete bound exceeding proofs in general during a restart
953 */
954 if( SCIPisInRestart(set->scip) )
955 {
956 int i;
957
958 for( i = conflictstore->ndualrayconfs-1; i >= 0 ; i-- )
959 {
960 if( conflictstore->drayrelaxonly[i] )
961 {
962 SCIP_CALL( delPosDualray(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
963 }
964 }
965
966 for( i = conflictstore->ndualsolconfs-1; i >= 0 ; i-- )
967 {
968 if( conflictstore->dsolrelaxonly[i] )
969 {
970 SCIP_CALL( delPosDualsol(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
971 }
972 else
973 {
974 conflictstore->updateside[i] = FALSE;
975 }
976 }
977 }
978
979 return SCIP_OKAY;
980}
981
982/** adds a constraint to the pool of proof constraints based on dual rays
983 *
984 * @note this methods captures the constraint
985 */
987 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
988 SCIP_CONS* dualproof, /**< constraint based on a dual ray */
989 BMS_BLKMEM* blkmem, /**< block memory */
990 SCIP_SET* set, /**< global SCIP settings */
991 SCIP_STAT* stat, /**< dynamic SCIP statistics */
992 SCIP_PROB* transprob, /**< transformed problem */
993 SCIP_REOPT* reopt, /**< reoptimization data */
994 SCIP_Bool hasrelaxvar /**< does the dual proof contain at least one variable that exists in
995 * the current relaxation only? */
996 )
997{
998 int nvars;
999 SCIP_Bool success;
1000
1001 assert(conflictstore != NULL);
1002 assert(conflictstore->ndualrayconfs <= CONFLICTSTORE_DUALRAYSIZE);
1003
1004 /* mark the constraint to be a conflict */
1005 SCIP_CALL( SCIPconsMarkConflict(dualproof) );
1006
1007 /* create an array to store constraints based on dual rays */
1008 if( conflictstore->dualrayconfs == NULL )
1009 {
1012 }
1013
1014 /* the store is full, we proceed as follows
1015 *
1016 * 1. check whether some constraints are marked as deleted and remove those
1017 * 2. if no constraint is marked as deleted: remove the oldest
1018 */
1019 if( conflictstore->ndualrayconfs == CONFLICTSTORE_DUALRAYSIZE )
1020 {
1021 int ndeleted = 0;
1022
1023 /* remove all as deleted marked dual infeasibility proofs */
1024 SCIP_CALL( cleanDeletedAndCheckedDualrayCons(conflictstore, set, stat, blkmem, reopt, &ndeleted) );
1025
1026 /* if we could not remove a dual ray that is already marked as deleted we need to remove the oldest active one */
1027 if( ndeleted == 0 )
1028 {
1029 SCIP_Bool local = SCIPconsIsLocal(dualproof);
1030 int pos = 0;
1031
1032 /* sort dual rays */
1033 SCIPsortPtrBool((void**)conflictstore->dualrayconfs, conflictstore->drayrelaxonly, compareConss,
1034 conflictstore->ndualrayconfs);
1035 assert(SCIPsetIsGE(set, SCIPconsGetAge(conflictstore->dualrayconfs[0]),
1036 SCIPconsGetAge(conflictstore->dualrayconfs[conflictstore->ndualrayconfs-1])));
1037
1038 while( pos < conflictstore->ndualrayconfs-1 && local != SCIPconsIsLocal(conflictstore->dualrayconfs[pos]) )
1039 pos++;
1040
1041 /* we don't want to keep the dual proof */
1042 if( pos >= conflictstore->ndualrayconfs )
1043 {
1044 SCIP_CALL( SCIPconsDelete(dualproof, blkmem, set, stat, transprob, reopt) );
1046 return SCIP_OKAY;
1047 }
1048
1049 SCIP_CALL( delPosDualray(conflictstore, set, stat, transprob, blkmem, reopt, pos, TRUE) );
1050 }
1051 }
1052
1053 /* add the new constraint based on a dual ray at the last position */
1054 SCIPconsCapture(dualproof);
1055 conflictstore->dualrayconfs[conflictstore->ndualrayconfs] = dualproof;
1056 conflictstore->drayrelaxonly[conflictstore->ndualrayconfs] = hasrelaxvar;
1057 ++conflictstore->ndualrayconfs;
1058
1059 /* add conflict locks */
1061
1062 /**@todo implement dualraycons upgrade */
1063 SCIPconsAddUpgradeLocks(dualproof, +1);
1064
1065 /* increase the number of non-zeros */
1066 SCIP_CALL( SCIPconsGetNVars(dualproof, set, &nvars, &success) );
1067 assert(success);
1068 conflictstore->nnzdualrays += nvars;
1069
1070 return SCIP_OKAY;
1071}
1072
1073/** adds a constraint to the pool of proof constraints based on dual solutions
1074 *
1075 * @note this methods captures the constraint
1076 */
1078 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1079 SCIP_CONS* dualproof, /**< constraint based on a dual solution */
1080 BMS_BLKMEM* blkmem, /**< block memory */
1081 SCIP_SET* set, /**< global SCIP settings */
1082 SCIP_STAT* stat, /**< dynamic SCIP statistics */
1083 SCIP_PROB* transprob, /**< transformed problem */
1084 SCIP_REOPT* reopt, /**< reoptimization data */
1085 SCIP_Real scale, /**< scaling factor that needs to be considered when updating the side */
1086 SCIP_Bool updateside, /**< should the side be updated if a new incumbent is found */
1087 SCIP_Bool hasrelaxvar /**< does the dual proof contain at least one variable that exists in
1088 * the current relaxation only? */
1089 )
1090{
1091 int nvars;
1092 SCIP_Bool success;
1093
1094 assert(conflictstore != NULL);
1095 assert(conflictstore->ndualsolconfs <= CONFLICTSTORE_DUALSOLSIZE);
1096
1097 /* mark the constraint to be a conflict */
1098 SCIP_CALL( SCIPconsMarkConflict(dualproof) );
1099
1100 /* create an array to store constraints based on dual rays */
1101 if( conflictstore->dualsolconfs == NULL )
1102 {
1108 }
1109
1110 /* the store is full, we proceed as follows
1111 *
1112 * 1. check whether some constraints are marked as deleted and remove those
1113 * 2. if no constraint is marked as deleted: remove the oldest
1114 */
1115 if( conflictstore->ndualsolconfs == CONFLICTSTORE_DUALSOLSIZE )
1116 {
1117 int ndeleted = 0;
1118
1119 /* remove all as deleted marked dual bound exceeding proofs */
1120 SCIP_CALL( cleanDeletedAndCheckedDualsolCons(conflictstore, set, stat, blkmem, reopt, &ndeleted) );
1121
1122 /* if we could not remove a dual proof that is already marked as deleted we need to remove the oldest active one */
1123 if( ndeleted == 0 )
1124 {
1125 SCIP_Bool local = SCIPconsIsLocal(dualproof);
1126 int pos = 0;
1127
1128 /* sort dual rays */
1129 SCIPsortPtrRealRealBoolBool((void**)conflictstore->dualsolconfs, conflictstore->dualprimalbnds,
1130 conflictstore->scalefactors, conflictstore->updateside, conflictstore->dsolrelaxonly,
1131 compareConss, conflictstore->ndualsolconfs);
1132 assert(SCIPsetIsGE(set, SCIPconsGetAge(conflictstore->dualsolconfs[0]),
1133 SCIPconsGetAge(conflictstore->dualsolconfs[conflictstore->ndualsolconfs-1])));
1134
1135 while( pos < conflictstore->ndualsolconfs-1 && local != SCIPconsIsLocal(conflictstore->dualsolconfs[pos]) )
1136 pos++;
1137
1138 /* we don't want to keep the dual proof */
1139 if( pos >= conflictstore->ndualsolconfs )
1140 {
1141 SCIP_CALL( SCIPconsDelete(dualproof, blkmem, set, stat, transprob, reopt) );
1143 return SCIP_OKAY;
1144 }
1145
1146 SCIP_CALL( delPosDualsol(conflictstore, set, stat, transprob, blkmem, reopt, pos, TRUE) );
1147 }
1148 }
1149
1150 /* add the new constraint based on a dual solution at the last position */
1151 SCIPconsCapture(dualproof);
1152 conflictstore->dualsolconfs[conflictstore->ndualsolconfs] = dualproof;
1153 conflictstore->dualprimalbnds[conflictstore->ndualsolconfs] = SCIPgetCutoffbound(set->scip) - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0);
1154 conflictstore->scalefactors[conflictstore->ndualsolconfs] = scale;
1155 conflictstore->updateside[conflictstore->ndualsolconfs] = updateside;
1156 conflictstore->dsolrelaxonly[conflictstore->ndualsolconfs] = hasrelaxvar;
1157 ++conflictstore->ndualsolconfs;
1158
1159 /* add conflict locks */
1161
1162 /**@todo implement dualsolcons upgrade */
1163 SCIPconsAddUpgradeLocks(dualproof, +1);
1164
1165 /* increase the number of non-zeros */
1166 SCIP_CALL( SCIPconsGetNVars(dualproof, set, &nvars, &success) );
1167 assert(success);
1168 conflictstore->nnzdualsols += nvars;
1169
1170 return SCIP_OKAY;
1171}
1172
1173/** adds a conflict to the conflict store
1174 *
1175 * @note this method captures the constraint
1176 */
1178 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1179 BMS_BLKMEM* blkmem, /**< block memory */
1180 SCIP_SET* set, /**< global SCIP settings */
1181 SCIP_STAT* stat, /**< dynamic SCIP statistics */
1182 SCIP_TREE* tree, /**< branch and bound tree (or NULL for an original constraint) */
1183 SCIP_PROB* transprob, /**< transformed problem (or NULL for an original constraint) */
1184 SCIP_REOPT* reopt, /**< reoptimization data */
1185 SCIP_CONS* cons, /**< constraint representing the conflict */
1186 SCIP_CONFTYPE conftype, /**< type of the conflict */
1187 SCIP_Bool cutoffinvolved, /**< is a cutoff bound involved in this conflict */
1188 SCIP_Real primalbound /**< primal bound the conflict depend on (or -SCIPinfinity) */
1189 )
1190{
1191 SCIP_Longint curnodenum;
1192 int nconflicts;
1193
1194 assert(conflictstore != NULL);
1195 assert(blkmem != NULL);
1196 assert(set != NULL);
1197 assert(stat != NULL);
1198 assert(tree != NULL || SCIPconsIsOriginal(cons));
1199 assert(transprob != NULL || SCIPconsIsOriginal(cons));
1200 assert(cons != NULL);
1201 assert(conftype != SCIP_CONFTYPE_BNDEXCEEDING || cutoffinvolved);
1202 assert(!cutoffinvolved || !SCIPsetIsInfinity(set, REALABS(primalbound)));
1203
1204 /* mark the constraint to be a conflict */
1206
1207 /* add the constraint to a special store */
1208 if( SCIPconsIsOriginal(cons) )
1209 {
1211 SCIP_CALL( conflictstoreAddOrigConflict(conflictstore, set, blkmem, cons) );
1212 return SCIP_OKAY;
1213 }
1214
1215 nconflicts = conflictstore->nconflicts;
1216
1217 /* initialize the storage */
1218 if( conflictstore->maxstoresize == -1 )
1219 {
1220 SCIP_CALL( initConflictstore(conflictstore, set, transprob) );
1221 }
1222 assert(conflictstore->initstoresize >= 0);
1223 assert(conflictstore->initstoresize <= conflictstore->maxstoresize);
1224
1225 /* return if conflict pool is disabled */
1226 if( conflictstore->maxstoresize <= 0 )
1227 return SCIP_OKAY;
1228
1229 SCIP_CALL( conflictstoreEnsureMem(conflictstore, set, blkmem, nconflicts+1) );
1230
1231 /* return if the store has size zero */
1232 if( conflictstore->conflictsize == 0 )
1233 {
1234 assert(conflictstore->maxstoresize == 0);
1235 return SCIP_OKAY;
1236 }
1237
1238 assert(tree != NULL);
1239 curnodenum = (SCIPtreeGetFocusNode(tree) == NULL ? -1 : SCIPnodeGetNumber(SCIPtreeGetFocusNode(tree)));
1240
1241 /* clean up the storage if we are at a new node or the storage is full */
1242 if( conflictstore->lastnodenum != curnodenum || conflictstore->nconflicts == conflictstore->conflictsize )
1243 {
1244 SCIP_CALL( conflictstoreCleanUpStorage(conflictstore, set, stat, transprob, blkmem, reopt) );
1245 }
1246
1247 /* update the last seen node */
1248 conflictstore->lastnodenum = curnodenum;
1249
1250 /* validate conflict position */
1251 assert(cons->confconsspos == -1);
1252 cons->confconsspos = conflictstore->nconflicts;
1253
1254 SCIPconsCapture(cons);
1255 conflictstore->conflicts[conflictstore->nconflicts] = cons;
1256 conflictstore->confprimalbnds[conflictstore->nconflicts] = primalbound;
1257 conflictstore->ncbconflicts += (SCIPsetIsInfinity(set, REALABS(primalbound)) ? 0 : 1);
1258
1259 ++conflictstore->nconflicts;
1260 ++conflictstore->nconflictsfound;
1261
1262 /* add conflict locks */
1264
1265#ifdef SCIP_PRINT_DETAILS
1266 SCIPsetDebugMsg(set, "add conflict <%s> to conflict store at position %d\n", SCIPconsGetName(cons), conflictstore->nconflicts-1);
1267 SCIPsetDebugMsg(set, " -> conflict type: %d, cutoff involved = %u\n", conftype, cutoffinvolved);
1268 if( cutoffinvolved )
1269 SCIPsetDebugMsg(set, " -> current primal bound: %g\n", primalbound);
1270#endif
1271
1272 return SCIP_OKAY;
1273}
1274
1275/** upgrades an unchecked conflict in the conflict store
1276 *
1277 * @note this method releases oldcons and captures newcons
1278 */
1280 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1281 BMS_BLKMEM* blkmem, /**< block memory */
1282 SCIP_SET* set, /**< global SCIP settings */
1283 SCIP_CONS* oldcons, /**< underlying constraint to upgrade */
1284 SCIP_CONS* newcons /**< upgraded constraint to add */
1285 )
1286{
1287 assert(conflictstore != NULL);
1288 assert(blkmem != NULL);
1289 assert(set != NULL);
1290 assert(SCIPconsIsConflict(oldcons));
1291 assert(!SCIPconsIsDeleted(oldcons));
1292 assert(oldcons->confconsspos >= -1);
1293 assert(!SCIPconsIsDeleted(newcons));
1294 assert(newcons->confconsspos == -1);
1295
1296 /* multiple upgrades unsupported */
1297 if( oldcons->confconsspos == -1 || SCIPconsIsChecked(oldcons) )
1298 {
1299 assert(SCIPconsIsChecked(oldcons));
1300 assert(SCIPconsIsChecked(newcons));
1301 return SCIP_OKAY;
1302 }
1303
1304 assert(conflictstore->conflicts != NULL);
1305 assert(!SCIPconsIsChecked(oldcons));
1306 assert(!SCIPconsIsChecked(newcons));
1307 assert(oldcons->confconsspos >= 0);
1308 assert(oldcons->confconsspos < conflictstore->nconflicts);
1309 assert(conflictstore->conflicts[oldcons->confconsspos] == oldcons);
1310
1311 /* mark constraint conflict */
1312 SCIP_CALL( SCIPconsMarkConflict(newcons) );
1313
1314 /* replace conflict constraint */
1315 conflictstore->conflicts[oldcons->confconsspos] = newcons;
1316 newcons->confconsspos = oldcons->confconsspos;
1317 oldcons->confconsspos = -1;
1318
1319 /* transfer conflict locks */
1322
1323 /* update conflict usage */
1324 SCIPconsCapture(newcons);
1325 SCIP_CALL( SCIPconsRelease(&oldcons, blkmem, set) );
1326
1327 return SCIP_OKAY;
1328}
1329
1330/** deletes all conflicts depending on a cutoff bound larger than the given bound */
1332 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1333 SCIP_SET* set, /**< global SCIP settings */
1334 SCIP_STAT* stat, /**< dynamic SCIP statistics */
1335 BMS_BLKMEM* blkmem, /**< block memory */
1336 SCIP_PROB* transprob, /**< transformed problem*/
1337 SCIP_REOPT* reopt, /**< reoptimization data */
1338 SCIP_Real cutoffbound /**< current cutoff bound */
1339 )
1340{
1341 SCIP_Real improvement;
1342 int ndelconfs;
1343 int nchgsides;
1344 int i;
1345
1346 assert(conflictstore != NULL);
1347 assert(set != NULL);
1348 assert(stat != NULL);
1349 assert(blkmem != NULL);
1350 assert(transprob != NULL);
1351
1352 /* return if we do not want to use the storage */
1353 if( set->conf_maxstoresize == 0 )
1354 return SCIP_OKAY;
1355
1356 /* return if we do not want to remove conflicts related to an older cutoff bound */
1357 if( !set->conf_cleanbnddepend )
1358 return SCIP_OKAY;
1359
1360 /* there is nothing to clean */
1361 if( conflictstore->ndualsolconfs == 0 && conflictstore->nconflicts == 0 )
1362 return SCIP_OKAY;
1363
1364 /* we can stop whenever we have found a new incumbent but the cutoff bound has not changed */
1365 if( conflictstore->lastcutoffbound != SCIP_INVALID && SCIPsetIsGE(set, cutoffbound, conflictstore->lastcutoffbound) ) /*lint !e777*/
1366 return SCIP_OKAY;
1367
1368 conflictstore->lastcutoffbound = cutoffbound;
1369
1370 /* calculate scalar to determine whether the old primal bound is worse enough to remove the conflict */
1371 if( SCIPsetIsPositive(set, cutoffbound) )
1372 improvement = (1 - set->conf_minimprove);
1373 else
1374 improvement = (1 + set->conf_minimprove);
1375
1376 /* remove all conflicts depending on a primalbound*improvement > cutoffbound
1377 *
1378 * note: we cannot remove conflicts that are marked as deleted because at this point in time we would destroy
1379 * the internal data structure
1380 */
1381 ndelconfs = 0;
1382 for( i = 0; i < conflictstore->nconflicts; )
1383 {
1384 assert(conflictstore->conflicts[i] != NULL);
1385
1386 /* check if the conflict depends on the cutoff bound */
1387 if( SCIPsetIsGT(set, improvement * conflictstore->confprimalbnds[i], cutoffbound) )
1388 {
1389 /* remove conflict at current position
1390 *
1391 * don't increase i because delPosConflict will swap the last pointer to the i-th position
1392 */
1393 SCIP_CALL( delPosConflict(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
1394 ++ndelconfs;
1395 }
1396 else
1397 /* increase i */
1398 ++i;
1399 }
1400 assert(conflictstore->ncbconflicts >= 0);
1401 assert(conflictstore->nconflicts >= 0);
1402
1403 SCIPsetDebugMsg(set, "-> removed %d/%d conflicts, %d depending on cutoff bound\n", ndelconfs,
1404 conflictstore->nconflicts+ndelconfs, ndelconfs);
1405
1406 ndelconfs = 0;
1407 nchgsides = 0;
1408 /* update all proof constraints based on a dual solution */
1409 for( i = 0; i < conflictstore->ndualsolconfs; )
1410 {
1411 SCIP_CONSHDLR* conshdlr;
1412 SCIP_CONS* dualproof;
1413
1414 dualproof = conflictstore->dualsolconfs[i];
1415 assert(dualproof != NULL);
1416
1417 if( SCIPconsIsDeleted(dualproof) )
1418 {
1419 ++i;
1420 continue;
1421 }
1422 if( !conflictstore->updateside[i] || SCIPsetIsLE(set, improvement * conflictstore->dualprimalbnds[i], cutoffbound) )
1423 {
1424 ++i;
1425 continue;
1426 }
1427 conshdlr = SCIPconsGetHdlr(dualproof);
1428 assert(conshdlr != NULL);
1429
1430 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0 )
1431 {
1432 SCIP_Real rhs;
1433 SCIP_Real newside;
1434
1435 assert(SCIPsetIsGT(set, conflictstore->dualprimalbnds[i], cutoffbound));
1436
1437 rhs = SCIPgetRhsLinear(set->scip, dualproof);
1438
1439 if( !SCIPsetIsInfinity(set, rhs) )
1440 {
1441 assert(SCIPsetIsInfinity(set, -SCIPgetLhsLinear(set->scip, dualproof)));
1442 assert(SCIPsetIsPositive(set, conflictstore->scalefactors[i]));
1443
1444 /* get unscaled rhs */
1445 newside = rhs * conflictstore->scalefactors[i];
1446 newside -= conflictstore->dualprimalbnds[i];
1447 newside += cutoffbound - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0);
1448
1449 /* scale rhs */
1450 newside /= conflictstore->scalefactors[i];
1451
1452 SCIP_CALL( SCIPchgRhsLinear(set->scip, dualproof, newside) );
1453 }
1454 else
1455 {
1456 SCIP_Real lhs;
1457
1458 lhs = SCIPgetLhsLinear(set->scip, dualproof);
1459 assert(!SCIPsetIsInfinity(set, -lhs));
1460 assert(SCIPsetIsNegative(set, conflictstore->scalefactors[i]));
1461
1462 /* get unscaled lhs */
1463 newside = lhs * conflictstore->scalefactors[i];
1464 newside += conflictstore->dualprimalbnds[i];
1465 newside -= (cutoffbound - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0));
1466
1467 /* scale lhs */
1468 newside /= conflictstore->scalefactors[i];
1469
1470 SCIP_CALL( SCIPchgLhsLinear(set->scip, dualproof, newside) );
1471 }
1472
1473 ++nchgsides;
1474
1475 conflictstore->dualprimalbnds[i] = cutoffbound - (SCIPprobIsObjIntegral(transprob) ? SCIPsetCutoffbounddelta(set) : 0.0);
1476
1477 ++i;
1478 }
1479 else if( SCIPsetIsGT(set, improvement * conflictstore->dualprimalbnds[i], cutoffbound) )
1480 {
1481 /* remove conflict at current position
1482 *
1483 * don't increase i because delPosDualsol will swap the last pointer to the i-th position
1484 */
1485 SCIP_CALL( delPosDualsol(conflictstore, set, stat, transprob, blkmem, reopt, i, TRUE) );
1486 ++ndelconfs;
1487 }
1488 else
1489 /* increase i */
1490 ++i;
1491 }
1492
1493 SCIPsetDebugMsg(set, "-> changed %d sides of dual solution constraints\n", nchgsides);
1494 SCIPsetDebugMsg(set, "-> deleted %d dual solution constraints\n", ndelconfs);
1495
1496 return SCIP_OKAY;
1497}
1498
1499/** returns the maximal size of the conflict pool */
1501 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1502 )
1503{
1504 assert(conflictstore != NULL);
1505
1506 return MIN(conflictstore->storesize, conflictstore->maxstoresize);
1507}
1508
1509/** returns the initial size of the conflict pool */
1511 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1512 )
1513{
1514 assert(conflictstore != NULL);
1515
1516 return conflictstore->initstoresize;
1517}
1518
1519/** returns the number of stored conflicts on the conflict pool
1520 *
1521 * @note the number of active conflicts can be less
1522 */
1524 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1525 )
1526{
1527 assert(conflictstore != NULL);
1528
1529 return conflictstore->nconflicts;
1530}
1531
1532/** returns all active conflicts stored in the conflict store */
1534 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1535 SCIP_CONS** conflicts, /**< array to store conflicts */
1536 int conflictsize, /**< size of the conflict array */
1537 int* nconflicts /**< pointer to store the number of conflicts */
1538 )
1539{
1540 int i;
1541
1542 assert(conflictstore != NULL);
1543
1544 /* return if the allocated memory is obviously to small */
1545 if( conflictstore->nconflicts > conflictsize )
1546 {
1547 (*nconflicts) = conflictstore->nconflicts;
1548 return SCIP_OKAY;
1549 }
1550
1551 (*nconflicts) = 0;
1552 for( i = 0; i < conflictstore->nconflicts; i++ )
1553 {
1554 SCIP_CONS* conflict;
1555
1556 conflict = conflictstore->conflicts[i];
1557 assert(conflict != NULL);
1558
1559 /* skip deactivated and deleted constraints */
1560 if( !SCIPconsIsActive(conflict) || SCIPconsIsDeleted(conflict) )
1561 continue;
1562
1563 /* count exact number conflicts */
1564 if( *nconflicts > conflictsize )
1565 ++(*nconflicts);
1566 else
1567 {
1568 conflicts[*nconflicts] = conflict;
1569 ++(*nconflicts);
1570 }
1571 }
1572
1573 return SCIP_OKAY;
1574}
1575
1576/** transformes all original conflicts into transformed conflicts */
1578 SCIP_CONFLICTSTORE* conflictstore, /**< conflict store */
1579 BMS_BLKMEM* blkmem, /**< block memory */
1580 SCIP_SET* set, /**< global SCIP settings */
1581 SCIP_STAT* stat, /**< dynamic SCIP statistics */
1582 SCIP_TREE* tree, /**< branch and bound tree */
1583 SCIP_PROB* transprob, /**< transformed problem */
1584 SCIP_REOPT* reopt /**< reoptimization data */
1585 )
1586{
1587 int ntransconss;
1588 int i;
1589
1590 assert(conflictstore != NULL);
1591 assert(set != NULL);
1593
1594 /* return if no original constraints are stored */
1595 if( conflictstore->norigconfs == 0 )
1596 return SCIP_OKAY;
1597
1598 ntransconss = 0;
1599
1600 for( i = 0; i < conflictstore->norigconfs; i++ )
1601 {
1602 SCIP_CONS* transcons;
1603
1604 assert(conflictstore->origconfs[i] != NULL);
1605 assert(SCIPconsIsOriginal(conflictstore->origconfs[i]));
1606
1607 transcons = SCIPconsGetTransformed(conflictstore->origconfs[i]);
1608
1609 if( transcons != NULL )
1610 {
1611 SCIP_CALL( SCIPconflictstoreAddConflict(conflictstore, blkmem, set, stat, tree, transprob, reopt, transcons, \
1613
1614 ++ntransconss;
1615 }
1616
1617 SCIP_CALL( SCIPconsRelease(&conflictstore->origconfs[i], blkmem, set) );
1618 }
1619
1620 SCIPsetDebugMsg(set, "-> transform %d/%d conflicts into transformed space\n", ntransconss, conflictstore->norigconfs);
1621
1622 conflictstore->norigconfs = 0;
1623
1624 return SCIP_OKAY;
1625}
1626
1627/** returns the average number of non-zeros over all stored dual ray constraints */
1629 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1630 )
1631{
1632 assert(conflictstore != NULL);
1633
1634 if( conflictstore->ndualrayconfs == 0 )
1635 return 0.0;
1636 else
1637 return (SCIP_Real) conflictstore->nnzdualrays / ((SCIP_Real) conflictstore->ndualrayconfs);
1638}
1639
1640/** returns the number of all stored dual ray constraints */
1642 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1643 )
1644{
1645 assert(conflictstore != NULL);
1646
1647 return conflictstore->ndualrayconfs;
1648}
1649
1650/** returns the average number of non-zeros over all stored boundexceeding proofs */
1652 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1653 )
1654{
1655 assert(conflictstore != NULL);
1656 assert(conflictstore->ndualsolconfs >= 0);
1657
1658 if( conflictstore->ndualsolconfs == 0 )
1659 return 0.0;
1660 else
1661 return (SCIP_Real) conflictstore->nnzdualsols / ((SCIP_Real) conflictstore->ndualsolconfs);
1662}
1663
1664/** returns the number of all stored boundexceeding proofs */
1666 SCIP_CONFLICTSTORE* conflictstore /**< conflict store */
1667 )
1668{
1669 assert(conflictstore != NULL);
1670
1671 return conflictstore->ndualsolconfs;
1672}
1673
SCIP_CERTIFICATE * SCIPgetCertificate(SCIP *scip)
methods for certificate output
static SCIP_DECL_EVENTEXITSOL(eventExitsolConflictstore)
#define CONFLICTSTORE_DUALSOLSIZE
Definition: conflictstore.c:54
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_DUALRAYSIZE
Definition: conflictstore.c:53
SCIP_RETCODE SCIPconflictstoreUpgradeConflict(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_CONS *oldcons, SCIP_CONS *newcons)
#define CONFLICTSTORE_MAXSIZE
Definition: conflictstore.c:56
static SCIP_RETCODE conflictstoreCleanUpStorage(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt)
SCIP_RETCODE SCIPconflictstoreAddDualraycons(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS *dualproof, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Bool hasrelaxvar)
static SCIP_RETCODE conflictstoreAddOrigConflict(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, BMS_BLKMEM *blkmem, SCIP_CONS *cons)
static SCIP_RETCODE initConflictstore(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_PROB *transprob)
int SCIPconflictstoreGetNDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_Real SCIPconflictstoreGetAvgNnzDualInfProofs(SCIP_CONFLICTSTORE *conflictstore)
SCIP_RETCODE SCIPconflictstoreCleanNewIncumbent(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Real cutoffbound)
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)
static SCIP_RETCODE cleanDeletedAndCheckedDualsolCons(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int *ndelproofs)
static SCIP_RETCODE cleanDeletedAndCheckedConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int *ndelconfs)
static void adjustStorageSize(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set)
SCIP_RETCODE SCIPconflictstoreClear(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt)
int SCIPconflictstoreGetMaxPoolSize(SCIP_CONFLICTSTORE *conflictstore)
int SCIPconflictstoreGetNDualBndProofs(SCIP_CONFLICTSTORE *conflictstore)
static SCIP_RETCODE cleanDeletedAndCheckedDualrayCons(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int *ndelproofs)
SCIP_RETCODE SCIPconflictstoreFree(SCIP_CONFLICTSTORE **conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_REOPT *reopt)
static SCIP_DECL_EVENTINITSOL(eventInitsolConflictstore)
Definition: conflictstore.c:84
SCIP_RETCODE SCIPconflictstoreGetConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS **conflicts, int conflictsize, int *nconflicts)
#define EVENTHDLR_DESC
Definition: conflictstore.c:62
int SCIPconflictstoreGetNConflictsInStore(SCIP_CONFLICTSTORE *conflictstore)
SCIP_RETCODE SCIPconflictstoreClean(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt)
static SCIP_RETCODE conflictstoreEnsureMem(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, BMS_BLKMEM *blkmem, int num)
SCIP_Real SCIPconflictstoreGetAvgNnzDualBndProofs(SCIP_CONFLICTSTORE *conflictstore)
static SCIP_DECL_SORTPTRCOMP(compareConss)
#define CONFLICTSTORE_SORTFREQ
Definition: conflictstore.c:58
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)
#define CONFLICTSTORE_MINSIZE
Definition: conflictstore.c:55
static SCIP_RETCODE delPosDualsol(SCIP_CONFLICTSTORE *conflictstore, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, BMS_BLKMEM *blkmem, SCIP_REOPT *reopt, int pos, SCIP_Bool deleteconflict)
SCIP_RETCODE SCIPconflictstoreAddDualsolcons(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS *dualproof, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_Real scale, SCIP_Bool updateside, SCIP_Bool hasrelaxvar)
#define EVENTHDLR_NAME
Definition: conflictstore.c:61
static SCIP_RETCODE removeExactConflictFromCertificateHashmap(SCIP_SET *set, SCIP_CONS *cons)
SCIP_RETCODE SCIPconflictstoreCreate(SCIP_CONFLICTSTORE **conflictstore, SCIP_SET *set)
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)
static SCIP_DECL_EVENTEXEC(eventExecConflictstore)
Definition: conflictstore.c:67
#define CONFLICTSTORE_SIZE
Definition: conflictstore.c:57
int SCIPconflictstoreGetInitPoolSize(SCIP_CONFLICTSTORE *conflictstore)
internal methods for storing conflicts
SCIP_RETCODE SCIPconsAddLocks(SCIP_CONS *cons, SCIP_SET *set, SCIP_LOCKTYPE locktype, int nlockspos, int nlocksneg)
Definition: cons.c:7553
void SCIPconsCapture(SCIP_CONS *cons)
Definition: cons.c:6427
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition: cons.c:6554
SCIP_RETCODE SCIPconsDelete(SCIP_CONS *cons, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_REOPT *reopt)
Definition: cons.c:6652
SCIP_RETCODE SCIPconsRelease(SCIP_CONS **cons, BMS_BLKMEM *blkmem, SCIP_SET *set)
Definition: cons.c:6439
SCIP_RETCODE SCIPconsMarkConflict(SCIP_CONS *cons)
Definition: cons.c:7293
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition: cons.c:7021
internal methods for constraints and constraint handlers
Constraint handler for linear constraints in their most general form, .
common defines and data types used in all packages of SCIP
#define NULL
Definition: def.h:248
#define SCIP_Longint
Definition: def.h:141
#define SCIP_INVALID
Definition: def.h:178
#define SCIP_Bool
Definition: def.h:91
#define MIN(x, y)
Definition: def.h:224
#define SCIP_ALLOC(x)
Definition: def.h:366
#define SCIP_Real
Definition: def.h:156
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define MAX(x, y)
Definition: def.h:220
#define REALABS(x)
Definition: def.h:182
#define SCIP_CALL(x)
Definition: def.h:355
SCIP_RETCODE SCIPeventhdlrCreate(SCIP_EVENTHDLR **eventhdlr, SCIP_SET *set, 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:195
internal methods for managing events
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgRhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real rhs)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPchgLhsLinear(SCIP *scip, SCIP_CONS *cons, SCIP_Real lhs)
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:444
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3466
SCIP_RETCODE SCIPhashmapRemove(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3482
SCIP_RETCODE SCIPclearConflictStore(SCIP *scip, SCIP_EVENT *event)
Definition: scip_prob.c:3864
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:250
SCIP_Bool SCIPisCertified(SCIP *scip)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4316
SCIP_Bool SCIPconshdlrIsExact(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4357
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
Definition: scip_cons.c:2621
void SCIPconsAddUpgradeLocks(SCIP_CONS *cons, int nlocks)
Definition: cons.c:8828
SCIP_Bool SCIPconsIsConflict(SCIP_CONS *cons)
Definition: cons.c:8538
SCIP_Real SCIPconsGetAge(SCIP_CONS *cons)
Definition: cons.c:8548
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8409
SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
Definition: cons.c:8688
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8588
SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
Definition: cons.c:8518
SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
Definition: cons.c:8450
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8628
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8389
const char * SCIPeventhdlrGetName(SCIP_EVENTHDLR *eventhdlr)
Definition: event.c:396
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
Definition: event.c:1194
SCIP_RETCODE SCIPcatchEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
Definition: scip_event.c:293
SCIP_RETCODE SCIPdropEvent(SCIP *scip, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
Definition: scip_event.c:333
SCIP_Bool SCIPisExact(SCIP *scip)
Definition: scip_exact.c:193
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:8483
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3709
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
void SCIPsortPtrRealRealBoolBool(void **ptrarray, SCIP_Real *realarray1, SCIP_Real *realarray2, SCIP_Bool *boolarray1, SCIP_Bool *boolarray2, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
void SCIPsortPtrBool(void **ptrarray, SCIP_Bool *boolarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:468
#define BMSfreeMemoryNull(ptr)
Definition: memory.h:146
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:454
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
Definition: memory.h:458
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
#define BMSallocMemory(ptr)
Definition: memory.h:118
internal miscellaneous methods
int SCIPprobGetNConss(SCIP_PROB *prob)
Definition: prob.c:2949
SCIP_Bool SCIPprobIsObjIntegral(SCIP_PROB *prob)
Definition: prob.c:2813
int SCIPprobGetNVars(SCIP_PROB *prob)
Definition: prob.c:2868
internal methods for storing and manipulating the main problem
data structures and methods for collecting reoptimization information
SCIP callable library.
public methods for certified solving
SCIP_Bool SCIPsetIsGE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6617
SCIP_Bool SCIPsetIsPositive(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6648
SCIP_Bool SCIPsetIsLE(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6577
SCIP_STAGE SCIPsetGetStage(SCIP_SET *set)
Definition: set.c:3197
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6380
SCIP_RETCODE SCIPsetGetIntParam(SCIP_SET *set, const char *name, int *value)
Definition: set.c:3382
SCIP_RETCODE SCIPsetIncludeEventhdlr(SCIP_SET *set, SCIP_EVENTHDLR *eventhdlr)
Definition: set.c:4988
SCIP_Bool SCIPsetIsInfinity(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6515
SCIP_Bool SCIPsetIsGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6597
SCIP_Real SCIPsetCutoffbounddelta(SCIP_SET *set)
Definition: set.c:6480
SCIP_EVENTHDLR * SCIPsetFindEventhdlr(SCIP_SET *set, const char *name)
Definition: set.c:5011
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:6080
SCIP_Bool SCIPsetIsNegative(SCIP_SET *set, SCIP_Real val)
Definition: set.c:6659
internal methods for global SCIP settings
#define SCIPsetDebugMsg
Definition: set.h:1811
SCIP_HASHMAP * rowdatahash
int confconsspos
Definition: struct_cons.h:63
data structures for certificate output
Definition: heur_padm.c:135
SCIP_NODE * SCIPtreeGetFocusNode(SCIP_TREE *tree)
Definition: tree.c:9387
internal methods for branch and bound tree
@ SCIP_CONFTYPE_BNDEXCEEDING
Definition: type_conflict.h:64
@ SCIP_CONFTYPE_UNKNOWN
Definition: type_conflict.h:61
enum SCIP_ConflictType SCIP_CONFTYPE
Definition: type_conflict.h:68
#define SCIP_EVENTTYPE_BESTSOLFOUND
Definition: type_event.h:106
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_STAGE_PROBLEM
Definition: type_set.h:45
@ SCIP_STAGE_PRESOLVING
Definition: type_set.h:49
@ SCIP_STAGE_SOLVING
Definition: type_set.h:53
@ SCIP_STAGE_TRANSFORMING
Definition: type_set.h:46
@ SCIP_LOCKTYPE_CONFLICT
Definition: type_var.h:142