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