1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*                  This file is part of the program and library             */
4 /*         SCIP --- Solving Constraint Integer Programs                      */
5 /*                                                                           */
6 /*    Copyright (C) 2002-2021 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 visit scipopt.org.         */
13 /*                                                                           */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file   conflictstore.h
17  * @ingroup INTERNALAPI
18  * @brief  internal methods for storing conflicts
19  * @author Jakob Witzig
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __SCIP_CONFLICTSTORE_H__
25 #define __SCIP_CONFLICTSTORE_H__
26 
27 
28 #include "scip/def.h"
29 #include "blockmemshell/memory.h"
30 #include "scip/type_conflictstore.h"
31 #include "scip/type_retcode.h"
32 #include "scip/type_cons.h"
33 #include "scip/type_event.h"
34 #include "scip/type_conflict.h"
35 #include "scip/type_prob.h"
36 #include "scip/type_reopt.h"
37 #include "scip/type_set.h"
38 #include "scip/type_stat.h"
39 #include "scip/type_tree.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /** creates separation storage */
46 SCIP_RETCODE SCIPconflictstoreCreate(
47    SCIP_CONFLICTSTORE**  conflictstore,      /**< pointer to store conflict store */
48    SCIP_SET*             set                 /**< global SCIP settings */
49    );
50 
51 /** frees separation storage */
52 SCIP_RETCODE SCIPconflictstoreFree(
53    SCIP_CONFLICTSTORE**  conflictstore,      /**< pointer to store conflict store */
54    BMS_BLKMEM*           blkmem,             /**< block memory */
55    SCIP_SET*             set,                /**< global SCIP settings */
56    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
57    SCIP_REOPT*           reopt               /**< reoptimization data */
58    );
59 
60 /** clears conflict store */
61 SCIP_RETCODE SCIPconflictstoreClear(
62    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
63    BMS_BLKMEM*           blkmem,             /**< block memory */
64    SCIP_SET*             set,                /**< global SCIP settings */
65    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
66    SCIP_REOPT*           reopt               /**< reoptimization data */
67    );
68 
69 /** cleans up conflict store */
70 SCIP_RETCODE SCIPconflictstoreClean(
71    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
72    BMS_BLKMEM*           blkmem,             /**< block memory */
73    SCIP_SET*             set,                /**< global SCIP settings */
74    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
75    SCIP_PROB*            transprob,          /**< transformed problem */
76    SCIP_REOPT*           reopt               /**< reoptimization data */
77    );
78 
79 /** adds a constraint to the pool of proof constraints based on dual rays
80  *
81  *  @note this methods captures the constraint
82  */
83 SCIP_RETCODE SCIPconflictstoreAddDualraycons(
84    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
85    SCIP_CONS*            dualproof,          /**< constraint based on a dual ray */
86    BMS_BLKMEM*           blkmem,             /**< block memory */
87    SCIP_SET*             set,                /**< global SCIP settings */
88    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
89    SCIP_PROB*            transprob,          /**< transformed problem */
90    SCIP_REOPT*           reopt,              /**< reoptimization data */
91    SCIP_Bool             hasrelaxvar         /**< does the dual proof contain at least one variable that exists in
92                                                *  the current relaxation only? */
93    );
94 
95 /** adds a constraint to the pool of proof constraints based on dual solutions
96  *
97  *  @note this methods captures the constraint
98  */
99 SCIP_RETCODE SCIPconflictstoreAddDualsolcons(
100    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
101    SCIP_CONS*            dualproof,          /**< constraint based on a dual solution */
102    BMS_BLKMEM*           blkmem,             /**< block memory */
103    SCIP_SET*             set,                /**< global SCIP settings */
104    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
105    SCIP_PROB*            transprob,          /**< transformed problem */
106    SCIP_REOPT*           reopt,              /**< reoptimization data */
107    SCIP_Real             scale,              /**< scaling factor that needs to be considered when updating the side */
108    SCIP_Bool             updateside,         /**< should the side be updated if a new incumbent is found */
109    SCIP_Bool             hasrelaxvar         /**< does the dual proof contain at least one variable that exists in
110                                                *  the current relaxation only? */
111    );
112 
113 /** adds a conflict to the conflict store
114  *
115  *  @note this method captures the constraint
116  */
117 SCIP_RETCODE SCIPconflictstoreAddConflict(
118    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
119    BMS_BLKMEM*           blkmem,             /**< block memory */
120    SCIP_SET*             set,                /**< global SCIP settings */
121    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
122    SCIP_TREE*            tree,               /**< branch and bound tree (or NULL for an original constraint) */
123    SCIP_PROB*            transprob,          /**< transformed problem (or NULL for an original constraint) */
124    SCIP_REOPT*           reopt,              /**< reoptimization data */
125    SCIP_CONS*            cons,               /**< constraint representing the conflict */
126    SCIP_CONFTYPE         conftype,           /**< type of the conflict */
127    SCIP_Bool             cutoffinvolved,     /**< is a cutoff bound involved in this conflict */
128    SCIP_Real             primalbound         /**< primal bound the conflict depend on (or -SCIPinfinity) */
129    );
130 
131 /** deletes all conflicts depending on a cutoff bound larger than the given bound */
132 SCIP_RETCODE SCIPconflictstoreCleanNewIncumbent(
133    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
134    SCIP_SET*             set,                /**< global SCIP settings */
135    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
136    BMS_BLKMEM*           blkmem,             /**< block memory */
137    SCIP_PROB*            transprob,          /**< transformed problem*/
138    SCIP_REOPT*           reopt,              /**< reoptimization data */
139    SCIP_Real             cutoffbound         /**< current cutoff bound */
140    );
141 
142 /** returns the maximal size of the conflict pool */
143 int SCIPconflictstoreGetMaxPoolSize(
144    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
145    );
146 
147 /** returns the initial size of the conflict pool */
148 int SCIPconflictstoreGetInitPoolSize(
149    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
150    );
151 
152 /** returns the number of stored conflicts on the conflict pool
153  *
154  *  @note the number of active conflicts can be less
155  */
156 int SCIPconflictstoreGetNConflictsInStore(
157    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
158    );
159 
160 /** returns all active conflicts stored in the conflict store */
161 SCIP_RETCODE SCIPconflictstoreGetConflicts(
162    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
163    SCIP_CONS**           conflicts,          /**< array to store conflicts */
164    int                   conflictsize,       /**< size of the conflict array */
165    int*                  nconflicts          /**< pointer to store the number of conflicts */
166    );
167 
168 /** transforms all original conflicts into transformed conflicts */
169 SCIP_RETCODE SCIPconflictstoreTransform(
170    SCIP_CONFLICTSTORE*   conflictstore,      /**< conflict store */
171    BMS_BLKMEM*           blkmem,             /**< block memory */
172    SCIP_SET*             set,                /**< global SCIP settings */
173    SCIP_STAT*            stat,               /**< dynamic SCIP statistics */
174    SCIP_TREE*            tree,               /**< branch and bound tree */
175    SCIP_PROB*            transprob,          /**< transformed problem */
176    SCIP_REOPT*           reopt               /**< reoptimization data */
177    );
178 
179 /** returns the average number of non-zeros over all stored dual ray constraints */
180 SCIP_Real SCIPconflictstoreGetAvgNnzDualInfProofs(
181    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
182    );
183 
184 /** return the number of stored dualray constraints */
185 int SCIPconflictstoreGetNDualInfProofs(
186    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
187    );
188 
189 /** returns the average number of non-zeros over all stored boundexceeding proofs */
190 SCIP_Real SCIPconflictstoreGetAvgNnzDualBndProofs(
191    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
192    );
193 
194 /** returns the number of all stored boundexceeding proofs */
195 int SCIPconflictstoreGetNDualBndProofs(
196    SCIP_CONFLICTSTORE*   conflictstore       /**< conflict store */
197    );
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif
204