1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*                  This file is part of the program and library             */
4 /*         SCIP --- Solving Constraint Integer Programs                      */
5 /*                                                                           */
6 /*    Copyright (C) 2002-2021 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_copy.h
17  * @ingroup PUBLICCOREAPI
18  * @brief  public methods for problem copies
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_COPY_H__
32 #define __SCIP_SCIP_COPY_H__
33 
34 
35 #include "scip/def.h"
36 #include "scip/type_cons.h"
37 #include "scip/type_misc.h"
38 #include "scip/type_retcode.h"
39 #include "scip/type_scip.h"
40 #include "scip/type_var.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**@addtogroup CopyMethods
47  *
48  * @{
49  */
50 
51 /** copies plugins from sourcescip to targetscip; in case that a constraint handler which does not need constraints
52  *  cannot be copied, valid will return FALSE. All plugins can declare that, if their copy process failed, the
53  *  copied SCIP instance might not represent the same problem semantics as the original.
54  *  Note that in this case dual reductions might be invalid.
55  *
56  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
57  *        Also, 'passmessagehdlr' should be set to FALSE.
58  *
59  *  @note Do not change the source SCIP environment during the copying process.
60  *
61  *  @note This method does not copy Benders' plugins. To this end, the method SCIPcopyBenders() must be called
62  *        separately.
63  *
64  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
65  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
66  *
67  *  @pre This method can be called if sourcescip is in one of the following stages:
68  *       - \ref SCIP_STAGE_PROBLEM
69  *       - \ref SCIP_STAGE_TRANSFORMED
70  *       - \ref SCIP_STAGE_INITPRESOLVE
71  *       - \ref SCIP_STAGE_PRESOLVING
72  *       - \ref SCIP_STAGE_EXITPRESOLVE
73  *       - \ref SCIP_STAGE_PRESOLVED
74  *       - \ref SCIP_STAGE_INITSOLVE
75  *       - \ref SCIP_STAGE_SOLVING
76  *       - \ref SCIP_STAGE_SOLVED
77  *
78  *  @pre This method can be called if targetscip is in one of the following stages:
79  *       - \ref SCIP_STAGE_INIT
80  *       - \ref SCIP_STAGE_FREE
81  *
82  *  @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
83  *        process was interrupted:
84  *       - \ref SCIP_STAGE_PROBLEM
85  *
86  *  @note sourcescip stage does not get changed
87  *
88  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
89  */
90 SCIP_EXPORT
91 SCIP_RETCODE SCIPcopyPlugins(
92    SCIP*                 sourcescip,         /**< source SCIP data structure */
93    SCIP*                 targetscip,         /**< target SCIP data structure */
94    SCIP_Bool             copyreaders,        /**< should the file readers be copied */
95    SCIP_Bool             copypricers,        /**< should the variable pricers be copied */
96    SCIP_Bool             copyconshdlrs,      /**< should the constraint handlers be copied */
97    SCIP_Bool             copyconflicthdlrs,  /**< should the conflict handlers be copied */
98    SCIP_Bool             copypresolvers,     /**< should the presolvers be copied */
99    SCIP_Bool             copyrelaxators,     /**< should the relaxation handler be copied */
100    SCIP_Bool             copyseparators,     /**< should the separators be copied */
101    SCIP_Bool             copypropagators,    /**< should the propagators be copied */
102    SCIP_Bool             copyheuristics,     /**< should the heuristics be copied */
103    SCIP_Bool             copyeventhdlrs,     /**< should the event handlers be copied */
104    SCIP_Bool             copynodeselectors,  /**< should the node selectors be copied */
105    SCIP_Bool             copybranchrules,    /**< should the branchrules be copied */
106    SCIP_Bool             copydisplays,       /**< should the display columns be copied */
107    SCIP_Bool             copydialogs,        /**< should the dialogs be copied */
108    SCIP_Bool             copytables,         /**< should the statistics tables be copied */
109    SCIP_Bool             copynlpis,          /**< should the NLPIs be copied */
110    SCIP_Bool             passmessagehdlr,    /**< should the message handler be passed */
111    SCIP_Bool*            valid               /**< pointer to store whether plugins, in particular all constraint
112                                               *   handlers which do not need constraints were validly copied */
113    );
114 
115 /** copies all Benders' decomposition plugins
116  *
117  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
118  *  @note the 'threadsafe' parameter must be set to TRUE if you are absolutely certain that the source and target
119  *        SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
120  *        typically incurs a performance cost.
121  *
122  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
123  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
124  *
125  *  @pre This method can be called if sourcescip is in one of the following stages:
126  *       - \ref SCIP_STAGE_PROBLEM
127  *       - \ref SCIP_STAGE_TRANSFORMED
128  *       - \ref SCIP_STAGE_INITPRESOLVE
129  *       - \ref SCIP_STAGE_PRESOLVING
130  *       - \ref SCIP_STAGE_EXITPRESOLVE
131  *       - \ref SCIP_STAGE_PRESOLVED
132  *       - \ref SCIP_STAGE_INITSOLVE
133  *       - \ref SCIP_STAGE_SOLVING
134  *       - \ref SCIP_STAGE_SOLVED
135  *
136  *  @pre This method can be called if targetscip is in one of the following stages:
137  *       - \ref SCIP_STAGE_INIT
138  *       - \ref SCIP_STAGE_FREE
139  *
140  *  @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
141  *        process was interrupted:
142  *       - \ref SCIP_STAGE_PROBLEM
143  *
144  *  @note sourcescip stage does not get changed
145  *
146  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
147  */
148 SCIP_EXPORT
149 SCIP_RETCODE SCIPcopyBenders(
150    SCIP*                 sourcescip,         /**< source SCIP data structure */
151    SCIP*                 targetscip,         /**< target SCIP data structure */
152    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
153                                               *   target variables; if NULL the transfer of cuts is not possible */
154    SCIP_Bool             threadsafe,         /**< FALSE, if data can be safely shared between the source and target
155                                                   SCIP, otherwise TRUE. This is usually set to FALSE */
156    SCIP_Bool*            valid               /**< pointer to store whether all plugins were validly copied */
157    );
158 
159 /** create a problem by copying the problem data of the source SCIP
160  *
161  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
162  *  @note Do not change the source SCIP environment during the copying process
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 sourcescip is in one of the following stages:
167  *       - \ref SCIP_STAGE_PROBLEM
168  *       - \ref SCIP_STAGE_TRANSFORMED
169  *       - \ref SCIP_STAGE_INITPRESOLVE
170  *       - \ref SCIP_STAGE_PRESOLVING
171  *       - \ref SCIP_STAGE_EXITPRESOLVE
172  *       - \ref SCIP_STAGE_PRESOLVED
173  *       - \ref SCIP_STAGE_INITSOLVE
174  *       - \ref SCIP_STAGE_SOLVING
175  *       - \ref SCIP_STAGE_SOLVED
176  *
177  *  @pre This method can be called if targetscip is in one of the following stages:
178  *       - \ref SCIP_STAGE_INIT
179  *       - \ref SCIP_STAGE_PROBLEM
180  *       - \ref SCIP_STAGE_TRANSFORMED
181  *       - \ref SCIP_STAGE_INITPRESOLVE
182  *       - \ref SCIP_STAGE_PRESOLVING
183  *       - \ref SCIP_STAGE_EXITPRESOLVE
184  *       - \ref SCIP_STAGE_PRESOLVED
185  *       - \ref SCIP_STAGE_INITSOLVE
186  *       - \ref SCIP_STAGE_SOLVING
187  *       - \ref SCIP_STAGE_SOLVED
188  *       - \ref SCIP_STAGE_FREE
189  *
190  *  @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
191  *        process was interrupted:
192  *       - \ref SCIP_STAGE_PROBLEM
193  *
194  *  @note sourcescip stage does not get changed
195  *
196  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
197  */
198 SCIP_EXPORT
199 SCIP_RETCODE SCIPcopyProb(
200    SCIP*                 sourcescip,         /**< source SCIP data structure */
201    SCIP*                 targetscip,         /**< target SCIP data structure */
202    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
203                                               *   target variables, or NULL */
204    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
205                                               *   target constraints, or NULL */
206    SCIP_Bool             global,             /**< create a global or a local copy? */
207    const char*           name                /**< problem name */
208    );
209 
210 /** create a problem by copying the original problem data of the source SCIP
211  *
212  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
213  *  @note Do not change the source SCIP environment during the copying process
214  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
215  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
216  *
217  *  @pre This method can be called if sourcescip is in one of the following stages:
218  *       - \ref SCIP_STAGE_PROBLEM
219  *       - \ref SCIP_STAGE_TRANSFORMED
220  *       - \ref SCIP_STAGE_INITPRESOLVE
221  *       - \ref SCIP_STAGE_PRESOLVING
222  *       - \ref SCIP_STAGE_EXITPRESOLVE
223  *       - \ref SCIP_STAGE_PRESOLVED
224  *       - \ref SCIP_STAGE_INITSOLVE
225  *       - \ref SCIP_STAGE_SOLVING
226  *       - \ref SCIP_STAGE_SOLVED
227  *
228  *  @pre This method can be called if targetscip is in one of the following stages:
229  *       - \ref SCIP_STAGE_INIT
230  *       - \ref SCIP_STAGE_FREE
231  *
232  *  @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
233  *        process was interrupted:
234  *       - \ref SCIP_STAGE_PROBLEM
235  *
236  *  @note sourcescip stage does not get changed
237  *
238  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
239  */
240 SCIP_EXPORT
241 SCIP_RETCODE SCIPcopyOrigProb(
242    SCIP*                 sourcescip,         /**< source SCIP data structure */
243    SCIP*                 targetscip,         /**< target SCIP data structure */
244    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
245                                               *   target variables, or NULL */
246    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
247                                               *   target constraints, or NULL  */
248    const char*           name                /**< problem name of target */
249    );
250 
251 /** enables constraint compression.
252  *
253  *  If constraint compression is enabled, fixed variables will be treated as constants
254  *  by all constraints that are copied after calling this method.
255  *
256  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
257  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
258  *
259  *  @pre This method can be called if scip is in one of the following stages:
260  *       - \ref SCIP_STAGE_PROBLEM
261  *
262  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
263  */
264 SCIP_EXPORT
265 SCIP_RETCODE SCIPenableConsCompression(
266    SCIP*                 scip                /**< source SCIP data structure */
267    );
268 
269 /** is constraint compression enabled?
270  *
271  *  If constraint compression is enabled, fixed variables can be treated as constants
272  *  by all constraints that are copied after calling this method.
273  *
274  *  @return TRUE if problem constraint compression is enabled, otherwise FALSE
275  *
276  *  @pre This method can be called if scip is in one of the following stages:
277   *      - \ref SCIP_STAGE_PROBLEM
278   *      - \ref SCIP_STAGE_TRANSFORMING
279  *       - \ref SCIP_STAGE_TRANSFORMED
280  *       - \ref SCIP_STAGE_INITPRESOLVE
281  *       - \ref SCIP_STAGE_PRESOLVING
282  *       - \ref SCIP_STAGE_EXITPRESOLVE
283  *       - \ref SCIP_STAGE_PRESOLVED
284  *       - \ref SCIP_STAGE_INITSOLVE
285  *       - \ref SCIP_STAGE_SOLVING
286  *       - \ref SCIP_STAGE_SOLVED
287  *       - \ref SCIP_STAGE_EXITSOLVE
288  *       - \ref SCIP_STAGE_FREETRANS
289  *
290  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
291  */
292 SCIP_EXPORT
293 SCIP_Bool SCIPisConsCompressionEnabled(
294    SCIP*                 scip                /**< source SCIP data structure */
295    );
296 
297 /** returns copy of the source variable; if there already is a copy of the source variable in the variable hash map,
298  *  it is just returned as target variable; otherwise, if the variables it not marked as relaxation-only, a new variable
299  *  will be created and added to the target SCIP; this created variable is added to the variable hash map and returned as target variable;
300  *  relaxation-only variables are not copied and FALSE is returned in *success
301  *
302  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
303  *  @note Do not change the source SCIP environment during the copying process
304  *  @note if a new variable was created, this variable will be added to the target-SCIP, but it is not captured
305  *
306  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
307  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
308  *
309  *  @pre This method can be called if sourcescip is in one of the following stages:
310  *       - \ref SCIP_STAGE_PROBLEM
311  *       - \ref SCIP_STAGE_TRANSFORMED
312  *       - \ref SCIP_STAGE_INITPRESOLVE
313  *       - \ref SCIP_STAGE_PRESOLVING
314  *       - \ref SCIP_STAGE_EXITPRESOLVE
315  *       - \ref SCIP_STAGE_PRESOLVED
316  *       - \ref SCIP_STAGE_INITSOLVE
317  *       - \ref SCIP_STAGE_SOLVING
318  *       - \ref SCIP_STAGE_SOLVED
319  *
320  *  @pre This method can be called if targetscip is in one of the following stages:
321  *       - \ref SCIP_STAGE_PROBLEM
322  *       - \ref SCIP_STAGE_TRANSFORMED
323  *       - \ref SCIP_STAGE_INITPRESOLVE
324  *       - \ref SCIP_STAGE_PRESOLVING
325  *       - \ref SCIP_STAGE_EXITPRESOLVE
326  *       - \ref SCIP_STAGE_SOLVING
327  *
328  *  @note targetscip stage does not get changed
329  *
330  *  @note sourcescip stage does not get changed
331  *
332  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
333  */
334 SCIP_EXPORT
335 SCIP_RETCODE SCIPgetVarCopy(
336    SCIP*                 sourcescip,         /**< source SCIP data structure */
337    SCIP*                 targetscip,         /**< target SCIP data structure */
338    SCIP_VAR*             sourcevar,          /**< source variable */
339    SCIP_VAR**            targetvar,          /**< pointer to store the target variable */
340    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables to the corresponding
341                                               *   target variables, or NULL */
342    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
343                                               *   target constraints, or NULL */
344    SCIP_Bool             global,             /**< should global or local bounds be used? */
345    SCIP_Bool*            success             /**< pointer to store whether the copying was successful or not */
346    );
347 
348 /** Copies all active (thus unfixed) variables from source-SCIP, except those that are marked as relaxation only,
349  *  and adds these variable to the target-SCIP.
350  *
351  *  The mapping between these variables are stored in the variable hashmap.
352  *
353  *  The target-SCIP has to be in problem creation stage.
354  *
355  *  @note the variables are added to the target-SCIP but not captured
356  *
357  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
358  *  @note Do not change the source SCIP environment during the copying process
359  *
360  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
361  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
362  *
363  *  @pre This method can be called if sourcescip is in one of the following stages:
364  *       - \ref SCIP_STAGE_PROBLEM
365  *       - \ref SCIP_STAGE_TRANSFORMED
366  *       - \ref SCIP_STAGE_INITPRESOLVE
367  *       - \ref SCIP_STAGE_PRESOLVING
368  *       - \ref SCIP_STAGE_EXITPRESOLVE
369  *       - \ref SCIP_STAGE_PRESOLVED
370  *       - \ref SCIP_STAGE_INITSOLVE
371  *       - \ref SCIP_STAGE_SOLVING
372  *       - \ref SCIP_STAGE_SOLVED
373  *
374  *  @pre This method can be called if targetscip is in one of the following stages:
375  *       - \ref SCIP_STAGE_PROBLEM
376  *
377  *  @note sourcescip stage does not get changed
378  *
379  *  @note targetscip stage does not get changed
380  *
381  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
382  */
383 SCIP_EXPORT
384 SCIP_RETCODE SCIPcopyVars(
385    SCIP*                 sourcescip,         /**< source SCIP data structure */
386    SCIP*                 targetscip,         /**< target SCIP data structure */
387    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables to the corresponding
388                                               *   target variables, or NULL */
389    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
390                                               *   target constraints, or NULL */
391    SCIP_VAR**            fixedvars,          /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
392    SCIP_Real*            fixedvals,          /**< array of fixing values for target SCIP variables, or NULL */
393    int                   nfixedvars,         /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
394    SCIP_Bool             global              /**< should global or local bounds be used? */
395    );
396 
397 /** copies all original variables from source-SCIP and adds these variable to the target-SCIP; the mapping between these
398  *  variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed and aggregated
399  *  variables do not get copied
400  *
401  *  @note the variables are added to the target-SCIP but not captured
402  *
403  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
404  *  @note Do not change the source SCIP environment during the copying process
405  *
406  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
407  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
408  *
409  *  @pre This method can be called if sourcescip is in one of the following stages:
410  *       - \ref SCIP_STAGE_PROBLEM
411  *       - \ref SCIP_STAGE_TRANSFORMED
412  *       - \ref SCIP_STAGE_INITPRESOLVE
413  *       - \ref SCIP_STAGE_PRESOLVING
414  *       - \ref SCIP_STAGE_EXITPRESOLVE
415  *       - \ref SCIP_STAGE_PRESOLVED
416  *       - \ref SCIP_STAGE_INITSOLVE
417  *       - \ref SCIP_STAGE_SOLVING
418  *       - \ref SCIP_STAGE_SOLVED
419  *
420  *  @pre This method can be called if targetscip is in one of the following stages:
421  *       - \ref SCIP_STAGE_PROBLEM
422  *
423  *  @note sourcescip stage does not get changed
424  *
425  *  @note targetscip stage does not get changed
426  *
427  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
428  */
429 SCIP_EXPORT
430 SCIP_RETCODE SCIPcopyOrigVars(
431    SCIP*                 sourcescip,         /**< source SCIP data structure */
432    SCIP*                 targetscip,         /**< target SCIP data structure */
433    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables to the corresponding
434                                               *   target variables, or NULL */
435    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
436                                               *   target constraints, or NULL */
437    SCIP_VAR**            fixedvars,          /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
438    SCIP_Real*            fixedvals,          /**< array of fixing values for target SCIP variables, or NULL */
439    int                   nfixedvars          /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
440    );
441 
442 /** merges the histories of variables from a source SCIP into a target SCIP. The two data structures should point to
443  *  different SCIP instances.
444  *
445  *  @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
446  *        \p targetscip denotes the original instance
447  */
448 
449 SCIP_EXPORT
450 SCIP_RETCODE SCIPmergeVariableStatistics(
451    SCIP*                 sourcescip,         /**< source SCIP data structure */
452    SCIP*                 targetscip,         /**< target SCIP data structure */
453    SCIP_VAR**            sourcevars,         /**< source variables for history merge, NULL entries are ignored */
454    SCIP_VAR**            targetvars,         /**< target variables for history merge, NULL entries are ignored */
455    int                   nvars               /**< number of variables in both variable arrays */
456    );
457 
458 /** translates a solution from a subscip to the main scip
459  *
460  * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
461  * are represented as NULL entry in the \p subvars array.
462  *
463  * @note This method allocates a new solution of the main \p scip that needs to be freed by the user.
464  */
465 SCIP_EXPORT
466 SCIP_RETCODE SCIPtranslateSubSol(
467    SCIP*                 scip,               /**< SCIP data structure of the original problem */
468    SCIP*                 subscip,            /**< SCIP data structure of the subproblem */
469    SCIP_SOL*             subsol,             /**< solution of the subproblem */
470    SCIP_HEUR*            heur,               /**< heuristic that found the solution */
471    SCIP_VAR**            subvars,            /**< the variables from the subproblem in the same order as the main \p scip */
472    SCIP_SOL**            newsol              /**< buffer to store pointer to created solution in main SCIP */
473    );
474 
475 /** checks the solutions from the subscip and adds the first one that is found feasible to the master SCIP
476  *
477  * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
478  * are represented as NULL entry in the \p subvars array.
479  */
480 SCIP_EXPORT
481 SCIP_RETCODE SCIPtranslateSubSols(
482    SCIP*                 scip,               /**< the SCIP data structure */
483    SCIP*                 subscip,            /**< SCIP data structure of the subproblem */
484    SCIP_HEUR*            heur,               /**< heuristic that found the solution */
485    SCIP_VAR**            subvars,            /**< the variables from the subproblem in the same order as the main \p scip */
486    SCIP_Bool*            success,            /**< pointer to store, whether new solution was found */
487    int*                  solindex            /**< pointer to store solution index of stored solution, or NULL if not of interest */
488    );
489 
490 /** returns copy of the source constraint; if there already is a copy of the source constraint in the constraint hash
491  *  map, it is just returned as target constraint; elsewise a new constraint will be created; this created constraint is
492  *  added to the constraint hash map and returned as target constraint; the variable map is used to map the variables of
493  *  the source SCIP to the variables of the target SCIP
494  *
495  *  @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
496  *           be declared feasible even if it violates this particular constraint.  This constellation should only be
497  *           used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
498  *           to the variable's local bounds.
499  *
500  *  @note The constraint is not added to the target SCIP. You can check whether a constraint is added by calling
501  *        SCIPconsIsAdded(). (If you mix SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add
502  *        explicitly and what is already added.)
503  *
504  *  @note The constraint is always captured, either during the creation of the copy or after finding the copy of the
505  *        constraint in the constraint hash map
506  *
507  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
508  *  @note Do not change the source SCIP environment during the copying process
509  *
510  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
511  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
512  *
513  *  @pre This method can be called if sourcescip is in one of the following stages:
514  *       - \ref SCIP_STAGE_PROBLEM
515  *       - \ref SCIP_STAGE_TRANSFORMED
516  *       - \ref SCIP_STAGE_INITPRESOLVE
517  *       - \ref SCIP_STAGE_PRESOLVING
518  *       - \ref SCIP_STAGE_EXITPRESOLVE
519  *       - \ref SCIP_STAGE_PRESOLVED
520  *       - \ref SCIP_STAGE_INITSOLVE
521  *       - \ref SCIP_STAGE_SOLVING
522  *       - \ref SCIP_STAGE_SOLVED
523  *
524  *  @pre This method can be called if targetscip is in one of the following stages:
525  *       - \ref SCIP_STAGE_PROBLEM
526  *       - \ref SCIP_STAGE_TRANSFORMING
527  *       - \ref SCIP_STAGE_INITPRESOLVE
528  *       - \ref SCIP_STAGE_PRESOLVING
529  *       - \ref SCIP_STAGE_EXITPRESOLVE
530  *       - \ref SCIP_STAGE_PRESOLVED
531  *       - \ref SCIP_STAGE_SOLVING
532  *       - \ref SCIP_STAGE_EXITSOLVE
533  *
534  *  @note sourcescip stage does not get changed
535  *
536  *  @note targetscip stage does not get changed
537  *
538  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
539  */
540 SCIP_EXPORT
541 SCIP_RETCODE SCIPgetConsCopy(
542    SCIP*                 sourcescip,         /**< source SCIP data structure */
543    SCIP*                 targetscip,         /**< target SCIP data structure */
544    SCIP_CONS*            sourcecons,         /**< source constraint of the source SCIP */
545    SCIP_CONS**           targetcons,         /**< pointer to store the created target constraint */
546    SCIP_CONSHDLR*        sourceconshdlr,     /**< source constraint handler for this constraint */
547    SCIP_HASHMAP*         varmap,             /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
548                                               *   variables of the target SCIP, or NULL */
549    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
550                                               *   target constraints, or NULL */
551    const char*           name,               /**< name of constraint, or NULL if the name of the source constraint should be used */
552    SCIP_Bool             initial,            /**< should the LP relaxation of constraint be in the initial LP? */
553    SCIP_Bool             separate,           /**< should the constraint be separated during LP processing? */
554    SCIP_Bool             enforce,            /**< should the constraint be enforced during node processing? */
555    SCIP_Bool             check,              /**< should the constraint be checked for feasibility? */
556    SCIP_Bool             propagate,          /**< should the constraint be propagated during node processing? */
557    SCIP_Bool             local,              /**< is constraint only valid locally? */
558    SCIP_Bool             modifiable,         /**< is constraint modifiable (subject to column generation)? */
559    SCIP_Bool             dynamic,            /**< is constraint subject to aging? */
560    SCIP_Bool             removable,          /**< should the relaxation be removed from the LP due to aging or cleanup? */
561    SCIP_Bool             stickingatnode,     /**< should the constraint always be kept at the node where it was added, even
562                                               *   if it may be moved to a more global node? */
563    SCIP_Bool             global,             /**< create a global or a local copy? */
564    SCIP_Bool*            valid               /**< pointer to store whether the copying was valid or not */
565    );
566 
567 /** copies constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
568  *  variables between the source and the target SCIP a hash map can be given; if the variable hash
569  *  map is NULL or necessary variable mapping is missing, the required variables are created in the
570  *  target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
571  *  the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
572  *  between the constraints of the source and target-SCIP is stored
573  *
574  *  *valid is set to TRUE iff all constraints that are marked as checked or enforced were copied successfully.
575  *  If other constraints could not be copied, *valid can still be set to TRUE.
576  *
577  *  @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
578  *        SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
579  *        added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
580  *
581  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
582  *  @note Do not change the source SCIP environment during the copying process
583  *
584  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
585  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
586  *
587  *  @pre This method can be called if sourcescip is in one of the following stages:
588  *       - \ref SCIP_STAGE_PROBLEM
589  *       - \ref SCIP_STAGE_TRANSFORMED
590  *       - \ref SCIP_STAGE_INITPRESOLVE
591  *       - \ref SCIP_STAGE_PRESOLVING
592  *       - \ref SCIP_STAGE_EXITPRESOLVE
593  *       - \ref SCIP_STAGE_PRESOLVED
594  *       - \ref SCIP_STAGE_INITSOLVE
595  *       - \ref SCIP_STAGE_SOLVING
596  *       - \ref SCIP_STAGE_SOLVED
597  *
598  *  @pre This method can be called if targetscip is in one of the following stages:
599  *       - \ref SCIP_STAGE_PROBLEM
600  *
601  *  @note sourcescip stage does not get changed
602  *
603  *  @note targetscip stage does not get changed
604  *
605  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
606  */
607 SCIP_EXPORT
608 SCIP_RETCODE SCIPcopyConss(
609    SCIP*                 sourcescip,         /**< source SCIP data structure */
610    SCIP*                 targetscip,         /**< target SCIP data structure */
611    SCIP_HASHMAP*         varmap,             /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
612                                               *   variables of the target SCIP, or NULL */
613    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
614                                               *   target constraints, or NULL */
615    SCIP_Bool             global,             /**< create a global or a local copy? */
616    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance?
617                                               *   If TRUE, the modifiable flag of constraints will be copied. */
618    SCIP_Bool*            valid               /**< pointer to store whether all checked or enforced constraints were validly copied */
619    );
620 
621 /** copies all original constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
622  *  variables between the source and the target SCIP a hash map can be given; if the variable hash
623  *  map is NULL or necessary variable mapping is missing, the required variables are created in the
624  *  target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
625  *  the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
626  *  between the constraints of the source and target-SCIP is stored
627  *
628  *  @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
629  *        SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
630  *        added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
631  *
632  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
633  *  @note Do not change the source SCIP environment during the copying process
634  *
635  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
636  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
637  *
638  *  @pre This method can be called if sourcescip is in one of the following stages:
639  *       - \ref SCIP_STAGE_PROBLEM
640  *       - \ref SCIP_STAGE_TRANSFORMED
641  *       - \ref SCIP_STAGE_INITPRESOLVE
642  *       - \ref SCIP_STAGE_PRESOLVING
643  *       - \ref SCIP_STAGE_EXITPRESOLVE
644  *       - \ref SCIP_STAGE_PRESOLVED
645  *       - \ref SCIP_STAGE_INITSOLVE
646  *       - \ref SCIP_STAGE_SOLVING
647  *       - \ref SCIP_STAGE_SOLVED
648  *
649  *  @pre This method can be called if targetscip is in one of the following stages:
650  *       - \ref SCIP_STAGE_PROBLEM
651  *
652  *  @note sourcescip stage does not get changed
653  *
654  *  @note targetscip stage does not get changed
655  *
656  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
657  */
658 SCIP_EXPORT
659 SCIP_RETCODE SCIPcopyOrigConss(
660    SCIP*                 sourcescip,         /**< source SCIP data structure */
661    SCIP*                 targetscip,         /**< target SCIP data structure */
662    SCIP_HASHMAP*         varmap,             /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
663                                               *   variables of the target SCIP, or NULL */
664    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
665                                               *   target constraints, or NULL */
666    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance?
667                                               *   If TRUE, the modifiable flag of constraints will be copied. */
668    SCIP_Bool*            valid               /**< pointer to store whether all constraints were validly copied */
669    );
670 
671 /** convert all active cuts from cutpool to linear constraints
672  *
673  *  @note Do not change the source SCIP environment during the copying process
674  *
675  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
676  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
677  *
678  *  @pre This method can be called if SCIP is in one of the following stages:
679  *       - \ref SCIP_STAGE_PROBLEM
680  *       - \ref SCIP_STAGE_INITPRESOLVE
681  *       - \ref SCIP_STAGE_PRESOLVING
682  *       - \ref SCIP_STAGE_EXITPRESOLVE
683  *       - \ref SCIP_STAGE_PRESOLVED
684  *       - \ref SCIP_STAGE_SOLVING
685  *       - \ref SCIP_STAGE_EXITSOLVE
686  *
687  *  @note SCIP stage does not get changed
688  *
689  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
690  */
691 SCIP_EXPORT
692 SCIP_RETCODE SCIPconvertCutsToConss(
693    SCIP*                 scip,               /**< SCIP data structure */
694    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
695                                               *   target variables, or NULL */
696    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
697                                               *   target constraints, or NULL */
698    SCIP_Bool             global,             /**< create a global or a local copy? */
699    int*                  ncutsadded          /**< pointer to store number of added cuts, or NULL */
700    );
701 
702 /** copies all active cuts from cutpool of sourcescip to linear constraints in targetscip
703  *
704  *  Cuts that contain variables that are marked as relaxation-only are skipped.
705  *
706  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
707  *  @note Do not change the source SCIP environment during the copying process
708  *
709  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
710  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
711  *
712  *  @pre This method can be called if sourcescip is in one of the following stages:
713  *       - \ref SCIP_STAGE_PROBLEM
714  *       - \ref SCIP_STAGE_TRANSFORMED
715  *       - \ref SCIP_STAGE_INITPRESOLVE
716  *       - \ref SCIP_STAGE_PRESOLVING
717  *       - \ref SCIP_STAGE_EXITPRESOLVE
718  *       - \ref SCIP_STAGE_PRESOLVED
719  *       - \ref SCIP_STAGE_SOLVING
720  *       - \ref SCIP_STAGE_SOLVED
721  *       - \ref SCIP_STAGE_EXITSOLVE
722  *
723  *  @pre This method can be called if targetscip is in one of the following stages:
724  *       - \ref SCIP_STAGE_PROBLEM
725  *       - \ref SCIP_STAGE_INITPRESOLVE
726  *       - \ref SCIP_STAGE_PRESOLVING
727  *       - \ref SCIP_STAGE_EXITPRESOLVE
728  *       - \ref SCIP_STAGE_PRESOLVED
729  *       - \ref SCIP_STAGE_SOLVING
730  *       - \ref SCIP_STAGE_EXITSOLVE
731  *
732  *  @note sourcescip stage does not get changed
733  *
734  *  @note targetscip stage does not get changed
735  *
736  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
737  */
738 SCIP_EXPORT
739 SCIP_RETCODE SCIPcopyCuts(
740    SCIP*                 sourcescip,         /**< source SCIP data structure */
741    SCIP*                 targetscip,         /**< target SCIP data structure */
742    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
743                                               *   target variables, or NULL */
744    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
745                                               *   target constraints, or NULL */
746    SCIP_Bool             global,             /**< create a global or a local copy? */
747    int*                  ncutsadded          /**< pointer to store number of copied cuts, or NULL */
748    );
749 
750 /** copies all active conflicts from the conflict pool of sourcescip and adds them as linear constraints to targetscip
751  *
752  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
753  *  @note Do not change the source SCIP environment during the copying process
754  *
755  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
756  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
757  *
758  *  @pre This method can be called if sourcescip is in one of the following stages:
759  *       - \ref SCIP_STAGE_PROBLEM
760  *       - \ref SCIP_STAGE_TRANSFORMED
761  *       - \ref SCIP_STAGE_INITPRESOLVE
762  *       - \ref SCIP_STAGE_PRESOLVING
763  *       - \ref SCIP_STAGE_EXITPRESOLVE
764  *       - \ref SCIP_STAGE_PRESOLVED
765  *       - \ref SCIP_STAGE_SOLVING
766  *       - \ref SCIP_STAGE_SOLVED
767  *       - \ref SCIP_STAGE_EXITSOLVE
768  *
769  *  @pre This method can be called if targetscip is in one of the following stages:
770  *       - \ref SCIP_STAGE_PROBLEM
771  *       - \ref SCIP_STAGE_INITPRESOLVE
772  *       - \ref SCIP_STAGE_PRESOLVING
773  *       - \ref SCIP_STAGE_EXITPRESOLVE
774  *       - \ref SCIP_STAGE_PRESOLVED
775  *       - \ref SCIP_STAGE_SOLVING
776  *       - \ref SCIP_STAGE_EXITSOLVE
777  *
778  *  @note sourcescip stage does not change
779  *
780  *  @note targetscip stage does not change
781  *
782  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
783  */
784 SCIP_EXPORT
785 SCIP_RETCODE SCIPcopyConflicts(
786    SCIP*                 sourcescip,         /**< source SCIP data structure */
787    SCIP*                 targetscip,         /**< target SCIP data structure */
788    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
789                                               *   target variables, or NULL */
790    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
791                                               *   target constraints, or NULL */
792    SCIP_Bool             global,             /**< create a global or a local copy? */
793    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance?
794                                               *   If TRUE, the modifiable flag of constraints will be copied. */
795    SCIP_Bool*            valid               /**< pointer to store whether all constraints were validly copied */
796    );
797 
798 /** copies implications and cliques of sourcescip to targetscip
799  *
800  *  This function should be called for a targetscip in transformed stage. It can save time in presolving of the
801  *  targetscip, since implications and cliques are copied.
802  *
803  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
804  *  @note Do not change the source SCIP environment during the copying process
805  *
806  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
807  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
808  *
809  *  @pre This method can be called if sourcescip is in one of the following stages:
810  *       - \ref SCIP_STAGE_TRANSFORMED
811  *       - \ref SCIP_STAGE_INITPRESOLVE
812  *       - \ref SCIP_STAGE_PRESOLVING
813  *       - \ref SCIP_STAGE_EXITPRESOLVE
814  *       - \ref SCIP_STAGE_PRESOLVED
815  *       - \ref SCIP_STAGE_SOLVING
816  *       - \ref SCIP_STAGE_SOLVED
817  *       - \ref SCIP_STAGE_EXITSOLVE
818  *
819  *  @pre This method can be called if targetscip is in one of the following stages:
820  *       - \ref SCIP_STAGE_TRANSFORMED
821  *       - \ref SCIP_STAGE_INITPRESOLVE
822  *       - \ref SCIP_STAGE_PRESOLVING
823  *       - \ref SCIP_STAGE_EXITPRESOLVE
824  *       - \ref SCIP_STAGE_PRESOLVED
825  *       - \ref SCIP_STAGE_INITSOLVE
826  *       - \ref SCIP_STAGE_SOLVING
827  *
828  *  @note sourcescip stage does not get changed
829  *
830  *  @note targetscip stage does not get changed
831  *
832  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
833  */
834 SCIP_EXPORT
835 SCIP_RETCODE SCIPcopyImplicationsCliques(
836    SCIP*                 sourcescip,         /**< source SCIP data structure */
837    SCIP*                 targetscip,         /**< target SCIP data structure */
838    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
839                                               *   target variables, or NULL */
840    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
841                                               *   target constraints, or NULL */
842    SCIP_Bool             global,             /**< create a global or a local copy? */
843    SCIP_Bool*            infeasible,         /**< pointer to store whether an infeasibility was detected */
844    int*                  nbdchgs,            /**< pointer to store the number of performed bound changes, or NULL */
845    int*                  ncopied             /**< pointer to store number of copied implications and cliques, or NULL */
846    );
847 
848 /** copies parameter settings from sourcescip to targetscip
849  *
850  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
851  *  @note Do not change the source SCIP environment during the copying process
852  *
853  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
854  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
855  *
856  *  @pre This method can be called if sourcescip is in one of the following stages:
857  *       - \ref SCIP_STAGE_PROBLEM
858  *       - \ref SCIP_STAGE_TRANSFORMED
859  *       - \ref SCIP_STAGE_INITPRESOLVE
860  *       - \ref SCIP_STAGE_PRESOLVING
861  *       - \ref SCIP_STAGE_EXITPRESOLVE
862  *       - \ref SCIP_STAGE_PRESOLVED
863  *       - \ref SCIP_STAGE_INITSOLVE
864  *       - \ref SCIP_STAGE_SOLVING
865  *       - \ref SCIP_STAGE_SOLVED
866  *
867  *  @pre This method can be called if targetscip is in one of the following stages:
868  *       - \ref SCIP_STAGE_INIT
869  *       - \ref SCIP_STAGE_PROBLEM
870  *       - \ref SCIP_STAGE_FREE
871  *
872  *  @note sourcescip stage does not get changed
873  *
874  *  @note targetscip stage does not get changed
875  *
876  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
877  */
878 SCIP_EXPORT
879 SCIP_RETCODE SCIPcopyParamSettings(
880    SCIP*                 sourcescip,         /**< source SCIP data structure */
881    SCIP*                 targetscip          /**< target SCIP data structure */
882    );
883 
884 /** gets depth of current scip instance (increased by each copy call)
885  *
886  *  @return Depth of subscip of SCIP is returned.
887  *
888  *  @pre This method can be called if SCIP is in one of the following stages:
889  *       - \ref SCIP_STAGE_PROBLEM
890  *       - \ref SCIP_STAGE_TRANSFORMING
891  *       - \ref SCIP_STAGE_TRANSFORMED
892  *       - \ref SCIP_STAGE_INITPRESOLVE
893  *       - \ref SCIP_STAGE_PRESOLVING
894  *       - \ref SCIP_STAGE_EXITPRESOLVE
895  *       - \ref SCIP_STAGE_PRESOLVED
896  *       - \ref SCIP_STAGE_INITSOLVE
897  *       - \ref SCIP_STAGE_SOLVING
898  *       - \ref SCIP_STAGE_SOLVED
899  *       - \ref SCIP_STAGE_EXITSOLVE
900  *       - \ref SCIP_STAGE_FREETRANS
901  *
902  *  @note SCIP stage does not get changed
903  *
904  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
905  */
906 SCIP_EXPORT
907 int SCIPgetSubscipDepth(
908    SCIP*                 scip                /**< SCIP data structure */
909    );
910 
911 /** sets depth of scip instance
912  *
913  *  @pre This method can be called if SCIP is in one of the following stages:
914  *       - \ref SCIP_STAGE_PROBLEM
915  *
916  *  @note SCIP stage does not get changed
917  *
918  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
919  */
920 SCIP_EXPORT
921 void SCIPsetSubscipDepth(
922    SCIP*                 scip,               /**< SCIP data structure */
923    int                   newdepth            /**< new subscip depth */
924    );
925 
926 /** copies source SCIP to target SCIP; the copying process is done in the following order:
927  *  1) copy the plugins
928  *  2) copy the settings
929  *  3) create problem data in target-SCIP and copy the problem data of the source-SCIP
930  *  4) copy all active variables except those are marked as relaxation-only
931  *  5) copy all constraints
932  *
933  *  The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
934  *  otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrig().
935  *
936  *  @note all variables and constraints which are created in the target-SCIP are not (user) captured
937  *
938  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
939  *        Also, 'passmessagehdlr' should be set to FALSE.
940  *  @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
941  *        SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
942  *        typically incurs a performance cost.
943  *  @note Do not change the source SCIP environment during the copying process
944  *
945  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
946  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
947  *
948  *  @pre This method can be called if sourcescip is in one of the following stages:
949  *       - \ref SCIP_STAGE_PROBLEM
950  *       - \ref SCIP_STAGE_TRANSFORMED
951  *       - \ref SCIP_STAGE_INITPRESOLVE
952  *       - \ref SCIP_STAGE_PRESOLVING
953  *       - \ref SCIP_STAGE_EXITPRESOLVE
954  *       - \ref SCIP_STAGE_PRESOLVED
955  *       - \ref SCIP_STAGE_INITSOLVE
956  *       - \ref SCIP_STAGE_SOLVING
957  *       - \ref SCIP_STAGE_SOLVED
958  *
959  *  @pre This method can be called if targetscip is in one of the following stages:
960  *       - \ref SCIP_STAGE_INIT
961  *       - \ref SCIP_STAGE_FREE
962  *
963  *  @note sourcescip stage does not get changed
964  *
965  *  @note targetscip stage does not get changed
966  *
967  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
968  */
969 SCIP_EXPORT
970 SCIP_RETCODE SCIPcopy(
971    SCIP*                 sourcescip,         /**< source SCIP data structure */
972    SCIP*                 targetscip,         /**< target SCIP data structure */
973    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
974                                               *   target variables, or NULL */
975    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
976                                               *   target constraints, or NULL */
977    const char*           suffix,             /**< optional suffix for problem name inside the target SCIP */
978    SCIP_Bool             global,             /**< create a global or a local copy? */
979    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
980                                               *   plugins will be copied and activated, and the modifiable flag of
981                                               *   constraints will be respected. If FALSE, valid will be set to FALSE, when
982                                               *   there are pricers present */
983    SCIP_Bool             threadsafe,         /**< FALSE, if data can be safely shared between the source and target
984                                                   SCIP, otherwise TRUE. This is usually set to FALSE */
985    SCIP_Bool             passmessagehdlr,    /**< should the message handler be passed */
986    SCIP_Bool*            valid               /**< pointer to store whether the copying was valid, or NULL */
987    );
988 
989 /** copies source SCIP to target SCIP but compresses constraints
990  *
991  *  constraint compression is performed by removing fixed variables immediately
992  *  during constraint creation if the involved constraint handlers support
993  *  compression
994  *
995  *  the copying process is done in the following order:
996  *  1) copy the plugins
997  *  2) copy the settings
998  *  3) create problem data in target-SCIP and copy the problem data of the source-SCIP
999  *  4) copy all active variables except those are marked as relaxation-only
1000  *     a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
1001  *     b) enable constraint compression
1002  *  5) copy all constraints
1003  *
1004  * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
1005  * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrigConsCompression().
1006  *
1007  *  @note: in case that a combination of local bounds and explicit fixing values should be used,
1008  *         the fixing value of a variable is preferred if local bounds and fixing value disagree.
1009  *
1010  *  @note all variables and constraints which are created in the target-SCIP are not (user) captured
1011  *
1012  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1013  *        Also, 'passmessagehdlr' should be set to FALSE.
1014  *  @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
1015  *        SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
1016  *        typically incurs a performance cost.
1017  *  @note Do not change the source SCIP environment during the copying process
1018  *
1019  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1020  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1021  *
1022  *  @pre This method can be called if sourcescip is in one of the following stages:
1023  *       - \ref SCIP_STAGE_PROBLEM
1024  *       - \ref SCIP_STAGE_TRANSFORMED
1025  *       - \ref SCIP_STAGE_INITPRESOLVE
1026  *       - \ref SCIP_STAGE_PRESOLVING
1027  *       - \ref SCIP_STAGE_EXITPRESOLVE
1028  *       - \ref SCIP_STAGE_PRESOLVED
1029  *       - \ref SCIP_STAGE_INITSOLVE
1030  *       - \ref SCIP_STAGE_SOLVING
1031  *       - \ref SCIP_STAGE_SOLVED
1032  *
1033  *  @pre This method can be called if targetscip is in one of the following stages:
1034  *       - \ref SCIP_STAGE_INIT
1035  *       - \ref SCIP_STAGE_FREE
1036  *
1037  *  @note sourcescip stage does not get changed
1038  *
1039  *  @note targetscip stage does not get changed
1040  *
1041  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1042  */
1043 SCIP_EXPORT
1044 SCIP_RETCODE SCIPcopyConsCompression(
1045    SCIP*                 sourcescip,         /**< source SCIP data structure */
1046    SCIP*                 targetscip,         /**< target SCIP data structure */
1047    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
1048                                               *   target variables, or NULL */
1049    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
1050                                               *   target constraints, or NULL */
1051    const char*           suffix,             /**< optional suffix for problem name inside the target SCIP */
1052    SCIP_VAR**            fixedvars,          /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
1053    SCIP_Real*            fixedvals,          /**< array of fixing values for target SCIP variables, or NULL */
1054    int                   nfixedvars,         /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
1055    SCIP_Bool             global,             /**< create a global or a local copy? */
1056    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
1057                                               *   plugins will be copied and activated, and the modifiable flag of
1058                                               *   constraints will be respected. If FALSE, valid will be set to FALSE, when
1059                                               *   there are pricers present */
1060    SCIP_Bool             threadsafe,         /**< FALSE, if data can be safely shared between the source and target
1061                                                   SCIP, otherwise TRUE. This is usually set to FALSE */
1062    SCIP_Bool             passmessagehdlr,    /**< should the message handler be passed */
1063    SCIP_Bool*            valid               /**< pointer to store whether the copying was valid, or NULL */
1064    );
1065 
1066 /** copies source SCIP original problem to target SCIP; the copying process is done in the following order:
1067  *  1) copy the plugins
1068  *  2) copy the settings
1069  *  3) create problem data in target-SCIP and copy the original problem data of the source-SCIP
1070  *  4) copy all original variables
1071  *  5) copy all original constraints
1072  *
1073  *  @note all variables and constraints which are created in the target-SCIP are not (user) captured
1074  *
1075  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1076  *        Also, 'passmessagehdlr' should be set to FALSE.
1077  *  @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
1078  *        SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
1079  *        typically incurs a performance cost.
1080  *  @note Do not change the source SCIP environment during the copying process
1081  *
1082  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1083  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1084  *
1085  *  @pre This method can be called if sourcescip is in one of the following stages:
1086  *       - \ref SCIP_STAGE_PROBLEM
1087  *       - \ref SCIP_STAGE_TRANSFORMED
1088  *       - \ref SCIP_STAGE_INITPRESOLVE
1089  *       - \ref SCIP_STAGE_PRESOLVING
1090  *       - \ref SCIP_STAGE_EXITPRESOLVE
1091  *       - \ref SCIP_STAGE_PRESOLVED
1092  *       - \ref SCIP_STAGE_INITSOLVE
1093  *       - \ref SCIP_STAGE_SOLVING
1094  *       - \ref SCIP_STAGE_SOLVED
1095  *
1096  *  @pre This method can be called if targetscip is in one of the following stages:
1097  *       - \ref SCIP_STAGE_INIT
1098  *       - \ref SCIP_STAGE_FREE
1099  *
1100  *  @note sourcescip stage does not get changed
1101  *
1102  *  @note targetscip stage does not get changed
1103  *
1104  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1105  */
1106 SCIP_EXPORT
1107 SCIP_RETCODE SCIPcopyOrig(
1108    SCIP*                 sourcescip,         /**< source SCIP data structure */
1109    SCIP*                 targetscip,         /**< target SCIP data structure */
1110    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
1111                                               *   target variables, or NULL */
1112    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
1113                                               *   target constraints, or NULL */
1114    const char*           suffix,             /**< suffix which will be added to the names of the target SCIP, might be empty */
1115    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
1116                                               *   plugins will be copied and activated, and the modifiable flag of
1117                                               *   constraints will be respected. If FALSE, valid will be set to FALSE, when
1118                                               *   there are pricers present */
1119    SCIP_Bool             threadsafe,         /**< FALSE, if data can be safely shared between the source and target
1120                                                   SCIP, otherwise TRUE. This is usually set to FALSE */
1121    SCIP_Bool             passmessagehdlr,    /**< should the message handler be passed */
1122    SCIP_Bool*            valid               /**< pointer to store whether the copying was valid, or NULL */
1123    );
1124 
1125 /** copies source SCIP original problem to target SCIP but compresses constraints
1126  *
1127  *  constraint compression is performed by removing fixed variables immediately
1128  *  during constraint creation if the involved constraint handlers support
1129  *  compression
1130  *
1131  *  the copying process is done in the following order:
1132  *  1) copy the plugins
1133  *  2) copy the settings
1134  *  3) create problem data in target-SCIP and copy the problem data of the source-SCIP
1135  *  4) copy all original variables
1136  *     a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
1137  *     b) enable constraint compression
1138  *  5) copy all constraints
1139  *
1140  *  @note all variables and constraints which are created in the target-SCIP are not (user) captured
1141  *
1142  *  @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
1143  *        Also, 'passmessagehdlr' should be set to FALSE.
1144  *  @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
1145  *        SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
1146  *        typically incurs a performance cost.
1147  *  @note Do not change the source SCIP environment during the copying process
1148  *
1149  *  @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1150  *          SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1151  *
1152  *  @pre This method can be called if sourcescip is in one of the following stages:
1153  *       - \ref SCIP_STAGE_PROBLEM
1154  *       - \ref SCIP_STAGE_TRANSFORMED
1155  *       - \ref SCIP_STAGE_INITPRESOLVE
1156  *       - \ref SCIP_STAGE_PRESOLVING
1157  *       - \ref SCIP_STAGE_EXITPRESOLVE
1158  *       - \ref SCIP_STAGE_PRESOLVED
1159  *       - \ref SCIP_STAGE_INITSOLVE
1160  *       - \ref SCIP_STAGE_SOLVING
1161  *       - \ref SCIP_STAGE_SOLVED
1162  *
1163  *  @pre This method can be called if targetscip is in one of the following stages:
1164  *       - \ref SCIP_STAGE_INIT
1165  *       - \ref SCIP_STAGE_FREE
1166  *
1167  *  @note sourcescip stage does not get changed
1168  *
1169  *  @note targetscip stage does not get changed
1170  *
1171  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1172  */
1173 SCIP_EXPORT
1174 SCIP_RETCODE SCIPcopyOrigConsCompression(
1175    SCIP*                 sourcescip,         /**< source SCIP data structure */
1176    SCIP*                 targetscip,         /**< target SCIP data structure */
1177    SCIP_HASHMAP*         varmap,             /**< a hashmap to store the mapping of source variables corresponding
1178                                               *   target variables, or NULL */
1179    SCIP_HASHMAP*         consmap,            /**< a hashmap to store the mapping of source constraints to the corresponding
1180                                               *   target constraints, or NULL */
1181    const char*           suffix,             /**< optional suffix for problem name inside the target SCIP */
1182    SCIP_VAR**            fixedvars,          /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
1183    SCIP_Real*            fixedvals,          /**< array of fixing values for target SCIP variables, or NULL */
1184    int                   nfixedvars,         /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
1185    SCIP_Bool             enablepricing,      /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
1186                                               *   plugins will be copied and activated, and the modifiable flag of
1187                                               *   constraints will be respected. If FALSE, valid will be set to FALSE, when
1188                                               *   there are pricers present */
1189    SCIP_Bool             threadsafe,         /**< FALSE, if data can be safely shared between the source and target
1190                                                   SCIP, otherwise TRUE. This is usually set to FALSE */
1191    SCIP_Bool             passmessagehdlr,    /**< should the message handler be passed */
1192    SCIP_Bool*            valid               /**< pointer to store whether the copying was valid, or NULL */
1193    );
1194 
1195 /** checks if there is enough time and memory left for copying the sourcescip into a sub-SCIP and solve the sub-SCIP
1196  *
1197  *  This is the case if the time and memory limit that would be passed to the sub-SCIP are larger than 0.0
1198  *
1199  *  @pre This method can be called if sourcescip is in one of the following stages:
1200  *       - \ref SCIP_STAGE_PROBLEM
1201  *       - \ref SCIP_STAGE_TRANSFORMED
1202  *       - \ref SCIP_STAGE_INITPRESOLVE
1203  *       - \ref SCIP_STAGE_PRESOLVING
1204  *       - \ref SCIP_STAGE_EXITPRESOLVE
1205  *       - \ref SCIP_STAGE_PRESOLVED
1206  *       - \ref SCIP_STAGE_INITSOLVE
1207  *       - \ref SCIP_STAGE_SOLVING
1208  *       - \ref SCIP_STAGE_SOLVED
1209  *
1210  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1211  */
1212 SCIP_EXPORT
1213 SCIP_RETCODE SCIPcheckCopyLimits(
1214    SCIP*                 sourcescip,         /**< source SCIP data structure */
1215    SCIP_Bool*            success             /**< pointer to store whether there is time and memory left to copy the
1216                                               *   problem and run the sub-SCIP */
1217    );
1218 
1219 /** copies limits from source SCIP to target SCIP
1220  *
1221  *  @note time and memory limit are reduced by the amount already spent in the source SCIP before installing the limit
1222  *        in the target SCIP
1223  *  @note all other limits are disabled and need to be enabled afterwards, if needed
1224  *
1225  *  @see SCIPsetCommonSubscipParams() to set further working limits and other parameters commonly used for auxiliary problems
1226  *
1227  *  @pre This method can be called if sourcescip is in one of the following stages:
1228  *       - \ref SCIP_STAGE_PROBLEM
1229  *       - \ref SCIP_STAGE_TRANSFORMED
1230  *       - \ref SCIP_STAGE_INITPRESOLVE
1231  *       - \ref SCIP_STAGE_PRESOLVING
1232  *       - \ref SCIP_STAGE_EXITPRESOLVE
1233  *       - \ref SCIP_STAGE_PRESOLVED
1234  *       - \ref SCIP_STAGE_INITSOLVE
1235  *       - \ref SCIP_STAGE_SOLVING
1236  *       - \ref SCIP_STAGE_SOLVED
1237  *
1238  *  See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1239  */
1240 SCIP_EXPORT
1241 SCIP_RETCODE SCIPcopyLimits(
1242    SCIP*                 sourcescip,         /**< source SCIP data structure */
1243    SCIP*                 targetscip          /**< target SCIP data structure */
1244    );
1245 
1246 
1247 /** sets the working limits as well as common search parameters for the auxiliary problem
1248  *
1249  *  @note memory and time limits are not affected, and must be set using SCIPcopyLimits() instead
1250  */
1251 SCIP_EXPORT
1252 SCIP_RETCODE SCIPsetCommonSubscipParams(
1253    SCIP*                 sourcescip,         /**< source SCIP data structure */
1254    SCIP*                 subscip,            /**< target SCIP data structure, often a copy of \p sourcescip */
1255    SCIP_Longint          nsubnodes,          /**< nodelimit for subscip, or -1 for no limit */
1256    SCIP_Longint          nstallnodes,        /**< stall node limit for subscip, or -1 for no limit */
1257    int                   bestsollimit        /**< the limit on the number of best solutions found, or -1 for no limit */
1258    );
1259 
1260 
1261 /**@} */
1262 
1263 #ifdef __cplusplus
1264 }
1265 #endif
1266 
1267 #endif
1268