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-2022 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 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 Leona 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 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**@addtogroup PublicSolveMethods
47  *
48  * @{
49  */
50 
51 /** initializes solving data structures and transforms problem
52  *
53  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
54  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
55  *
56  * @pre This method can be called if @p scip is in one of the following stages:
57  * - \ref SCIP_STAGE_PROBLEM
58  * - \ref SCIP_STAGE_TRANSFORMED
59  * - \ref SCIP_STAGE_INITPRESOLVE
60  * - \ref SCIP_STAGE_PRESOLVING
61  * - \ref SCIP_STAGE_EXITPRESOLVE
62  * - \ref SCIP_STAGE_PRESOLVED
63  * - \ref SCIP_STAGE_INITSOLVE
64  * - \ref SCIP_STAGE_SOLVING
65  * - \ref SCIP_STAGE_SOLVED
66  * - \ref SCIP_STAGE_EXITSOLVE
67  * - \ref SCIP_STAGE_FREETRANS
68  * - \ref SCIP_STAGE_FREE
69  *
70  * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
71  * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
72  *
73  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
74  */
75 SCIP_EXPORT
77  SCIP* scip /**< SCIP data structure */
78  );
79 
80 /** transforms and presolves problem
81  *
82  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
83  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
84  *
85  * @pre This method can be called if @p scip is in one of the following stages:
86  * - \ref SCIP_STAGE_PROBLEM
87  * - \ref SCIP_STAGE_TRANSFORMED
88  * - \ref SCIP_STAGE_PRESOLVING
89  * - \ref SCIP_STAGE_PRESOLVED
90  * - \ref SCIP_STAGE_SOLVED
91  *
92  * @post After calling this method \SCIP reaches one of the following stages:
93  * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted
94  * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem
95  * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving
96  *
97  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
98  */
99 SCIP_EXPORT
101  SCIP* scip /**< SCIP data structure */
102  );
103 
104 /** transforms, presolves, and solves problem
105  *
106  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
107  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
108  *
109  * @pre This method can be called if @p scip is in one of the following stages:
110  * - \ref SCIP_STAGE_PROBLEM
111  * - \ref SCIP_STAGE_TRANSFORMED
112  * - \ref SCIP_STAGE_PRESOLVING
113  * - \ref SCIP_STAGE_PRESOLVED
114  * - \ref SCIP_STAGE_SOLVING
115  * - \ref SCIP_STAGE_SOLVED
116  *
117  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
118  * process was interrupted:
119 
120  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
121  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
122  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
123  *
124  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
125  */
126 SCIP_EXPORT
128  SCIP* scip /**< SCIP data structure */
129  );
130 
131 /** transforms, presolves, and solves problem using additional solvers which emphasize on
132  * finding solutions.
133  *
134  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
135  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
136  *
137  * @pre This method can be called if @p scip is in one of the following stages:
138  * - \ref SCIP_STAGE_PROBLEM
139  * - \ref SCIP_STAGE_TRANSFORMED
140  * - \ref SCIP_STAGE_PRESOLVING
141  * - \ref SCIP_STAGE_PRESOLVED
142  * - \ref SCIP_STAGE_SOLVING
143  * - \ref SCIP_STAGE_SOLVED
144  *
145  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
146  * process was interrupted:
147  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
148  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
149  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
150  *
151  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
152  *
153  * @deprecated Please use SCIPsolveConcurrent() instead.
154  */
155 SCIP_EXPORT
157  SCIP* scip /**< SCIP data structure */
158  );
159 
160 /** transforms, presolves, and solves problem using additional solvers which emphasize on
161  * finding solutions.
162  *
163  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
164  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
165  *
166  * @pre This method can be called if @p scip is in one of the following stages:
167  * - \ref SCIP_STAGE_PROBLEM
168  * - \ref SCIP_STAGE_TRANSFORMED
169  * - \ref SCIP_STAGE_PRESOLVING
170  * - \ref SCIP_STAGE_PRESOLVED
171  * - \ref SCIP_STAGE_SOLVING
172  * - \ref SCIP_STAGE_SOLVED
173  *
174  * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
175  * process was interrupted:
176  * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
177  * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
178  * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
179  *
180  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
181  */
182 SCIP_EXPORT
184  SCIP* scip /**< SCIP data structure */
185  );
186 
187 /** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
188  * preserved
189  *
190  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
191  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
192  *
193  * @pre This method can be called if @p scip is in one of the following stages:
194  * - \ref SCIP_STAGE_INIT
195  * - \ref SCIP_STAGE_PROBLEM
196  * - \ref SCIP_STAGE_TRANSFORMED
197  * - \ref SCIP_STAGE_PRESOLVING
198  * - \ref SCIP_STAGE_PRESOLVED
199  * - \ref SCIP_STAGE_SOLVING
200  * - \ref SCIP_STAGE_SOLVED
201  *
202  * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
203  * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_TRANSFORMED
204  *
205  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
206  */
207 SCIP_EXPORT
209  SCIP* scip, /**< SCIP data structure */
210  SCIP_Bool restart /**< should certain data be preserved for improved restarting? */
211  );
212 
213 /** frees all solution process data including presolving and transformed problem, only original problem is kept
214  *
215  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
216  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
217  *
218  * @pre This method can be called if @p scip is in one of the following stages:
219  * - \ref SCIP_STAGE_INIT
220  * - \ref SCIP_STAGE_PROBLEM
221  * - \ref SCIP_STAGE_TRANSFORMED
222  * - \ref SCIP_STAGE_PRESOLVING
223  * - \ref SCIP_STAGE_PRESOLVED
224  * - \ref SCIP_STAGE_SOLVING
225  * - \ref SCIP_STAGE_SOLVED
226  *
227  * @post After calling this method \SCIP reaches one of the following stages:
228  * - \ref SCIP_STAGE_INIT if the method was called from \SCIP stage \ref SCIP_STAGE_INIT
229  * - \ref SCIP_STAGE_PROBLEM if the method was called from any other of the allowed stages
230  *
231  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
232  */
233 SCIP_EXPORT
235  SCIP* scip /**< SCIP data structure */
236  );
237 
238 /** informs \SCIP that the solving process should be interrupted as soon as possible (e.g., after the current node has
239  * been solved)
240  *
241  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
242  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
243  *
244  * @pre This method can be called if @p scip is in one of the following stages:
245  * - \ref SCIP_STAGE_PROBLEM
246  * - \ref SCIP_STAGE_TRANSFORMING
247  * - \ref SCIP_STAGE_TRANSFORMED
248  * - \ref SCIP_STAGE_INITPRESOLVE
249  * - \ref SCIP_STAGE_PRESOLVING
250  * - \ref SCIP_STAGE_EXITPRESOLVE
251  * - \ref SCIP_STAGE_PRESOLVED
252  * - \ref SCIP_STAGE_SOLVING
253  * - \ref SCIP_STAGE_SOLVED
254  * - \ref SCIP_STAGE_EXITSOLVE
255  * - \ref SCIP_STAGE_FREETRANS
256  *
257  * @note the \SCIP stage does not get changed
258  */
259 SCIP_EXPORT
261  SCIP* scip /**< SCIP data structure */
262  );
263 
264 /** indicates whether \SCIP has been informed that the solving process should be interrupted as soon as possible
265  *
266  * This function returns whether SCIPinterruptSolve() has been called, which is different from SCIPinterrupted(),
267  * which returns whether a SIGINT signal has been received by the SCIP signal handler.
268  *
269  * @pre This method can be called if @p scip is in one of the following stages:
270  * - \ref SCIP_STAGE_PROBLEM
271  * - \ref SCIP_STAGE_TRANSFORMING
272  * - \ref SCIP_STAGE_TRANSFORMED
273  * - \ref SCIP_STAGE_INITPRESOLVE
274  * - \ref SCIP_STAGE_PRESOLVING
275  * - \ref SCIP_STAGE_EXITPRESOLVE
276  * - \ref SCIP_STAGE_PRESOLVED
277  * - \ref SCIP_STAGE_SOLVING
278  * - \ref SCIP_STAGE_SOLVED
279  * - \ref SCIP_STAGE_EXITSOLVE
280  * - \ref SCIP_STAGE_FREETRANS
281  *
282  * @note the \SCIP stage does not get changed
283  */
284 SCIP_EXPORT
286  SCIP* scip /**< SCIP data structure */
287  );
288 
289 /** informs SCIP that the solving process should be restarted as soon as possible (e.g., after the current node has
290  * been solved)
291  *
292  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
293  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
294  *
295  * @pre This method can be called if @p scip is in one of the following stages:
296  * - \ref SCIP_STAGE_INITPRESOLVE
297  * - \ref SCIP_STAGE_PRESOLVING
298  * - \ref SCIP_STAGE_EXITPRESOLVE
299  * - \ref SCIP_STAGE_SOLVING
300  *
301  * @note the \SCIP stage does not get changed
302  */
303 SCIP_EXPORT
305  SCIP* scip /**< SCIP data structure */
306  );
307 
308 /** returns whether we are in the restarting phase
309  *
310  * @return TRUE, if we are in the restarting phase; FALSE, otherwise
311  *
312  * @pre This method can be called if @p scip is in one of the following stages:
313  * - \ref SCIP_STAGE_INITPRESOLVE
314  * - \ref SCIP_STAGE_PRESOLVING
315  * - \ref SCIP_STAGE_EXITPRESOLVE
316  * - \ref SCIP_STAGE_PRESOLVED
317  * - \ref SCIP_STAGE_INITSOLVE
318  * - \ref SCIP_STAGE_SOLVING
319  * - \ref SCIP_STAGE_SOLVED
320  * - \ref SCIP_STAGE_EXITSOLVE
321  * - \ref SCIP_STAGE_FREETRANS
322  */
323 SCIP_EXPORT
325  SCIP* scip /**< SCIP data structure */
326  );
327 
328 /**@} */
329 
330 /**@addtogroup PublicReoptimizationMethods
331  *
332  * @{
333  */
334 
335 /** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
336  * preserved
337  *
338  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
339  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
340  *
341  * @pre This method can be called if @p scip is in one of the following stages:
342  * - \ref SCIP_STAGE_INIT
343  * - \ref SCIP_STAGE_PROBLEM
344  * - \ref SCIP_STAGE_TRANSFORMED
345  * - \ref SCIP_STAGE_PRESOLVING
346  * - \ref SCIP_STAGE_PRESOLVED
347  * - \ref SCIP_STAGE_SOLVING
348  * - \ref SCIP_STAGE_SOLVED
349  *
350  * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
351  * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_PRESOLVED.
352  *
353  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
354  */
355 SCIP_EXPORT
357  SCIP* scip /**< SCIP data structure */
358  );
359 
360 /** include specific heuristics and branching rules for reoptimization
361  *
362  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
363  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
364  *
365  * @pre This method can be called if @p scip is in one of the following stages:
366  * - \ref SCIP_STAGE_PROBLEM
367  */
368 SCIP_EXPORT
370  SCIP* scip, /**< SCIP data structure */
371  SCIP_Bool enable /**< enable reoptimization (TRUE) or disable it (FALSE) */
372  );
373 
374 /** returns whether reoptimization is enabled or not */
375 SCIP_EXPORT
377  SCIP* scip /**< SCIP data structure */
378  );
379 
380 /** returns the stored solutions corresponding to a given run */
381 SCIP_EXPORT
383  SCIP* scip, /**< SCIP data structue */
384  int run, /**< number of the run */
385  SCIP_SOL** sols, /**< array to store solutions */
386  int allocmem, /**< allocated size of the array */
387  int* nsols /**< number of solutions */
388  );
389 
390 /** mark all stored solutions as not updated */
391 SCIP_EXPORT
393  SCIP* scip /**< SCIP data structure */
394  );
395 
396 /** check if the reoptimization process should be restarted
397  *
398  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
399  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
400  *
401  * @pre This method can be called if @p scip is in one of the following stages:
402  * - \ref SCIP_STAGE_TRANSFORMED
403  * - \ref SCIP_STAGE_SOLVING
404  */
405 SCIP_EXPORT
407  SCIP* scip, /**< SCIP data structure */
408  SCIP_NODE* node, /**< current node of the branch and bound tree (or NULL) */
409  SCIP_Bool* restart /**< pointer to store of the reoptimitation process should be restarted */
410  );
411 
412 /** save bound change based on dual information in the reoptimization tree
413  *
414  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
415  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
416  *
417  * @pre This method can be called if @p scip is in one of the following stages:
418  * - \ref SCIP_STAGE_SOLVING
419  * - \ref SCIP_STAGE_SOLVED
420  */
421 SCIP_EXPORT
423  SCIP* scip, /**< SCIP data structure */
424  SCIP_NODE* node, /**< node of the search tree */
425  SCIP_VAR* var, /**< variable whose bound changed */
426  SCIP_Real newbound, /**< new bound of the variable */
427  SCIP_Real oldbound /**< old bound of the variable */
428  );
429 
430 /** returns the optimal solution of the last iteration or NULL of none exists */
431 SCIP_EXPORT
433  SCIP* scip /**< SCIP data structure */
434  );
435 
436 /** returns the objective coefficent of a given variable in a previous iteration
437  *
438  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
439  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
440  *
441  * @pre This method can be called if @p scip is in one of the following stages:
442  * - \ref SCIP_STAGE_PRESOLVING
443  * - \ref SCIP_STAGE_SOLVING
444  */
445 SCIP_EXPORT
447  SCIP* scip, /**< SCIP data structure */
448  SCIP_VAR* var, /**< variable */
449  int run, /**< number of the run */
450  SCIP_Real* objcoef /**< pointer to store the objective coefficient */
451  );
452 
453 /**@} */
454 
455 #ifdef __cplusplus
456 }
457 #endif
458 
459 #endif
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
Definition: scip_solve.c:3131
SCIP_RETCODE SCIPcheckReoptRestart(SCIP *scip, SCIP_NODE *node, SCIP_Bool *restart)
Definition: scip_solve.c:3644
SCIP_RETCODE SCIPgetReoptSolsRun(SCIP *scip, int run, SCIP_SOL **sols, int allocmem, int *nsols)
Definition: scip_solve.c:3594
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
type definitions for return codes for SCIP methods
SCIP_Bool SCIPisReoptEnabled(SCIP *scip)
Definition: scip_solve.c:3584
void SCIPresetReoptSolMarks(SCIP *scip)
Definition: scip_solve.c:3620
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2613
SCIP_SOL * SCIPgetReoptLastOptSol(SCIP *scip)
Definition: scip_solve.c:3219
type definitions for SCIP&#39;s main datastructure
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2443
type definitions for problem variables
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
Definition: scip_solve.c:3432
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPaddReoptDualBndchg(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound, SCIP_Real oldbound)
Definition: scip_solve.c:3201
type definitions for branch and bound tree
type definitions for storing primal CIP solutions
SCIP_RETCODE SCIPsolveConcurrent(SCIP *scip)
Definition: scip_solve.c:2948
SCIP_RETCODE SCIPrestartSolve(SCIP *scip)
Definition: scip_solve.c:3571
#define SCIP_Real
Definition: def.h:177
SCIP_RETCODE SCIPsolveParallel(SCIP *scip)
Definition: scip_solve.c:2918
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:358
SCIP_RETCODE SCIPgetReoptOldObjCoef(SCIP *scip, SCIP_VAR *var, int run, SCIP_Real *objcoef)
Definition: scip_solve.c:3246
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip_solve.c:3516
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
Definition: scip_solve.c:3369
SCIP_RETCODE SCIPfreeSolve(SCIP *scip, SCIP_Bool restart)
Definition: scip_solve.c:3302
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3677
SCIP_Bool SCIPisSolveInterrupted(SCIP *scip)
Definition: scip_solve.c:3548