Scippy

    SCIP

    Solving Constraint Integer Programs

    scip_copy.c
    Go to the documentation of this file.
    1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    2/* */
    3/* This file is part of the program and library */
    4/* SCIP --- Solving Constraint Integer Programs */
    5/* */
    6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
    7/* */
    8/* Licensed under the Apache License, Version 2.0 (the "License"); */
    9/* you may not use this file except in compliance with the License. */
    10/* You may obtain a copy of the License at */
    11/* */
    12/* http://www.apache.org/licenses/LICENSE-2.0 */
    13/* */
    14/* Unless required by applicable law or agreed to in writing, software */
    15/* distributed under the License is distributed on an "AS IS" BASIS, */
    16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
    17/* See the License for the specific language governing permissions and */
    18/* limitations under the License. */
    19/* */
    20/* You should have received a copy of the Apache-2.0 license */
    21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
    22/* */
    23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    24
    25/**@file scip_copy.c
    26 * @ingroup OTHER_CFILES
    27 * @brief public methods for problem copies
    28 * @author Tobias Achterberg
    29 * @author Timo Berthold
    30 * @author Gerald Gamrath
    31 * @author Leona Gottwald
    32 * @author Stefan Heinz
    33 * @author Gregor Hendel
    34 * @author Thorsten Koch
    35 * @author Alexander Martin
    36 * @author Marc Pfetsch
    37 * @author Michael Winkler
    38 * @author Kati Wolter
    39 *
    40 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
    41 */
    42
    43/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    44
    46#include "scip/benders.h"
    47#include "scip/clock.h"
    48#include "scip/conflictstore.h"
    49#include "scip/cons.h"
    50#include "scip/cons_linear.h"
    51#include "scip/dcmp.h"
    52#include "scip/debug.h"
    53#include "scip/primal.h"
    54#include "scip/prob.h"
    55#include "scip/pub_cons.h"
    56#include "scip/pub_cutpool.h"
    57#include "scip/pub_implics.h"
    58#include "scip/pub_lp.h"
    59#include "scip/pub_message.h"
    60#include "scip/pub_misc.h"
    61#include "scip/pub_nlpi.h"
    62#include "scip/pub_sol.h"
    63#include "scip/pub_var.h"
    64#include "scip/scip_branch.h"
    65#include "scip/scip_cons.h"
    66#include "scip/scip_copy.h"
    67#include "scip/scip_cut.h"
    68#include "scip/scip_exact.h"
    69#include "scip/scip_general.h"
    70#include "scip/scip_mem.h"
    71#include "scip/scip_message.h"
    72#include "scip/scip_nodesel.h"
    73#include "scip/scip_numerics.h"
    74#include "scip/scip_param.h"
    75#include "scip/scip_pricer.h"
    76#include "scip/scip_prob.h"
    77#include "scip/scip_sol.h"
    78#include "scip/scip_solve.h"
    80#include "scip/scip_timing.h"
    81#include "scip/scip_var.h"
    82#include "scip/set.h"
    83#include "scip/stat.h"
    84#include "scip/struct_mem.h"
    85#include "scip/struct_scip.h"
    86#include "scip/struct_set.h"
    87#include "scip/struct_stat.h"
    88#include "scip/struct_var.h"
    89#include "scip/syncstore.h"
    90#include "scip/var.h"
    91
    92/** returns true if the @p cut matches the selection criterium for copying */
    93static
    95 SCIP* scip, /**< SCIP data structure */
    96 SCIP_CUT* cut, /**< a cut */
    97 char cutsel /**< cut selection for sub SCIPs ('a'ge, activity 'q'uotient) */
    98 )
    99{
    100 SCIP_Bool takecut;
    101
    102 assert(cut != NULL);
    103
    104 if( !SCIProwIsInLP(SCIPcutGetRow(cut)) )
    105 return FALSE;
    106
    107 switch( cutsel )
    108 {
    109 case 'a':
    110 takecut = (SCIPcutGetAge(cut) == 0);
    111 break;
    112 case 'q':
    113 takecut = (SCIPcutGetLPActivityQuot(cut) >= scip->set->sepa_minactivityquot);
    114 break;
    115 default:
    116 SCIPerrorMessage("unknown cut selection strategy %c, must be either 'a' or 'q'\n", cutsel);
    117 SCIPABORT();
    118 takecut = FALSE; /*lint !e527*/
    119 break;
    120 }
    121
    122 return takecut;
    123}
    124
    125/** copy active and tight cuts from one SCIP instance to linear constraints of another SCIP instance */
    126static
    128 SCIP* sourcescip, /**< source SCIP data structure */
    129 SCIP* targetscip, /**< target SCIP data structure */
    130 SCIP_CUT** cuts, /**< cuts to copy */
    131 int ncuts, /**< number of cuts to copy */
    132 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    133 * target variables, or NULL */
    134 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    135 * target constraints, or NULL */
    136 SCIP_Bool global, /**< create a global or a local copy? */
    137 int* ncutsadded /**< pointer to store number of copied cuts */
    138 )
    139{
    140 int c;
    141
    142 assert(sourcescip != NULL);
    143 assert(targetscip != NULL);
    144 assert(cuts != NULL || ncuts == 0);
    145 assert(ncutsadded != NULL);
    146
    147 for( c = 0; c < ncuts; ++c )
    148 {
    149 SCIP_ROW* row;
    150 SCIP_Bool takecut;
    151
    152 assert( cuts[c] != NULL ); /*lint !e613*/
    153 row = SCIPcutGetRow(cuts[c]); /*lint !e613*/
    154 assert(!SCIProwIsLocal(row));
    155 assert(!SCIProwIsModifiable(row));
    156
    157 /* in case of a restart, convert the cuts with a good LP activity quotient; in other cases, e.g., when heuristics
    158 * copy cuts into subscips, take only currently active ones
    159 */
    160 if( sourcescip == targetscip )
    161 {
    162 assert( SCIPisInRestart(sourcescip) );
    163 takecut = takeCut(sourcescip, cuts[c], sourcescip->set->sepa_cutselrestart); /*lint !e613*/
    164 }
    165 else
    166 takecut = takeCut(sourcescip, cuts[c], sourcescip->set->sepa_cutselsubscip); /*lint !e613*/
    167
    168 /* create a linear constraint out of the cut */
    169 if( takecut )
    170 {
    171 char name[SCIP_MAXSTRLEN];
    172 SCIP_CONS* cons;
    173 SCIP_COL** cols;
    174 SCIP_VAR** vars;
    175 int ncols;
    176 int i;
    177
    178 cols = SCIProwGetCols(row);
    179 ncols = SCIProwGetNNonz(row);
    180
    181 /* get all variables of the row */
    182 SCIP_CALL( SCIPallocBufferArray(targetscip, &vars, ncols) );
    183 for( i = 0; i < ncols && takecut; ++i )
    184 {
    185 vars[i] = SCIPcolGetVar(cols[i]);
    186 takecut = !SCIPvarIsRelaxationOnly(vars[i]);
    187 }
    188
    189 /* discard cut if it contains a variable which is invalid after a restart */
    190 if( !takecut )
    191 {
    192 /* free temporary memory */
    193 SCIPfreeBufferArray(targetscip, &vars);
    194 continue;
    195 }
    196
    197 /* get corresponding variables in targetscip if necessary */
    198 if( sourcescip != targetscip )
    199 {
    200 SCIP_Bool success;
    201
    202 for( i = 0; i < ncols; ++i )
    203 {
    204 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, vars[i], &vars[i], varmap, consmap, global, &success) );
    205
    206 if( !success )
    207 {
    208 SCIPdebugMsg(sourcescip, "Converting cuts to constraints failed.\n");
    209
    210 /* free temporary memory */
    211 SCIPfreeBufferArray(targetscip, &vars);
    212 return SCIP_OKAY;
    213 }
    214 }
    215 }
    216
    217 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%d", SCIProwGetName(row), SCIPgetNRuns(sourcescip));
    218 SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, ncols, vars, SCIProwGetVals(row),
    221 SCIP_CALL( SCIPaddCons(targetscip, cons) );
    222
    223 SCIPdebugMsg(sourcescip, "Converted cut <%s> to constraint <%s>.\n", SCIProwGetName(row), SCIPconsGetName(cons));
    224 SCIPdebugPrintCons(targetscip, cons, NULL);
    225 SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
    226
    227 /* free temporary memory */
    228 SCIPfreeBufferArray(targetscip, &vars);
    229
    230 ++(*ncutsadded);
    231 }
    232 }
    233
    234 return SCIP_OKAY;
    235}
    236
    237/** copies plugins from sourcescip to targetscip; in case that a constraint handler which does not need constraints
    238 * cannot be copied, valid will return FALSE. All plugins can declare that, if their copy process failed, the
    239 * copied SCIP instance might not represent the same problem semantics as the original.
    240 * Note that in this case dual reductions might be invalid.
    241 *
    242 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    243 * Also, 'passmessagehdlr' should be set to FALSE.
    244 *
    245 * @note Do not change the source SCIP environment during the copying process
    246 *
    247 * @note This method does not copy Benders' plugins. To this end, the method SCIPcopyBenders() must be called
    248 * separately.
    249 *
    250 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    251 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    252 *
    253 * @pre This method can be called if sourcescip is in one of the following stages:
    254 * - \ref SCIP_STAGE_PROBLEM
    255 * - \ref SCIP_STAGE_TRANSFORMED
    256 * - \ref SCIP_STAGE_INITPRESOLVE
    257 * - \ref SCIP_STAGE_PRESOLVING
    258 * - \ref SCIP_STAGE_EXITPRESOLVE
    259 * - \ref SCIP_STAGE_PRESOLVED
    260 * - \ref SCIP_STAGE_INITSOLVE
    261 * - \ref SCIP_STAGE_SOLVING
    262 * - \ref SCIP_STAGE_SOLVED
    263 *
    264 * @pre This method can be called if targetscip is in one of the following stages:
    265 * - \ref SCIP_STAGE_INIT
    266 * - \ref SCIP_STAGE_FREE
    267 *
    268 * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
    269 * process was interrupted:
    270 * - \ref SCIP_STAGE_PROBLEM
    271 *
    272 * @note sourcescip stage does not get changed
    273 *
    274 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    275 */
    277 SCIP* sourcescip, /**< source SCIP data structure */
    278 SCIP* targetscip, /**< target SCIP data structure */
    279 SCIP_Bool copyreaders, /**< should the file readers be copied */
    280 SCIP_Bool copypricers, /**< should the variable pricers be copied */
    281 SCIP_Bool copyconshdlrs, /**< should the constraint handlers be copied */
    282 SCIP_Bool copyconflicthdlrs, /**< should the conflict handlers be copied */
    283 SCIP_Bool copypresolvers, /**< should the presolvers be copied */
    284 SCIP_Bool copyrelaxators, /**< should the relaxation handlers be copied */
    285 SCIP_Bool copyseparators, /**< should the separators be copied */
    286 SCIP_Bool copycutselectors, /**< should the cut selectors be copied */
    287 SCIP_Bool copypropagators, /**< should the propagators be copied */
    288 SCIP_Bool copyheuristics, /**< should the heuristics be copied */
    289 SCIP_Bool copyeventhdlrs, /**< should the event handlers be copied */
    290 SCIP_Bool copynodeselectors, /**< should the node selectors be copied */
    291 SCIP_Bool copybranchrules, /**< should the branchrules be copied */
    292 SCIP_Bool copyiisfinders, /**< should the IIS finders be copied */
    293 SCIP_Bool copydisplays, /**< should the display columns be copied */
    294 SCIP_Bool copydialogs, /**< should the dialogs be copied */
    295 SCIP_Bool copytables, /**< should the statistics tables be copied */
    296 SCIP_Bool copyexprhdlrs, /**< should the expression handlers be copied */
    297 SCIP_Bool copynlpis, /**< should the NLPIs be copied */
    298 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    299 SCIP_Bool* valid /**< pointer to store whether plugins, in particular all constraint
    300 * handlers which do not need constraints were validly copied */
    301 )
    302{
    303 assert(sourcescip != NULL);
    304 assert(targetscip != NULL);
    305 assert(sourcescip->set != NULL);
    306 assert(targetscip->set != NULL);
    307
    308 /* check stages for both, the source and the target SCIP data structure */
    309 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyPlugins", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    310 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyPlugins", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    311
    312 /* passes the message handler of the source SCIP to the target SCIP, also if NULL */
    313 if( passmessagehdlr )
    314 {
    315 SCIP_CALL( SCIPsetMessagehdlr(targetscip, SCIPgetMessagehdlr(sourcescip)) );
    316 }
    317
    318 SCIP_CALL( SCIPsetCopyPlugins(sourcescip->set, targetscip->set,
    319 copyreaders, copypricers, copyconshdlrs, copyconflicthdlrs, copypresolvers, copyrelaxators, copyseparators, copycutselectors, copypropagators,
    320 copyheuristics, copyeventhdlrs, copynodeselectors, copybranchrules, copyiisfinders, copydisplays, copydialogs, copytables, copyexprhdlrs, copynlpis, valid) );
    321
    322 return SCIP_OKAY;
    323}
    324
    325/** copies all Benders' decomposition plugins
    326 *
    327 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    328 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    329 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    330 * typically incurs a performance cost.
    331 *
    332 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    333 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    334 *
    335 * @pre This method can be called if sourcescip is in one of the following stages:
    336 * - \ref SCIP_STAGE_PROBLEM
    337 * - \ref SCIP_STAGE_TRANSFORMED
    338 * - \ref SCIP_STAGE_INITPRESOLVE
    339 * - \ref SCIP_STAGE_PRESOLVING
    340 * - \ref SCIP_STAGE_EXITPRESOLVE
    341 * - \ref SCIP_STAGE_PRESOLVED
    342 * - \ref SCIP_STAGE_INITSOLVE
    343 * - \ref SCIP_STAGE_SOLVING
    344 * - \ref SCIP_STAGE_SOLVED
    345 *
    346 * @pre This method can be called if targetscip is in one of the following stages:
    347 * - \ref SCIP_STAGE_INIT
    348 * - \ref SCIP_STAGE_FREE
    349 * - \ref SCIP_STAGE_PROBLEM
    350 *
    351 * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
    352 * process was interrupted:
    353 * - \ref SCIP_STAGE_PROBLEM
    354 *
    355 * @note sourcescip stage does not get changed
    356 *
    357 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    358 */
    360 SCIP* sourcescip, /**< source SCIP data structure */
    361 SCIP* targetscip, /**< target SCIP data structure */
    362 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    363 * target variables; if NULL the transfer of cuts is not possible */
    364 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    365 * SCIP, otherwise TRUE. This is usually set to FALSE */
    366 SCIP_Bool* valid /**< pointer to store whether all plugins were validly copied */
    367 )
    368{
    369 /* TODO: If the Benders' decomposition is not copied, then cons_benders needs to be deactivated. */
    370 SCIP_Bool copybendersvalid;
    371 int p;
    372
    373 assert(sourcescip != NULL);
    374 assert(targetscip != NULL);
    375 assert(sourcescip != targetscip);
    376 assert(sourcescip->set != NULL);
    377 assert(targetscip->set != NULL);
    378 assert(valid != NULL);
    379
    380 /* check stages for both, the source and the target SCIP data structure */
    381 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyBenders", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    382 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyBenders", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    383
    384 *valid = TRUE;
    385
    386 if( sourcescip->set->benders != NULL )
    387 {
    388 for( p = sourcescip->set->nbenders - 1; p >= 0; --p )
    389 {
    390 copybendersvalid = FALSE;
    391 SCIP_CALL( SCIPbendersCopyInclude(sourcescip->set->benders[p], sourcescip->set, targetscip->set, varmap,
    392 threadsafe, &copybendersvalid) );
    393 *valid = *valid && copybendersvalid;
    394 }
    395 }
    396
    397 return SCIP_OKAY;
    398}
    399
    400/** create a problem by copying the problem data of the source SCIP */
    401static
    403 SCIP* sourcescip, /**< source SCIP data structure */
    404 SCIP* targetscip, /**< target SCIP data structure */
    405 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    406 * target variables, or NULL */
    407 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    408 * target constraints, or NULL */
    409 SCIP_Bool original, /**< should the original problem be copied? */
    410 SCIP_Bool global, /**< create a global or a local copy? (set to TRUE for original copy) */
    411 const char* name /**< problem name of target */
    412 )
    413{
    414 SCIP_PROB* sourceprob;
    415 SCIP_HASHMAP* localvarmap;
    416 SCIP_HASHMAP* localconsmap;
    417 SCIP_Bool uselocalvarmap;
    418 SCIP_Bool uselocalconsmap;
    419
    420 assert(sourcescip != NULL);
    421 assert(targetscip != NULL);
    422 assert(!original || global);
    423 assert(original || SCIPisTransformed(sourcescip));
    424
    425 /* free old problem */
    426 SCIP_CALL( SCIPfreeProb(targetscip) );
    427 assert(targetscip->set->stage == SCIP_STAGE_INIT);
    428
    429 uselocalvarmap = (varmap == NULL);
    430 uselocalconsmap = (consmap == NULL);
    431
    432 if( uselocalvarmap )
    433 {
    434 /* create the variable mapping hash map */
    435 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    436 }
    437 else
    438 localvarmap = varmap;
    439
    440 if( uselocalconsmap )
    441 {
    442 /* create the constraint mapping hash map */
    443 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    444 }
    445 else
    446 localconsmap = consmap;
    447
    448 /* switch stage to PROBLEM */
    449 targetscip->set->stage = SCIP_STAGE_PROBLEM;
    450
    451 if( original )
    452 sourceprob = sourcescip->origprob;
    453 else
    454 sourceprob = sourcescip->transprob;
    455
    456 /* create the statistics data structure */
    457 SCIP_CALL( SCIPstatCreate(&targetscip->stat, targetscip->mem->probmem, targetscip->set, targetscip->transprob, targetscip->origprob, targetscip->messagehdlr) );
    458 targetscip->stat->subscipdepth = sourcescip->stat->subscipdepth + 1;
    459
    460 /* create the problem by copying the source problem */
    461 SCIP_CALL( SCIPprobCopy(&targetscip->origprob, targetscip->mem->probmem, targetscip->set, name, sourcescip, sourceprob, localvarmap, localconsmap, original, global) );
    462
    463 /* creating the solution candidates storage */
    464 /**@todo copy solution of source SCIP as candidates for the target SCIP */
    465 SCIP_CALL( SCIPprimalCreate(&targetscip->origprimal) );
    466
    467 /* create conflict store to store conflict constraints */
    468 SCIP_CALL( SCIPconflictstoreCreate(&targetscip->conflictstore, targetscip->set) );
    469
    471
    473
    474 if( uselocalvarmap )
    475 {
    476 /* free hash map */
    477 SCIPhashmapFree(&localvarmap);
    478 }
    479
    480 if( uselocalconsmap )
    481 {
    482 /* free hash map */
    483 SCIPhashmapFree(&localconsmap);
    484 }
    485
    486 return SCIP_OKAY;
    487}
    488
    489
    490/** create a problem by copying the problem data of the source SCIP
    491 *
    492 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    493 * @note Do not change the source SCIP environment during the copying process
    494 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    495 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    496 *
    497 * @pre This method can be called if sourcescip is in one of the following stages:
    498 * - \ref SCIP_STAGE_PROBLEM
    499 * - \ref SCIP_STAGE_TRANSFORMED
    500 * - \ref SCIP_STAGE_INITPRESOLVE
    501 * - \ref SCIP_STAGE_PRESOLVING
    502 * - \ref SCIP_STAGE_EXITPRESOLVE
    503 * - \ref SCIP_STAGE_PRESOLVED
    504 * - \ref SCIP_STAGE_INITSOLVE
    505 * - \ref SCIP_STAGE_SOLVING
    506 * - \ref SCIP_STAGE_SOLVED
    507 *
    508 * @pre This method can be called if targetscip is in one of the following stages:
    509 * - \ref SCIP_STAGE_INIT
    510 * - \ref SCIP_STAGE_PROBLEM
    511 * - \ref SCIP_STAGE_TRANSFORMED
    512 * - \ref SCIP_STAGE_INITPRESOLVE
    513 * - \ref SCIP_STAGE_PRESOLVING
    514 * - \ref SCIP_STAGE_EXITPRESOLVE
    515 * - \ref SCIP_STAGE_PRESOLVED
    516 * - \ref SCIP_STAGE_INITSOLVE
    517 * - \ref SCIP_STAGE_SOLVING
    518 * - \ref SCIP_STAGE_SOLVED
    519 * - \ref SCIP_STAGE_FREE
    520 *
    521 * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
    522 * process was interrupted:
    523 * - \ref SCIP_STAGE_PROBLEM
    524 *
    525 * @note sourcescip stage does not get changed
    526 *
    527 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    528 */
    530 SCIP* sourcescip, /**< source SCIP data structure */
    531 SCIP* targetscip, /**< target SCIP data structure */
    532 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    533 * target variables, or NULL */
    534 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    535 * target constraints, or NULL */
    536 SCIP_Bool global, /**< create a global or a local copy? */
    537 const char* name /**< problem name of target */
    538 )
    539{
    540 assert(sourcescip != NULL);
    541 assert(targetscip != NULL);
    542
    543 /* check stages for both, the source and the target SCIP data structure */
    544 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyProb", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    545 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyProb", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE) );
    546
    547 SCIP_CALL( copyProb(sourcescip, targetscip, varmap, consmap, FALSE, global, name) );
    548
    549 return SCIP_OKAY;
    550}
    551
    552/** create a problem by copying the original problem data of the source SCIP
    553 *
    554 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    555 * @note Do not change the source SCIP environment during the copying process
    556 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    557 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    558 *
    559 * @pre This method can be called if sourcescip is in one of the following stages:
    560 * - \ref SCIP_STAGE_PROBLEM
    561 * - \ref SCIP_STAGE_TRANSFORMED
    562 * - \ref SCIP_STAGE_INITPRESOLVE
    563 * - \ref SCIP_STAGE_PRESOLVING
    564 * - \ref SCIP_STAGE_EXITPRESOLVE
    565 * - \ref SCIP_STAGE_PRESOLVED
    566 * - \ref SCIP_STAGE_INITSOLVE
    567 * - \ref SCIP_STAGE_SOLVING
    568 * - \ref SCIP_STAGE_SOLVED
    569 *
    570 * @pre This method can be called if targetscip is in one of the following stages:
    571 * - \ref SCIP_STAGE_INIT
    572 * - \ref SCIP_STAGE_FREE
    573 *
    574 * @post After calling this method targetscip reaches one of the following stages depending on if and when the solution
    575 * process was interrupted:
    576 * - \ref SCIP_STAGE_PROBLEM
    577 *
    578 * @note sourcescip stage does not get changed
    579 *
    580 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    581 */
    583 SCIP* sourcescip, /**< source SCIP data structure */
    584 SCIP* targetscip, /**< target SCIP data structure */
    585 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    586 * target variables, or NULL */
    587 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    588 * target constraints, or NULL */
    589 const char* name /**< problem name of target */
    590 )
    591{
    592 assert(sourcescip != NULL);
    593 assert(targetscip != NULL);
    594
    595 /* check stages for both, the source and the target SCIP data structure */
    596 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigProb", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    597 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigProb", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    598
    599 SCIP_CALL( copyProb(sourcescip, targetscip, varmap, consmap, TRUE, TRUE, name) );
    600
    601 /* set the correct objective sense; necessary if we maximize in the original problem */
    602 SCIP_CALL( SCIPsetObjsense(targetscip, SCIPgetObjsense(sourcescip)) );
    603
    604 /* set the objective offset */
    605 SCIP_CALL( SCIPaddOrigObjoffset(targetscip, SCIPgetOrigObjoffset(sourcescip)) );
    606
    607 return SCIP_OKAY;
    608}
    609
    610/** enables constraint compression.
    611 *
    612 * If constraint compression is enabled, fixed variables will be treated as constants
    613 * by all constraints that are copied after calling this method.
    614 *
    615 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    616 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    617 *
    618 * @pre This method can be called if scip is in one of the following stages:
    619 * - \ref SCIP_STAGE_PROBLEM
    620 *
    621 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    622 */
    624 SCIP* scip /**< source SCIP data structure */
    625 )
    626{
    627 assert(scip != NULL);
    628 assert(scip->origprob != NULL);
    629
    630 /* check stage */
    631 SCIP_CALL( SCIPcheckStage(scip, "SCIPenableConsCompression", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    632
    633 /* enable problem compression */
    635
    636 return SCIP_OKAY;
    637}
    638
    639/** is constraint compression enabled?
    640 *
    641 * If constraint compression is enabled, fixed variables can be treated as constants
    642 * by all constraints that are copied after calling this method.
    643 *
    644 * @return TRUE if problem constraint compression is enabled, otherwise FALSE
    645 *
    646 * @pre This method can be called if scip is in one of the following stages:
    647 * - \ref SCIP_STAGE_PROBLEM
    648 * - \ref SCIP_STAGE_TRANSFORMING
    649 * - \ref SCIP_STAGE_TRANSFORMED
    650 * - \ref SCIP_STAGE_INITPRESOLVE
    651 * - \ref SCIP_STAGE_PRESOLVING
    652 * - \ref SCIP_STAGE_EXITPRESOLVE
    653 * - \ref SCIP_STAGE_PRESOLVED
    654 * - \ref SCIP_STAGE_INITSOLVE
    655 * - \ref SCIP_STAGE_SOLVING
    656 * - \ref SCIP_STAGE_SOLVED
    657 * - \ref SCIP_STAGE_EXITSOLVE
    658 * - \ref SCIP_STAGE_FREETRANS
    659 *
    660 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    661 */
    663 SCIP* scip /**< source SCIP data structure */
    664 )
    665{
    666 assert(scip != NULL);
    667 assert(scip->origprob != NULL);
    668
    669 /* check stage */
    670 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisConsCompressionEnabled", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
    671
    672 /* is problem compression enabled */
    674}
    675
    676/** returns copy of the source variable; if there already is a copy of the source variable in the variable hash map,
    677 * it is just returned as target variable; otherwise, if the variables it not marked as relaxation-only, a new variable
    678 * will be created and added to the target SCIP; this created variable is added to the variable hash map and returned as target variable;
    679 * relaxation-only variables are not copied and FALSE is returned in *success
    680 *
    681 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    682 * @note Do not change the source SCIP environment during the copying process
    683 * @note if a new variable was created, this variable will be added to the target-SCIP, but it is not captured
    684 *
    685 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    686 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    687 *
    688 * @pre This method can be called if sourcescip is in one of the following stages:
    689 * - \ref SCIP_STAGE_PROBLEM
    690 * - \ref SCIP_STAGE_TRANSFORMED
    691 * - \ref SCIP_STAGE_INITPRESOLVE
    692 * - \ref SCIP_STAGE_PRESOLVING
    693 * - \ref SCIP_STAGE_EXITPRESOLVE
    694 * - \ref SCIP_STAGE_PRESOLVED
    695 * - \ref SCIP_STAGE_INITSOLVE
    696 * - \ref SCIP_STAGE_SOLVING
    697 * - \ref SCIP_STAGE_SOLVED
    698 *
    699 * @pre This method can be called if targetscip is in one of the following stages:
    700 * - \ref SCIP_STAGE_PROBLEM
    701 * - \ref SCIP_STAGE_TRANSFORMED
    702 * - \ref SCIP_STAGE_INITPRESOLVE
    703 * - \ref SCIP_STAGE_PRESOLVING
    704 * - \ref SCIP_STAGE_EXITPRESOLVE
    705 * - \ref SCIP_STAGE_SOLVING
    706 *
    707 * @note targetscip stage does not get changed
    708 *
    709 * @note sourcescip stage does not get changed
    710 *
    711 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    712 */
    714 SCIP* sourcescip, /**< source SCIP data structure */
    715 SCIP* targetscip, /**< target SCIP data structure */
    716 SCIP_VAR* sourcevar, /**< source variable */
    717 SCIP_VAR** targetvar, /**< pointer to store the target variable */
    718 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    719 * target variables, or NULL */
    720 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    721 * target constraints, or NULL */
    722 SCIP_Bool global, /**< should global or local bounds be used? */
    723 SCIP_Bool* success /**< pointer to store whether the copying was successful or not */
    724 )
    725{
    726 SCIP_HASHMAP* localvarmap;
    727 SCIP_HASHMAP* localconsmap;
    728 SCIP_VAR* var;
    729 SCIP_Bool uselocalvarmap;
    730 SCIP_Bool uselocalconsmap;
    731
    732 assert(sourcescip != NULL);
    733 assert(targetscip != NULL);
    734 assert(sourcevar != NULL);
    735 assert(targetvar != NULL);
    736 assert(sourcevar->scip == sourcescip);
    737
    738 /* check stages for both, the source and the target SCIP data structure */
    739 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPgetVarCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    740 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPgetVarCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
    741
    742 uselocalvarmap = (varmap == NULL);
    743 uselocalconsmap = (consmap == NULL);
    744 *success = TRUE;
    745
    746 /* try to retrieve copied variable from hashmap */
    747 if( !uselocalvarmap )
    748 {
    749 *targetvar = (SCIP_VAR*) SCIPhashmapGetImage(varmap, sourcevar);
    750 assert(*targetvar == NULL || (*targetvar)->scip == targetscip);
    751 if( *targetvar != NULL )
    752 return SCIP_OKAY;
    753 }
    754
    755 /* reject copying of relaxation-only variables */
    756 if( SCIPvarIsRelaxationOnly(sourcevar) )
    757 {
    758 *success = FALSE;
    759 *targetvar = NULL;
    760 }
    761
    762 /* if the target SCIP is already in solving stage we currently are not copying the variable!
    763 * this has to be done because we cannot simply add variables to SCIP during solving and thereby enlarge the search
    764 * space.
    765 * unlike column generation we cannot assume here that the variable could be implicitly set to zero in all prior
    766 * computations
    767 */
    768 if( SCIPgetStage(targetscip) > SCIP_STAGE_PROBLEM )
    769 {
    770 *success = FALSE;
    771 *targetvar = NULL;
    772
    773 return SCIP_OKAY;
    774 }
    775
    776 /* create the variable mapping hash map */
    777 if( uselocalvarmap )
    778 {
    779 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    780 }
    781 else
    782 localvarmap = varmap;
    783
    784 if( uselocalconsmap )
    785 {
    786 /* create the constraint mapping hash map */
    787 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    788 }
    789 else
    790 localconsmap = consmap;
    791
    792 /* if variable does not exist yet in target SCIP, create it */
    793 switch( SCIPvarGetStatus(sourcevar) )
    794 {
    799 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    800 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    801 break;
    802
    804 {
    805 SCIP_CONS* cons;
    806 char name[SCIP_MAXSTRLEN];
    807
    808 SCIP_VAR* sourceaggrvar;
    809 SCIP_VAR* targetaggrvar;
    810 SCIP_Real aggrcoef;
    811 SCIP_Real constant;
    812
    813 /* get aggregation data */
    814 sourceaggrvar = SCIPvarGetAggrVar(sourcevar);
    815 aggrcoef = SCIPvarGetAggrScalar(sourcevar);
    816 constant = SCIPvarGetAggrConstant(sourcevar);
    817
    818 /* get copy of the aggregation variable */
    819 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvar, &targetaggrvar, localvarmap, localconsmap, global, success) );
    820 assert(*success);
    821
    822 /* create copy of the aggregated variable */
    823 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    824 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    825
    826 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_aggr", SCIPvarGetName(sourcevar));
    827
    828 /* add aggregation x = a*y + c as linear constraint x - a*y = c */
    829 SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, 0, NULL, NULL, constant,
    830 constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    831 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, 1.0) );
    832 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, targetaggrvar, -aggrcoef) );
    833
    834 SCIP_CALL( SCIPaddCons(targetscip, cons) );
    835 SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
    836
    837 break;
    838 }
    840 {
    841 SCIP_CONS* cons;
    842 char name[SCIP_MAXSTRLEN];
    843
    844 SCIP_VAR** sourceaggrvars;
    845 SCIP_VAR** targetaggrvars;
    846 SCIP_Real* aggrcoefs;
    847 SCIP_Real constant;
    848
    849 int naggrvars;
    850 int i;
    851
    852 /* get the active representation */
    853 SCIP_CALL( SCIPflattenVarAggregationGraph(sourcescip, sourcevar) );
    854
    855 /* get multi-aggregation data */
    856 naggrvars = SCIPvarGetMultaggrNVars(sourcevar);
    857 sourceaggrvars = SCIPvarGetMultaggrVars(sourcevar);
    858 aggrcoefs = SCIPvarGetMultaggrScalars(sourcevar);
    859 constant = SCIPvarGetMultaggrConstant(sourcevar);
    860
    861 SCIP_CALL( SCIPallocBufferArray(targetscip, &targetaggrvars, naggrvars) );
    862
    863 /* get copies of the active variables of the multi-aggregation */
    864 for( i = 0; i < naggrvars; ++i )
    865 {
    866 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvars[i], &targetaggrvars[i], localvarmap, localconsmap, global, success) );
    867 assert(*success);
    868 }
    869
    870 /* create copy of the multi-aggregated variable */
    871 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    872 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    873
    874 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_multaggr", SCIPvarGetName(sourcevar));
    875
    876 /* add multi-aggregation x = a^T y + c as linear constraint a^T y - x = -c */
    877 SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, naggrvars, targetaggrvars, aggrcoefs, -constant,
    878 -constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    879 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, -1.0) );
    880 SCIP_CALL( SCIPaddCons(targetscip, cons) );
    881 SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
    882
    883 SCIPfreeBufferArray(targetscip, &targetaggrvars);
    884
    885 break;
    886 }
    888 {
    889 SCIP_VAR* sourcenegatedvar;
    890 SCIP_VAR* targetnegatedvar;
    891
    892 /* get negated source variable */
    893 sourcenegatedvar = SCIPvarGetNegationVar(sourcevar);
    894 assert(sourcenegatedvar != NULL);
    895 assert(SCIPvarGetStatus(sourcenegatedvar) != SCIP_VARSTATUS_NEGATED);
    896
    897 /* get copy of negated source variable */
    898 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcenegatedvar, &targetnegatedvar, localvarmap, localconsmap, global, success) );
    899 assert(*success);
    900 assert(SCIPvarGetStatus(targetnegatedvar) != SCIP_VARSTATUS_NEGATED);
    901
    902 /* get negation of copied negated source variable, this is the target variable */
    903 SCIP_CALL( SCIPgetNegatedVar(targetscip, targetnegatedvar, targetvar) );
    904 assert(SCIPvarGetStatus(*targetvar) == SCIP_VARSTATUS_NEGATED);
    905
    906 /* free local hash maps if necessary */
    907 if( uselocalvarmap )
    908 SCIPhashmapFree(&localvarmap);
    909
    910 if( uselocalconsmap )
    911 SCIPhashmapFree(&localconsmap);
    912
    913 /* we have to return right away, to avoid adding the negated variable to the problem since the "not negated"
    914 * variable was already added */
    915 return SCIP_OKAY;
    916 }
    917 default:
    918 /* note that this is in an internal SCIP error since the variable status is only handled by the core */
    919 SCIPerrorMessage("unknown variable status\n");
    920 SCIPABORT();
    921 return SCIP_ERROR; /*lint !e527*/
    922 }
    923
    924 /* add the (new) target variable to the target problem */
    925 SCIP_CALL( SCIPaddVar(targetscip, var) );
    926
    927 *targetvar = var;
    928 assert((*targetvar)->scip == targetscip);
    929
    930 /* remove the variable capture which was done due to the creation of the variable */
    931 SCIP_CALL( SCIPreleaseVar(targetscip, &var) );
    932
    933 /* free local hash maps if necessary */
    934 if( uselocalvarmap )
    935 SCIPhashmapFree(&localvarmap);
    936
    937 if( uselocalconsmap )
    938 SCIPhashmapFree(&localconsmap);
    939
    940 return SCIP_OKAY;
    941}
    942
    943/** copies all original or active variables from source-SCIP except those that are marked as relaxation-only, fixed, or aggregated
    944 * and adds these variable to the target-SCIP
    945 *
    946 * the mapping between these variables are stored in the variable hashmap
    947 * target-SCIP has to be in problem creation stage
    948 */
    949static
    951 SCIP* sourcescip, /**< source SCIP data structure */
    952 SCIP* targetscip, /**< target SCIP data structure */
    953 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    954 * target variables, or NULL */
    955 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    956 * target constraints, or NULL */
    957 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    958 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    959 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    960 SCIP_Bool original, /**< should original variables be copied? */
    961 SCIP_Bool global /**< should global or local bounds be used? (for original=FALSE) */
    962 )
    963{
    964 SCIP_VAR** sourcevars;
    965 SCIP_HASHMAP* localvarmap;
    966 SCIP_HASHMAP* localconsmap;
    967 SCIP_Bool uselocalvarmap;
    968 SCIP_Bool uselocalconsmap;
    969 int nsourcevars;
    970#ifndef NDEBUG
    971 int nrelaxonlybinvars = 0;
    972 int nrelaxonlyintvars = 0;
    973 int nrelaxonlyimplvars = 0;
    974 int nrelaxonlycontvars = 0;
    975#endif
    976 int i;
    977
    978 assert(sourcescip != NULL);
    979 assert(targetscip != NULL);
    980 assert(nfixedvars == 0 || fixedvars != NULL);
    981 assert(nfixedvars == 0 || fixedvals != NULL);
    982
    983 if( original )
    984 {
    985 /* get original variables of the source SCIP */
    986 SCIP_CALL( SCIPgetOrigVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
    987 }
    988 else
    989 {
    990 /* get active variables of the source SCIP */
    991 SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
    992 }
    993
    994 uselocalvarmap = (varmap == NULL);
    995 uselocalconsmap = (consmap == NULL);
    996
    997 if( uselocalvarmap )
    998 {
    999 /* create the variable mapping hash map */
    1000 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1001 }
    1002 else
    1003 localvarmap = varmap;
    1004
    1005 if( uselocalconsmap )
    1006 {
    1007 /* create the constraint mapping hash map */
    1008 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1009 }
    1010 else
    1011 localconsmap = consmap;
    1012
    1013 /* create the variables of the target SCIP */
    1014 for( i = 0; i < nsourcevars; ++i )
    1015 {
    1016 SCIP_Bool success;
    1017 SCIP_VAR* targetvar;
    1018
    1019 if( SCIPvarIsRelaxationOnly(sourcevars[i]) )
    1020 {
    1021#ifndef NDEBUG
    1022 if( SCIPvarIsImpliedIntegral(sourcevars[i]) )
    1023 ++nrelaxonlyimplvars;
    1024 else
    1025 {
    1026 switch( SCIPvarGetType(sourcevars[i]) )
    1027 {
    1029 ++nrelaxonlybinvars;
    1030 break;
    1032 ++nrelaxonlyintvars;
    1033 break;
    1035 ++nrelaxonlycontvars;
    1036 break;
    1037 default:
    1038 SCIPerrorMessage("unknown variable type\n");
    1039 return SCIP_INVALIDDATA;
    1040 } /*lint !e788*/
    1041 }
    1042#endif
    1043 continue;
    1044 }
    1045
    1046 /* copy variable and add this copy to the target SCIP if the copying was valid */
    1047 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevars[i], &targetvar, localvarmap, localconsmap, global, &success) );
    1048 /* copy exact data, if solving exactly */
    1049 if( SCIPisExact(targetscip) && SCIPisExact(sourcescip) )
    1050 {
    1051 SCIP_CALL( SCIPvarCopyExactData(targetscip->mem->probmem, targetvar, sourcevars[i], FALSE) );
    1052 }
    1053 assert(success);
    1054 assert(targetvar != NULL);
    1055 }
    1056
    1057 /* fix the variables that should be fixed right away */
    1058 for( i = 0; i < nfixedvars; ++i )
    1059 {
    1060 SCIP_VAR* targetvar;
    1061 SCIP_Bool infeasible;
    1062 SCIP_Bool fixed;
    1063
    1064 if( SCIPvarIsRelaxationOnly(fixedvars[i]) )
    1065 continue;
    1066
    1067 /* retrieve target variable as image of the source variable */
    1068 targetvar = (SCIP_VAR*) SCIPhashmapGetImage(localvarmap, (void *)fixedvars[i]);
    1069 assert(targetvar != NULL);
    1070
    1071 /* fix the variable to the specified value */
    1072 infeasible = fixed = FALSE;
    1073 SCIP_CALL( SCIPfixVar(targetscip, targetvar, fixedvals[i], &infeasible, &fixed) );
    1074
    1075 assert(!infeasible);
    1076 assert(fixed);
    1077 }
    1078
    1079 /* integer variables that are fixed to zero or one or have bounds [0,1] will be converted to binaries */
    1080#ifndef NDEBUG
    1081 if( original )
    1082 {
    1083 /* TODO : account for integers converted to binaries
    1084 assert(SCIPgetNOrigBinVars(sourcescip) == SCIPgetNOrigBinVars(targetscip));
    1085 assert(SCIPgetNOrigIntVars(sourcescip) == SCIPgetNOrigIntVars(targetscip));
    1086 assert(SCIPgetNOrigImplVars(sourcescip) == SCIPgetNOrigImplVars(targetscip));
    1087 assert(SCIPgetNOrigContVars(sourcescip) == SCIPgetNOrigContVars(targetscip));
    1088 */
    1089 }
    1090 else
    1091 {
    1092 SCIP_VAR** sourcefixedvars = SCIPgetFixedVars(sourcescip);
    1093 int nsourcefixedvars = SCIPgetNFixedVars(sourcescip);
    1094 int nfixedbinvars;
    1095 int nfixedintvars;
    1096 int nfixedbinimplvars;
    1097 int nfixedintimplvars;
    1098 int nfixedcontimplvars;
    1099 int nfixedcontvars;
    1100 int nfixedimplvars;
    1101
    1102 /* count number of fixed variables for all variable types */
    1103 SCIPvarsCountTypes(sourcefixedvars, nsourcefixedvars, &nfixedbinvars, &nfixedintvars,
    1104 &nfixedbinimplvars, &nfixedintimplvars, &nfixedcontimplvars, &nfixedcontvars);
    1105 nfixedimplvars = nfixedbinimplvars + nfixedintimplvars + nfixedcontimplvars;
    1106 assert(nsourcefixedvars == nfixedbinvars + nfixedintvars + nfixedimplvars + nfixedcontvars);
    1107 assert(SCIPgetNBinVars(sourcescip) <= SCIPgetNBinVars(targetscip) + nrelaxonlybinvars);
    1108 assert(SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) <= SCIPgetNIntVars(targetscip) + nrelaxonlyintvars + SCIPgetNBinVars(targetscip) + nrelaxonlybinvars);
    1109 assert(SCIPgetNIntVars(targetscip) + nrelaxonlyintvars + SCIPgetNBinVars(targetscip) + nrelaxonlybinvars <= SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) + nfixedbinvars + nfixedintvars );
    1110 assert(SCIPgetNImplVars(sourcescip) <= SCIPgetNImplVars(targetscip) + nrelaxonlyimplvars);
    1111 assert(SCIPgetNImplVars(targetscip) + nrelaxonlyimplvars <= SCIPgetNImplVars(sourcescip) + nfixedimplvars);
    1112 assert(SCIPgetNContVars(sourcescip) <= SCIPgetNContVars(targetscip) + nrelaxonlycontvars);
    1113 assert(SCIPgetNContVars(targetscip) + nrelaxonlycontvars <= SCIPgetNContVars(sourcescip) + nfixedcontvars);
    1114 }
    1115#endif
    1116
    1117 if( uselocalvarmap )
    1118 {
    1119 /* free hash map */
    1120 SCIPhashmapFree(&localvarmap);
    1121 }
    1122
    1123 if( uselocalconsmap )
    1124 {
    1125 /* free hash map */
    1126 SCIPhashmapFree(&localconsmap);
    1127 }
    1128
    1129 return SCIP_OKAY;
    1130}
    1131
    1132/** Copies all active (thus unfixed) variables from source-SCIP, except those that are marked as relaxation only,
    1133 * and adds these variable to the target-SCIP.
    1134 *
    1135 * The mapping between these variables are stored in the variable hashmap.
    1136 *
    1137 * The target-SCIP has to be in problem creation stage.
    1138 *
    1139 * @note the variables are added to the target-SCIP but not captured
    1140 *
    1141 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1142 * @note Do not change the source SCIP environment during the copying process
    1143 *
    1144 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1145 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1146 *
    1147 * @pre This method can be called if sourcescip is in one of the following stages:
    1148 * - \ref SCIP_STAGE_PROBLEM
    1149 * - \ref SCIP_STAGE_TRANSFORMED
    1150 * - \ref SCIP_STAGE_INITPRESOLVE
    1151 * - \ref SCIP_STAGE_PRESOLVING
    1152 * - \ref SCIP_STAGE_EXITPRESOLVE
    1153 * - \ref SCIP_STAGE_PRESOLVED
    1154 * - \ref SCIP_STAGE_INITSOLVE
    1155 * - \ref SCIP_STAGE_SOLVING
    1156 * - \ref SCIP_STAGE_SOLVED
    1157 *
    1158 * @pre This method can be called if targetscip is in one of the following stages:
    1159 * - \ref SCIP_STAGE_PROBLEM
    1160 *
    1161 * @note sourcescip stage does not get changed
    1162 *
    1163 * @note targetscip stage does not get changed
    1164 *
    1165 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1166 */
    1168 SCIP* sourcescip, /**< source SCIP data structure */
    1169 SCIP* targetscip, /**< target SCIP data structure */
    1170 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    1171 * target variables, or NULL */
    1172 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1173 * target constraints, or NULL */
    1174 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1175 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    1176 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1177 SCIP_Bool global /**< should global or local bounds be used? */
    1178 )
    1179{
    1180 assert(sourcescip != NULL);
    1181 assert(targetscip != NULL);
    1182
    1183 /* check stages for both, the source and the target SCIP data structure */
    1184 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1185 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1186
    1187 SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, FALSE, global) );
    1188
    1189 return SCIP_OKAY;
    1190}
    1191
    1192/** copies all original variables from source-SCIP and adds these variable to the target-SCIP; the mapping between these
    1193 * variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed and aggregated
    1194 * variables do not get copied
    1195 *
    1196 * @note the variables are added to the target-SCIP but not captured
    1197 *
    1198 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1199 * @note Do not change the source SCIP environment during the copying process
    1200 *
    1201 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1202 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1203 *
    1204 * @pre This method can be called if sourcescip is in one of the following stages:
    1205 * - \ref SCIP_STAGE_PROBLEM
    1206 * - \ref SCIP_STAGE_TRANSFORMED
    1207 * - \ref SCIP_STAGE_INITPRESOLVE
    1208 * - \ref SCIP_STAGE_PRESOLVING
    1209 * - \ref SCIP_STAGE_EXITPRESOLVE
    1210 * - \ref SCIP_STAGE_PRESOLVED
    1211 * - \ref SCIP_STAGE_INITSOLVE
    1212 * - \ref SCIP_STAGE_SOLVING
    1213 * - \ref SCIP_STAGE_SOLVED
    1214 *
    1215 * @pre This method can be called if targetscip is in one of the following stages:
    1216 * - \ref SCIP_STAGE_PROBLEM
    1217 *
    1218 * @note sourcescip stage does not get changed
    1219 *
    1220 * @note targetscip stage does not get changed
    1221 *
    1222 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1223 */
    1225 SCIP* sourcescip, /**< source SCIP data structure */
    1226 SCIP* targetscip, /**< target SCIP data structure */
    1227 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    1228 * target variables, or NULL */
    1229 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1230 * target constraints, or NULL */
    1231 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1232 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    1233 int nfixedvars /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1234 )
    1235{
    1236 assert(sourcescip != NULL);
    1237 assert(targetscip != NULL);
    1238
    1239 /* check stages for both, the source and the target SCIP data structure */
    1240 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1241 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1242
    1243 SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, TRUE, TRUE) );
    1244
    1245 return SCIP_OKAY;
    1246}
    1247
    1248/** merges the histories of variables from a source SCIP into a target SCIP. The two data structures should point to
    1249 * different SCIP instances.
    1250 *
    1251 * @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
    1252 * \p targetscip denotes the original instance
    1253 */
    1255 SCIP* sourcescip, /**< source SCIP data structure */
    1256 SCIP* targetscip, /**< target SCIP data structure */
    1257 SCIP_VAR** sourcevars, /**< source variables for history merge, NULL entries are ignored */
    1258 SCIP_VAR** targetvars, /**< target variables for history merge, NULL entries are ignored */
    1259 int nvars /**< number of variables in both variable arrays */
    1260 )
    1261{
    1262 int i;
    1263
    1264 /* check if target scip has been set to allow merging variable statistics */
    1265 if( !targetscip->set->history_allowmerge )
    1266 return SCIP_OKAY;
    1267
    1268 assert(nvars == 0 || (sourcevars != NULL && targetvars != NULL));
    1269 assert(sourcescip != targetscip);
    1270
    1271 /* we do not want to copy statistics from a scip that has not really started solving */
    1272 if( SCIPgetStage(sourcescip) < SCIP_STAGE_SOLVING )
    1273 return SCIP_OKAY;
    1274
    1275 /* if the transformation of the source was subject to scaling, the history information cannot be just copied */
    1276 if( !SCIPsetIsEQ(targetscip->set, 1.0, SCIPgetOrigObjscale(sourcescip))
    1277 || !SCIPsetIsEQ(targetscip->set, 0.0, SCIPgetOrigObjoffset(sourcescip)) )
    1278 return SCIP_OKAY;
    1279
    1280 /* merge histories of the targetSCIP-variables to the SCIP variables. */
    1281 for( i = 0; i < nvars; ++i )
    1282 {
    1283 SCIP_VARSTATUS sourcevarstatus;
    1284
    1285 if( sourcevars[i] == NULL || targetvars[i] == NULL )
    1286 continue;
    1287
    1288 assert(sourcevars[i]->scip == sourcescip);
    1289 assert(targetvars[i]->scip == targetscip);
    1290
    1291 sourcevarstatus = SCIPvarGetStatus(sourcevars[i]);
    1292
    1293 /* depending on the variable status, we use either the transformed variable history or the history of the col itself */
    1294 switch( sourcevarstatus )
    1295 {
    1297 assert(NULL != SCIPvarGetTransVar(sourcevars[i]));
    1298 SCIPvarMergeHistories(targetvars[i], SCIPvarGetTransVar(sourcevars[i]), targetscip->stat);
    1299 break;
    1301 SCIPvarMergeHistories(targetvars[i], sourcevars[i], targetscip->stat);
    1302 break;
    1303 default:
    1304 /* other variable status are currently not supported for the merging */
    1305 break;
    1306 } /*lint !e788*/
    1307 }
    1308
    1309 return SCIP_OKAY;
    1310}
    1311
    1312/** merges the statistics of NLPIs from a source SCIP into a target SCIP
    1313 *
    1314 * The two SCIP instances should point to different SCIP instances.
    1315 *
    1316 * @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
    1317 * \p targetscip denotes the original instance
    1318 */
    1320 SCIP* sourcescip, /**< source SCIP data structure */
    1321 SCIP* targetscip, /**< target SCIP data structure */
    1322 SCIP_Bool reset /**< whether to reset statistics in sourcescip */
    1323 )
    1324{
    1325 int i;
    1326
    1327 assert(sourcescip != targetscip);
    1328
    1329 for( i = 0; i < sourcescip->set->nnlpis; ++i )
    1330 {
    1331 SCIP_NLPI* sourcenlpi;
    1332 SCIP_NLPI* targetnlpi;
    1333
    1334 sourcenlpi = sourcescip->set->nlpis[i];
    1335 /* probably NLPI is on same position in target and source, otherwise do search */
    1336 if( strcmp(SCIPnlpiGetName(targetscip->set->nlpis[i]), SCIPnlpiGetName(sourcenlpi)) == 0 )
    1337 targetnlpi = targetscip->set->nlpis[i];
    1338 else
    1339 targetnlpi = SCIPsetFindNlpi(targetscip->set, SCIPnlpiGetName(sourcenlpi));
    1340
    1341 if( targetnlpi != NULL )
    1342 SCIPnlpiMergeStatistics(targetnlpi, sourcenlpi, reset);
    1343 else
    1344 {
    1345 SCIPdebugMsg(targetscip, "NLPI <%s> from source SCIP not available in target SCIP\n", SCIPnlpiGetName(sourcenlpi));
    1346 }
    1347 }
    1348}
    1349
    1350/** provides values of a solution from a subscip according to the variable in the main scip
    1351 *
    1352 * Given a subscip solution, fills an array with solution values, matching the variables given by SCIPgetVars().
    1353 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1354 * are represented as NULL entry in the subvars array.
    1355 */
    1356static
    1358 SCIP* scip, /**< SCIP data structure of the original problem */
    1359 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1360 SCIP_SOL* subsol, /**< solution of the subproblem */
    1361 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1362 SCIP_Real* solvals /**< array where to set values taken from subsol, must have length at least SCIPgetNVars(scip) */
    1363 )
    1364{
    1365 SCIP_VAR** vars;
    1366 int nvars;
    1367 int i;
    1368
    1369 assert(scip != NULL);
    1370 assert(subscip != NULL);
    1371 assert(subsol != NULL);
    1372 assert(subvars != NULL);
    1373 assert(solvals != NULL);
    1374
    1375 /* copy the solution */
    1376 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1377
    1378 /* copy the solution */
    1379 for( i = 0; i < nvars; ++i )
    1380 {
    1381 if( subvars[i] != NULL )
    1382 solvals[i] = SCIPgetSolVal(subscip, subsol, subvars[i]);
    1383 else
    1384 solvals[i] = MIN(MAX(0.0, SCIPvarGetLbLocal(vars[i])), SCIPvarGetUbLocal(vars[i])); /*lint !e666*/
    1385 }
    1386
    1387 return SCIP_OKAY;
    1388}
    1389
    1390/** translates a solution from a subscip to the main scip
    1391 *
    1392 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1393 * are represented as NULL entry in the subvars array.
    1394 *
    1395 * @note This method allocates a new solution of the main scip that needs to be freed by the user.
    1396 */
    1398 SCIP* scip, /**< SCIP data structure of the original problem */
    1399 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1400 SCIP_SOL* subsol, /**< solution of the subproblem */
    1401 SCIP_HEUR* heur, /**< heuristic that found the solution */
    1402 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1403 SCIP_SOL** newsol /**< buffer to store pointer to created solution in main SCIP */
    1404 )
    1405{
    1406 SCIP_VAR** vars;
    1407 int nvars;
    1408 SCIP_Real* subsolvals;
    1409
    1410 assert(scip != NULL);
    1411 assert(subscip != NULL);
    1412 assert(subsol != NULL);
    1413 assert(subvars != NULL);
    1414 assert(newsol != NULL);
    1415
    1416 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1417
    1418 SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
    1419
    1420 /* get the solution values */
    1421 SCIP_CALL( translateSubSol(scip, subscip, subsol, subvars, subsolvals) );
    1422
    1423 /* create new solution for the original problem */
    1424 SCIP_CALL( SCIPcreateSol(scip, newsol, heur) );
    1425 SCIP_CALL( SCIPsetSolVals(scip, *newsol, nvars, vars, subsolvals) );
    1426
    1427 SCIPfreeBufferArray(scip, &subsolvals);
    1428
    1429 return SCIP_OKAY;
    1430}
    1431
    1432/** checks the solutions from the subscip and adds the first one that is found feasible to the master SCIP
    1433 *
    1434 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1435 * are represented as NULL entry in the subvars array.
    1436 */
    1438 SCIP* scip, /**< the SCIP data structure */
    1439 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1440 SCIP_HEUR* heur, /**< heuristic that found the solution */
    1441 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1442 SCIP_Bool* success, /**< pointer to store, whether new solution was found */
    1443 int* solindex /**< pointer to store solution index of stored solution, or NULL if not of interest */
    1444 )
    1445{
    1446 SCIP_SOL* newsol = NULL;
    1447 SCIP_SOL** subsols;
    1448 int nsubsols;
    1449 int i;
    1450 SCIP_VAR** vars;
    1451 int nvars;
    1452 SCIP_Real* solvals;
    1453
    1454 assert(scip != NULL);
    1455 assert(subscip != NULL);
    1456 assert(heur != NULL);
    1457 assert(subvars != NULL);
    1458 assert(success != NULL);
    1459
    1460 *success = FALSE;
    1461
    1462 /* check, whether a solution was found */
    1463 if( SCIPgetNSols(subscip) == 0 )
    1464 return SCIP_OKAY;
    1465
    1466 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1467
    1468 SCIP_CALL( SCIPallocBufferArray(scip, &solvals, nvars) );
    1469
    1470 /* check, whether a solution was found;
    1471 * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
    1472 */
    1473 nsubsols = SCIPgetNSols(subscip);
    1474 subsols = SCIPgetSols(subscip);
    1475 for( i = 0; i < nsubsols; ++i )
    1476 {
    1477 /* create or clear main solution */
    1478 if( newsol == NULL )
    1479 {
    1480 SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
    1481 if( solindex != NULL )
    1482 *solindex = SCIPsolGetIndex(newsol);
    1483 }
    1484 else
    1485 SCIP_CALL( SCIPclearSol(scip, newsol) );
    1486
    1487 /* get values from subsol */
    1488 SCIP_CALL( translateSubSol(scip, subscip, subsols[i], subvars, solvals) );
    1489
    1490 /* put values into newsol */
    1491 SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, solvals) );
    1492
    1493 /* reject solution with invalid objective value */
    1494 if( SCIPgetSolTransObj(scip, newsol) == SCIP_INVALID ) /*lint !e777*/
    1495 continue;
    1496
    1497 /* check whether feasible */
    1498 SCIP_CALL( SCIPcheckSol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
    1499 if( *success )
    1500 {
    1501 /* if feasible, then there is a good chance that we can add it
    1502 * we use SCIPaddSolFree to make sure that newsol is indeed added and not some copy, so *solindex stays valid
    1503 */
    1504 SCIP_CALL( SCIPaddSolFree(scip, &newsol, success) );
    1505 if( *success )
    1506 {
    1507 SCIPdebugMsg(scip, "-> accepted solution of value %g\n", SCIPgetSolOrigObj(subscip, subsols[i]));
    1508 break;
    1509 }
    1510 else
    1511 {
    1512 /* continue with next subsol
    1513 * as we have used addSolFree, newsol should be NULL now
    1514 */
    1515 assert(newsol == NULL);
    1516 }
    1517 }
    1518 }
    1519
    1520 SCIPfreeBufferArray(scip, &solvals);
    1521
    1522 if( newsol != NULL )
    1523 {
    1524 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
    1525 }
    1526
    1527 return SCIP_OKAY;
    1528}
    1529
    1530/** returns copy of the source constraint; if there already is a copy of the source constraint in the constraint hash
    1531 * map, it is just returned as target constraint; elsewise a new constraint will be created; this created constraint is
    1532 * added to the constraint hash map and returned as target constraint; the variable map is used to map the variables of
    1533 * the source SCIP to the variables of the target SCIP
    1534 *
    1535 * @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
    1536 * be declared feasible even if it violates this particular constraint. This constellation should only be
    1537 * used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
    1538 * to the variable's local bounds.
    1539 *
    1540 * @note The constraint is not added to the target SCIP. You can check whether a constraint is added by calling
    1541 * SCIPconsIsAdded(). (If you mix SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add
    1542 * explicitly and what is already added.)
    1543 *
    1544 * @note The constraint is always captured, either during the creation of the copy or after finding the copy of the
    1545 * constraint in the constraint hash map
    1546 *
    1547 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1548 * @note Do not change the source SCIP environment during the copying process
    1549 *
    1550 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1551 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1552 *
    1553 * @pre This method can be called if sourcescip is in one of the following stages:
    1554 * - \ref SCIP_STAGE_PROBLEM
    1555 * - \ref SCIP_STAGE_TRANSFORMED
    1556 * - \ref SCIP_STAGE_INITPRESOLVE
    1557 * - \ref SCIP_STAGE_PRESOLVING
    1558 * - \ref SCIP_STAGE_EXITPRESOLVE
    1559 * - \ref SCIP_STAGE_PRESOLVED
    1560 * - \ref SCIP_STAGE_INITSOLVE
    1561 * - \ref SCIP_STAGE_SOLVING
    1562 * - \ref SCIP_STAGE_SOLVED
    1563 *
    1564 * @pre This method can be called if targetscip is in one of the following stages:
    1565 * - \ref SCIP_STAGE_PROBLEM
    1566 * - \ref SCIP_STAGE_TRANSFORMING
    1567 * - \ref SCIP_STAGE_INITPRESOLVE
    1568 * - \ref SCIP_STAGE_PRESOLVING
    1569 * - \ref SCIP_STAGE_EXITPRESOLVE
    1570 * - \ref SCIP_STAGE_PRESOLVED
    1571 * - \ref SCIP_STAGE_SOLVING
    1572 * - \ref SCIP_STAGE_EXITSOLVE
    1573 *
    1574 * @note sourcescip stage does not get changed
    1575 *
    1576 * @note targetscip stage does not get changed
    1577 *
    1578 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1579 */
    1581 SCIP* sourcescip, /**< source SCIP data structure */
    1582 SCIP* targetscip, /**< target SCIP data structure */
    1583 SCIP_CONS* sourcecons, /**< source constraint of the source SCIP */
    1584 SCIP_CONS** targetcons, /**< pointer to store the created target constraint */
    1585 SCIP_CONSHDLR* sourceconshdlr, /**< source constraint handler for this constraint */
    1586 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1587 * variables of the target SCIP, or NULL */
    1588 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1589 * target constraints, or NULL */
    1590 const char* name, /**< name of constraint, or NULL if the name of the source constraint should be used */
    1591 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
    1592 SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
    1593 SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
    1594 SCIP_Bool check, /**< should the constraint be checked for feasibility? */
    1595 SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
    1596 SCIP_Bool local, /**< is constraint only valid locally? */
    1597 SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
    1598 SCIP_Bool dynamic, /**< is constraint subject to aging? */
    1599 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
    1600 SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
    1601 * if it may be moved to a more global node? */
    1602 SCIP_Bool global, /**< create a global or a local copy? */
    1603 SCIP_Bool* valid /**< pointer to store whether the copying was valid or not */
    1604 )
    1605{
    1606 SCIP_HASHMAP* localvarmap;
    1607 SCIP_HASHMAP* localconsmap;
    1608 SCIP_Bool uselocalvarmap;
    1609 SCIP_Bool uselocalconsmap;
    1610
    1611 assert(targetcons != NULL);
    1612 assert(sourceconshdlr != NULL);
    1613
    1614 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPgetConsCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1615 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPgetConsCopy", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    1616
    1617 uselocalvarmap = (varmap == NULL);
    1618 uselocalconsmap = (consmap == NULL);
    1619
    1620 /* a variables map and a constraint map is needed to avoid infinite recursion */
    1621 if( uselocalvarmap )
    1622 {
    1623 /* create the variable mapping hash map */
    1624 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1625 }
    1626 else
    1627 localvarmap = varmap;
    1628
    1629 *targetcons = NULL;
    1630 if( uselocalconsmap )
    1631 {
    1632 /* create local constraint mapping hash map */
    1633 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1634 }
    1635 else
    1636 {
    1637 /* use global map and try to retrieve copied constraint */
    1638 localconsmap = consmap;
    1639 *targetcons = (SCIP_CONS*) SCIPhashmapGetImage(localconsmap, sourcecons);
    1640 }
    1641
    1642 if( *targetcons != NULL )
    1643 {
    1644 /* if found capture existing copy of the constraint */
    1645 SCIP_CALL( SCIPcaptureCons(targetscip, *targetcons) );
    1646 *valid = TRUE;
    1647 }
    1648 else
    1649 {
    1650 /* otherwise create a copy of the constraint */
    1651 SCIP_CALL( SCIPconsCopy(targetcons, targetscip->set, name, sourcescip, sourceconshdlr, sourcecons, localvarmap, localconsmap,
    1652 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) );
    1653
    1654 /* if a target constraint was created */
    1655 if( *targetcons != NULL && !uselocalconsmap )
    1656 {
    1657 /* insert constraint into mapping between source SCIP and the target SCIP */
    1658 SCIP_CALL( SCIPhashmapInsert(consmap, sourcecons, *targetcons) );
    1659 }
    1660 }
    1661
    1662 /* free locally allocated hash maps */
    1663 if( uselocalvarmap )
    1664 {
    1665 SCIPhashmapFree(&localvarmap);
    1666 }
    1667
    1668 if( uselocalconsmap )
    1669 {
    1670 SCIPhashmapFree(&localconsmap);
    1671 }
    1672
    1673 return SCIP_OKAY;
    1674}
    1675
    1676/** copies constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
    1677 * variables between the source and the target SCIP a hash map can be given; if the variable hash
    1678 * map is NULL or necessary variable mapping is missing, the required variables are created in the
    1679 * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
    1680 * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
    1681 * between the constraints of the source and target-SCIP is stored
    1682 *
    1683 * *valid is set to TRUE iff all constraints that are marked as checked or enforced were copied successfully.
    1684 * If other constraints could not be copied, *valid can still be set to TRUE.
    1685 *
    1686 * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
    1687 * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
    1688 * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
    1689 *
    1690 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1691 * @note Do not change the source SCIP environment during the copying process
    1692 *
    1693 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1694 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1695 *
    1696 * @pre This method can be called if sourcescip is in one of the following stages:
    1697 * - \ref SCIP_STAGE_PROBLEM
    1698 * - \ref SCIP_STAGE_TRANSFORMED
    1699 * - \ref SCIP_STAGE_INITPRESOLVE
    1700 * - \ref SCIP_STAGE_PRESOLVING
    1701 * - \ref SCIP_STAGE_EXITPRESOLVE
    1702 * - \ref SCIP_STAGE_PRESOLVED
    1703 * - \ref SCIP_STAGE_INITSOLVE
    1704 * - \ref SCIP_STAGE_SOLVING
    1705 * - \ref SCIP_STAGE_SOLVED
    1706 *
    1707 * @pre This method can be called if targetscip is in one of the following stages:
    1708 * - \ref SCIP_STAGE_PROBLEM
    1709 *
    1710 * @note sourcescip stage does not get changed
    1711 *
    1712 * @note targetscip stage does not get changed
    1713 *
    1714 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1715 */
    1717 SCIP* sourcescip, /**< source SCIP data structure */
    1718 SCIP* targetscip, /**< target SCIP data structure */
    1719 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1720 * variables of the target SCIP, or NULL */
    1721 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1722 * target constraints, or NULL */
    1723 SCIP_Bool global, /**< create a global or a local copy? */
    1724 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    1725 * If TRUE, the modifiable flag of constraints will be copied. */
    1726 SCIP_Bool* valid /**< pointer to store whether all checked or enforced constraints were validly copied */
    1727 )
    1728{
    1729 SCIP_CONSHDLR** sourceconshdlrs;
    1730 SCIP_HASHMAP* localvarmap;
    1731 SCIP_HASHMAP* localconsmap;
    1732 SCIP_Bool uselocalvarmap;
    1733 SCIP_Bool uselocalconsmap;
    1734 int nsourceconshdlrs;
    1735 int i;
    1736
    1737 assert(sourcescip != NULL);
    1738 assert(targetscip != NULL);
    1739 assert(valid != NULL);
    1740
    1741 /* check stages for both, the source and the target SCIP data structure */
    1742 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1743 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1744
    1745 /* check if we locally need to create a variable or constraint hash map */
    1746 uselocalvarmap = (varmap == NULL);
    1747 uselocalconsmap = (consmap == NULL);
    1748
    1749 if( uselocalvarmap )
    1750 {
    1751 /* create the variable mapping hash map */
    1752 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1753 }
    1754 else
    1755 localvarmap = varmap;
    1756
    1757 if( uselocalconsmap )
    1758 {
    1759 /* create the constraint mapping hash map */
    1760 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1761 }
    1762 else
    1763 localconsmap = consmap;
    1764
    1765 nsourceconshdlrs = SCIPgetNConshdlrs(sourcescip);
    1766 sourceconshdlrs = SCIPgetConshdlrs(sourcescip);
    1767 assert(nsourceconshdlrs == 0 || sourceconshdlrs != NULL);
    1768
    1769 *valid = TRUE;
    1770
    1771 /* copy constraints: loop through all (source) constraint handlers */
    1772 for( i = 0; i < nsourceconshdlrs; ++i )
    1773 {
    1774 SCIP_CONS** sourceconss;
    1775 SCIP_CONS* targetcons;
    1776 int nsourceconss;
    1777 int c;
    1778
    1779 assert(sourceconshdlrs[i] != NULL);
    1780
    1781 /* constraint handlers have to explicitly set the valid pointer to TRUE for every single constraint */
    1782
    1783 /* Get all active constraints for copying; this array contains all active constraints;
    1784 * constraints are active if they are globally valid and not deleted after presolving OR they
    1785 * were locally added during the search and we are currently in a node which belongs to the
    1786 * corresponding subtree.
    1787 */
    1788 nsourceconss = SCIPconshdlrGetNActiveConss(sourceconshdlrs[i]);
    1789 sourceconss = SCIPconshdlrGetConss(sourceconshdlrs[i]);
    1790
    1791#ifdef SCIP_DISABLED_CODE
    1792 /* @todo using the following might reduce the number of copied constraints - check whether this is better */
    1793 /* Get all checked constraints for copying; this included local constraints */
    1794 if( !global )
    1795 {
    1796 nsourceconss = SCIPconshdlrGetNCheckConss(sourceconshdlrs[i]);
    1797 sourceconss = SCIPconshdlrGetCheckConss(sourceconshdlrs[i]);
    1798 }
    1799#endif
    1800
    1801 assert(nsourceconss == 0 || sourceconss != NULL);
    1802
    1803 if( nsourceconss > 0 )
    1804 {
    1805 SCIPdebugMsg(sourcescip, "Attempting to copy %d %s constraints\n", nsourceconss, SCIPconshdlrGetName(sourceconshdlrs[i]));
    1806 }
    1807
    1808 /* copy all constraints of one constraint handler */
    1809 for( c = 0; c < nsourceconss; ++c )
    1810 {
    1811 SCIP_Bool singlevalid = FALSE;
    1812 /* all constraints have to be active */
    1813 assert(sourceconss[c] != NULL);
    1814 assert(SCIPconsIsActive(sourceconss[c]));
    1815 assert(!SCIPconsIsDeleted(sourceconss[c]));
    1816
    1817 /* in case of copying the global problem we have to ignore the local constraints which are active */
    1818 if( global && SCIPconsIsLocal(sourceconss[c]) )
    1819 {
    1820 SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconss[c]));
    1821 continue;
    1822 }
    1823
    1824 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    1825 targetcons = NULL;
    1826 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, sourceconshdlrs[i], localvarmap, localconsmap, NULL,
    1827 SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
    1828 SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
    1829 SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
    1830 SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, global, &singlevalid) );
    1831
    1832 /* add the copied constraint to target SCIP if the copying process created a constraint */
    1833 if( targetcons != NULL )
    1834 {
    1835 if( !enablepricing )
    1836 SCIPconsSetModifiable(targetcons, FALSE);
    1837
    1838 /* add constraint to target SCIP */
    1839 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    1840
    1841 /* add the conflict constraint to the store of targetscip */
    1842 if( SCIPconsIsConflict(sourceconss[c]) )
    1843 {
    1844 /* add the constraint as a conflict to the conflict pool of targetscip */
    1845 SCIP_CALL( SCIPconflictstoreAddConflict(targetscip->conflictstore, targetscip->mem->probmem, targetscip->set,
    1846 targetscip->stat, NULL, NULL, targetscip->reopt, targetcons, SCIP_CONFTYPE_UNKNOWN, FALSE, -SCIPinfinity(targetscip)) );
    1847 }
    1848
    1849 /* release constraint once for the creation capture */
    1850 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    1851 }
    1852 else
    1853 {
    1854 /* if an enforced or checked constraint could not be copied, then the copy is not valid, i.e.,
    1855 * the feasible set may be larger; for other constraints, it should be safe if they are omitted
    1856 * from the copy
    1857 */
    1858 if( SCIPconsIsEnforced(sourceconss[c]) || SCIPconsIsChecked(sourceconss[c]) )
    1859 *valid = FALSE;
    1860 SCIPdebugMsg(sourcescip, "Constraint %s not copied, copy is %svalid\n",
    1861 SCIPconsGetName(sourceconss[c]), *valid ? "" : "not ");
    1862 }
    1863 }
    1864 }
    1865
    1866 if( uselocalvarmap )
    1867 {
    1868 /* free hash map */
    1869 SCIPhashmapFree(&localvarmap);
    1870 }
    1871
    1872 if( uselocalconsmap )
    1873 {
    1874 /* free hash map */
    1875 SCIPhashmapFree(&localconsmap);
    1876 }
    1877
    1878 return SCIP_OKAY;
    1879}
    1880
    1881/** copies all original constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
    1882 * variables between the source and the target SCIP a hash map can be given; if the variable hash
    1883 * map is NULL or necessary variable mapping is missing, the required variables are created in the
    1884 * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
    1885 * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
    1886 * between the constraints of the source and target-SCIP is stored
    1887 *
    1888 * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
    1889 * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
    1890 * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
    1891 *
    1892 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1893 * @note Do not change the source SCIP environment during the copying process
    1894 *
    1895 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1896 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1897 *
    1898 * @pre This method can be called if sourcescip is in one of the following stages:
    1899 * - \ref SCIP_STAGE_PROBLEM
    1900 * - \ref SCIP_STAGE_TRANSFORMED
    1901 * - \ref SCIP_STAGE_INITPRESOLVE
    1902 * - \ref SCIP_STAGE_PRESOLVING
    1903 * - \ref SCIP_STAGE_EXITPRESOLVE
    1904 * - \ref SCIP_STAGE_PRESOLVED
    1905 * - \ref SCIP_STAGE_INITSOLVE
    1906 * - \ref SCIP_STAGE_SOLVING
    1907 * - \ref SCIP_STAGE_SOLVED
    1908 *
    1909 * @pre This method can be called if targetscip is in one of the following stages:
    1910 * - \ref SCIP_STAGE_PROBLEM
    1911 *
    1912 * @note sourcescip stage does not get changed
    1913 *
    1914 * @note targetscip stage does not get changed
    1915 *
    1916 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1917 */
    1919 SCIP* sourcescip, /**< source SCIP data structure */
    1920 SCIP* targetscip, /**< target SCIP data structure */
    1921 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1922 * variables of the target SCIP, or NULL */
    1923 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1924 * target constraints, or NULL */
    1925 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    1926 * If TRUE, the modifiable flag of constraints will be copied. */
    1927 SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
    1928 )
    1929{
    1930 SCIP_CONS** sourceconss;
    1931 SCIP_HASHMAP* localvarmap;
    1932 SCIP_HASHMAP* localconsmap;
    1933 SCIP_Bool uselocalvarmap;
    1934 SCIP_Bool uselocalconsmap;
    1935 int nsourceconss;
    1936 int c;
    1937
    1938 assert(sourcescip != NULL);
    1939 assert(targetscip != NULL);
    1940 assert(valid != NULL);
    1941
    1942 /* check stages for both, the source and the target SCIP data structure */
    1943 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1944 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1945
    1946 /* check if we locally need to create a variable or constraint hash map */
    1947 uselocalvarmap = (varmap == NULL);
    1948 uselocalconsmap = (consmap == NULL);
    1949
    1950 if( uselocalvarmap )
    1951 {
    1952 /* create the variable mapping hash map */
    1953 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1954 }
    1955 else
    1956 localvarmap = varmap;
    1957
    1958 if( uselocalconsmap )
    1959 {
    1960 /* create the constraint mapping hash map */
    1961 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1962 }
    1963 else
    1964 localconsmap = consmap;
    1965
    1966 sourceconss = SCIPgetOrigConss(sourcescip);
    1967 nsourceconss = SCIPgetNOrigConss(sourcescip);
    1968
    1969 *valid = TRUE;
    1970
    1971 SCIPdebugMsg(sourcescip, "Attempting to copy %d original constraints\n", nsourceconss);
    1972
    1973 /* copy constraints: loop through all (source) constraint handlers */
    1974 for( c = 0; c < nsourceconss; ++c )
    1975 {
    1976 SCIP_CONS* targetcons;
    1977 SCIP_Bool success;
    1978
    1979 /* constraint handlers have to explicitly set the success pointer to TRUE */
    1980 success = FALSE;
    1981
    1982 /* all constraints have to be active */
    1983 assert(sourceconss[c] != NULL);
    1984 assert(SCIPconsIsOriginal(sourceconss[c]));
    1985
    1986 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    1987 targetcons = NULL;
    1988 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, SCIPconsGetHdlr(sourceconss[c]), localvarmap, localconsmap, NULL,
    1989 SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
    1990 SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
    1991 SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
    1992 SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, TRUE, &success) );
    1993
    1994 /* add the copied constraint to target SCIP if the copying process was valid */
    1995 if( success )
    1996 {
    1997 assert(targetcons != NULL);
    1998
    1999 if( !enablepricing )
    2000 SCIPconsSetModifiable(targetcons, FALSE);
    2001
    2002 /* add constraint to target SCIP */
    2003 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    2004
    2005 /* release constraint once for the creation capture */
    2006 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    2007 }
    2008 else
    2009 {
    2010 *valid = FALSE;
    2011 SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconss[c]));
    2012 }
    2013 }
    2014
    2015 if( uselocalvarmap )
    2016 {
    2017 /* free hash map */
    2018 SCIPhashmapFree(&localvarmap);
    2019 }
    2020
    2021 if( uselocalconsmap )
    2022 {
    2023 /* free hash map */
    2024 SCIPhashmapFree(&localconsmap);
    2025 }
    2026
    2027 return SCIP_OKAY;
    2028}
    2029
    2030
    2031/** convert all active cuts from cutpool to linear constraints
    2032 *
    2033 * @note Do not change the source SCIP environment during the copying process
    2034 *
    2035 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2036 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2037 *
    2038 * @pre This method can be called if SCIP is in one of the following stages:
    2039 * - \ref SCIP_STAGE_PROBLEM
    2040 * - \ref SCIP_STAGE_INITPRESOLVE
    2041 * - \ref SCIP_STAGE_PRESOLVING
    2042 * - \ref SCIP_STAGE_EXITPRESOLVE
    2043 * - \ref SCIP_STAGE_PRESOLVED
    2044 * - \ref SCIP_STAGE_SOLVING
    2045 * - \ref SCIP_STAGE_EXITSOLVE
    2046 *
    2047 * @note SCIP stage does not get changed
    2048 *
    2049 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2050 */
    2052 SCIP* scip, /**< SCIP data structure */
    2053 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2054 * target variables, or NULL */
    2055 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2056 * target constraints, or NULL */
    2057 SCIP_Bool global, /**< create a global or a local copy? */
    2058 int* ncutsadded /**< pointer to store number of added cuts, or NULL */
    2059 )
    2060{
    2061 assert(scip != NULL);
    2062 assert(scip->set != NULL);
    2063
    2064 /* check stages for the SCIP data structure */
    2065 SCIP_CALL( SCIPcheckStage(scip, "SCIPconvertCutsToConss", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    2066
    2067 /* if we do not have any cuts, nothing can be converted */
    2068 if( scip->set->stage < SCIP_STAGE_SOLVING )
    2069 return SCIP_OKAY;
    2070
    2071 /* create out of all active cuts in cutpool linear constraints in targetscip */
    2072 SCIP_CALL( SCIPcopyCuts(scip, scip, varmap, consmap, global, ncutsadded) );
    2073
    2074 return SCIP_OKAY;
    2075}
    2076
    2077/** copies all active cuts from cutpool of sourcescip to linear constraints in targetscip
    2078 *
    2079 * Cuts that contain variables that are marked as relaxation-only are skipped.
    2080 *
    2081 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2082 * @note Do not change the source SCIP environment during the copying process
    2083 *
    2084 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2085 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2086 *
    2087 * @pre This method can be called if sourcescip is in one of the following stages:
    2088 * - \ref SCIP_STAGE_PROBLEM
    2089 * - \ref SCIP_STAGE_TRANSFORMED
    2090 * - \ref SCIP_STAGE_INITPRESOLVE
    2091 * - \ref SCIP_STAGE_PRESOLVING
    2092 * - \ref SCIP_STAGE_EXITPRESOLVE
    2093 * - \ref SCIP_STAGE_PRESOLVED
    2094 * - \ref SCIP_STAGE_SOLVING
    2095 * - \ref SCIP_STAGE_SOLVED
    2096 * - \ref SCIP_STAGE_EXITSOLVE
    2097 *
    2098 * @pre This method can be called if targetscip is in one of the following stages:
    2099 * - \ref SCIP_STAGE_PROBLEM
    2100 * - \ref SCIP_STAGE_INITPRESOLVE
    2101 * - \ref SCIP_STAGE_PRESOLVING
    2102 * - \ref SCIP_STAGE_EXITPRESOLVE
    2103 * - \ref SCIP_STAGE_PRESOLVED
    2104 * - \ref SCIP_STAGE_SOLVING
    2105 * - \ref SCIP_STAGE_EXITSOLVE
    2106 *
    2107 * @note sourcescip stage does not get changed
    2108 *
    2109 * @note targetscip stage does not get changed
    2110 *
    2111 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2112 */
    2114 SCIP* sourcescip, /**< source SCIP data structure */
    2115 SCIP* targetscip, /**< target SCIP data structure */
    2116 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2117 * target variables, or NULL */
    2118 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2119 * target constraints, or NULL */
    2120 SCIP_Bool global, /**< create a global or a local copy? */
    2121 int* ncutsadded /**< pointer to store number of copied cuts, or NULL */
    2122 )
    2123{
    2124 SCIP_CUT** cuts;
    2125 int ncuts;
    2126 int nlocalcutsadded;
    2127
    2128 assert(sourcescip != NULL);
    2129 assert(targetscip != NULL);
    2130
    2131 /* check stages for both, the source and the target SCIP data structure */
    2132 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyCuts", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
    2133 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyCuts", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    2134
    2135 if ( ncutsadded != NULL )
    2136 *ncutsadded = 0;
    2137 nlocalcutsadded = 0;
    2138
    2139 /* if we do not have any cuts, nothing can be converted */
    2140 if( sourcescip->set->stage < SCIP_STAGE_SOLVING )
    2141 return SCIP_OKAY;
    2142
    2143 if( SCIPfindConshdlr(targetscip, "linear") == NULL )
    2144 {
    2145 SCIPdebugMsg(sourcescip, "No linear constraint handler available. Cannot convert cuts.\n");
    2146 return SCIP_OKAY;
    2147 }
    2148
    2149 /* convert cut from global cut pool */
    2150 cuts = SCIPgetPoolCuts(sourcescip);
    2151 ncuts = SCIPgetNPoolCuts(sourcescip);
    2152
    2153 SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
    2154
    2155 SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
    2156
    2157 /* convert delayed cuts from global delayed cut pool */
    2158 cuts = SCIPgetDelayedPoolCuts(sourcescip);
    2159 ncuts = SCIPgetNDelayedPoolCuts(sourcescip);
    2160
    2161 SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
    2162
    2163 if( ncutsadded != NULL )
    2164 *ncutsadded = nlocalcutsadded;
    2165
    2166 SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
    2167
    2168 return SCIP_OKAY;
    2169}
    2170
    2171/** copies all active conflicts from the conflict pool of sourcescip and adds them as linear constraints to targetscip
    2172 *
    2173 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2174 * @note Do not change the source SCIP environment during the copying process
    2175 *
    2176 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2177 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2178 *
    2179 * @pre This method can be called if sourcescip is in one of the following stages:
    2180 * - \ref SCIP_STAGE_PROBLEM
    2181 * - \ref SCIP_STAGE_TRANSFORMED
    2182 * - \ref SCIP_STAGE_INITPRESOLVE
    2183 * - \ref SCIP_STAGE_PRESOLVING
    2184 * - \ref SCIP_STAGE_EXITPRESOLVE
    2185 * - \ref SCIP_STAGE_PRESOLVED
    2186 * - \ref SCIP_STAGE_SOLVING
    2187 * - \ref SCIP_STAGE_SOLVED
    2188 * - \ref SCIP_STAGE_EXITSOLVE
    2189 *
    2190 * @pre This method can be called if targetscip is in one of the following stages:
    2191 * - \ref SCIP_STAGE_PROBLEM
    2192 * - \ref SCIP_STAGE_INITPRESOLVE
    2193 * - \ref SCIP_STAGE_PRESOLVING
    2194 * - \ref SCIP_STAGE_EXITPRESOLVE
    2195 * - \ref SCIP_STAGE_PRESOLVED
    2196 * - \ref SCIP_STAGE_SOLVING
    2197 * - \ref SCIP_STAGE_EXITSOLVE
    2198 *
    2199 * @note sourcescip stage does not change
    2200 *
    2201 * @note targetscip stage does not change
    2202 *
    2203 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2204 */
    2206 SCIP* sourcescip, /**< source SCIP data structure */
    2207 SCIP* targetscip, /**< target SCIP data structure */
    2208 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2209 * target variables, or NULL */
    2210 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2211 * target constraints, or NULL */
    2212 SCIP_Bool global, /**< create a global or a local copy? */
    2213 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    2214 * If TRUE, the modifiable flag of constraints will be copied. */
    2215 SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
    2216 )
    2217{
    2218 SCIP_CONS** sourceconfs;
    2219 SCIP_HASHMAP* localvarmap;
    2220 SCIP_HASHMAP* localconsmap;
    2221 SCIP_Bool uselocalvarmap;
    2222 SCIP_Bool uselocalconsmap;
    2223 SCIP_Bool success;
    2224 int sourceconfssize;
    2225 int nsourceconfs;
    2226 int c;
    2227
    2228 assert(sourcescip != NULL);
    2229 assert(targetscip != NULL);
    2230
    2231 /* check stages for both, the source and the target SCIP data structure */
    2232 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConflicts", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2233 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConflicts", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    2234
    2235 /* check if we locally need to create a variable or constraint hash map */
    2236 uselocalvarmap = (varmap == NULL);
    2237 uselocalconsmap = (consmap == NULL);
    2238
    2239 if( uselocalvarmap )
    2240 {
    2241 /* create the variable mapping hash map */
    2242 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    2243 }
    2244 else
    2245 localvarmap = varmap;
    2246
    2247 if( uselocalconsmap )
    2248 {
    2249 /* create the constraint mapping hash map */
    2250 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    2251 }
    2252 else
    2253 localconsmap = consmap;
    2254
    2255 /* get number of conflicts stored in the conflict pool */
    2256 sourceconfssize = SCIPconflictstoreGetNConflictsInStore(sourcescip->conflictstore);
    2257
    2258 /* allocate buffer */
    2259 SCIP_CALL( SCIPallocBufferArray(sourcescip, &sourceconfs, sourceconfssize) );
    2260
    2261 /* get all conflicts stored in the conflict pool */
    2262 SCIP_CALL( SCIPconflictstoreGetConflicts(sourcescip->conflictstore, sourceconfs, sourceconfssize, &nsourceconfs) );
    2263 assert(nsourceconfs <= sourceconfssize);
    2264
    2265 /* copy conflicts */
    2266 for( c = 0; c < nsourceconfs; ++c )
    2267 {
    2268 SCIP_CONS* targetcons;
    2269
    2270 /* all constraints have to be active */
    2271 assert(sourceconfs[c] != NULL);
    2272 assert(SCIPconsIsActive(sourceconfs[c]));
    2273 assert(!SCIPconsIsDeleted(sourceconfs[c]));
    2274 assert(SCIPconsIsConflict(sourceconfs[c]));
    2275
    2276 /* in case of copying the global problem we have to ignore the local constraints which are active */
    2277 if( global && SCIPconsIsLocal(sourceconfs[c]) )
    2278 {
    2279 SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconfs[c]));
    2280 continue;
    2281 }
    2282
    2283 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    2284 targetcons = NULL;
    2285 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconfs[c], &targetcons, SCIPconsGetHdlr(sourceconfs[c]),
    2286 localvarmap, localconsmap, NULL, SCIPconsIsInitial(sourceconfs[c]), SCIPconsIsSeparated(sourceconfs[c]),
    2287 SCIPconsIsEnforced(sourceconfs[c]), SCIPconsIsChecked(sourceconfs[c]),
    2288 SCIPconsIsPropagated(sourceconfs[c]), FALSE, SCIPconsIsModifiable(sourceconfs[c]),
    2289 SCIPconsIsDynamic(sourceconfs[c]), SCIPconsIsRemovable(sourceconfs[c]), FALSE, global, &success) );
    2290
    2291 /* add the copied constraint to target SCIP if the copying process was valid */
    2292 if( success )
    2293 {
    2294 assert(targetcons != NULL);
    2295
    2296 if( !enablepricing )
    2297 SCIPconsSetModifiable(targetcons, FALSE);
    2298
    2299 /* add constraint to target SCIP */
    2300 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    2301
    2302 /* release constraint once for the creation capture */
    2303 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    2304 }
    2305 else
    2306 {
    2307 *valid = FALSE;
    2308 SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconfs[c]));
    2309 }
    2310 }
    2311
    2312 if( uselocalvarmap )
    2313 {
    2314 /* free hash map */
    2315 SCIPhashmapFree(&localvarmap);
    2316 }
    2317
    2318 if( uselocalconsmap )
    2319 {
    2320 /* free hash map */
    2321 SCIPhashmapFree(&localconsmap);
    2322 }
    2323
    2324 return SCIP_OKAY;
    2325}
    2326
    2327/** copies implications and cliques of sourcescip to targetscip
    2328 *
    2329 * This function should be called for a targetscip in transformed stage. It can save time in presolving of the
    2330 * targetscip, since implications and cliques are copied.
    2331 *
    2332 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2333 * @note Do not change the source SCIP environment during the copying process
    2334 *
    2335 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2336 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2337 *
    2338 * @pre This method can be called if sourcescip is in one of the following stages:
    2339 * - \ref SCIP_STAGE_TRANSFORMED
    2340 * - \ref SCIP_STAGE_INITPRESOLVE
    2341 * - \ref SCIP_STAGE_PRESOLVING
    2342 * - \ref SCIP_STAGE_EXITPRESOLVE
    2343 * - \ref SCIP_STAGE_PRESOLVED
    2344 * - \ref SCIP_STAGE_SOLVING
    2345 * - \ref SCIP_STAGE_SOLVED
    2346 * - \ref SCIP_STAGE_EXITSOLVE
    2347 *
    2348 * @pre This method can be called if targetscip is in one of the following stages:
    2349 * - \ref SCIP_STAGE_TRANSFORMED
    2350 * - \ref SCIP_STAGE_INITPRESOLVE
    2351 * - \ref SCIP_STAGE_PRESOLVING
    2352 * - \ref SCIP_STAGE_EXITPRESOLVE
    2353 * - \ref SCIP_STAGE_PRESOLVED
    2354 * - \ref SCIP_STAGE_INITSOLVE
    2355 * - \ref SCIP_STAGE_SOLVING
    2356 *
    2357 * @note sourcescip stage does not get changed
    2358 *
    2359 * @note targetscip stage does not get changed
    2360 *
    2361 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2362 */
    2364 SCIP* sourcescip, /**< source SCIP data structure */
    2365 SCIP* targetscip, /**< target SCIP data structure */
    2366 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2367 * target variables, or NULL */
    2368 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2369 * target constraints, or NULL */
    2370 SCIP_Bool global, /**< create a global or a local copy? */
    2371 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
    2372 int* nbdchgs, /**< pointer to store the number of performed bound changes, or NULL */
    2373 int* ncopied /**< pointer to store number of copied implications and cliques, or NULL */
    2374 )
    2375{
    2376 SCIP_CLIQUE** cliques;
    2377 SCIP_VAR** sourcevars;
    2378 SCIP_Bool success;
    2379 int nvars;
    2380 int nbinvars;
    2381 int ncliques;
    2382 int j;
    2383 int c;
    2384
    2385 assert( sourcescip != NULL );
    2386 assert( targetscip != NULL );
    2387 assert( sourcescip != targetscip );
    2388 assert( infeasible != NULL );
    2389
    2390 /* check stages for both, the source and the target SCIP data structure */
    2391 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
    2392 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
    2393
    2394 if ( ncopied != NULL )
    2395 *ncopied = 0;
    2396 if ( nbdchgs != NULL )
    2397 *nbdchgs = 0;
    2398
    2399 /* get all active variables */
    2400 SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nvars, &nbinvars, NULL, NULL, NULL) );
    2401
    2402 /* stop if no possible variables for cliques exist */
    2403 if ( nbinvars == 0 )
    2404 return SCIP_OKAY;
    2405
    2406 /* get cliques */
    2407 ncliques = SCIPgetNCliques(sourcescip);
    2408 if ( ncliques > 0 )
    2409 {
    2410 SCIP_VAR** targetclique;
    2411
    2412 /* get space for target cliques */
    2413 SCIP_CALL( SCIPallocBufferArray(targetscip, &targetclique, nvars) );
    2414 cliques = SCIPgetCliques(sourcescip);
    2415
    2416 /* loop through all cliques */
    2417 for (c = 0; c < ncliques; ++c)
    2418 {
    2419 SCIP_VAR** cliquevars;
    2420 SCIP_Bool* cliquevals;
    2421 int cliquesize;
    2422 int nboundchg = 0;
    2423
    2424 assert( cliques[c] != NULL );
    2425 cliquevals = SCIPcliqueGetValues(cliques[c]);
    2426 cliquevars = SCIPcliqueGetVars(cliques[c]);
    2427 cliquesize = SCIPcliqueGetNVars(cliques[c]);
    2428
    2429 /* get target variables of clique */
    2430 for (j = 0; j < cliquesize; ++j)
    2431 {
    2432 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, cliquevars[j], &targetclique[j], varmap, consmap, global, &success) );
    2433 if ( ! success )
    2434 {
    2435 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(cliquevars[j]));
    2436 SCIPfreeBufferArray(targetscip, &targetclique);
    2437 return SCIP_OKAY;
    2438 }
    2439 }
    2440
    2441 /* create clique */
    2442 SCIP_CALL( SCIPaddClique(targetscip, targetclique, cliquevals, cliquesize, SCIPcliqueIsEquation(cliques[c]),
    2443 infeasible, &nboundchg) );
    2444
    2445 if ( *infeasible )
    2446 {
    2447 SCIPfreeBufferArray(targetscip, &targetclique);
    2448 return SCIP_OKAY;
    2449 }
    2450 if ( ncopied != NULL )
    2451 ++(*ncopied);
    2452 if ( nbdchgs != NULL )
    2453 *nbdchgs += nboundchg;
    2454 }
    2455 SCIPfreeBufferArray(targetscip, &targetclique);
    2456 }
    2457
    2458 /* create binary implications */
    2459 for (j = 0; j < nbinvars; ++j)
    2460 {
    2461 SCIP_VAR* sourcevar;
    2462 SCIP_VAR* targetvar;
    2463 SCIP_Bool d;
    2464
    2465 sourcevar = sourcevars[j];
    2466 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevar, &targetvar, varmap, consmap, global, &success) );
    2467 if ( ! success )
    2468 {
    2469 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(sourcevar));
    2470 return SCIP_OKAY;
    2471 }
    2472
    2473 /* consider both possible implications */
    2474 for (d = 0; d <= 1; ++d)
    2475 {
    2476 SCIP_BOUNDTYPE* impltypes;
    2477 SCIP_VAR** implvars;
    2478 SCIP_Real* implbounds;
    2479 int nimpls;
    2480 int l;
    2481
    2482 nimpls = SCIPvarGetNImpls(sourcevar, d);
    2483 if ( nimpls == 0 )
    2484 continue;
    2485
    2486 impltypes = SCIPvarGetImplTypes(sourcevar, d);
    2487 implvars = SCIPvarGetImplVars(sourcevar, d);
    2488 implbounds = SCIPvarGetImplBounds(sourcevar, d);
    2489
    2490 /* create implications */
    2491 for (l = 0; l < nimpls; ++l)
    2492 {
    2493 SCIP_VAR* implvar;
    2494 int nboundchg = 0;
    2495
    2496 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, implvars[l], &implvar, varmap, consmap, global, &success) );
    2497 if ( ! success )
    2498 {
    2499 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(implvars[l]));
    2500 return SCIP_OKAY;
    2501 }
    2502
    2503 SCIP_CALL( SCIPaddVarImplication(targetscip, targetvar, d, implvar, impltypes[l], implbounds[l], infeasible, &nboundchg) );
    2504 if ( *infeasible )
    2505 return SCIP_OKAY;
    2506 if ( ncopied != NULL )
    2507 ++(*ncopied);
    2508 if ( nbdchgs != NULL )
    2509 *nbdchgs += nboundchg;
    2510 }
    2511 }
    2512 }
    2513
    2514 return SCIP_OKAY;
    2515}
    2516
    2517/** copies parameter settings from sourcescip to targetscip
    2518 *
    2519 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2520 * @note Do not change the source SCIP environment during the copying process
    2521 *
    2522 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2523 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2524 *
    2525 * @pre This method can be called if sourcescip is in one of the following stages:
    2526 * - \ref SCIP_STAGE_PROBLEM
    2527 * - \ref SCIP_STAGE_TRANSFORMED
    2528 * - \ref SCIP_STAGE_INITPRESOLVE
    2529 * - \ref SCIP_STAGE_PRESOLVING
    2530 * - \ref SCIP_STAGE_EXITPRESOLVE
    2531 * - \ref SCIP_STAGE_PRESOLVED
    2532 * - \ref SCIP_STAGE_INITSOLVE
    2533 * - \ref SCIP_STAGE_SOLVING
    2534 * - \ref SCIP_STAGE_SOLVED
    2535 *
    2536 * @pre This method can be called if targetscip is in one of the following stages:
    2537 * - \ref SCIP_STAGE_INIT
    2538 * - \ref SCIP_STAGE_PROBLEM
    2539 * - \ref SCIP_STAGE_FREE
    2540 *
    2541 * @note sourcescip stage does not get changed
    2542 *
    2543 * @note targetscip stage does not get changed
    2544 *
    2545 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2546 */
    2548 SCIP* sourcescip, /**< source SCIP data structure */
    2549 SCIP* targetscip /**< target SCIP data structure */
    2550 )
    2551{
    2552 assert(sourcescip != NULL);
    2553 assert(targetscip != NULL);
    2554 assert(sourcescip->set != NULL);
    2555 assert(targetscip->set != NULL);
    2556
    2557 /* check stages for both, the source and the target SCIP data structure */
    2558 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyParamSettings", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2559 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyParamSettings", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2560
    2561 SCIP_CALL( SCIPsetCopyParams(sourcescip->set, targetscip->set, targetscip->messagehdlr) );
    2562
    2563 return SCIP_OKAY;
    2564}
    2565
    2566/** gets depth of current scip instance (increased by each copy call)
    2567 *
    2568 * @return Depth of subscip of SCIP is returned.
    2569 *
    2570 * @pre This method can be called if SCIP is in one of the following stages:
    2571 * - \ref SCIP_STAGE_PROBLEM
    2572 * - \ref SCIP_STAGE_TRANSFORMING
    2573 * - \ref SCIP_STAGE_TRANSFORMED
    2574 * - \ref SCIP_STAGE_INITPRESOLVE
    2575 * - \ref SCIP_STAGE_PRESOLVING
    2576 * - \ref SCIP_STAGE_EXITPRESOLVE
    2577 * - \ref SCIP_STAGE_PRESOLVED
    2578 * - \ref SCIP_STAGE_INITSOLVE
    2579 * - \ref SCIP_STAGE_SOLVING
    2580 * - \ref SCIP_STAGE_SOLVED
    2581 * - \ref SCIP_STAGE_EXITSOLVE
    2582 * - \ref SCIP_STAGE_FREETRANS
    2583 *
    2584 * @note SCIP stage does not get changed
    2585 *
    2586 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2587 */
    2589 SCIP* scip /**< SCIP data structure */
    2590 )
    2591{
    2592 assert( scip != NULL );
    2593 assert( scip->stat != NULL );
    2594
    2595 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSubscipDepth", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
    2596
    2597 return scip->stat->subscipdepth;
    2598}
    2599
    2600/** sets depth of scip instance
    2601 *
    2602 * @pre This method can be called if SCIP is in one of the following stages:
    2603 * - \ref SCIP_STAGE_PROBLEM
    2604 *
    2605 * @note SCIP stage does not get changed
    2606 *
    2607 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2608 */
    2610 SCIP* scip, /**< SCIP data structure */
    2611 int newdepth /**< new subscip depth */
    2612 )
    2613{
    2614 assert( scip != NULL );
    2615 assert( newdepth > 0 );
    2616
    2618
    2619 assert( scip->stat != NULL );
    2620 scip->stat->subscipdepth = newdepth;
    2621}
    2622
    2623/** copies source SCIP data into target SCIP data structure
    2624 *
    2625 * distinguishes between
    2626 * - local and global copies
    2627 * - copies of the original or transformed problem
    2628 *
    2629 * Allows for constraint compression by specifying a number of source variables
    2630 * and values that should be fixed in the copy.
    2631 */
    2632static
    2634 SCIP* sourcescip, /**< source SCIP data structure */
    2635 SCIP* targetscip, /**< target SCIP data structure */
    2636 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2637 * target variables, or NULL */
    2638 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2639 * target constraints, or NULL */
    2640 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2641 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2642 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    2643 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2644 SCIP_Bool useconscompression, /**< should constraint compression be used when constraints are created? */
    2645 SCIP_Bool global, /**< create a global or a local copy? */
    2646 SCIP_Bool original, /**< copy original or transformed problem? if TRUE, a copy using local bounds is not possible */
    2647 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2648 * plugins will be copied and activated, and the modifiable flag of
    2649 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2650 * there are pricers present */
    2651 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2652 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2653 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2654 SCIP_Bool* valid /**< pointer to store whether the copying was valid or not, or NULL */
    2655 )
    2656{
    2657 SCIP_HASHMAP* localvarmap;
    2658 SCIP_HASHMAP* localconsmap;
    2659 SCIP_Real startcopytime;
    2660 SCIP_Real copytime;
    2661 SCIP_Bool uselocalvarmap;
    2662 SCIP_Bool uselocalconsmap;
    2663 SCIP_Bool consscopyvalid;
    2664 SCIP_Bool benderscopyvalid;
    2665 SCIP_Bool localvalid;
    2666 SCIP_Bool msghdlrquiet;
    2667 char name[SCIP_MAXSTRLEN];
    2668
    2669 assert(sourcescip != NULL);
    2670 assert(targetscip != NULL);
    2671 assert(suffix != NULL);
    2672
    2673 /* copy the original problem if we are in SCIP_STAGE_PROBLEM stage */
    2674 if( SCIPgetStage(sourcescip) == SCIP_STAGE_PROBLEM )
    2675 original = TRUE;
    2676
    2677 /* global must be TRUE for the original problem */
    2678 assert(global || !original);
    2679
    2680 /* get time before start of copy procedure */
    2681 startcopytime = SCIPclockGetTime(sourcescip->stat->copyclock);
    2682
    2683 /* start time measuring */
    2684 SCIPclockStart(sourcescip->stat->copyclock, sourcescip->set);
    2685
    2686 /* copy all plugins */
    2687 SCIP_CALL( SCIPcopyPlugins(sourcescip, targetscip, TRUE, enablepricing, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
    2688 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, passmessagehdlr, &localvalid) );
    2689
    2690 /* in case there are active pricers and pricing is disabled, targetscip will not be a valid copy of sourcescip */
    2691 if( ! enablepricing && SCIPgetNActivePricers(sourcescip) > 0 )
    2692 localvalid = FALSE;
    2693
    2694 SCIPdebugMsg(sourcescip, "Copying plugins was%s valid.\n", localvalid ? "" : " not");
    2695
    2696 uselocalvarmap = (varmap == NULL);
    2697 uselocalconsmap = (consmap == NULL);
    2698
    2699 if( uselocalvarmap )
    2700 {
    2701 /* create the variable mapping hash map */
    2702 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    2703 }
    2704 else
    2705 localvarmap = varmap;
    2706
    2707 if( uselocalconsmap )
    2708 {
    2709 /* create the constraint mapping hash map */
    2710 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    2711 }
    2712 else
    2713 localconsmap = consmap;
    2714
    2715 /* construct name for the target SCIP using the source problem name and the given suffix string */
    2716 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPgetProbName(sourcescip), suffix);
    2717
    2718 /* store the quiet state of the message handler, if existent */
    2719 msghdlrquiet = SCIPmessagehdlrIsQuiet(targetscip->messagehdlr);
    2720
    2721 /* explicitly suppress output when copying parameters */
    2722 SCIPsetMessagehdlrQuiet(targetscip, TRUE);
    2723
    2724 /* copy all settings */
    2725 SCIP_CALL( SCIPcopyParamSettings(sourcescip, targetscip) );
    2726
    2727 /* even when solving exactly, sub-SCIP heuristics should be run in floating-point mode, since the exactsol constraint
    2728 * handler is in place to perform a final repair step
    2729 */
    2730 SCIP_CALL( SCIPenableExactSolving(targetscip, FALSE) );
    2731
    2732 /* restore original quiet state */
    2733 SCIPsetMessagehdlrQuiet(targetscip, msghdlrquiet);
    2734
    2735 /* create problem in the target SCIP copying the source original or transformed problem data */
    2736 if( original )
    2737 {
    2738 SCIP_CALL( SCIPcopyOrigProb(sourcescip, targetscip, localvarmap, localconsmap, name) );
    2739 }
    2740 else
    2741 {
    2742 SCIP_CALL( SCIPcopyProb(sourcescip, targetscip, localvarmap, localconsmap, global, name) );
    2743 }
    2744
    2745 /* copy original or transformed variables and perform fixings if needed */
    2746 SCIP_CALL( copyVars(sourcescip, targetscip, localvarmap, localconsmap, fixedvars, fixedvals, nfixedvars, original, global) );
    2747
    2748 /* if fixed variables are directly specified or inferred from local bounds, enable constraint compression */
    2749 if( useconscompression && (nfixedvars > 0 || !global) )
    2750 {
    2751 SCIP_CALL( SCIPenableConsCompression(targetscip) );
    2752
    2753 SCIPdebugMsg(sourcescip, "SCIPenableConsCompression() with nxfixedvars=%d and global=%u invalidates copy.\n",
    2754 nfixedvars, global);
    2755
    2756 /* domain reductions yield a copy that is no longer guaranteed to be valid */
    2757 localvalid = FALSE;
    2758 }
    2759
    2760 /* copy all (original) constraints */
    2761 if( original )
    2762 {
    2763 SCIP_CALL( SCIPcopyOrigConss(sourcescip, targetscip, localvarmap, localconsmap, enablepricing, &consscopyvalid) );
    2764 }
    2765 else
    2766 {
    2767 SCIP_CALL( SCIPcopyConss(sourcescip, targetscip, localvarmap, localconsmap, global, enablepricing, &consscopyvalid) );
    2768 }
    2769
    2770 SCIPdebugMsg(sourcescip, "Copying%s constraints was%s valid.\n",
    2771 original ? " (original)" : "", consscopyvalid ? "" : " not");
    2772
    2773 localvalid = localvalid && consscopyvalid;
    2774
    2775 /* copy the Benders' decomposition plugins explicitly, because it requires the variable mapping hash map */
    2776 SCIP_CALL( SCIPcopyBenders(sourcescip, targetscip, localvarmap, threadsafe, &benderscopyvalid) );
    2777
    2778 SCIPdebugMsg(sourcescip, "Copying Benders' decomposition plugins was%s valid.\n", benderscopyvalid ? "" : " not");
    2779
    2780 localvalid = localvalid && benderscopyvalid;
    2781
    2782 if( uselocalvarmap )
    2783 {
    2784 /* free hash map */
    2785 SCIPhashmapFree(&localvarmap);
    2786 }
    2787
    2788 if( uselocalconsmap )
    2789 {
    2790 /* free hash map */
    2791 SCIPhashmapFree(&localconsmap);
    2792 }
    2793
    2794 /* stop time measuring */
    2795 SCIPclockStop(sourcescip->stat->copyclock, sourcescip->set);
    2796
    2797 /* get time after copying procedure */
    2798 copytime = SCIPclockGetTime(sourcescip->stat->copyclock) - startcopytime;
    2799
    2800 if( copytime > sourcescip->stat->maxcopytime )
    2801 sourcescip->stat->maxcopytime = copytime;
    2802 if( copytime < sourcescip->stat->mincopytime )
    2803 sourcescip->stat->mincopytime = copytime;
    2804
    2805 /* increase copy counter */
    2806 ++(sourcescip->stat->ncopies);
    2807
    2808 targetscip->concurrent = sourcescip->concurrent;
    2809 SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
    2810 targetscip->syncstore = sourcescip->syncstore;
    2812
    2813 /* return the information about a valid copy to the user */
    2814 if( valid != NULL )
    2815 *valid = localvalid;
    2816
    2817 return SCIP_OKAY;
    2818}
    2819
    2820/** copies source SCIP to target SCIP; the copying process is done in the following order:
    2821 * 1) copy those plugins that have copy callbacks
    2822 * 2) copy the settings for the present parameters
    2823 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    2824 * 4) copy all active variables except those that are marked as relaxation-only
    2825 * 5) copy all constraints
    2826 *
    2827 * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
    2828 * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrig().
    2829 *
    2830 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    2831 *
    2832 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2833 * Also, 'passmessagehdlr' should be set to FALSE.
    2834 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    2835 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    2836 * typically incurs a performance cost.
    2837 * @note Do not change the source SCIP environment during the copying process
    2838 *
    2839 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    2840 *
    2841 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2842 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2843 *
    2844 * @pre This method can be called if sourcescip is in one of the following stages:
    2845 * - \ref SCIP_STAGE_PROBLEM
    2846 * - \ref SCIP_STAGE_TRANSFORMED
    2847 * - \ref SCIP_STAGE_INITPRESOLVE
    2848 * - \ref SCIP_STAGE_PRESOLVING
    2849 * - \ref SCIP_STAGE_EXITPRESOLVE
    2850 * - \ref SCIP_STAGE_PRESOLVED
    2851 * - \ref SCIP_STAGE_INITSOLVE
    2852 * - \ref SCIP_STAGE_SOLVING
    2853 * - \ref SCIP_STAGE_SOLVED
    2854 *
    2855 * @pre This method can be called if targetscip is in one of the following stages:
    2856 * - \ref SCIP_STAGE_INIT
    2857 * - \ref SCIP_STAGE_FREE
    2858 *
    2859 * @note sourcescip stage does not get changed
    2860 *
    2861 * @note targetscip stage does not get changed
    2862 *
    2863 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2864 */
    2866 SCIP* sourcescip, /**< source SCIP data structure */
    2867 SCIP* targetscip, /**< target SCIP data structure */
    2868 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2869 * target variables, or NULL */
    2870 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2871 * target constraints, or NULL */
    2872 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2873 SCIP_Bool global, /**< create a global or a local copy? */
    2874 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2875 * plugins will be copied and activated, and the modifiable flag of
    2876 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2877 * there are pricers present */
    2878 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2879 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2880 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2881 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    2882 )
    2883{
    2884 SCIP_VAR** fixedvars = NULL;
    2885 SCIP_Real* fixedvals = NULL;
    2886 int nfixedvars = 0;
    2887 SCIP_Bool original = FALSE;
    2888 SCIP_Bool useconscompression = FALSE;
    2889
    2890 assert(sourcescip != NULL);
    2891 assert(targetscip != NULL);
    2892 assert(suffix != NULL);
    2893
    2894 /* check stages for both, the source and the target SCIP data structure */
    2895 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2896 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopy", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2897
    2898 /* copy source SCIP data into target SCIP data structure */
    2899 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    2900 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    2901
    2902 return SCIP_OKAY;
    2903}
    2904
    2905/** copies source SCIP to target SCIP but compresses constraints
    2906 *
    2907 * constraint compression is performed by removing fixed variables immediately
    2908 * during constraint creation if the involved constraint handlers support
    2909 * compression
    2910 *
    2911 * the copying process is done in the following order:
    2912 * 1) copy the plugins
    2913 * 2) copy the settings
    2914 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    2915 * 4) copy all active variables except those that are marked as relaxation-only
    2916 * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
    2917 * b) enable constraint compression
    2918 * 5) copy all constraints
    2919 *
    2920 * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
    2921 * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrigConsCompression().
    2922 *
    2923 * @note: in case that a combination of local bounds and explicit fixing values should be used,
    2924 * the fixing value of a variable is preferred if local bounds and fixing value disagree.
    2925 *
    2926 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    2927 *
    2928 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2929 * Also, 'passmessagehdlr' should be set to FALSE.
    2930 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    2931 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    2932 * typically incurs a performance cost.
    2933 * @note Do not change the source SCIP environment during the copying process
    2934 *
    2935 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    2936 *
    2937 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2938 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2939 *
    2940 * @pre This method can be called if sourcescip is in one of the following stages:
    2941 * - \ref SCIP_STAGE_PROBLEM
    2942 * - \ref SCIP_STAGE_TRANSFORMED
    2943 * - \ref SCIP_STAGE_INITPRESOLVE
    2944 * - \ref SCIP_STAGE_PRESOLVING
    2945 * - \ref SCIP_STAGE_EXITPRESOLVE
    2946 * - \ref SCIP_STAGE_PRESOLVED
    2947 * - \ref SCIP_STAGE_INITSOLVE
    2948 * - \ref SCIP_STAGE_SOLVING
    2949 * - \ref SCIP_STAGE_SOLVED
    2950 *
    2951 * @pre This method can be called if targetscip is in one of the following stages:
    2952 * - \ref SCIP_STAGE_INIT
    2953 * - \ref SCIP_STAGE_FREE
    2954 *
    2955 * @note sourcescip stage does not get changed
    2956 *
    2957 * @note targetscip stage does not get changed
    2958 *
    2959 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2960 */
    2962 SCIP* sourcescip, /**< source SCIP data structure */
    2963 SCIP* targetscip, /**< target SCIP data structure */
    2964 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2965 * target variables, or NULL */
    2966 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2967 * target constraints, or NULL */
    2968 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2969 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2970 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    2971 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2972 SCIP_Bool global, /**< create a global or a local copy? */
    2973 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2974 * plugins will be copied and activated, and the modifiable flag of
    2975 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2976 * there are pricers present */
    2977 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2978 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2979 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2980 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    2981 )
    2982{
    2983 SCIP_Bool original = FALSE;
    2984 SCIP_Bool useconscompression = TRUE;
    2985
    2986 assert(sourcescip != NULL);
    2987 assert(targetscip != NULL);
    2988 assert(suffix != NULL);
    2989
    2990 /* check stages for both, the source and the target SCIP data structure */
    2991 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2992 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2993
    2994 /* copy the source problem data */
    2995 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    2996 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    2997
    2998 return SCIP_OKAY;
    2999}
    3000
    3001
    3002/** copies source SCIP original problem to target SCIP; the copying process is done in the following order:
    3003 * 1) copy the plugins
    3004 * 2) copy the settings
    3005 * 3) create problem data in target-SCIP and copy the original problem data of the source-SCIP
    3006 * 4) copy all original variables
    3007 * 5) copy all original constraints
    3008 *
    3009 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    3010 *
    3011 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    3012 * Also, 'passmessagehdlr' should be set to FALSE.
    3013 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    3014 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    3015 * typically incurs a performance cost.
    3016 * @note Do not change the source SCIP environment during the copying process
    3017 *
    3018 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    3019 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    3020 *
    3021 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    3022 *
    3023 * @pre This method can be called if sourcescip is in one of the following stages:
    3024 * - \ref SCIP_STAGE_PROBLEM
    3025 * - \ref SCIP_STAGE_TRANSFORMED
    3026 * - \ref SCIP_STAGE_INITPRESOLVE
    3027 * - \ref SCIP_STAGE_PRESOLVING
    3028 * - \ref SCIP_STAGE_EXITPRESOLVE
    3029 * - \ref SCIP_STAGE_PRESOLVED
    3030 * - \ref SCIP_STAGE_INITSOLVE
    3031 * - \ref SCIP_STAGE_SOLVING
    3032 * - \ref SCIP_STAGE_SOLVED
    3033 *
    3034 * @pre This method can be called if targetscip is in one of the following stages:
    3035 * - \ref SCIP_STAGE_INIT
    3036 * - \ref SCIP_STAGE_FREE
    3037 *
    3038 * @note sourcescip stage does not get changed
    3039 *
    3040 * @note targetscip stage does not get changed
    3041 *
    3042 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3043 */
    3045 SCIP* sourcescip, /**< source SCIP data structure */
    3046 SCIP* targetscip, /**< target SCIP data structure */
    3047 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    3048 * target variables, or NULL */
    3049 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    3050 * target constraints, or NULL */
    3051 const char* suffix, /**< suffix which will be added to the names of the target SCIP, might be empty */
    3052 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    3053 * plugins will be copied and activated, and the modifiable flag of
    3054 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    3055 * there are pricers present */
    3056 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    3057 * SCIP, otherwise TRUE. This is usually set to FALSE */
    3058 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    3059 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    3060 )
    3061{
    3062 SCIP_VAR** fixedvars = NULL;
    3063 SCIP_Real* fixedvals = NULL;
    3064 int nfixedvars = 0;
    3065 SCIP_Bool global = TRUE;
    3066 SCIP_Bool original = TRUE;
    3067 SCIP_Bool useconscompression = FALSE;
    3068
    3069 assert(sourcescip != NULL);
    3070 assert(targetscip != NULL);
    3071 assert(suffix != NULL);
    3072
    3073 /* check stages for both, the source and the target SCIP data structure */
    3074 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    3075 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrig", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    3076
    3077 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    3078 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    3079
    3080 return SCIP_OKAY;
    3081}
    3082
    3083/** copies source SCIP original problem to target SCIP but compresses constraints
    3084 *
    3085 * constraint compression is performed by removing fixed variables immediately
    3086 * during constraint creation if the involved constraint handlers support
    3087 * compression
    3088 *
    3089 * the copying process is done in the following order:
    3090 * 1) copy the plugins
    3091 * 2) copy the settings
    3092 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    3093 * 4) copy all original variables
    3094 * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
    3095 * b) enable constraint compression
    3096 * 5) copy all constraints
    3097 *
    3098 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    3099 *
    3100 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    3101 * Also, 'passmessagehdlr' should be set to FALSE.
    3102 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    3103 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    3104 * typically incurs a performance cost.
    3105 * @note Do not change the source SCIP environment during the copying process
    3106 *
    3107 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    3108 *
    3109 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    3110 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    3111 *
    3112 * @pre This method can be called if sourcescip is in one of the following stages:
    3113 * - \ref SCIP_STAGE_PROBLEM
    3114 * - \ref SCIP_STAGE_TRANSFORMED
    3115 * - \ref SCIP_STAGE_INITPRESOLVE
    3116 * - \ref SCIP_STAGE_PRESOLVING
    3117 * - \ref SCIP_STAGE_EXITPRESOLVE
    3118 * - \ref SCIP_STAGE_PRESOLVED
    3119 * - \ref SCIP_STAGE_INITSOLVE
    3120 * - \ref SCIP_STAGE_SOLVING
    3121 * - \ref SCIP_STAGE_SOLVED
    3122 *
    3123 * @pre This method can be called if targetscip is in one of the following stages:
    3124 * - \ref SCIP_STAGE_INIT
    3125 * - \ref SCIP_STAGE_FREE
    3126 *
    3127 * @note sourcescip stage does not get changed
    3128 *
    3129 * @note targetscip stage does not get changed
    3130 *
    3131 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3132 */
    3134 SCIP* sourcescip, /**< source SCIP data structure */
    3135 SCIP* targetscip, /**< target SCIP data structure */
    3136 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    3137 * target variables, or NULL */
    3138 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    3139 * target constraints, or NULL */
    3140 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    3141 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    3142 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    3143 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    3144 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    3145 * plugins will be copied and activated, and the modifiable flag of
    3146 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    3147 * there are pricers present */
    3148 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    3149 * SCIP, otherwise TRUE. This is usually set to FALSE */
    3150 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    3151 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    3152 )
    3153{
    3154 SCIP_Bool original = TRUE;
    3155 SCIP_Bool global = TRUE;
    3156 SCIP_Bool useconscompression = TRUE;
    3157
    3158 assert(sourcescip != NULL);
    3159 assert(targetscip != NULL);
    3160 assert(suffix != NULL);
    3161
    3162 /* check stages for both, the source and the target SCIP data structure */
    3163 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    3164 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    3165
    3166 /* copy the source problem data */
    3167 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    3168 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    3169
    3170 SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
    3171 targetscip->syncstore = sourcescip->syncstore;
    3173
    3174 return SCIP_OKAY;
    3175}
    3176
    3177/** return updated time limit for a sub-SCIP */
    3178static
    3180 SCIP* sourcescip, /**< source SCIP data structure */
    3181 SCIP_Real* timelimit /**< pointer to store sub-SCIP time limit */
    3182 )
    3183{
    3184 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/time", timelimit) );
    3185 if( !SCIPisInfinity(sourcescip, *timelimit) )
    3186 (*timelimit) -= SCIPgetSolvingTime(sourcescip);
    3187
    3188 return SCIP_OKAY;
    3189}
    3190
    3191/** set updated time limit for a sub-SCIP */
    3192static
    3194 SCIP* sourcescip, /**< source SCIP data structure */
    3195 SCIP* targetscip /**< target SCIP data structure */
    3196 )
    3197{
    3198 if( SCIPgetParam(targetscip, "limits/softtime") == NULL )
    3199 return SCIP_OKAY;
    3200 else
    3201 {
    3202 SCIP_Real timelimit = -1.0;
    3203
    3204 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/softtime", &timelimit) );
    3205 if( !SCIPisNegative(sourcescip, timelimit) )
    3206 {
    3207 timelimit -= SCIPgetSolvingTime(sourcescip);
    3208 timelimit = MAX(0.0, timelimit);
    3209 }
    3210
    3211 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/softtime", timelimit) );
    3212 }
    3213 return SCIP_OKAY;
    3214}
    3215
    3216/** return updated memory limit for a sub-SCIP */
    3217static
    3219 SCIP* sourcescip, /**< source SCIP data structure */
    3220 SCIP_Real* memorylimit /**< pointer to store sub-SCIP memory limit */
    3221 )
    3222{
    3223 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/memory", memorylimit) );
    3224
    3225 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
    3226 if( !SCIPisInfinity(sourcescip, *memorylimit) )
    3227 (*memorylimit) -= (SCIPgetMemUsed(sourcescip) + SCIPgetMemExternEstim(sourcescip))/1048576.0;
    3228
    3229 return SCIP_OKAY;
    3230}
    3231
    3232/** checks if there is enough time and memory left for copying the sourcescip into a sub-SCIP and solve the sub-SCIP
    3233 *
    3234 * This is the case if the time and memory limit that would be passed to the sub-SCIP are larger than 0.0
    3235 *
    3236 * @pre This method can be called if sourcescip is in one of the following stages:
    3237 * - \ref SCIP_STAGE_PROBLEM
    3238 * - \ref SCIP_STAGE_TRANSFORMED
    3239 * - \ref SCIP_STAGE_INITPRESOLVE
    3240 * - \ref SCIP_STAGE_PRESOLVING
    3241 * - \ref SCIP_STAGE_EXITPRESOLVE
    3242 * - \ref SCIP_STAGE_PRESOLVED
    3243 * - \ref SCIP_STAGE_INITSOLVE
    3244 * - \ref SCIP_STAGE_SOLVING
    3245 * - \ref SCIP_STAGE_SOLVED
    3246 *
    3247 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3248 */
    3250 SCIP* sourcescip, /**< source SCIP data structure */
    3251 SCIP_Bool* success /**< pointer to store whether there is time and memory left to copy the
    3252 * problem and run the sub-SCIP */
    3253 )
    3254{
    3255 SCIP_Real timelimit;
    3256
    3257 SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
    3258
    3259 if( sourcescip->set->misc_avoidmemout )
    3260 {
    3261 SCIP_Real memorylimit;
    3262
    3263 /* try to avoid running into memory limit */
    3264 SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
    3265 *success = timelimit > 0.0 && memorylimit > 2.0 * SCIPgetMemExternEstim(sourcescip) / 1048576.0;
    3266 }
    3267 else
    3268 *success = timelimit > 0.0;
    3269
    3270 return SCIP_OKAY;
    3271}
    3272
    3273/** copies limits from source SCIP to target SCIP
    3274 *
    3275 * @note time and memory limit are reduced by the amount already spent in the source SCIP before installing the limit
    3276 * in the target SCIP
    3277 * @note all other limits are disabled and need to be enabled afterwards, if needed
    3278 *
    3279 * @pre This method can be called if sourcescip is in one of the following stages:
    3280 * - \ref SCIP_STAGE_PROBLEM
    3281 * - \ref SCIP_STAGE_TRANSFORMED
    3282 * - \ref SCIP_STAGE_INITPRESOLVE
    3283 * - \ref SCIP_STAGE_PRESOLVING
    3284 * - \ref SCIP_STAGE_EXITPRESOLVE
    3285 * - \ref SCIP_STAGE_PRESOLVED
    3286 * - \ref SCIP_STAGE_INITSOLVE
    3287 * - \ref SCIP_STAGE_SOLVING
    3288 * - \ref SCIP_STAGE_SOLVED
    3289 *
    3290 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3291 */
    3293 SCIP* sourcescip, /**< source SCIP data structure */
    3294 SCIP* targetscip /**< target SCIP data structure */
    3295 )
    3296{
    3297 SCIP_Real timelimit;
    3298 SCIP_Real memorylimit;
    3299
    3300 SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
    3301 SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
    3302
    3303 /* avoid negative limits */
    3304 if( timelimit < 0.0 )
    3305 timelimit = 0.0;
    3306 if( memorylimit < 0.0 )
    3307 memorylimit = 0.0;
    3308
    3309 /* set time and memory limit to the adjusted values */
    3310 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/time", timelimit) );
    3311 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/memory", memorylimit) );
    3312
    3313 /* copy and adjust soft time limit (or disable it) */
    3314 SCIP_CALL( copySofttimelimit(sourcescip, targetscip) );
    3315
    3316 /* disable all other limits */
    3317 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/absgap", 0.0) );
    3318 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/bestsol", -1) );
    3319 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/gap", 0.0) );
    3320 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/nodes", -1LL) );
    3321 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/restarts", -1) );
    3322 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/solutions", -1) );
    3323 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/stallnodes", -1LL) );
    3324 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/totalnodes", -1LL) );
    3325 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/primal", SCIP_INVALID) );
    3326 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/dual", SCIP_INVALID) );
    3327
    3328 return SCIP_OKAY;
    3329}
    3330
    3331/** sets the working limits as well as common search parameters for the auxiliary problem
    3332 *
    3333 * @note memory and time limits are not affected, and must be set using SCIPcopyLimits() instead
    3334 */
    3336 SCIP* sourcescip, /**< source SCIP data structure */
    3337 SCIP* subscip, /**< target SCIP data structure, often a copy of sourcescip */
    3338 SCIP_Longint nsubnodes, /**< nodelimit for subscip, or -1 for no limit */
    3339 SCIP_Longint nstallnodes, /**< stall node limit for subscip, or -1 for no limit */
    3340 int bestsollimit /**< the limit on the number of best solutions found, or -1 for no limit */
    3341 )
    3342{
    3343 SCIP_Bool useuct;
    3344
    3345 assert(sourcescip != NULL);
    3346 assert(subscip != NULL);
    3347
    3348 /* do not abort subproblem on CTRL-C */
    3349 SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
    3350
    3351#ifdef SCIP_DEBUG
    3352 /* for debugging, enable full output */
    3353 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
    3354 SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
    3355#else
    3356 /* disable statistic timing inside sub SCIP and output to console */
    3357 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
    3358 SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
    3359#endif
    3360
    3361 /* set limits for the subproblem */
    3362 SCIP_CALL( SCIPcopyLimits(sourcescip, subscip) );
    3363 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nsubnodes) );
    3364 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
    3365 SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", bestsollimit) );
    3366
    3367 /* forbid recursive call of heuristics and separators solving subMIPs */
    3368 SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
    3369
    3370 /* disable cutting plane separation */
    3372
    3373 /* disable expensive presolving */
    3375
    3376 /* use best estimate node selection */
    3377 if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
    3378 {
    3379 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
    3380 }
    3381
    3382 /* activate uct node selection at the top of the tree */
    3383 SCIP_CALL( SCIPgetBoolParam(sourcescip, "heuristics/useuctsubscip", &useuct) );
    3384 if( useuct && SCIPfindNodesel(subscip, "uct") != NULL && !SCIPisParamFixed(subscip, "nodeselection/uct/stdpriority") )
    3385 {
    3386 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/uct/stdpriority", INT_MAX/2) );
    3387 }
    3388
    3389 /* use inference branching */
    3390 if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
    3391 {
    3392 SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
    3393 }
    3394
    3395 /* enable conflict analysis, disable analysis of boundexceeding LPs, and restrict conflict pool */
    3396 if( !SCIPisParamFixed(subscip, "conflict/enable") )
    3397 {
    3398 SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", TRUE) );
    3399 }
    3400 if( !SCIPisParamFixed(subscip, "conflict/useboundlp") )
    3401 {
    3402 SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useboundlp", 'o') );
    3403 }
    3404 if( !SCIPisParamFixed(subscip, "conflict/maxstoresize") )
    3405 {
    3406 SCIP_CALL( SCIPsetIntParam(subscip, "conflict/maxstoresize", 100) );
    3407 }
    3408
    3409 /* speed up sub-SCIP by not checking dual LP feasibility */
    3410 SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
    3411
    3412 return SCIP_OKAY;
    3413}
    void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
    Definition: clock.c:360
    void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
    Definition: clock.c:290
    SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
    Definition: clock.c:438
    internal methods for clocks and timing issues
    SCIP_RETCODE SCIPconflictstoreGetConflicts(SCIP_CONFLICTSTORE *conflictstore, SCIP_CONS **conflicts, int conflictsize, int *nconflicts)
    int SCIPconflictstoreGetNConflictsInStore(SCIP_CONFLICTSTORE *conflictstore)
    SCIP_RETCODE SCIPconflictstoreCreate(SCIP_CONFLICTSTORE **conflictstore, SCIP_SET *set)
    SCIP_RETCODE SCIPconflictstoreAddConflict(SCIP_CONFLICTSTORE *conflictstore, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_PROB *transprob, SCIP_REOPT *reopt, SCIP_CONS *cons, SCIP_CONFTYPE conftype, SCIP_Bool cutoffinvolved, SCIP_Real primalbound)
    internal methods for storing conflicts
    SCIP_RETCODE SCIPconsCopy(SCIP_CONS **cons, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_CONSHDLR *sourceconshdlr, SCIP_CONS *sourcecons, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
    Definition: cons.c:6172
    void SCIPconsSetModifiable(SCIP_CONS *cons, SCIP_Bool modifiable)
    Definition: cons.c:6962
    internal methods for constraints and constraint handlers
    Constraint handler for linear constraints in their most general form, .
    SCIP_RETCODE SCIPdecompstoreCreate(SCIP_DECOMPSTORE **decompstore, BMS_BLKMEM *blkmem, int nslots)
    Definition: dcmp.c:500
    internal methods for decompositions and the decomposition store
    #define SCIP_DECOMPSTORE_CAPA
    Definition: dcmp.h:48
    methods for debugging
    #define SCIPcheckStage(scip, method, init, problem, transforming, transformed, initpresolve, presolving, exitpresolve, presolved, initsolve, solving, solved, exitsolve, freetrans, freescip)
    Definition: debug.h:364
    #define SCIPdebugSolDataCreate(debugsoldata)
    Definition: debug.h:290
    #define NULL
    Definition: def.h:248
    #define SCIP_MAXSTRLEN
    Definition: def.h:269
    #define SCIP_Longint
    Definition: def.h:141
    #define SCIP_INVALID
    Definition: def.h:178
    #define SCIP_Bool
    Definition: def.h:91
    #define MIN(x, y)
    Definition: def.h:224
    #define SCIP_Real
    Definition: def.h:156
    #define TRUE
    Definition: def.h:93
    #define FALSE
    Definition: def.h:94
    #define MAX(x, y)
    Definition: def.h:220
    #define SCIP_CALL_ABORT(x)
    Definition: def.h:334
    #define SCIPABORT()
    Definition: def.h:327
    #define SCIP_CALL(x)
    Definition: def.h:355
    SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
    SCIP_RETCODE SCIPcreateConsLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
    SCIP_RETCODE SCIPcopyPlugins(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copycutselectors, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copyiisfinders, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copyexprhdlrs, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:276
    SCIP_RETCODE SCIPcopyImplicationsCliques(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *infeasible, int *nbdchgs, int *ncopied)
    Definition: scip_copy.c:2363
    SCIP_RETCODE SCIPcopyOrig(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:3044
    void SCIPmergeNLPIStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool reset)
    Definition: scip_copy.c:1319
    SCIP_RETCODE SCIPcopyBenders(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_Bool threadsafe, SCIP_Bool *valid)
    Definition: scip_copy.c:359
    void SCIPsetSubscipDepth(SCIP *scip, int newdepth)
    Definition: scip_copy.c:2609
    SCIP_RETCODE SCIPtranslateSubSols(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
    Definition: scip_copy.c:1437
    SCIP_RETCODE SCIPcopyOrigVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars)
    Definition: scip_copy.c:1224
    SCIP_RETCODE SCIPcopyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global)
    Definition: scip_copy.c:1167
    SCIP_RETCODE SCIPsetCommonSubscipParams(SCIP *sourcescip, SCIP *subscip, SCIP_Longint nsubnodes, SCIP_Longint nstallnodes, int bestsollimit)
    Definition: scip_copy.c:3335
    SCIP_RETCODE SCIPcopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:2865
    SCIP_RETCODE SCIPcopyOrigConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:3133
    SCIP_RETCODE SCIPcopyConsCompression(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:2961
    SCIP_RETCODE SCIPcopyOrigConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool enablepricing, SCIP_Bool *valid)
    Definition: scip_copy.c:1918
    SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
    Definition: scip_copy.c:3249
    int SCIPgetSubscipDepth(SCIP *scip)
    Definition: scip_copy.c:2588
    SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
    Definition: scip_copy.c:1254
    SCIP_RETCODE SCIPgetConsCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_CONS *sourcecons, SCIP_CONS **targetcons, SCIP_CONSHDLR *sourceconshdlr, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode, SCIP_Bool global, SCIP_Bool *valid)
    Definition: scip_copy.c:1580
    SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
    Definition: scip_copy.c:2113
    SCIP_RETCODE SCIPconvertCutsToConss(SCIP *scip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
    Definition: scip_copy.c:2051
    SCIP_RETCODE SCIPenableConsCompression(SCIP *scip)
    Definition: scip_copy.c:623
    SCIP_RETCODE SCIPcopyProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, const char *name)
    Definition: scip_copy.c:529
    SCIP_RETCODE SCIPtranslateSubSol(SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_SOL **newsol)
    Definition: scip_copy.c:1397
    SCIP_Bool SCIPisConsCompressionEnabled(SCIP *scip)
    Definition: scip_copy.c:662
    SCIP_RETCODE SCIPcopyConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
    Definition: scip_copy.c:1716
    SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:2547
    SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:3292
    SCIP_RETCODE SCIPgetVarCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR *sourcevar, SCIP_VAR **targetvar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *success)
    Definition: scip_copy.c:713
    SCIP_RETCODE SCIPcopyConflicts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
    Definition: scip_copy.c:2205
    SCIP_RETCODE SCIPcopyOrigProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name)
    Definition: scip_copy.c:582
    SCIP_Bool SCIPisTransformed(SCIP *scip)
    Definition: scip_general.c:647
    SCIP_STAGE SCIPgetStage(SCIP *scip)
    Definition: scip_general.c:444
    SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
    Definition: scip_prob.c:1907
    int SCIPgetNIntVars(SCIP *scip)
    Definition: scip_prob.c:2340
    SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
    Definition: scip_prob.c:2753
    int SCIPgetNImplVars(SCIP *scip)
    Definition: scip_prob.c:2387
    const char * SCIPgetProbName(SCIP *scip)
    Definition: scip_prob.c:1242
    int SCIPgetNContVars(SCIP *scip)
    Definition: scip_prob.c:2569
    SCIP_Real SCIPgetOrigObjscale(SCIP *scip)
    Definition: scip_prob.c:1583
    SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
    Definition: scip_prob.c:2115
    int SCIPgetNOrigConss(SCIP *scip)
    Definition: scip_prob.c:3712
    SCIP_Real SCIPgetOrigObjoffset(SCIP *scip)
    Definition: scip_prob.c:1529
    int SCIPgetNVars(SCIP *scip)
    Definition: scip_prob.c:2246
    SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
    Definition: scip_prob.c:3274
    int SCIPgetNConss(SCIP *scip)
    Definition: scip_prob.c:3620
    SCIP_RETCODE SCIPfreeProb(SCIP *scip)
    Definition: scip_prob.c:835
    SCIP_RETCODE SCIPsetObjsense(SCIP *scip, SCIP_OBJSENSE objsense)
    Definition: scip_prob.c:1417
    SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
    Definition: scip_prob.c:1486
    SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
    Definition: scip_prob.c:3739
    SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
    Definition: scip_prob.c:1400
    int SCIPgetNFixedVars(SCIP *scip)
    Definition: scip_prob.c:2705
    int SCIPgetNBinVars(SCIP *scip)
    Definition: scip_prob.c:2293
    SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
    Definition: scip_prob.c:2662
    void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
    Definition: misc.c:3095
    void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
    Definition: misc.c:3284
    SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
    Definition: misc.c:3143
    SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
    Definition: misc.c:3061
    SCIP_RETCODE SCIPsetMessagehdlr(SCIP *scip, SCIP_MESSAGEHDLR *messagehdlr)
    Definition: scip_message.c:64
    SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
    Definition: scip_message.c:88
    #define SCIPdebugMsg
    Definition: scip_message.h:78
    void SCIPsetMessagehdlrQuiet(SCIP *scip, SCIP_Bool quiet)
    Definition: scip_message.c:108
    SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
    Definition: scip_param.c:250
    SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
    Definition: scip_param.c:219
    SCIP_PARAM * SCIPgetParam(SCIP *scip, const char *name)
    Definition: scip_param.c:234
    SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
    Definition: scip_param.c:545
    SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
    Definition: scip_param.c:487
    SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
    Definition: scip_param.c:904
    SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
    Definition: scip_param.c:307
    SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
    Definition: scip_param.c:956
    SCIP_RETCODE SCIPsetCharParam(SCIP *scip, const char *name, char value)
    Definition: scip_param.c:661
    SCIP_RETCODE SCIPsetBoolParam(SCIP *scip, const char *name, SCIP_Bool value)
    Definition: scip_param.c:429
    SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
    Definition: scip_param.c:603
    SCIP_RETCODE SCIPsetSeparating(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
    Definition: scip_param.c:985
    SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
    Definition: scip_branch.c:304
    SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
    Definition: lp.c:17425
    int SCIPconshdlrGetNCheckConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4798
    SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4755
    int SCIPgetNConshdlrs(SCIP *scip)
    Definition: scip_cons.c:964
    const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4316
    SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
    Definition: scip_cons.c:940
    int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4812
    SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4735
    SCIP_CONSHDLR ** SCIPgetConshdlrs(SCIP *scip)
    Definition: scip_cons.c:953
    SCIP_Bool SCIPconsIsConflict(SCIP_CONS *cons)
    Definition: cons.c:8538
    SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
    Definition: cons.c:8648
    SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
    Definition: cons.c:8409
    SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
    Definition: cons.c:8558
    SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
    Definition: cons.c:8688
    SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
    Definition: cons.c:8588
    SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
    Definition: cons.c:8518
    SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
    Definition: cons.c:8578
    SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
    Definition: cons.c:8450
    SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
    Definition: cons.c:8608
    SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
    Definition: cons.c:8628
    const char * SCIPconsGetName(SCIP_CONS *cons)
    Definition: cons.c:8389
    SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
    Definition: cons.c:8638
    SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
    Definition: scip_cons.c:1173
    SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
    Definition: cons.c:8568
    SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
    Definition: scip_cons.c:1138
    SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
    Definition: cons.c:8658
    SCIP_CUT ** SCIPgetDelayedPoolCuts(SCIP *scip)
    Definition: scip_cut.c:654
    SCIP_Real SCIPcutGetLPActivityQuot(SCIP_CUT *cut)
    Definition: cutpool.c:406
    int SCIPgetNPoolCuts(SCIP *scip)
    Definition: scip_cut.c:395
    SCIP_ROW * SCIPcutGetRow(SCIP_CUT *cut)
    Definition: cutpool.c:382
    SCIP_CUT ** SCIPgetPoolCuts(SCIP *scip)
    Definition: scip_cut.c:377
    int SCIPgetNDelayedPoolCuts(SCIP *scip)
    Definition: scip_cut.c:670
    int SCIPcutGetAge(SCIP_CUT *cut)
    Definition: cutpool.c:392
    SCIP_Bool SCIPisExact(SCIP *scip)
    Definition: scip_exact.c:193
    SCIP_RETCODE SCIPenableExactSolving(SCIP *scip, SCIP_Bool enable)
    Definition: scip_exact.c:151
    SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
    Definition: scip_mem.c:126
    SCIP_Longint SCIPgetMemUsed(SCIP *scip)
    Definition: scip_mem.c:100
    BMS_BLKMEM * SCIPblkmem(SCIP *scip)
    Definition: scip_mem.c:57
    #define SCIPallocBufferArray(scip, ptr, num)
    Definition: scip_mem.h:124
    #define SCIPfreeBufferArray(scip, ptr)
    Definition: scip_mem.h:136
    void SCIPnlpiMergeStatistics(SCIP_NLPI *targetnlpi, SCIP_NLPI *sourcenlpi, SCIP_Bool reset)
    Definition: nlpi.c:833
    const char * SCIPnlpiGetName(SCIP_NLPI *nlpi)
    Definition: nlpi.c:722
    SCIP_NODESEL * SCIPfindNodesel(SCIP *scip, const char *name)
    Definition: scip_nodesel.c:242
    int SCIPgetNActivePricers(SCIP *scip)
    Definition: scip_pricer.c:348
    SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
    Definition: lp.c:17686
    SCIP_Bool SCIProwIsModifiable(SCIP_ROW *row)
    Definition: lp.c:17805
    int SCIProwGetNNonz(SCIP_ROW *row)
    Definition: lp.c:17607
    SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
    Definition: lp.c:17632
    SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
    Definition: lp.c:17696
    SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
    Definition: lp.c:17795
    const char * SCIProwGetName(SCIP_ROW *row)
    Definition: lp.c:17745
    SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
    Definition: lp.c:17652
    SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
    Definition: lp.c:17917
    SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
    Definition: lp.c:17642
    SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
    Definition: scip_sol.c:516
    SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
    Definition: scip_sol.c:1252
    SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
    Definition: scip_sol.c:3909
    SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:1475
    int SCIPgetNSols(SCIP *scip)
    Definition: scip_sol.c:2882
    int SCIPsolGetIndex(SCIP_SOL *sol)
    Definition: sol.c:4290
    SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
    Definition: scip_sol.c:1662
    SCIP_SOL ** SCIPgetSols(SCIP *scip)
    Definition: scip_sol.c:2931
    SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
    Definition: scip_sol.c:4312
    SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:1892
    SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
    Definition: scip_sol.c:1765
    SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:2005
    SCIP_Bool SCIPisInRestart(SCIP *scip)
    Definition: scip_solve.c:3709
    int SCIPgetNRuns(SCIP *scip)
    SCIP_Real SCIPgetSolvingTime(SCIP *scip)
    Definition: scip_timing.c:378
    SCIP_Real SCIPinfinity(SCIP *scip)
    SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
    SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
    SCIP_Real SCIPvarGetMultaggrConstant(SCIP_VAR *var)
    Definition: var.c:23843
    SCIP_RETCODE SCIPaddClique(SCIP *scip, SCIP_VAR **vars, SCIP_Bool *values, int nvars, SCIP_Bool isequation, SCIP_Bool *infeasible, int *nbdchgs)
    Definition: scip_var.c:8882
    int SCIPvarGetNImpls(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24568
    SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
    Definition: var.c:23386
    SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
    Definition: var.c:23771
    SCIP_Bool SCIPvarIsImpliedIntegral(SCIP_VAR *var)
    Definition: var.c:23498
    SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
    Definition: var.c:24268
    SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
    Definition: var.c:23748
    SCIP_CLIQUE ** SCIPgetCliques(SCIP *scip)
    Definition: scip_var.c:9566
    SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
    Definition: var.c:23453
    SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24585
    const char * SCIPvarGetName(SCIP_VAR *var)
    Definition: var.c:23267
    SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
    Definition: scip_var.c:1887
    SCIP_Real * SCIPvarGetImplBounds(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24614
    SCIP_RETCODE SCIPflattenVarAggregationGraph(SCIP *scip, SCIP_VAR *var)
    Definition: scip_var.c:2332
    SCIP_RETCODE SCIPgetNegatedVar(SCIP *scip, SCIP_VAR *var, SCIP_VAR **negvar)
    Definition: scip_var.c:2166
    SCIP_VAR ** SCIPvarGetMultaggrVars(SCIP_VAR *var)
    Definition: var.c:23806
    int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
    Definition: var.c:23794
    SCIP_RETCODE SCIPaddVarImplication(SCIP *scip, SCIP_VAR *var, SCIP_Bool varfixing, SCIP_VAR *implvar, SCIP_BOUNDTYPE impltype, SCIP_Real implbound, SCIP_Bool *infeasible, int *nbdchgs)
    Definition: scip_var.c:8740
    SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
    Definition: var.c:24234
    SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
    Definition: var.c:23600
    SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
    Definition: var.c:23878
    int SCIPgetNCliques(SCIP *scip)
    Definition: scip_var.c:9512
    SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
    Definition: scip_var.c:10318
    void SCIPvarsCountTypes(SCIP_VAR **vars, int nvars, int *nbinvars, int *nintvars, int *nbinimplvars, int *nintimplvars, int *ncontimplvars, int *ncontvars)
    Definition: var.c:22942
    SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
    Definition: var.c:23672
    SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24600
    SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
    Definition: var.c:23818
    SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
    Definition: var.c:23736
    int SCIPsnprintf(char *t, int len, const char *s,...)
    Definition: misc.c:10827
    SCIP_VAR ** SCIPcliqueGetVars(SCIP_CLIQUE *clique)
    Definition: implics.c:3384
    int SCIPcliqueGetNVars(SCIP_CLIQUE *clique)
    Definition: implics.c:3374
    SCIP_Bool * SCIPcliqueGetValues(SCIP_CLIQUE *clique)
    Definition: implics.c:3396
    SCIP_Bool SCIPcliqueIsEquation(SCIP_CLIQUE *clique)
    Definition: implics.c:3440
    memory allocation routines
    SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
    Definition: message.c:910
    SCIP_RETCODE SCIPprimalCreate(SCIP_PRIMAL **primal)
    Definition: primal.c:133
    internal methods for collecting primal CIP solutions and primal informations
    void SCIPprobEnableConsCompression(SCIP_PROB *prob)
    Definition: prob.c:3046
    SCIP_RETCODE SCIPprobCopy(SCIP_PROB **prob, BMS_BLKMEM *blkmem, SCIP_SET *set, const char *name, SCIP *sourcescip, SCIP_PROB *sourceprob, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool original, SCIP_Bool global)
    Definition: prob.c:208
    SCIP_Bool SCIPprobIsConsCompressionEnabled(SCIP_PROB *prob)
    Definition: prob.c:3036
    internal methods for storing and manipulating the main problem
    public methods for managing constraints
    public methods for storing cuts in a cut pool
    public methods for implications, variable bounds, and cliques
    public methods for LP management
    public methods for message output
    #define SCIPerrorMessage
    Definition: pub_message.h:64
    #define SCIPdebugPrintCons(x, y, z)
    Definition: pub_message.h:102
    public data structures and miscellaneous methods
    public methods for NLP solver interfaces
    public methods for primal CIP solutions
    public methods for problem variables
    public methods for branching rule plugins and branching
    public methods for constraint handler plugins and constraints
    static SCIP_Bool takeCut(SCIP *scip, SCIP_CUT *cut, char cutsel)
    Definition: scip_copy.c:94
    static SCIP_RETCODE doCopy(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool useconscompression, SCIP_Bool global, SCIP_Bool original, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
    Definition: scip_copy.c:2633
    static SCIP_RETCODE copyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_CUT **cuts, int ncuts, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
    Definition: scip_copy.c:127
    static SCIP_RETCODE translateSubSol(SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_VAR **subvars, SCIP_Real *solvals)
    Definition: scip_copy.c:1357
    static SCIP_RETCODE copyVars(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool original, SCIP_Bool global)
    Definition: scip_copy.c:950
    static SCIP_RETCODE getCopyTimelimit(SCIP *sourcescip, SCIP_Real *timelimit)
    Definition: scip_copy.c:3179
    static SCIP_RETCODE copyProb(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool original, SCIP_Bool global, const char *name)
    Definition: scip_copy.c:402
    static SCIP_RETCODE getCopyMemlimit(SCIP *sourcescip, SCIP_Real *memorylimit)
    Definition: scip_copy.c:3218
    static SCIP_RETCODE copySofttimelimit(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:3193
    public methods for problem copies
    public methods for cuts and aggregation rows
    public methods for exact solving
    general public methods
    public methods for memory management
    public methods for message handling
    public methods for node selector plugins
    public methods for numerical tolerances
    public methods for SCIP parameter handling
    public methods for variable pricer plugins
    public methods for global and local (sub)problems
    public methods for solutions
    public solving methods
    public methods for querying solving statistics
    public methods for timing
    public methods for SCIP variables
    static SCIP_RETCODE separate(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *sol, SCIP_RESULT *result)
    Main separation function.
    Definition: sepa_flower.c:1221
    SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
    Definition: set.c:6537
    SCIP_NLPI * SCIPsetFindNlpi(SCIP_SET *set, const char *name)
    Definition: set.c:5481
    SCIP_RETCODE SCIPsetCopyPlugins(SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_Bool copyreaders, SCIP_Bool copypricers, SCIP_Bool copyconshdlrs, SCIP_Bool copyconflicthdlrs, SCIP_Bool copypresolvers, SCIP_Bool copyrelaxators, SCIP_Bool copyseparators, SCIP_Bool copycutselectors, SCIP_Bool copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copyiisfinders, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copyexprhdlrs, SCIP_Bool copynlpis, SCIP_Bool *allvalid)
    Definition: set.c:931
    SCIP_RETCODE SCIPsetCopyParams(SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_MESSAGEHDLR *messagehdlr)
    Definition: set.c:1167
    internal methods for global SCIP settings
    SCIP_RETCODE SCIPbendersCopyInclude(SCIP_BENDERS *benders, SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_HASHMAP *varmap, SCIP_Bool threadsafe, SCIP_Bool *valid)
    Definition: benders.c:1058
    internal methods for Benders' decomposition
    SCIP_RETCODE SCIPstatCreate(SCIP_STAT **stat, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_MESSAGEHDLR *messagehdlr)
    Definition: stat.c:56
    internal methods for problem statistics
    BMS_BLKMEM * probmem
    Definition: struct_mem.h:49
    SCIP_DEBUGSOLDATA * debugsoldata
    Definition: struct_set.h:114
    SCIP_Bool misc_avoidmemout
    Definition: struct_set.h:429
    SCIP_STAGE stage
    Definition: struct_set.h:76
    SCIP_BENDERS ** benders
    Definition: struct_set.h:113
    char sepa_cutselsubscip
    Definition: struct_set.h:581
    char sepa_cutselrestart
    Definition: struct_set.h:580
    SCIP_NLPI ** nlpis
    Definition: struct_set.h:110
    SCIP_Bool history_allowmerge
    Definition: struct_set.h:320
    int nbenders
    Definition: struct_set.h:163
    int nnlpis
    Definition: struct_set.h:157
    SCIP_CLOCK * copyclock
    Definition: struct_stat.h:192
    SCIP_Real maxcopytime
    Definition: struct_stat.h:142
    SCIP_Real mincopytime
    Definition: struct_stat.h:143
    int subscipdepth
    Definition: struct_stat.h:253
    SCIP * scip
    Definition: struct_var.h:345
    SCIP_PROB * origprob
    Definition: struct_scip.h:83
    SCIP_CONCURRENT * concurrent
    Definition: struct_scip.h:115
    SCIP_MEM * mem
    Definition: struct_scip.h:74
    SCIP_REOPT * reopt
    Definition: struct_scip.h:88
    SCIP_STAT * stat
    Definition: struct_scip.h:82
    SCIP_SYNCSTORE * syncstore
    Definition: struct_scip.h:114
    SCIP_MESSAGEHDLR * messagehdlr
    Definition: struct_scip.h:78
    SCIP_CONFLICTSTORE * conflictstore
    Definition: struct_scip.h:109
    SCIP_SET * set
    Definition: struct_scip.h:75
    SCIP_DECOMPSTORE * decompstore
    Definition: struct_scip.h:85
    SCIP_PRIMAL * origprimal
    Definition: struct_scip.h:84
    SCIP_PROB * transprob
    Definition: struct_scip.h:102
    datastructures for block memory pools and memory buffers
    SCIP main data structure.
    datastructures for global SCIP settings
    datastructures for problem statistics
    datastructures for problem variables
    SCIP_RETCODE SCIPsyncstoreRelease(SCIP_SYNCSTORE **syncstore)
    Definition: syncstore.c:89
    SCIP_RETCODE SCIPsyncstoreCapture(SCIP_SYNCSTORE *syncstore)
    Definition: syncstore.c:124
    the function declarations for the synchronization store
    @ SCIP_CONFTYPE_UNKNOWN
    Definition: type_conflict.h:61
    enum SCIP_BoundType SCIP_BOUNDTYPE
    Definition: type_lp.h:60
    @ SCIP_PARAMSETTING_OFF
    Definition: type_paramset.h:63
    @ SCIP_PARAMSETTING_FAST
    Definition: type_paramset.h:62
    @ SCIP_INVALIDDATA
    Definition: type_retcode.h:52
    @ SCIP_OKAY
    Definition: type_retcode.h:42
    @ SCIP_ERROR
    Definition: type_retcode.h:43
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63
    @ SCIP_STAGE_PROBLEM
    Definition: type_set.h:45
    @ SCIP_STAGE_INIT
    Definition: type_set.h:44
    @ SCIP_STAGE_SOLVING
    Definition: type_set.h:53
    @ SCIP_VARTYPE_INTEGER
    Definition: type_var.h:65
    @ SCIP_VARTYPE_CONTINUOUS
    Definition: type_var.h:71
    @ SCIP_VARTYPE_BINARY
    Definition: type_var.h:64
    @ SCIP_VARSTATUS_ORIGINAL
    Definition: type_var.h:51
    @ SCIP_VARSTATUS_FIXED
    Definition: type_var.h:54
    @ SCIP_VARSTATUS_COLUMN
    Definition: type_var.h:53
    @ SCIP_VARSTATUS_MULTAGGR
    Definition: type_var.h:56
    @ SCIP_VARSTATUS_NEGATED
    Definition: type_var.h:57
    @ SCIP_VARSTATUS_AGGREGATED
    Definition: type_var.h:55
    @ SCIP_VARSTATUS_LOOSE
    Definition: type_var.h:52
    enum SCIP_Varstatus SCIP_VARSTATUS
    Definition: type_var.h:59
    SCIP_RETCODE SCIPvarCopy(SCIP_VAR **var, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP *sourcescip, SCIP_VAR *sourcevar, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global)
    Definition: var.c:2751
    void SCIPvarMergeHistories(SCIP_VAR *targetvar, SCIP_VAR *othervar, SCIP_STAT *stat)
    Definition: var.c:6116
    SCIP_RETCODE SCIPvarCopyExactData(BMS_BLKMEM *blkmem, SCIP_VAR *targetvar, SCIP_VAR *sourcevar, SCIP_Bool negateobj)
    Definition: var.c:2686
    internal methods for problem variables