Scippy

SCIP

Solving Constraint Integer Programs

scip_compr.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-2018 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 scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_compr.c
17  * @brief public methods for compression plugins
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <ctype.h>
36 #include <stdarg.h>
37 #include <assert.h>
38 #include <string.h>
39 #if defined(_WIN32) || defined(_WIN64)
40 #else
41 #include <strings.h> /*lint --e{766}*/
42 #endif
43 
44 
45 #include "lpi/lpi.h"
46 #include "nlpi/exprinterpret.h"
47 #include "nlpi/nlpi.h"
48 #include "scip/benders.h"
49 #include "scip/benderscut.h"
50 #include "scip/branch.h"
51 #include "scip/branch_nodereopt.h"
52 #include "scip/clock.h"
53 #include "scip/compr.h"
54 #include "scip/concsolver.h"
55 #include "scip/concurrent.h"
56 #include "scip/conflict.h"
57 #include "scip/conflictstore.h"
58 #include "scip/cons.h"
59 #include "scip/cons_linear.h"
60 #include "scip/cutpool.h"
61 #include "scip/cuts.h"
62 #include "scip/debug.h"
63 #include "scip/def.h"
64 #include "scip/dialog.h"
65 #include "scip/dialog_default.h"
66 #include "scip/disp.h"
67 #include "scip/event.h"
68 #include "scip/heur.h"
69 #include "scip/heur_ofins.h"
70 #include "scip/heur_reoptsols.h"
72 #include "scip/heuristics.h"
73 #include "scip/history.h"
74 #include "scip/implics.h"
75 #include "scip/interrupt.h"
76 #include "scip/lp.h"
77 #include "scip/mem.h"
78 #include "scip/message_default.h"
79 #include "scip/misc.h"
80 #include "scip/nlp.h"
81 #include "scip/nodesel.h"
82 #include "scip/paramset.h"
83 #include "scip/presol.h"
84 #include "scip/presolve.h"
85 #include "scip/pricer.h"
86 #include "scip/pricestore.h"
87 #include "scip/primal.h"
88 #include "scip/prob.h"
89 #include "scip/prop.h"
90 #include "scip/reader.h"
91 #include "scip/relax.h"
92 #include "scip/reopt.h"
93 #include "scip/retcode.h"
94 #include "scip/scipbuildflags.h"
95 #include "scip/scipcoreplugins.h"
96 #include "scip/scipgithash.h"
97 #include "scip/sepa.h"
98 #include "scip/sepastore.h"
99 #include "scip/set.h"
100 #include "scip/sol.h"
101 #include "scip/solve.h"
102 #include "scip/stat.h"
103 #include "scip/syncstore.h"
104 #include "scip/table.h"
105 #include "scip/tree.h"
106 #include "scip/var.h"
107 #include "scip/visual.h"
108 #include "xml/xml.h"
109 
110 #include "scip/scip_compr.h"
111 
112 #include "scip/pub_message.h"
113 
114 
115 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
116  * this structure except the interface methods in scip.c.
117  * In optimized mode, the structure is included in scip.h, because some of the methods
118  * are implemented as defines for performance reasons (e.g. the numerical comparisons)
119  */
120 #ifndef NDEBUG
121 #include "scip/struct_scip.h"
122 #endif
123 
124 /** creates a tree compression and includes it in SCIP.
125  *
126  * @note method has all compression callbacks as arguments and is thus changed every time a new
127  * callback is added in future releases; consider using SCIPincludeComprBasic() and setter functions
128  * if you seek for a method which is less likely to change in future releases
129  */
131  SCIP* scip, /**< SCIP data structure */
132  const char* name, /**< name of tree compression */
133  const char* desc, /**< description of tree compression */
134  int priority, /**< priority of the tree compression */
135  int minnnodes, /**< minimal number of nodes to call compression */
136  SCIP_DECL_COMPRCOPY ((*comprcopy)), /**< copy method of tree compression or NULL if you don't want to copy your plugin into sub-SCIPs */
137  SCIP_DECL_COMPRFREE ((*comprfree)), /**< destructor of tree compression */
138  SCIP_DECL_COMPRINIT ((*comprinit)), /**< initialize tree compression */
139  SCIP_DECL_COMPREXIT ((*comprexit)), /**< deinitialize tree compression */
140  SCIP_DECL_COMPRINITSOL ((*comprinitsol)), /**< solving process initialization method of tree compression */
141  SCIP_DECL_COMPREXITSOL ((*comprexitsol)), /**< solving process deinitialization method of tree compression */
142  SCIP_DECL_COMPREXEC ((*comprexec)), /**< execution method of tree compression */
143  SCIP_COMPRDATA* comprdata /**< tree compression data */
144  )
145 {
146  SCIP_COMPR* compr;
147 
148  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeCompr", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
149 
150  /* check whether compression is already present */
151  if( SCIPfindCompr(scip, name) != NULL )
152  {
153  SCIPerrorMessage("compression <%s> already included.\n", name);
154  return SCIP_INVALIDDATA;
155  }
156 
157  SCIP_CALL( SCIPcomprCreate(&compr, scip->set, scip->messagehdlr, scip->mem->setmem, name, desc, priority, minnnodes,
158  comprcopy, comprfree, comprinit, comprexit, comprinitsol, comprexitsol, comprexec, comprdata) );
159 
160  SCIP_CALL( SCIPsetIncludeCompr(scip->set, compr) );
161 
162  return SCIP_OKAY;
163 }
164 
165 /** creates a tree compression and includes it in SCIP with its most fundamental callbacks.
166  * All non-fundamental (or optional) callbacks
167  * as, e. g., init and exit callbacks, will be set to NULL.
168  * Optional callbacks can be set via specific setter functions, see SCIPsetComprCopy(), SCIPsetComprFree(),
169  * SCIPsetComprInit(), SCIPsetComprExit(), SCIPsetComprInitsol(), and SCIPsetComprExitsol()
170  *
171  * @note if you want to set all callbacks with a single method call, consider using SCIPincludeCompr() instead
172  */
174  SCIP* scip, /**< SCIP data structure */
175  SCIP_COMPR** compr, /**< pointer to tree compression */
176  const char* name, /**< name of tree compression */
177  const char* desc, /**< description of tree compression */
178  int priority, /**< priority of the tree compression */
179  int minnnodes, /**< minimal number of nodes to call the compression */
180  SCIP_DECL_COMPREXEC ((*comprexec)), /**< execution method of tree compression */
181  SCIP_COMPRDATA* comprdata /**< tree compression data */
182  )
183 {
184  SCIP_COMPR* comprptr;
185 
186  SCIP_CALL( SCIPcheckStage(scip, "SCIPincludeComprBasic", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
187 
188  /* check whether heuristic is already present */
189  if( SCIPfindCompr(scip, name) != NULL )
190  {
191  SCIPerrorMessage("tree compression <%s> already included.\n", name);
192  return SCIP_INVALIDDATA;
193  }
194 
195  SCIP_CALL( SCIPcomprCreate(&comprptr, scip->set, scip->messagehdlr, scip->mem->setmem, name, desc, priority,
196  minnnodes, NULL, NULL, NULL, NULL, NULL, NULL, comprexec, comprdata) );
197 
198  assert(comprptr != NULL);
199 
200  SCIP_CALL( SCIPsetIncludeCompr(scip->set, comprptr) );
201 
202  if( compr != NULL )
203  *compr = comprptr;
204 
205  return SCIP_OKAY;
206 }
207 
208 /* new callback/method setter methods */
209 
210 /** sets copy method of tree compression */
212  SCIP* scip, /**< SCIP data structure */
213  SCIP_COMPR* compr, /**< tree compression */
214  SCIP_DECL_COMPRCOPY ((*comprcopy)) /**< copy method of tree compression or NULL if you don't want to copy your plugin into sub-SCIPs */
215  )
216 {
217  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprCopy", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
218 
219  assert(compr != NULL);
220 
221  SCIPcomprSetCopy(compr, comprcopy);
222 
223  return SCIP_OKAY;
224 }
225 
226 /** sets destructor method of tree compression */
228  SCIP* scip, /**< SCIP data structure */
229  SCIP_COMPR* compr, /**< tree compression */
230  SCIP_DECL_COMPRFREE ((*comprfree)) /**< destructor of tree compression */
231  )
232 {
233  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprFree", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
234 
235  assert(compr != NULL);
236 
237  SCIPcomprSetFree(compr, comprfree);
238 
239  return SCIP_OKAY;
240 }
241 
242 /** sets initialization method of tree compression */
244  SCIP* scip, /**< SCIP data structure */
245  SCIP_COMPR* compr, /**< tree compression */
246  SCIP_DECL_COMPRINIT ((*comprinit)) /**< initialize tree compression */
247  )
248 {
249  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprInit", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
250 
251  assert(compr != NULL);
252 
253  SCIPcomprSetInit(compr, comprinit);
254 
255  return SCIP_OKAY;
256 }
257 
258 /** sets deinitialization method of tree compression */
260  SCIP* scip, /**< SCIP data structure */
261  SCIP_COMPR* compr, /**< tree compression */
262  SCIP_DECL_COMPREXIT ((*comprexit)) /**< deinitialize tree compression */
263  )
264 {
265  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprExit", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
266 
267  assert(compr != NULL);
268 
269  SCIPcomprSetExit(compr, comprexit);
270 
271  return SCIP_OKAY;
272 }
273 
274 /** sets solving process initialization method of tree compression */
276  SCIP* scip, /**< SCIP data structure */
277  SCIP_COMPR* compr, /**< tree compression */
278  SCIP_DECL_COMPRINITSOL ((*comprinitsol)) /**< solving process initialization method of tree compression */
279  )
280 {
281  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprInitsol", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
282 
283  assert(compr != NULL);
284 
285  SCIPcomprSetInitsol(compr, comprinitsol);
286 
287  return SCIP_OKAY;
288 }
289 
290 /** sets solving process deinitialization method of tree compression */
292  SCIP* scip, /**< SCIP data structure */
293  SCIP_COMPR* compr, /**< tree compression */
294  SCIP_DECL_COMPREXITSOL ((*comprexitsol)) /**< solving process deinitialization method of tree compression */
295  )
296 {
297  SCIP_CALL( SCIPcheckStage(scip, "SCIPsetComprExitsol", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
298 
299  assert(compr != NULL);
300 
301  SCIPcomprSetExitsol(compr, comprexitsol);
302 
303  return SCIP_OKAY;
304 }
305 
306 /** returns the tree compression of the given name, or NULL if not existing */
308  SCIP* scip, /**< SCIP data structure */
309  const char* name /**< name of tree compression */
310  )
311 {
312  assert(scip != NULL);
313  assert(scip->set != NULL);
314  assert(name != NULL);
315 
316  return SCIPsetFindCompr(scip->set, name);
317 }
318 
319 /** returns the array of currently available tree compression */
321  SCIP* scip /**< SCIP data structure */
322  )
323 {
324  assert(scip != NULL);
325  assert(scip->set != NULL);
326 
327  SCIPsetSortComprs(scip->set);
328 
329  return scip->set->comprs;
330 }
331 
332 /** returns the number of currently available tree compression */
334  SCIP* scip /**< SCIP data structure */
335  )
336 {
337  assert(scip != NULL);
338  assert(scip->set != NULL);
339 
340  return scip->set->ncomprs;
341 }
342 
343 /** set the priority of a tree compression method */
345  SCIP* scip, /**< SCIP data structure */
346  SCIP_COMPR* compr, /**< compression */
347  int priority /**< new priority of the tree compression */
348  )
349 {
350  assert(scip != NULL);
351  assert(scip->set != NULL);
352 
353  SCIPcomprSetPriority(compr, scip->set, priority);
354 
355  return SCIP_OKAY;
356 }
internal methods for separators
void SCIPcomprSetInitsol(SCIP_COMPR *compr, SCIP_DECL_COMPRINITSOL((*comprinitsol)))
Definition: compr.c:410
SCIP_RETCODE SCIPsetComprFree(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRFREE((*comprfree)))
Definition: scip_compr.c:227
#define NULL
Definition: def.h:239
internal methods for managing events
default message handler
trivialnegation primal heuristic
internal methods for storing primal CIP solutions
methods to interpret (evaluate) an expression tree "fast"
internal methods for branch and bound tree
#define SCIP_DECL_COMPREXEC(x)
Definition: type_compr.h:111
void SCIPcomprSetCopy(SCIP_COMPR *compr, SCIP_DECL_COMPRCOPY((*comprcopy)))
Definition: compr.c:366
methods for implications, variable bounds, and cliques
SCIP_RETCODE SCIPsetComprInit(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRINIT((*comprinit)))
Definition: scip_compr.c:243
public methods for compression plugins
internal methods for clocks and timing issues
SCIP_RETCODE SCIPcomprCreate(SCIP_COMPR **compr, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, int minnnodes, SCIP_DECL_COMPRCOPY((*comprcopy)), SCIP_DECL_COMPRFREE((*comprfree)), SCIP_DECL_COMPRINIT((*comprinit)), SCIP_DECL_COMPREXIT((*comprexit)), SCIP_DECL_COMPRINITSOL((*comprinitsol)), SCIP_DECL_COMPREXITSOL((*comprexitsol)), SCIP_DECL_COMPREXEC((*comprexec)), SCIP_COMPRDATA *comprdata)
Definition: compr.c:160
internal methods for NLPI solver interfaces
#define SCIP_DECL_COMPREXITSOL(x)
Definition: type_compr.h:95
interface methods for specific LP solvers
internal methods for displaying statistics tables
void SCIPcomprSetExitsol(SCIP_COMPR *compr, SCIP_DECL_COMPREXITSOL((*comprexitsol)))
Definition: compr.c:421
#define FALSE
Definition: def.h:65
methods for the aggregation rows
SCIP_RETCODE SCIPincludeCompr(SCIP *scip, const char *name, const char *desc, int priority, int minnnodes, SCIP_DECL_COMPRCOPY((*comprcopy)), SCIP_DECL_COMPRFREE((*comprfree)), SCIP_DECL_COMPRINIT((*comprinit)), SCIP_DECL_COMPREXIT((*comprexit)), SCIP_DECL_COMPRINITSOL((*comprinitsol)), SCIP_DECL_COMPREXITSOL((*comprexitsol)), SCIP_DECL_COMPREXEC((*comprexec)), SCIP_COMPRDATA *comprdata)
Definition: scip_compr.c:130
internal methods for Benders&#39; decomposition
SCIP_COMPR * SCIPfindCompr(SCIP *scip, const char *name)
Definition: scip_compr.c:307
#define TRUE
Definition: def.h:64
SCIP_RETCODE SCIPincludeComprBasic(SCIP *scip, SCIP_COMPR **compr, const char *name, const char *desc, int priority, int minnnodes, SCIP_DECL_COMPREXEC((*comprexec)), SCIP_COMPRDATA *comprdata)
Definition: scip_compr.c:173
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
methods commonly used by primal heuristics
void SCIPcomprSetPriority(SCIP_COMPR *compr, SCIP_SET *set, int priority)
Definition: compr.c:476
void SCIPcomprSetInit(SCIP_COMPR *compr, SCIP_DECL_COMPRINIT((*comprinit)))
Definition: compr.c:388
SCIP_RETCODE SCIPsetComprInitsol(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRINITSOL((*comprinitsol)))
Definition: scip_compr.c:275
internal methods for branching rules and branching candidate storage
datastructures for concurrent solvers
internal methods for handling parameter settings
methods for creating output for visualization tools (VBC, BAK)
nodereopt branching rule
#define SCIP_DECL_COMPRINIT(x)
Definition: type_compr.h:65
internal methods for LP management
internal methods for branching and inference history
SCIP_RETCODE SCIPsetIncludeCompr(SCIP_SET *set, SCIP_COMPR *compr)
Definition: set.c:4492
internal methods for collecting primal CIP solutions and primal informations
#define SCIP_DECL_COMPRFREE(x)
Definition: type_compr.h:57
internal methods for propagators
SCIP_MEM * mem
Definition: struct_scip.h:61
git hash methods
SCIP_RETCODE SCIPsetComprCopy(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPRCOPY((*comprcopy)))
Definition: scip_compr.c:211
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
#define SCIP_DECL_COMPRCOPY(x)
Definition: type_compr.h:49
methods for block memory pools and memory buffers
register additional core functionality that is designed as plugins
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition: debug.c:1933
internal methods for presolvers
void SCIPsetSortComprs(SCIP_SET *set)
Definition: set.c:4536
internal methods for NLP management
internal miscellaneous methods
internal methods for node selectors and node priority queues
internal methods for variable pricers
internal methods for global SCIP settings
internal methods for storing conflicts
#define SCIP_CALL(x)
Definition: def.h:351
SCIP main data structure.
BMS_BLKMEM * setmem
Definition: struct_mem.h:39
struct SCIP_ComprData SCIP_COMPRDATA
Definition: type_compr.h:40
internal methods for storing priced variables
internal methods for relaxators
internal methods for storing separated cuts
#define SCIP_DECL_COMPRINITSOL(x)
Definition: type_compr.h:84
methods commonly used for presolving
methods for catching the user CTRL-C interrupt
internal methods for problem variables
data structures and methods for collecting reoptimization information
SCIP_COMPR * SCIPsetFindCompr(SCIP_SET *set, const char *name)
Definition: set.c:4516
the function declarations for the synchronization store
SCIP_COMPR ** SCIPgetComprs(SCIP *scip)
Definition: scip_compr.c:320
internal methods for user interface dialog
SCIP_RETCODE SCIPsetComprExitsol(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPREXITSOL((*comprexitsol)))
Definition: scip_compr.c:291
internal methods for input file readers
methods for debugging
#define SCIP_DECL_COMPREXIT(x)
Definition: type_compr.h:73
reoptsols primal heuristic
internal methods for storing cuts in a cut pool
Constraint handler for linear constraints in their most general form, .
helper functions for concurrent scip solvers
SCIP_RETCODE SCIPsetComprPriority(SCIP *scip, SCIP_COMPR *compr, int priority)
Definition: scip_compr.c:344
internal methods for return codes for SCIP methods
SCIP_COMPR ** comprs
Definition: struct_set.h:81
internal methods for conflict analysis
internal methods for tree compressions
internal methods for main solving loop and node processing
SCIP_RETCODE SCIPsetComprExit(SCIP *scip, SCIP_COMPR *compr, SCIP_DECL_COMPREXIT((*comprexit)))
Definition: scip_compr.c:259
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
int ncomprs
Definition: struct_set.h:116
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
default user interface dialog
internal methods for problem statistics
internal methods for constraints and constraint handlers
int SCIPgetNCompr(SCIP *scip)
Definition: scip_compr.c:333
declarations for XML parsing
void SCIPcomprSetFree(SCIP_COMPR *compr, SCIP_DECL_COMPRFREE((*comprfree)))
Definition: compr.c:377
build flags methods
common defines and data types used in all packages of SCIP
void SCIPcomprSetExit(SCIP_COMPR *compr, SCIP_DECL_COMPREXIT((*comprexit)))
Definition: compr.c:399
internal methods for primal heuristics
internal methods for Benders&#39; decomposition cuts
internal methods for displaying runtime statistics
OFINS - Objective Function Induced Neighborhood Search - a primal heuristic for reoptimization.