Scippy

SCIP

Solving Constraint Integer Programs

scip_solve.h
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-2019 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_solve.h
17  * @ingroup PUBLICCOREAPI
18  * @brief public solving methods
19  * @author Tobias Achterberg
20  * @author Timo Berthold
21  * @author Thorsten Koch
22  * @author Alexander Martin
23  * @author Marc Pfetsch
24  * @author Kati Wolter
25  * @author Gregor Hendel
26  * @author Robert Lion Gottwald
27  */
28 
29 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
30 
31 #ifndef __SCIP_SCIP_SOLVE_H__
32 #define __SCIP_SCIP_SOLVE_H__
33 
34 
35 #include "scip/def.h"
36 #include "scip/type_retcode.h"
37 #include "scip/type_scip.h"
38 #include "scip/type_sol.h"
39 #include "scip/type_tree.h"
40 #include "scip/type_var.h"
41 
42 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access
43  * this structure except the interface methods in scip.c.
44  * In optimized mode, the structure is included in scip.h, because some of the methods
45  * are implemented as defines for performance reasons (e.g. the numerical comparisons).
46  * Additionally, the internal "set.h" is included, such that the defines in set.h are
47  * available in optimized mode.
48  */
49 #ifdef NDEBUG
50 #include "scip/struct_scip.h"
51 #include "scip/struct_stat.h"
52 #include "scip/set.h"
53 #include "scip/tree.h"
54 #include "scip/misc.h"
55 #include "scip/var.h"
56 #include "scip/cons.h"
57 #include "scip/solve.h"
58 #include "scip/debug.h"
59 #endif
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 /**@addtogroup PublicSolveMethods
66  *
67  * @{
68  */
69 
70 /** initializes solving data structures and transforms problem
71  *
72  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
73  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
74  *
75  * @pre This method can be called if @p scip is in one of the following stages:
76  * - \ref SCIP_STAGE_PROBLEM
77  * - \ref SCIP_STAGE_TRANSFORMED
78  * - \ref SCIP_STAGE_INITPRESOLVE
79  * - \ref SCIP_STAGE_PRESOLVING
80  * - \ref SCIP_STAGE_EXITPRESOLVE
81  * - \ref SCIP_STAGE_PRESOLVED
82  * - \ref SCIP_STAGE_INITSOLVE
83  * - \ref SCIP_STAGE_SOLVING
84  * - \ref SCIP_STAGE_SOLVED
85  * - \ref SCIP_STAGE_EXITSOLVE
86  * - \ref SCIP_STAGE_FREETRANS
87  * - \ref SCIP_STAGE_FREE
88  *
89  * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
90  * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
91  *
92  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
93  */
94 extern
96  SCIP* scip /**< SCIP data structure */
97  );
98 
99 /** transforms and presolves problem
100  *
101  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
102  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
103  *
104  * @pre This method can be called if @p scip is in one of the following stages:
105  * - \ref SCIP_STAGE_PROBLEM
106  * - \ref SCIP_STAGE_TRANSFORMED
107  * - \ref SCIP_STAGE_PRESOLVING
108  * - \ref SCIP_STAGE_PRESOLVED
109  *
110  * @post After calling this method \SCIP reaches one of the following stages:
111  * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted
112  * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem
113  * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving
114  *
115  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
116  */
117 extern
119  SCIP* scip /**< SCIP data structure */
120  );
121 
122 /** transforms, presolves, and solves problem
123  *
124  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
125  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
126  *
127  * @pre This method can be called if @p scip is in one of the following stages:
128  * - \ref SCIP_STAGE_PROBLEM
129  * - \ref SCIP_STAGE_TRANSFORMED
130  * - \ref SCIP_STAGE_PRESOLVING
131  * - \ref SCIP_STAGE_PRESOLVED
132  * - \ref SCIP_STAGE_SOLVING
133  * - \ref SCIP_STAGE_SOLVED
134  *
135  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
136  * process was interrupted:
137 
138  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
139  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
140  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
141  *
142  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
143  */
144 extern
146  SCIP* scip /**< SCIP data structure */
147  );
148 
149 /** transforms, presolves, and solves problem using additional solvers which emphasize on
150  * finding solutions.
151  *
152  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
153  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
154  *
155  * @pre This method can be called if @p scip is in one of the following stages:
156  * - \ref SCIP_STAGE_PROBLEM
157  * - \ref SCIP_STAGE_TRANSFORMED
158  * - \ref SCIP_STAGE_PRESOLVING
159  * - \ref SCIP_STAGE_PRESOLVED
160  * - \ref SCIP_STAGE_SOLVING
161  * - \ref SCIP_STAGE_SOLVED
162  *
163  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
164  * process was interrupted:
165  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
166  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
167  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
168  *
169  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
170  *
171  * @deprecated Please use SCIPsolveConcurrent() instead.
172  */
173 extern
175  SCIP* scip /**< SCIP data structure */
176  );
177 
178 /** transforms, presolves, and solves problem using additional solvers which emphasize on
179  * finding solutions.
180  *
181  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
182  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
183  *
184  * @pre This method can be called if @p scip is in one of the following stages:
185  * - \ref SCIP_STAGE_PROBLEM
186  * - \ref SCIP_STAGE_TRANSFORMED
187  * - \ref SCIP_STAGE_PRESOLVING
188  * - \ref SCIP_STAGE_PRESOLVED
189  * - \ref SCIP_STAGE_SOLVING
190  * - \ref SCIP_STAGE_SOLVED
191  *
192  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
193  * process was interrupted:
194  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
195  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
196  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
197  *
198  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
199  */
200 extern
202  SCIP* scip /**< SCIP data structure */
203  );
204 
205 /** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
206  * preserved
207  *
208  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
209  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
210  *
211  * @pre This method can be called if @p scip is in one of the following stages:
212  * - \ref SCIP_STAGE_INIT
213  * - \ref SCIP_STAGE_PROBLEM
214  * - \ref SCIP_STAGE_TRANSFORMED
215  * - \ref SCIP_STAGE_PRESOLVING
216  * - \ref SCIP_STAGE_PRESOLVED
217  * - \ref SCIP_STAGE_SOLVING
218  * - \ref SCIP_STAGE_SOLVED
219  *
220  * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
221  * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_TRANSFORMED
222  *
223  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
224  */
225 extern
227  SCIP* scip, /**< SCIP data structure */
228  SCIP_Bool restart /**< should certain data be preserved for improved restarting? */
229  );
230 
231 /** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
232  * preserved
233  *
234  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
235  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
236  *
237  * @pre This method can be called if @p scip is in one of the following stages:
238  * - \ref SCIP_STAGE_INIT
239  * - \ref SCIP_STAGE_PROBLEM
240  * - \ref SCIP_STAGE_TRANSFORMED
241  * - \ref SCIP_STAGE_PRESOLVING
242  * - \ref SCIP_STAGE_PRESOLVED
243  * - \ref SCIP_STAGE_SOLVING
244  * - \ref SCIP_STAGE_SOLVED
245  *
246  * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
247  * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_PRESOLVED.
248  *
249  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
250  */
251 extern
253  SCIP* scip /**< SCIP data structure */
254  );
255 
256 /** frees all solution process data including presolving and transformed problem, only original problem is kept
257  *
258  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
259  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
260  *
261  * @pre This method can be called if @p scip is in one of the following stages:
262  * - \ref SCIP_STAGE_INIT
263  * - \ref SCIP_STAGE_PROBLEM
264  * - \ref SCIP_STAGE_TRANSFORMED
265  * - \ref SCIP_STAGE_PRESOLVING
266  * - \ref SCIP_STAGE_PRESOLVED
267  * - \ref SCIP_STAGE_SOLVING
268  * - \ref SCIP_STAGE_SOLVED
269  *
270  * @post After calling this method \SCIP reaches one of the following stages:
271  * - \ref SCIP_STAGE_INIT if the method was called from \SCIP stage \ref SCIP_STAGE_INIT
272  * - \ref SCIP_STAGE_PROBLEM if the method was called from any other of the allowed stages
273  *
274  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
275  */
276 extern
278  SCIP* scip /**< SCIP data structure */
279  );
280 
281 /** informs \SCIP that the solving process should be interrupted as soon as possible (e.g., after the current node has
282  * been solved)
283  *
284  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
285  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
286  *
287  * @pre This method can be called if @p scip is in one of the following stages:
288  * - \ref SCIP_STAGE_PROBLEM
289  * - \ref SCIP_STAGE_TRANSFORMING
290  * - \ref SCIP_STAGE_TRANSFORMED
291  * - \ref SCIP_STAGE_INITPRESOLVE
292  * - \ref SCIP_STAGE_PRESOLVING
293  * - \ref SCIP_STAGE_EXITPRESOLVE
294  * - \ref SCIP_STAGE_PRESOLVED
295  * - \ref SCIP_STAGE_SOLVING
296  * - \ref SCIP_STAGE_SOLVED
297  * - \ref SCIP_STAGE_EXITSOLVE
298  * - \ref SCIP_STAGE_FREETRANS
299  *
300  * @note the \SCIP stage does not get changed
301  */
302 extern
304  SCIP* scip /**< SCIP data structure */
305  );
306 
307 /** informs SCIP that the solving process should be restarted as soon as possible (e.g., after the current node has
308  * been solved)
309  *
310  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
311  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
312  *
313  * @pre This method can be called if @p scip is in one of the following stages:
314  * - \ref SCIP_STAGE_INITPRESOLVE
315  * - \ref SCIP_STAGE_PRESOLVING
316  * - \ref SCIP_STAGE_EXITPRESOLVE
317  * - \ref SCIP_STAGE_SOLVING
318  *
319  * @note the \SCIP stage does not get changed
320  */
321 extern
323  SCIP* scip /**< SCIP data structure */
324  );
325 
326 /** include specific heuristics and branching rules for reoptimization
327  *
328  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
329  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
330  *
331  * @pre This method can be called if @p scip is in one of the following stages:
332  * - \ref SCIP_STAGE_PROBLEM
333  */
334 extern
336  SCIP* scip, /**< SCIP data structure */
337  SCIP_Bool enable /**< enable reoptimization (TRUE) or disable it (FALSE) */
338  );
339 
340 /** returns whether reoptimization is enabled or not */
341 extern
343  SCIP* scip /**< SCIP data structure */
344  );
345 
346 /** returns the stored solutions corresponding to a given run */
347 extern
349  SCIP* scip, /**< SCIP data structue */
350  int run, /**< number of the run */
351  SCIP_SOL** sols, /**< array to store solutions */
352  int allocmem, /**< allocated size of the array */
353  int* nsols /**< number of solutions */
354  );
355 
356 /** mark all stored solutions as not updated */
357 extern
359  SCIP* scip /**< SCIP data structure */
360  );
361 
362 /** check if the reoptimization process should be restarted
363  *
364  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
365  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
366  *
367  * @pre This method can be called if @p scip is in one of the following stages:
368  * - \ref SCIP_STAGE_TRANSFORMED
369  * - \ref SCIP_STAGE_SOLVING
370  */
371 extern
373  SCIP* scip, /**< SCIP data structure */
374  SCIP_NODE* node, /**< current node of the branch and bound tree (or NULL) */
375  SCIP_Bool* restart /**< pointer to store of the reoptimitation process should be restarted */
376  );
377 
378 /** save bound change based on dual information in the reoptimization tree
379  *
380  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
381  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
382  *
383  * @pre This method can be called if @p scip is in one of the following stages:
384  * - \ref SCIP_STAGE_SOLVING
385  * - \ref SCIP_STAGE_SOLVED
386  */
387 extern
389  SCIP* scip, /**< SCIP data structure */
390  SCIP_NODE* node, /**< node of the search tree */
391  SCIP_VAR* var, /**< variable whose bound changed */
392  SCIP_Real newbound, /**< new bound of the variable */
393  SCIP_Real oldbound /**< old bound of the variable */
394  );
395 
396 /** returns the optimal solution of the last iteration or NULL of none exists */
397 extern
399  SCIP* scip /**< SCIP data structure */
400  );
401 
402 /** returns the objective coefficent of a given variable in a previous iteration
403  *
404  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
405  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
406  *
407  * @pre This method can be called if @p scip is in one of the following stages:
408  * - \ref SCIP_STAGE_PRESOLVING
409  * - \ref SCIP_STAGE_SOLVING
410  */
411 extern
413  SCIP* scip, /**< SCIP data structure */
414  SCIP_VAR* var, /**< variable */
415  int run, /**< number of the run */
416  SCIP_Real* objcoef /**< pointer to store the objective coefficient */
417  );
418 
419 /** returns whether we are in the restarting phase
420  *
421  * @return TRUE, if we are in the restarting phase; FALSE, otherwise
422  *
423  * @pre This method can be called if @p scip is in one of the following stages:
424  * - \ref SCIP_STAGE_INITPRESOLVE
425  * - \ref SCIP_STAGE_PRESOLVING
426  * - \ref SCIP_STAGE_EXITPRESOLVE
427  * - \ref SCIP_STAGE_PRESOLVED
428  * - \ref SCIP_STAGE_INITSOLVE
429  * - \ref SCIP_STAGE_SOLVING
430  * - \ref SCIP_STAGE_SOLVED
431  * - \ref SCIP_STAGE_EXITSOLVE
432  * - \ref SCIP_STAGE_FREETRANS
433  */
434 extern
436  SCIP* scip /**< SCIP data structure */
437  );
438 
439 /**@} */
440 
441 #ifdef __cplusplus
442 }
443 #endif
444 
445 #endif
internal methods for branch and bound tree
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
type definitions for return codes for SCIP methods
void SCIPresetReoptSolMarks(SCIP *scip)
Definition: scip_solve.c:3514
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
Definition: scip_solve.c:3304
SCIP_RETCODE SCIPaddReoptDualBndchg(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound, SCIP_Real oldbound)
Definition: scip_solve.c:3136
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2577
type definitions for SCIP&#39;s main datastructure
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2416
SCIP_RETCODE SCIPgetReoptSolsRun(SCIP *scip, int run, SCIP_SOL **sols, int allocmem, int *nsols)
Definition: scip_solve.c:3488
SCIP_Bool SCIPisReoptEnabled(SCIP *scip)
Definition: scip_solve.c:3478
internal miscellaneous methods
internal methods for global SCIP settings
SCIP_SOL * SCIPgetReoptLastOptSol(SCIP *scip)
Definition: scip_solve.c:3154
SCIP main data structure.
type definitions for problem variables
internal methods for problem variables
SCIP_RETCODE SCIPcheckReoptRestart(SCIP *scip, SCIP_NODE *node, SCIP_Bool *restart)
Definition: scip_solve.c:3538
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
Definition: scip_solve.c:3367
#define SCIP_Bool
Definition: def.h:69
methods for debugging
type definitions for branch and bound tree
datastructures for problem statistics
type definitions for storing primal CIP solutions
SCIP_RETCODE SCIPgetReoptOldObjCoef(SCIP *scip, SCIP_VAR *var, int run, SCIP_Real *objcoef)
Definition: scip_solve.c:3181
SCIP_RETCODE SCIPsolveConcurrent(SCIP *scip)
Definition: scip_solve.c:2893
internal methods for main solving loop and node processing
SCIP_RETCODE SCIPrestartSolve(SCIP *scip)
Definition: scip_solve.c:3465
#define SCIP_Real
Definition: def.h:157
SCIP_RETCODE SCIPsolveParallel(SCIP *scip)
Definition: scip_solve.c:2863
internal methods for constraints and constraint handlers
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:400
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip_solve.c:3439
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPfreeSolve(SCIP *scip, SCIP_Bool restart)
Definition: scip_solve.c:3237
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3571
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
Definition: scip_solve.c:3066