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-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 scip_solve.h
26 * @ingroup PUBLICCOREAPI
27 * @brief public solving methods
28 * @author Tobias Achterberg
29 * @author Timo Berthold
30 * @author Thorsten Koch
31 * @author Alexander Martin
32 * @author Marc Pfetsch
33 * @author Kati Wolter
34 * @author Gregor Hendel
35 * @author Leona Gottwald
36 */
37
38/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
39
40#ifndef __SCIP_SCIP_SOLVE_H__
41#define __SCIP_SCIP_SOLVE_H__
42
43
44#include "scip/def.h"
45#include "scip/type_retcode.h"
46#include "scip/type_scip.h"
47#include "scip/type_sol.h"
48#include "scip/type_tree.h"
49#include "scip/type_var.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/**@addtogroup PublicSolveMethods
56 *
57 * @{
58 */
59
60/** initializes solving data structures and transforms problem
61 *
62 * Before SCIP 10, this function also called the garbage collection for block memory explicitly.
63 * It has been removed for performance reason, but if memory is very tight, then the previous behavior can be
64 * restored by adding a call to SCIPcollectMemoryGarbage() before SCIPtransformProb().
65 *
66 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
67 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
68 *
69 * @pre This method can be called if @p scip is in one of the following stages:
70 * - \ref SCIP_STAGE_PROBLEM
71 * - \ref SCIP_STAGE_TRANSFORMED
72 * - \ref SCIP_STAGE_INITPRESOLVE
73 * - \ref SCIP_STAGE_PRESOLVING
74 * - \ref SCIP_STAGE_EXITPRESOLVE
75 * - \ref SCIP_STAGE_PRESOLVED
76 * - \ref SCIP_STAGE_INITSOLVE
77 * - \ref SCIP_STAGE_SOLVING
78 * - \ref SCIP_STAGE_SOLVED
79 * - \ref SCIP_STAGE_EXITSOLVE
80 * - \ref SCIP_STAGE_FREETRANS
81 * - \ref SCIP_STAGE_FREE
82 *
83 * @post When calling this method in the \ref SCIP_STAGE_PROBLEM stage, the \SCIP stage is changed to \ref
84 * SCIP_STAGE_TRANSFORMED; otherwise, the stage is not changed
85 *
86 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
87 */
88SCIP_EXPORT
90 SCIP* scip /**< SCIP data structure */
91 );
92
93/** transforms and presolves problem
94 *
95 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
96 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
97 *
98 * @pre This method can be called if @p scip is in one of the following stages:
99 * - \ref SCIP_STAGE_PROBLEM
100 * - \ref SCIP_STAGE_TRANSFORMED
101 * - \ref SCIP_STAGE_PRESOLVING
102 * - \ref SCIP_STAGE_PRESOLVED
103 * - \ref SCIP_STAGE_SOLVED
104 *
105 * @post After calling this method \SCIP reaches one of the following stages:
106 * - \ref SCIP_STAGE_PRESOLVING if the presolving process was interrupted
107 * - \ref SCIP_STAGE_PRESOLVED if the presolving process was finished and did not solve the problem
108 * - \ref SCIP_STAGE_SOLVED if the problem was solved during presolving
109 *
110 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
111 */
112SCIP_EXPORT
114 SCIP* scip /**< SCIP data structure */
115 );
116
117/** transforms, presolves, and solves problem
118 *
119 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
120 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
121 *
122 * @pre This method can be called if @p scip is in one of the following stages:
123 * - \ref SCIP_STAGE_PROBLEM
124 * - \ref SCIP_STAGE_TRANSFORMED
125 * - \ref SCIP_STAGE_PRESOLVING
126 * - \ref SCIP_STAGE_PRESOLVED
127 * - \ref SCIP_STAGE_SOLVING
128 * - \ref SCIP_STAGE_SOLVED
129 *
130 * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
131 * process was interrupted:
132
133 * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
134 * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
135 * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
136 *
137 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
138 */
139SCIP_EXPORT
141 SCIP* scip /**< SCIP data structure */
142 );
143
144/** transforms, presolves, and solves problem using the configured concurrent solvers
145 *
146 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
147 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
148 *
149 * @pre This method can be called if @p scip is in one of the following stages:
150 * - \ref SCIP_STAGE_PROBLEM
151 * - \ref SCIP_STAGE_TRANSFORMED
152 * - \ref SCIP_STAGE_PRESOLVING
153 * - \ref SCIP_STAGE_PRESOLVED
154 * - \ref SCIP_STAGE_SOLVING
155 * - \ref SCIP_STAGE_SOLVED
156 *
157 * @post After calling this method \SCIP reaches one of the following stages depending on if and when the solution
158 * process was interrupted:
159 * - \ref SCIP_STAGE_PRESOLVING if the solution process was interrupted during presolving
160 * - \ref SCIP_STAGE_SOLVING if the solution process was interrupted during the tree search
161 * - \ref SCIP_STAGE_SOLVED if the solving process was not interrupted
162 *
163 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
164 */
165SCIP_EXPORT
167 SCIP* scip /**< SCIP data structure */
168 );
169
170/** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
171 * preserved
172 *
173 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
174 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
175 *
176 * @pre This method can be called if @p scip is in one of the following stages:
177 * - \ref SCIP_STAGE_INIT
178 * - \ref SCIP_STAGE_PROBLEM
179 * - \ref SCIP_STAGE_TRANSFORMED
180 * - \ref SCIP_STAGE_PRESOLVING
181 * - \ref SCIP_STAGE_PRESOLVED
182 * - \ref SCIP_STAGE_SOLVING
183 * - \ref SCIP_STAGE_SOLVED
184 *
185 * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
186 * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_TRANSFORMED
187 *
188 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
189 */
190SCIP_EXPORT
192 SCIP* scip, /**< SCIP data structure */
193 SCIP_Bool restart /**< should certain data be preserved for improved restarting? */
194 );
195
196/** frees all solution process data including presolving and transformed problem, only original problem is kept
197 *
198 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
199 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
200 *
201 * @pre This method can be called if @p scip is in one of the following stages:
202 * - \ref SCIP_STAGE_INIT
203 * - \ref SCIP_STAGE_PROBLEM
204 * - \ref SCIP_STAGE_TRANSFORMED
205 * - \ref SCIP_STAGE_PRESOLVING
206 * - \ref SCIP_STAGE_PRESOLVED
207 * - \ref SCIP_STAGE_SOLVING
208 * - \ref SCIP_STAGE_SOLVED
209 *
210 * @post After calling this method \SCIP reaches one of the following stages:
211 * - \ref SCIP_STAGE_INIT if the method was called from \SCIP stage \ref SCIP_STAGE_INIT
212 * - \ref SCIP_STAGE_PROBLEM if the method was called from any other of the allowed stages
213 *
214 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
215 */
216SCIP_EXPORT
218 SCIP* scip /**< SCIP data structure */
219 );
220
221/** informs \SCIP that the solving process should be interrupted as soon as possible (e.g., after the current node has
222 * been solved)
223 *
224 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
225 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
226 *
227 * @pre This method can be called if @p scip is in one of the following stages:
228 * - \ref SCIP_STAGE_PROBLEM
229 * - \ref SCIP_STAGE_TRANSFORMING
230 * - \ref SCIP_STAGE_TRANSFORMED
231 * - \ref SCIP_STAGE_INITPRESOLVE
232 * - \ref SCIP_STAGE_PRESOLVING
233 * - \ref SCIP_STAGE_EXITPRESOLVE
234 * - \ref SCIP_STAGE_PRESOLVED
235 * - \ref SCIP_STAGE_SOLVING
236 * - \ref SCIP_STAGE_SOLVED
237 * - \ref SCIP_STAGE_EXITSOLVE
238 * - \ref SCIP_STAGE_FREETRANS
239 *
240 * @note the \SCIP stage does not get changed
241 */
242SCIP_EXPORT
244 SCIP* scip /**< SCIP data structure */
245 );
246
247/** indicates whether \SCIP has been informed that the solving process should be interrupted as soon as possible
248 *
249 * This function returns whether SCIPinterruptSolve() has been called, which is different from SCIPinterrupted(),
250 * which returns whether a SIGINT signal has been received by the SCIP signal handler.
251 *
252 * @pre This method can be called if @p scip is in one of the following stages:
253 * - \ref SCIP_STAGE_PROBLEM
254 * - \ref SCIP_STAGE_TRANSFORMING
255 * - \ref SCIP_STAGE_TRANSFORMED
256 * - \ref SCIP_STAGE_INITPRESOLVE
257 * - \ref SCIP_STAGE_PRESOLVING
258 * - \ref SCIP_STAGE_EXITPRESOLVE
259 * - \ref SCIP_STAGE_PRESOLVED
260 * - \ref SCIP_STAGE_SOLVING
261 * - \ref SCIP_STAGE_SOLVED
262 * - \ref SCIP_STAGE_EXITSOLVE
263 * - \ref SCIP_STAGE_FREETRANS
264 *
265 * @note the \SCIP stage does not get changed
266 */
267SCIP_EXPORT
269 SCIP* scip /**< SCIP data structure */
270 );
271
272/** informs SCIP that the solving process should be restarted as soon as possible (e.g., after the current node has
273 * been solved)
274 *
275 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
276 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
277 *
278 * @pre This method can be called if @p scip is in one of the following stages:
279 * - \ref SCIP_STAGE_INITPRESOLVE
280 * - \ref SCIP_STAGE_PRESOLVING
281 * - \ref SCIP_STAGE_EXITPRESOLVE
282 * - \ref SCIP_STAGE_SOLVING
283 *
284 * @note the \SCIP stage does not get changed
285 */
286SCIP_EXPORT
288 SCIP* scip /**< SCIP data structure */
289 );
290
291/** returns whether we are in the restarting phase
292 *
293 * @return TRUE, if we are in the restarting phase; FALSE, otherwise
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_PRESOLVED
300 * - \ref SCIP_STAGE_INITSOLVE
301 * - \ref SCIP_STAGE_SOLVING
302 * - \ref SCIP_STAGE_SOLVED
303 * - \ref SCIP_STAGE_EXITSOLVE
304 * - \ref SCIP_STAGE_FREETRANS
305 */
306SCIP_EXPORT
308 SCIP* scip /**< SCIP data structure */
309 );
310
311/**@} */
312
313/**@addtogroup PublicReoptimizationMethods
314 *
315 * @{
316 */
317
318/** frees branch and bound tree and all solution process data; statistics, presolving data and transformed problem is
319 * preserved
320 *
321 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
322 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
323 *
324 * @pre This method can be called if @p scip is in one of the following stages:
325 * - \ref SCIP_STAGE_INIT
326 * - \ref SCIP_STAGE_PROBLEM
327 * - \ref SCIP_STAGE_TRANSFORMED
328 * - \ref SCIP_STAGE_PRESOLVING
329 * - \ref SCIP_STAGE_PRESOLVED
330 * - \ref SCIP_STAGE_SOLVING
331 * - \ref SCIP_STAGE_SOLVED
332 *
333 * @post If this method is called in \SCIP stage \ref SCIP_STAGE_INIT or \ref SCIP_STAGE_PROBLEM, the stage of
334 * \SCIP is not changed; otherwise, the \SCIP stage is changed to \ref SCIP_STAGE_PRESOLVED.
335 *
336 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
337 */
338SCIP_EXPORT
340 SCIP* scip /**< SCIP data structure */
341 );
342
343/** include specific heuristics and branching rules for reoptimization
344 *
345 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
346 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
347 *
348 * @pre This method can be called if @p scip is in one of the following stages:
349 * - \ref SCIP_STAGE_PROBLEM
350 */
351SCIP_EXPORT
353 SCIP* scip, /**< SCIP data structure */
354 SCIP_Bool enable /**< enable reoptimization (TRUE) or disable it (FALSE) */
355 );
356
357/** returns whether reoptimization is enabled or not */
358SCIP_EXPORT
360 SCIP* scip /**< SCIP data structure */
361 );
362
363/** returns the stored solutions corresponding to a given run */
364SCIP_EXPORT
366 SCIP* scip, /**< SCIP data structue */
367 int run, /**< number of the run */
368 SCIP_SOL** sols, /**< array to store solutions */
369 int solssize, /**< allocated size of the array */
370 int* nsols /**< number of solutions */
371 );
372
373/** mark all stored solutions as not updated */
374SCIP_EXPORT
376 SCIP* scip /**< SCIP data structure */
377 );
378
379/** check if the reoptimization process should be restarted
380 *
381 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
382 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
383 *
384 * @pre This method can be called if @p scip is in one of the following stages:
385 * - \ref SCIP_STAGE_TRANSFORMED
386 * - \ref SCIP_STAGE_SOLVING
387 */
388SCIP_EXPORT
390 SCIP* scip, /**< SCIP data structure */
391 SCIP_NODE* node, /**< current node of the branch and bound tree (or NULL) */
392 SCIP_Bool* restart /**< pointer to store of the reoptimitation process should be restarted */
393 );
394
395/** save bound change based on dual information in the reoptimization tree
396 *
397 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
398 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
399 *
400 * @pre This method can be called if @p scip is in one of the following stages:
401 * - \ref SCIP_STAGE_SOLVING
402 * - \ref SCIP_STAGE_SOLVED
403 */
404SCIP_EXPORT
406 SCIP* scip, /**< SCIP data structure */
407 SCIP_NODE* node, /**< node of the search tree */
408 SCIP_VAR* var, /**< variable whose bound changed */
409 SCIP_Real newbound, /**< new bound of the variable */
410 SCIP_Real oldbound /**< old bound of the variable */
411 );
412
413/** returns the optimal solution of the last iteration or NULL of none exists */
414SCIP_EXPORT
416 SCIP* scip /**< SCIP data structure */
417 );
418
419/** returns the objective coefficent of a given variable in a previous iteration
420 *
421 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
422 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
423 *
424 * @pre This method can be called if @p scip is in one of the following stages:
425 * - \ref SCIP_STAGE_PRESOLVING
426 * - \ref SCIP_STAGE_SOLVING
427 */
428SCIP_EXPORT
430 SCIP* scip, /**< SCIP data structure */
431 SCIP_VAR* var, /**< variable */
432 int run, /**< number of the run */
433 SCIP_Real* objcoef /**< pointer to store the objective coefficient */
434 );
435
436/**@} */
437
438#ifdef __cplusplus
439}
440#endif
441
442#endif
common defines and data types used in all packages of SCIP
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
SCIP_SOL * SCIPgetReoptLastOptSol(SCIP *scip)
Definition: scip_solve.c:3248
void SCIPresetReoptSolMarks(SCIP *scip)
Definition: scip_solve.c:3652
SCIP_RETCODE SCIPgetReoptOldObjCoef(SCIP *scip, SCIP_VAR *var, int run, SCIP_Real *objcoef)
Definition: scip_solve.c:3275
SCIP_RETCODE SCIPcheckReoptRestart(SCIP *scip, SCIP_NODE *node, SCIP_Bool *restart)
Definition: scip_solve.c:3676
SCIP_RETCODE SCIPaddReoptDualBndchg(SCIP *scip, SCIP_NODE *node, SCIP_VAR *var, SCIP_Real newbound, SCIP_Real oldbound)
Definition: scip_solve.c:3230
SCIP_RETCODE SCIPgetReoptSolsRun(SCIP *scip, int run, SCIP_SOL **sols, int solssize, int *nsols)
Definition: scip_solve.c:3626
SCIP_Bool SCIPisReoptEnabled(SCIP *scip)
Definition: scip_solve.c:3616
SCIP_RETCODE SCIPenableReoptimization(SCIP *scip, SCIP_Bool enable)
Definition: scip_solve.c:3153
SCIP_RETCODE SCIPfreeReoptSolve(SCIP *scip)
Definition: scip_solve.c:3399
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
Definition: scip_solve.c:232
SCIP_RETCODE SCIPrestartSolve(SCIP *scip)
Definition: scip_solve.c:3603
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2449
SCIP_RETCODE SCIPsolveConcurrent(SCIP *scip)
Definition: scip_solve.c:2961
SCIP_Bool SCIPisSolveInterrupted(SCIP *scip)
Definition: scip_solve.c:3580
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
Definition: scip_solve.c:3462
SCIP_RETCODE SCIPinterruptSolve(SCIP *scip)
Definition: scip_solve.c:3548
SCIP_RETCODE SCIPfreeSolve(SCIP *scip, SCIP_Bool restart)
Definition: scip_solve.c:3331
SCIP_Bool SCIPisInRestart(SCIP *scip)
Definition: scip_solve.c:3709
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2635
type definitions for return codes for SCIP methods
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for SCIP's main datastructure
type definitions for storing primal CIP solutions
type definitions for branch and bound tree
type definitions for problem variables