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