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-2026 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 return SCIP_OKAY;
    761 }
    762
    763 /* if the target SCIP is already in solving stage we currently are not copying the variable!
    764 * this has to be done because we cannot simply add variables to SCIP during solving and thereby enlarge the search
    765 * space.
    766 * unlike column generation we cannot assume here that the variable could be implicitly set to zero in all prior
    767 * computations
    768 */
    769 if( SCIPgetStage(targetscip) > SCIP_STAGE_PROBLEM )
    770 {
    771 *success = FALSE;
    772 *targetvar = NULL;
    773
    774 return SCIP_OKAY;
    775 }
    776
    777 /* create the variable mapping hash map */
    778 if( uselocalvarmap )
    779 {
    780 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    781 }
    782 else
    783 localvarmap = varmap;
    784
    785 if( uselocalconsmap )
    786 {
    787 /* create the constraint mapping hash map */
    788 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    789 }
    790 else
    791 localconsmap = consmap;
    792
    793 /* if variable does not exist yet in target SCIP, create it */
    794 switch( SCIPvarGetStatus(sourcevar) )
    795 {
    800 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    801 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    802 break;
    803
    805 {
    806 SCIP_CONS* cons;
    807 char name[SCIP_MAXSTRLEN];
    808
    809 SCIP_VAR* sourceaggrvar;
    810 SCIP_VAR* targetaggrvar;
    811 SCIP_Real aggrcoef;
    812 SCIP_Real constant;
    813
    814 /* get aggregation data */
    815 sourceaggrvar = SCIPvarGetAggrVar(sourcevar);
    816 aggrcoef = SCIPvarGetAggrScalar(sourcevar);
    817 constant = SCIPvarGetAggrConstant(sourcevar);
    818
    819 /* get copy of the aggregation variable */
    820 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvar, &targetaggrvar, localvarmap, localconsmap, global, success) );
    821 assert(*success);
    822
    823 /* create copy of the aggregated variable */
    824 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    825 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    826
    827 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_aggr", SCIPvarGetName(sourcevar));
    828
    829 /* add aggregation x = a*y + c as linear constraint x - a*y = c */
    830 SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, 0, NULL, NULL, constant,
    831 constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    832 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, 1.0) );
    833 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, targetaggrvar, -aggrcoef) );
    834
    835 SCIP_CALL( SCIPaddCons(targetscip, cons) );
    836 SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
    837
    838 break;
    839 }
    841 {
    842 SCIP_CONS* cons;
    843 char name[SCIP_MAXSTRLEN];
    844
    845 SCIP_VAR** sourceaggrvars;
    846 SCIP_VAR** targetaggrvars;
    847 SCIP_Real* aggrcoefs;
    848 SCIP_Real constant;
    849
    850 int naggrvars;
    851 int i;
    852
    853 /* get the active representation */
    854 SCIP_CALL( SCIPflattenVarAggregationGraph(sourcescip, sourcevar) );
    855
    856 /* get multi-aggregation data */
    857 naggrvars = SCIPvarGetMultaggrNVars(sourcevar);
    858 sourceaggrvars = SCIPvarGetMultaggrVars(sourcevar);
    859 aggrcoefs = SCIPvarGetMultaggrScalars(sourcevar);
    860 constant = SCIPvarGetMultaggrConstant(sourcevar);
    861
    862 SCIP_CALL( SCIPallocBufferArray(targetscip, &targetaggrvars, naggrvars) );
    863
    864 /* get copies of the active variables of the multi-aggregation */
    865 for( i = 0; i < naggrvars; ++i )
    866 {
    867 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourceaggrvars[i], &targetaggrvars[i], localvarmap, localconsmap, global, success) );
    868 assert(*success);
    869 }
    870
    871 /* create copy of the multi-aggregated variable */
    872 SCIP_CALL( SCIPvarCopy(&var, targetscip->mem->probmem, targetscip->set, targetscip->stat,
    873 sourcescip, sourcevar, localvarmap, localconsmap, global) );
    874
    875 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_multaggr", SCIPvarGetName(sourcevar));
    876
    877 /* add multi-aggregation x = a^T y + c as linear constraint a^T y - x = -c */
    878 SCIP_CALL( SCIPcreateConsLinear(targetscip, &cons, name, naggrvars, targetaggrvars, aggrcoefs, -constant,
    879 -constant, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    880 SCIP_CALL( SCIPaddCoefLinear(targetscip, cons, var, -1.0) );
    881 SCIP_CALL( SCIPaddCons(targetscip, cons) );
    882 SCIP_CALL( SCIPreleaseCons(targetscip, &cons) );
    883
    884 SCIPfreeBufferArray(targetscip, &targetaggrvars);
    885
    886 break;
    887 }
    889 {
    890 SCIP_VAR* sourcenegatedvar;
    891 SCIP_VAR* targetnegatedvar;
    892
    893 /* get negated source variable */
    894 sourcenegatedvar = SCIPvarGetNegationVar(sourcevar);
    895 assert(sourcenegatedvar != NULL);
    896 assert(SCIPvarGetStatus(sourcenegatedvar) != SCIP_VARSTATUS_NEGATED);
    897
    898 /* get copy of negated source variable */
    899 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcenegatedvar, &targetnegatedvar, localvarmap, localconsmap, global, success) );
    900 assert(*success);
    901 assert(SCIPvarGetStatus(targetnegatedvar) != SCIP_VARSTATUS_NEGATED);
    902
    903 /* get negation of copied negated source variable, this is the target variable */
    904 SCIP_CALL( SCIPgetNegatedVar(targetscip, targetnegatedvar, targetvar) );
    905 assert(SCIPvarGetStatus(*targetvar) == SCIP_VARSTATUS_NEGATED);
    906
    907 /* free local hash maps if necessary */
    908 if( uselocalvarmap )
    909 SCIPhashmapFree(&localvarmap);
    910
    911 if( uselocalconsmap )
    912 SCIPhashmapFree(&localconsmap);
    913
    914 /* we have to return right away, to avoid adding the negated variable to the problem since the "not negated"
    915 * variable was already added */
    916 return SCIP_OKAY;
    917 }
    918 default:
    919 /* note that this is in an internal SCIP error since the variable status is only handled by the core */
    920 SCIPerrorMessage("unknown variable status\n");
    921 SCIPABORT();
    922 return SCIP_ERROR; /*lint !e527*/
    923 }
    924
    925 /* add the (new) target variable to the target problem */
    926 SCIP_CALL( SCIPaddVar(targetscip, var) );
    927
    928 *targetvar = var;
    929 assert((*targetvar)->scip == targetscip);
    930
    931 /* remove the variable capture which was done due to the creation of the variable */
    932 SCIP_CALL( SCIPreleaseVar(targetscip, &var) );
    933
    934 /* free local hash maps if necessary */
    935 if( uselocalvarmap )
    936 SCIPhashmapFree(&localvarmap);
    937
    938 if( uselocalconsmap )
    939 SCIPhashmapFree(&localconsmap);
    940
    941 return SCIP_OKAY;
    942}
    943
    944/** copies all original or active variables from source-SCIP except those that are marked as relaxation-only, fixed, or aggregated
    945 * and adds these variable to the target-SCIP
    946 *
    947 * the mapping between these variables are stored in the variable hashmap
    948 * target-SCIP has to be in problem creation stage
    949 */
    950static
    952 SCIP* sourcescip, /**< source SCIP data structure */
    953 SCIP* targetscip, /**< target SCIP data structure */
    954 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    955 * target variables, or NULL */
    956 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    957 * target constraints, or NULL */
    958 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    959 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    960 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    961 SCIP_Bool original, /**< should original variables be copied? */
    962 SCIP_Bool global /**< should global or local bounds be used? (for original=FALSE) */
    963 )
    964{
    965 SCIP_VAR** sourcevars;
    966 SCIP_HASHMAP* localvarmap;
    967 SCIP_HASHMAP* localconsmap;
    968 SCIP_Bool uselocalvarmap;
    969 SCIP_Bool uselocalconsmap;
    970 int nsourcevars;
    971#ifndef NDEBUG
    972 int nrelaxonlybinvars = 0;
    973 int nrelaxonlyintvars = 0;
    974 int nrelaxonlyimplvars = 0;
    975 int nrelaxonlycontvars = 0;
    976#endif
    977 int i;
    978
    979 assert(sourcescip != NULL);
    980 assert(targetscip != NULL);
    981 assert(nfixedvars == 0 || fixedvars != NULL);
    982 assert(nfixedvars == 0 || fixedvals != NULL);
    983
    984 if( original )
    985 {
    986 /* get original variables of the source SCIP */
    987 SCIP_CALL( SCIPgetOrigVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
    988 }
    989 else
    990 {
    991 /* get active variables of the source SCIP */
    992 SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nsourcevars, NULL, NULL, NULL, NULL) );
    993 }
    994
    995 uselocalvarmap = (varmap == NULL);
    996 uselocalconsmap = (consmap == NULL);
    997
    998 if( uselocalvarmap )
    999 {
    1000 /* create the variable mapping hash map */
    1001 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1002 }
    1003 else
    1004 localvarmap = varmap;
    1005
    1006 if( uselocalconsmap )
    1007 {
    1008 /* create the constraint mapping hash map */
    1009 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1010 }
    1011 else
    1012 localconsmap = consmap;
    1013
    1014 /* create the variables of the target SCIP */
    1015 for( i = 0; i < nsourcevars; ++i )
    1016 {
    1017 SCIP_Bool success;
    1018 SCIP_VAR* targetvar;
    1019
    1020 if( SCIPvarIsRelaxationOnly(sourcevars[i]) )
    1021 {
    1022#ifndef NDEBUG
    1023 if( SCIPvarIsImpliedIntegral(sourcevars[i]) )
    1024 ++nrelaxonlyimplvars;
    1025 else
    1026 {
    1027 switch( SCIPvarGetType(sourcevars[i]) )
    1028 {
    1030 ++nrelaxonlybinvars;
    1031 break;
    1033 ++nrelaxonlyintvars;
    1034 break;
    1036 ++nrelaxonlycontvars;
    1037 break;
    1038 default:
    1039 SCIPerrorMessage("unknown variable type\n");
    1040 return SCIP_INVALIDDATA;
    1041 } /*lint !e788*/
    1042 }
    1043#endif
    1044 continue;
    1045 }
    1046
    1047 /* copy variable and add this copy to the target SCIP if the copying was valid */
    1048 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevars[i], &targetvar, localvarmap, localconsmap, global, &success) );
    1049 /* copy exact data, if solving exactly */
    1050 if( SCIPisExact(targetscip) && SCIPisExact(sourcescip) )
    1051 {
    1052 SCIP_CALL( SCIPvarCopyExactData(targetscip->mem->probmem, targetvar, sourcevars[i], FALSE) );
    1053 }
    1054 assert(success);
    1055 assert(targetvar != NULL);
    1056 }
    1057
    1058 /* fix the variables that should be fixed right away */
    1059 for( i = 0; i < nfixedvars; ++i )
    1060 {
    1061 SCIP_VAR* targetvar;
    1062 SCIP_Bool infeasible;
    1063 SCIP_Bool fixed;
    1064
    1065 if( SCIPvarIsRelaxationOnly(fixedvars[i]) )
    1066 continue;
    1067
    1068 /* retrieve target variable as image of the source variable */
    1069 targetvar = (SCIP_VAR*) SCIPhashmapGetImage(localvarmap, (void *)fixedvars[i]);
    1070 assert(targetvar != NULL);
    1071
    1072 /* fix the variable to the specified value */
    1073 infeasible = fixed = FALSE;
    1074 SCIP_CALL( SCIPfixVar(targetscip, targetvar, fixedvals[i], &infeasible, &fixed) );
    1075
    1076 assert(!infeasible);
    1077 assert(fixed);
    1078 }
    1079
    1080 /* integer variables that are fixed to zero or one or have bounds [0,1] will be converted to binaries */
    1081#ifndef NDEBUG
    1082 if( original )
    1083 {
    1084 /* TODO : account for integers converted to binaries
    1085 assert(SCIPgetNOrigBinVars(sourcescip) == SCIPgetNOrigBinVars(targetscip));
    1086 assert(SCIPgetNOrigIntVars(sourcescip) == SCIPgetNOrigIntVars(targetscip));
    1087 assert(SCIPgetNOrigImplVars(sourcescip) == SCIPgetNOrigImplVars(targetscip));
    1088 assert(SCIPgetNOrigContVars(sourcescip) == SCIPgetNOrigContVars(targetscip));
    1089 */
    1090 }
    1091 else
    1092 {
    1093 SCIP_VAR** sourcefixedvars = SCIPgetFixedVars(sourcescip);
    1094 int nsourcefixedvars = SCIPgetNFixedVars(sourcescip);
    1095 int nfixedbinvars;
    1096 int nfixedintvars;
    1097 int nfixedbinimplvars;
    1098 int nfixedintimplvars;
    1099 int nfixedcontimplvars;
    1100 int nfixedcontvars;
    1101 int nfixedimplvars;
    1102
    1103 /* count number of fixed variables for all variable types */
    1104 SCIPvarsCountTypes(sourcefixedvars, nsourcefixedvars, &nfixedbinvars, &nfixedintvars,
    1105 &nfixedbinimplvars, &nfixedintimplvars, &nfixedcontimplvars, &nfixedcontvars);
    1106 nfixedimplvars = nfixedbinimplvars + nfixedintimplvars + nfixedcontimplvars;
    1107 assert(nsourcefixedvars == nfixedbinvars + nfixedintvars + nfixedimplvars + nfixedcontvars);
    1108 assert(SCIPgetNBinVars(sourcescip) <= SCIPgetNBinVars(targetscip) + nrelaxonlybinvars);
    1109 assert(SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) <= SCIPgetNIntVars(targetscip) + nrelaxonlyintvars + SCIPgetNBinVars(targetscip) + nrelaxonlybinvars);
    1110 assert(SCIPgetNIntVars(targetscip) + nrelaxonlyintvars + SCIPgetNBinVars(targetscip) + nrelaxonlybinvars <= SCIPgetNIntVars(sourcescip) + SCIPgetNBinVars(sourcescip) + nfixedbinvars + nfixedintvars );
    1111 assert(SCIPgetNImplVars(sourcescip) <= SCIPgetNImplVars(targetscip) + nrelaxonlyimplvars);
    1112 assert(SCIPgetNImplVars(targetscip) + nrelaxonlyimplvars <= SCIPgetNImplVars(sourcescip) + nfixedimplvars);
    1113 assert(SCIPgetNContVars(sourcescip) <= SCIPgetNContVars(targetscip) + nrelaxonlycontvars);
    1114 assert(SCIPgetNContVars(targetscip) + nrelaxonlycontvars <= SCIPgetNContVars(sourcescip) + nfixedcontvars);
    1115 }
    1116#endif
    1117
    1118 if( uselocalvarmap )
    1119 {
    1120 /* free hash map */
    1121 SCIPhashmapFree(&localvarmap);
    1122 }
    1123
    1124 if( uselocalconsmap )
    1125 {
    1126 /* free hash map */
    1127 SCIPhashmapFree(&localconsmap);
    1128 }
    1129
    1130 return SCIP_OKAY;
    1131}
    1132
    1133/** Copies all active (thus unfixed) variables from source-SCIP, except those that are marked as relaxation only,
    1134 * and adds these variable to the target-SCIP.
    1135 *
    1136 * The mapping between these variables are stored in the variable hashmap.
    1137 *
    1138 * The target-SCIP has to be in problem creation stage.
    1139 *
    1140 * @note the variables are added to the target-SCIP but not captured
    1141 *
    1142 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1143 * @note Do not change the source SCIP environment during the copying process
    1144 *
    1145 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1146 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1147 *
    1148 * @pre This method can be called if sourcescip is in one of the following stages:
    1149 * - \ref SCIP_STAGE_PROBLEM
    1150 * - \ref SCIP_STAGE_TRANSFORMED
    1151 * - \ref SCIP_STAGE_INITPRESOLVE
    1152 * - \ref SCIP_STAGE_PRESOLVING
    1153 * - \ref SCIP_STAGE_EXITPRESOLVE
    1154 * - \ref SCIP_STAGE_PRESOLVED
    1155 * - \ref SCIP_STAGE_INITSOLVE
    1156 * - \ref SCIP_STAGE_SOLVING
    1157 * - \ref SCIP_STAGE_SOLVED
    1158 *
    1159 * @pre This method can be called if targetscip is in one of the following stages:
    1160 * - \ref SCIP_STAGE_PROBLEM
    1161 *
    1162 * @note sourcescip stage does not get changed
    1163 *
    1164 * @note targetscip stage does not get changed
    1165 *
    1166 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1167 */
    1169 SCIP* sourcescip, /**< source SCIP data structure */
    1170 SCIP* targetscip, /**< target SCIP data structure */
    1171 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    1172 * target variables, or NULL */
    1173 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1174 * target constraints, or NULL */
    1175 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1176 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    1177 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1178 SCIP_Bool global /**< should global or local bounds be used? */
    1179 )
    1180{
    1181 assert(sourcescip != NULL);
    1182 assert(targetscip != NULL);
    1183
    1184 /* check stages for both, the source and the target SCIP data structure */
    1185 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1186 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1187
    1188 SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, FALSE, global) );
    1189
    1190 return SCIP_OKAY;
    1191}
    1192
    1193/** copies all original variables from source-SCIP and adds these variable to the target-SCIP; the mapping between these
    1194 * variables are stored in the variable hashmap, target-SCIP has to be in problem creation stage, fixed and aggregated
    1195 * variables do not get copied
    1196 *
    1197 * @note the variables are added to the target-SCIP but not captured
    1198 *
    1199 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1200 * @note Do not change the source SCIP environment during the copying process
    1201 *
    1202 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1203 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1204 *
    1205 * @pre This method can be called if sourcescip is in one of the following stages:
    1206 * - \ref SCIP_STAGE_PROBLEM
    1207 * - \ref SCIP_STAGE_TRANSFORMED
    1208 * - \ref SCIP_STAGE_INITPRESOLVE
    1209 * - \ref SCIP_STAGE_PRESOLVING
    1210 * - \ref SCIP_STAGE_EXITPRESOLVE
    1211 * - \ref SCIP_STAGE_PRESOLVED
    1212 * - \ref SCIP_STAGE_INITSOLVE
    1213 * - \ref SCIP_STAGE_SOLVING
    1214 * - \ref SCIP_STAGE_SOLVED
    1215 *
    1216 * @pre This method can be called if targetscip is in one of the following stages:
    1217 * - \ref SCIP_STAGE_PROBLEM
    1218 *
    1219 * @note sourcescip stage does not get changed
    1220 *
    1221 * @note targetscip stage does not get changed
    1222 *
    1223 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1224 */
    1226 SCIP* sourcescip, /**< source SCIP data structure */
    1227 SCIP* targetscip, /**< target SCIP data structure */
    1228 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables to the corresponding
    1229 * target variables, or NULL */
    1230 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1231 * target constraints, or NULL */
    1232 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1233 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    1234 int nfixedvars /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    1235 )
    1236{
    1237 assert(sourcescip != NULL);
    1238 assert(targetscip != NULL);
    1239
    1240 /* check stages for both, the source and the target SCIP data structure */
    1241 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1242 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigVars", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1243
    1244 SCIP_CALL( copyVars(sourcescip, targetscip, varmap, consmap, fixedvars, fixedvals, nfixedvars, TRUE, TRUE) );
    1245
    1246 return SCIP_OKAY;
    1247}
    1248
    1249/** merges the histories of variables from a source SCIP into a target SCIP. The two data structures should point to
    1250 * different SCIP instances.
    1251 *
    1252 * @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
    1253 * \p targetscip denotes the original instance
    1254 */
    1256 SCIP* sourcescip, /**< source SCIP data structure */
    1257 SCIP* targetscip, /**< target SCIP data structure */
    1258 SCIP_VAR** sourcevars, /**< source variables for history merge, NULL entries are ignored */
    1259 SCIP_VAR** targetvars, /**< target variables for history merge, NULL entries are ignored */
    1260 int nvars /**< number of variables in both variable arrays */
    1261 )
    1262{
    1263 int i;
    1264
    1265 /* check if target scip has been set to allow merging variable statistics */
    1266 if( !targetscip->set->history_allowmerge )
    1267 return SCIP_OKAY;
    1268
    1269 assert(nvars == 0 || (sourcevars != NULL && targetvars != NULL));
    1270 assert(sourcescip != targetscip);
    1271
    1272 /* we do not want to copy statistics from a scip that has not really started solving */
    1273 if( SCIPgetStage(sourcescip) < SCIP_STAGE_SOLVING )
    1274 return SCIP_OKAY;
    1275
    1276 /* if the transformation of the source was subject to scaling, the history information cannot be just copied */
    1277 if( !SCIPsetIsEQ(targetscip->set, 1.0, SCIPgetOrigObjscale(sourcescip))
    1278 || !SCIPsetIsEQ(targetscip->set, 0.0, SCIPgetOrigObjoffset(sourcescip)) )
    1279 return SCIP_OKAY;
    1280
    1281 /* merge histories of the targetSCIP-variables to the SCIP variables. */
    1282 for( i = 0; i < nvars; ++i )
    1283 {
    1284 SCIP_VARSTATUS sourcevarstatus;
    1285
    1286 if( sourcevars[i] == NULL || targetvars[i] == NULL )
    1287 continue;
    1288
    1289 assert(sourcevars[i]->scip == sourcescip);
    1290 assert(targetvars[i]->scip == targetscip);
    1291
    1292 sourcevarstatus = SCIPvarGetStatus(sourcevars[i]);
    1293
    1294 /* depending on the variable status, we use either the transformed variable history or the history of the col itself */
    1295 switch( sourcevarstatus )
    1296 {
    1298 assert(NULL != SCIPvarGetTransVar(sourcevars[i]));
    1299 SCIPvarMergeHistories(targetvars[i], SCIPvarGetTransVar(sourcevars[i]), targetscip->stat);
    1300 break;
    1302 SCIPvarMergeHistories(targetvars[i], sourcevars[i], targetscip->stat);
    1303 break;
    1304 default:
    1305 /* other variable status are currently not supported for the merging */
    1306 break;
    1307 } /*lint !e788*/
    1308 }
    1309
    1310 return SCIP_OKAY;
    1311}
    1312
    1313/** merges the statistics of NLPIs from a source SCIP into a target SCIP
    1314 *
    1315 * The two SCIP instances should point to different SCIP instances.
    1316 *
    1317 * @note the notion of source and target is inverted here; \p sourcescip usually denotes a copied SCIP instance, whereas
    1318 * \p targetscip denotes the original instance
    1319 */
    1321 SCIP* sourcescip, /**< source SCIP data structure */
    1322 SCIP* targetscip, /**< target SCIP data structure */
    1323 SCIP_Bool reset /**< whether to reset statistics in sourcescip */
    1324 )
    1325{
    1326 int i;
    1327
    1328 assert(sourcescip != targetscip);
    1329
    1330 for( i = 0; i < sourcescip->set->nnlpis; ++i )
    1331 {
    1332 SCIP_NLPI* sourcenlpi;
    1333 SCIP_NLPI* targetnlpi;
    1334
    1335 sourcenlpi = sourcescip->set->nlpis[i];
    1336 /* probably NLPI is on same position in target and source, otherwise do search */
    1337 if( strcmp(SCIPnlpiGetName(targetscip->set->nlpis[i]), SCIPnlpiGetName(sourcenlpi)) == 0 )
    1338 targetnlpi = targetscip->set->nlpis[i];
    1339 else
    1340 targetnlpi = SCIPsetFindNlpi(targetscip->set, SCIPnlpiGetName(sourcenlpi));
    1341
    1342 if( targetnlpi != NULL )
    1343 SCIPnlpiMergeStatistics(targetnlpi, sourcenlpi, reset);
    1344 else
    1345 {
    1346 SCIPdebugMsg(targetscip, "NLPI <%s> from source SCIP not available in target SCIP\n", SCIPnlpiGetName(sourcenlpi));
    1347 }
    1348 }
    1349}
    1350
    1351/** provides values of a solution from a subscip according to the variable in the main scip
    1352 *
    1353 * Given a subscip solution, fills an array with solution values, matching the variables given by SCIPgetVars().
    1354 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1355 * are represented as NULL entry in the subvars array.
    1356 */
    1357static
    1359 SCIP* scip, /**< SCIP data structure of the original problem */
    1360 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1361 SCIP_SOL* subsol, /**< solution of the subproblem */
    1362 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1363 SCIP_Real* solvals /**< array where to set values taken from subsol, must have length at least SCIPgetNVars(scip) */
    1364 )
    1365{
    1366 SCIP_VAR** vars;
    1367 int nvars;
    1368 int i;
    1369
    1370 assert(scip != NULL);
    1371 assert(subscip != NULL);
    1372 assert(subsol != NULL);
    1373 assert(subvars != NULL);
    1374 assert(solvals != NULL);
    1375
    1376 /* copy the solution */
    1377 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1378
    1379 /* copy the solution */
    1380 for( i = 0; i < nvars; ++i )
    1381 {
    1382 if( subvars[i] != NULL )
    1383 solvals[i] = SCIPgetSolVal(subscip, subsol, subvars[i]);
    1384 else
    1385 solvals[i] = MIN(MAX(0.0, SCIPvarGetLbLocal(vars[i])), SCIPvarGetUbLocal(vars[i])); /*lint !e666*/
    1386 }
    1387
    1388 return SCIP_OKAY;
    1389}
    1390
    1391/** translates a solution from a subscip to the main scip
    1392 *
    1393 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1394 * are represented as NULL entry in the subvars array.
    1395 *
    1396 * @note This method allocates a new solution of the main scip that needs to be freed by the user.
    1397 */
    1399 SCIP* scip, /**< SCIP data structure of the original problem */
    1400 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1401 SCIP_SOL* subsol, /**< solution of the subproblem */
    1402 SCIP_HEUR* heur, /**< heuristic that found the solution */
    1403 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1404 SCIP_SOL** newsol /**< buffer to store pointer to created solution in main SCIP */
    1405 )
    1406{
    1407 SCIP_VAR** vars;
    1408 int nvars;
    1409 SCIP_Real* subsolvals;
    1410
    1411 assert(scip != NULL);
    1412 assert(subscip != NULL);
    1413 assert(subsol != NULL);
    1414 assert(subvars != NULL);
    1415 assert(newsol != NULL);
    1416
    1417 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1418
    1419 SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
    1420
    1421 /* get the solution values */
    1422 SCIP_CALL( translateSubSol(scip, subscip, subsol, subvars, subsolvals) );
    1423
    1424 /* create new solution for the original problem */
    1425 SCIP_CALL( SCIPcreateSol(scip, newsol, heur) );
    1426 SCIP_CALL( SCIPsetSolVals(scip, *newsol, nvars, vars, subsolvals) );
    1427
    1428 SCIPfreeBufferArray(scip, &subsolvals);
    1429
    1430 return SCIP_OKAY;
    1431}
    1432
    1433/** checks the solutions from the subscip and adds the first one that is found feasible to the master SCIP
    1434 *
    1435 * Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables
    1436 * are represented as NULL entry in the subvars array.
    1437 */
    1439 SCIP* scip, /**< the SCIP data structure */
    1440 SCIP* subscip, /**< SCIP data structure of the subproblem */
    1441 SCIP_HEUR* heur, /**< heuristic that found the solution */
    1442 SCIP_VAR** subvars, /**< the variables from the subproblem in the same order as the main scip */
    1443 SCIP_Bool* success, /**< pointer to store, whether new solution was found */
    1444 int* solindex /**< pointer to store solution index of stored solution, or NULL if not of interest */
    1445 )
    1446{
    1447 SCIP_SOL* newsol = NULL;
    1448 SCIP_SOL** subsols;
    1449 int nsubsols;
    1450 int i;
    1451 SCIP_VAR** vars;
    1452 int nvars;
    1453 SCIP_Real* solvals;
    1454
    1455 assert(scip != NULL);
    1456 assert(subscip != NULL);
    1457 assert(heur != NULL);
    1458 assert(subvars != NULL);
    1459 assert(success != NULL);
    1460
    1461 *success = FALSE;
    1462
    1463 /* check, whether a solution was found */
    1464 if( SCIPgetNSols(subscip) == 0 )
    1465 return SCIP_OKAY;
    1466
    1467 SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
    1468
    1469 SCIP_CALL( SCIPallocBufferArray(scip, &solvals, nvars) );
    1470
    1471 /* check, whether a solution was found;
    1472 * due to numerics, it might happen that not all solutions are feasible -> try all solutions until one was accepted
    1473 */
    1474 nsubsols = SCIPgetNSols(subscip);
    1475 subsols = SCIPgetSols(subscip);
    1476 for( i = 0; i < nsubsols; ++i )
    1477 {
    1478 /* create or clear main solution */
    1479 if( newsol == NULL )
    1480 {
    1481 SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
    1482 if( solindex != NULL )
    1483 *solindex = SCIPsolGetIndex(newsol);
    1484 }
    1485 else
    1486 SCIP_CALL( SCIPclearSol(scip, newsol) );
    1487
    1488 /* get values from subsol */
    1489 SCIP_CALL( translateSubSol(scip, subscip, subsols[i], subvars, solvals) );
    1490
    1491 /* put values into newsol */
    1492 SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, solvals) );
    1493
    1494 /* reject solution with invalid objective value */
    1495 if( SCIPgetSolTransObj(scip, newsol) == SCIP_INVALID ) /*lint !e777*/
    1496 continue;
    1497
    1498 /* check whether feasible */
    1499 SCIP_CALL( SCIPcheckSol(scip, newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
    1500 if( *success )
    1501 {
    1502 /* if feasible, then there is a good chance that we can add it
    1503 * we use SCIPaddSolFree to make sure that newsol is indeed added and not some copy, so *solindex stays valid
    1504 */
    1505 SCIP_CALL( SCIPaddSolFree(scip, &newsol, success) );
    1506 if( *success )
    1507 {
    1508 SCIPdebugMsg(scip, "-> accepted solution of value %g\n", SCIPgetSolOrigObj(subscip, subsols[i]));
    1509 break;
    1510 }
    1511 else
    1512 {
    1513 /* continue with next subsol
    1514 * as we have used addSolFree, newsol should be NULL now
    1515 */
    1516 assert(newsol == NULL);
    1517 }
    1518 }
    1519 }
    1520
    1521 SCIPfreeBufferArray(scip, &solvals);
    1522
    1523 if( newsol != NULL )
    1524 {
    1525 SCIP_CALL( SCIPfreeSol(scip, &newsol) );
    1526 }
    1527
    1528 return SCIP_OKAY;
    1529}
    1530
    1531/** returns copy of the source constraint; if there already is a copy of the source constraint in the constraint hash
    1532 * map, it is just returned as target constraint; elsewise a new constraint will be created; this created constraint is
    1533 * added to the constraint hash map and returned as target constraint; the variable map is used to map the variables of
    1534 * the source SCIP to the variables of the target SCIP
    1535 *
    1536 * @warning If a constraint is marked to be checked for feasibility but not to be enforced, a LP or pseudo solution may
    1537 * be declared feasible even if it violates this particular constraint. This constellation should only be
    1538 * used, if no LP or pseudo solution can violate the constraint -- e.g. if a local constraint is redundant due
    1539 * to the variable's local bounds.
    1540 *
    1541 * @note The constraint is not added to the target SCIP. You can check whether a constraint is added by calling
    1542 * SCIPconsIsAdded(). (If you mix SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add
    1543 * explicitly and what is already added.)
    1544 *
    1545 * @note The constraint is always captured, either during the creation of the copy or after finding the copy of the
    1546 * constraint in the constraint hash map
    1547 *
    1548 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1549 * @note Do not change the source SCIP environment during the copying process
    1550 *
    1551 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1552 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1553 *
    1554 * @pre This method can be called if sourcescip is in one of the following stages:
    1555 * - \ref SCIP_STAGE_PROBLEM
    1556 * - \ref SCIP_STAGE_TRANSFORMED
    1557 * - \ref SCIP_STAGE_INITPRESOLVE
    1558 * - \ref SCIP_STAGE_PRESOLVING
    1559 * - \ref SCIP_STAGE_EXITPRESOLVE
    1560 * - \ref SCIP_STAGE_PRESOLVED
    1561 * - \ref SCIP_STAGE_INITSOLVE
    1562 * - \ref SCIP_STAGE_SOLVING
    1563 * - \ref SCIP_STAGE_SOLVED
    1564 *
    1565 * @pre This method can be called if targetscip is in one of the following stages:
    1566 * - \ref SCIP_STAGE_PROBLEM
    1567 * - \ref SCIP_STAGE_TRANSFORMING
    1568 * - \ref SCIP_STAGE_INITPRESOLVE
    1569 * - \ref SCIP_STAGE_PRESOLVING
    1570 * - \ref SCIP_STAGE_EXITPRESOLVE
    1571 * - \ref SCIP_STAGE_PRESOLVED
    1572 * - \ref SCIP_STAGE_SOLVING
    1573 * - \ref SCIP_STAGE_EXITSOLVE
    1574 *
    1575 * @note sourcescip stage does not get changed
    1576 *
    1577 * @note targetscip stage does not get changed
    1578 *
    1579 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1580 */
    1582 SCIP* sourcescip, /**< source SCIP data structure */
    1583 SCIP* targetscip, /**< target SCIP data structure */
    1584 SCIP_CONS* sourcecons, /**< source constraint of the source SCIP */
    1585 SCIP_CONS** targetcons, /**< pointer to store the created target constraint */
    1586 SCIP_CONSHDLR* sourceconshdlr, /**< source constraint handler for this constraint */
    1587 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1588 * variables of the target SCIP, or NULL */
    1589 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1590 * target constraints, or NULL */
    1591 const char* name, /**< name of constraint, or NULL if the name of the source constraint should be used */
    1592 SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP? */
    1593 SCIP_Bool separate, /**< should the constraint be separated during LP processing? */
    1594 SCIP_Bool enforce, /**< should the constraint be enforced during node processing? */
    1595 SCIP_Bool check, /**< should the constraint be checked for feasibility? */
    1596 SCIP_Bool propagate, /**< should the constraint be propagated during node processing? */
    1597 SCIP_Bool local, /**< is constraint only valid locally? */
    1598 SCIP_Bool modifiable, /**< is constraint modifiable (subject to column generation)? */
    1599 SCIP_Bool dynamic, /**< is constraint subject to aging? */
    1600 SCIP_Bool removable, /**< should the relaxation be removed from the LP due to aging or cleanup? */
    1601 SCIP_Bool stickingatnode, /**< should the constraint always be kept at the node where it was added, even
    1602 * if it may be moved to a more global node? */
    1603 SCIP_Bool global, /**< create a global or a local copy? */
    1604 SCIP_Bool* valid /**< pointer to store whether the copying was valid or not */
    1605 )
    1606{
    1607 SCIP_HASHMAP* localvarmap;
    1608 SCIP_HASHMAP* localconsmap;
    1609 SCIP_Bool uselocalvarmap;
    1610 SCIP_Bool uselocalconsmap;
    1611
    1612 assert(targetcons != NULL);
    1613 assert(sourceconshdlr != NULL);
    1614
    1615 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPgetConsCopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1616 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPgetConsCopy", FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    1617
    1618 uselocalvarmap = (varmap == NULL);
    1619 uselocalconsmap = (consmap == NULL);
    1620
    1621 /* a variables map and a constraint map is needed to avoid infinite recursion */
    1622 if( uselocalvarmap )
    1623 {
    1624 /* create the variable mapping hash map */
    1625 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1626 }
    1627 else
    1628 localvarmap = varmap;
    1629
    1630 *targetcons = NULL;
    1631 if( uselocalconsmap )
    1632 {
    1633 /* create local constraint mapping hash map */
    1634 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1635 }
    1636 else
    1637 {
    1638 /* use global map and try to retrieve copied constraint */
    1639 localconsmap = consmap;
    1640 *targetcons = (SCIP_CONS*) SCIPhashmapGetImage(localconsmap, sourcecons);
    1641 }
    1642
    1643 if( *targetcons != NULL )
    1644 {
    1645 /* if found capture existing copy of the constraint */
    1646 SCIP_CALL( SCIPcaptureCons(targetscip, *targetcons) );
    1647 *valid = TRUE;
    1648 }
    1649 else
    1650 {
    1651 /* otherwise create a copy of the constraint */
    1652 SCIP_CALL( SCIPconsCopy(targetcons, targetscip->set, name, sourcescip, sourceconshdlr, sourcecons, localvarmap, localconsmap,
    1653 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) );
    1654
    1655 /* if a target constraint was created */
    1656 if( *targetcons != NULL && !uselocalconsmap )
    1657 {
    1658 /* insert constraint into mapping between source SCIP and the target SCIP */
    1659 SCIP_CALL( SCIPhashmapInsert(consmap, sourcecons, *targetcons) );
    1660 }
    1661 }
    1662
    1663 /* free locally allocated hash maps */
    1664 if( uselocalvarmap )
    1665 {
    1666 SCIPhashmapFree(&localvarmap);
    1667 }
    1668
    1669 if( uselocalconsmap )
    1670 {
    1671 SCIPhashmapFree(&localconsmap);
    1672 }
    1673
    1674 return SCIP_OKAY;
    1675}
    1676
    1677/** copies constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
    1678 * variables between the source and the target SCIP a hash map can be given; if the variable hash
    1679 * map is NULL or necessary variable mapping is missing, the required variables are created in the
    1680 * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
    1681 * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
    1682 * between the constraints of the source and target-SCIP is stored
    1683 *
    1684 * *valid is set to TRUE iff all constraints that are marked as checked or enforced were copied successfully.
    1685 * If other constraints could not be copied, *valid can still be set to TRUE.
    1686 *
    1687 * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
    1688 * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
    1689 * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
    1690 *
    1691 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1692 * @note Do not change the source SCIP environment during the copying process
    1693 *
    1694 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1695 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1696 *
    1697 * @pre This method can be called if sourcescip is in one of the following stages:
    1698 * - \ref SCIP_STAGE_PROBLEM
    1699 * - \ref SCIP_STAGE_TRANSFORMED
    1700 * - \ref SCIP_STAGE_INITPRESOLVE
    1701 * - \ref SCIP_STAGE_PRESOLVING
    1702 * - \ref SCIP_STAGE_EXITPRESOLVE
    1703 * - \ref SCIP_STAGE_PRESOLVED
    1704 * - \ref SCIP_STAGE_INITSOLVE
    1705 * - \ref SCIP_STAGE_SOLVING
    1706 * - \ref SCIP_STAGE_SOLVED
    1707 *
    1708 * @pre This method can be called if targetscip is in one of the following stages:
    1709 * - \ref SCIP_STAGE_PROBLEM
    1710 *
    1711 * @note sourcescip stage does not get changed
    1712 *
    1713 * @note targetscip stage does not get changed
    1714 *
    1715 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1716 */
    1718 SCIP* sourcescip, /**< source SCIP data structure */
    1719 SCIP* targetscip, /**< target SCIP data structure */
    1720 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1721 * variables of the target SCIP, or NULL */
    1722 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1723 * target constraints, or NULL */
    1724 SCIP_Bool global, /**< create a global or a local copy? */
    1725 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    1726 * If TRUE, the modifiable flag of constraints will be copied. */
    1727 SCIP_Bool* valid /**< pointer to store whether all checked or enforced constraints were validly copied */
    1728 )
    1729{
    1730 SCIP_CONSHDLR** sourceconshdlrs;
    1731 SCIP_HASHMAP* localvarmap;
    1732 SCIP_HASHMAP* localconsmap;
    1733 SCIP_Bool uselocalvarmap;
    1734 SCIP_Bool uselocalconsmap;
    1735 int nsourceconshdlrs;
    1736 int i;
    1737
    1738 assert(sourcescip != NULL);
    1739 assert(targetscip != NULL);
    1740 assert(valid != NULL);
    1741
    1742 /* check stages for both, the source and the target SCIP data structure */
    1743 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1744 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1745
    1746 /* check if we locally need to create a variable or constraint hash map */
    1747 uselocalvarmap = (varmap == NULL);
    1748 uselocalconsmap = (consmap == NULL);
    1749
    1750 if( uselocalvarmap )
    1751 {
    1752 /* create the variable mapping hash map */
    1753 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1754 }
    1755 else
    1756 localvarmap = varmap;
    1757
    1758 if( uselocalconsmap )
    1759 {
    1760 /* create the constraint mapping hash map */
    1761 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1762 }
    1763 else
    1764 localconsmap = consmap;
    1765
    1766 nsourceconshdlrs = SCIPgetNConshdlrs(sourcescip);
    1767 sourceconshdlrs = SCIPgetConshdlrs(sourcescip);
    1768 assert(nsourceconshdlrs == 0 || sourceconshdlrs != NULL);
    1769
    1770 *valid = TRUE;
    1771
    1772 /* copy constraints: loop through all (source) constraint handlers */
    1773 for( i = 0; i < nsourceconshdlrs; ++i )
    1774 {
    1775 SCIP_CONS** sourceconss;
    1776 SCIP_CONS* targetcons;
    1777 int nsourceconss;
    1778 int c;
    1779
    1780 assert(sourceconshdlrs[i] != NULL);
    1781
    1782 /* constraint handlers have to explicitly set the valid pointer to TRUE for every single constraint */
    1783
    1784 /* Get all active constraints for copying; this array contains all active constraints;
    1785 * constraints are active if they are globally valid and not deleted after presolving OR they
    1786 * were locally added during the search and we are currently in a node which belongs to the
    1787 * corresponding subtree.
    1788 */
    1789 nsourceconss = SCIPconshdlrGetNActiveConss(sourceconshdlrs[i]);
    1790 sourceconss = SCIPconshdlrGetConss(sourceconshdlrs[i]);
    1791
    1792#ifdef SCIP_DISABLED_CODE
    1793 /* @todo using the following might reduce the number of copied constraints - check whether this is better */
    1794 /* Get all checked constraints for copying; this included local constraints */
    1795 if( !global )
    1796 {
    1797 nsourceconss = SCIPconshdlrGetNCheckConss(sourceconshdlrs[i]);
    1798 sourceconss = SCIPconshdlrGetCheckConss(sourceconshdlrs[i]);
    1799 }
    1800#endif
    1801
    1802 assert(nsourceconss == 0 || sourceconss != NULL);
    1803
    1804 if( nsourceconss > 0 )
    1805 {
    1806 SCIPdebugMsg(sourcescip, "Attempting to copy %d %s constraints\n", nsourceconss, SCIPconshdlrGetName(sourceconshdlrs[i]));
    1807 }
    1808
    1809 /* copy all constraints of one constraint handler */
    1810 for( c = 0; c < nsourceconss; ++c )
    1811 {
    1812 SCIP_Bool singlevalid = FALSE;
    1813 /* all constraints have to be active */
    1814 assert(sourceconss[c] != NULL);
    1815 assert(SCIPconsIsActive(sourceconss[c]));
    1816 assert(!SCIPconsIsDeleted(sourceconss[c]));
    1817
    1818 /* in case of copying the global problem we have to ignore the local constraints which are active */
    1819 if( global && SCIPconsIsLocal(sourceconss[c]) )
    1820 {
    1821 SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconss[c]));
    1822 continue;
    1823 }
    1824
    1825 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    1826 targetcons = NULL;
    1827 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, sourceconshdlrs[i], localvarmap, localconsmap, NULL,
    1828 SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
    1829 SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
    1830 SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
    1831 SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, global, &singlevalid) );
    1832
    1833 /* add the copied constraint to target SCIP if the copying process created a constraint */
    1834 if( targetcons != NULL )
    1835 {
    1836 if( !enablepricing )
    1837 SCIPconsSetModifiable(targetcons, FALSE);
    1838
    1839 /* add constraint to target SCIP */
    1840 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    1841
    1842 /* add the conflict constraint to the store of targetscip */
    1843 if( SCIPconsIsConflict(sourceconss[c]) )
    1844 {
    1845 /* add the constraint as a conflict to the conflict pool of targetscip */
    1846 SCIP_CALL( SCIPconflictstoreAddConflict(targetscip->conflictstore, targetscip->mem->probmem, targetscip->set,
    1847 targetscip->stat, NULL, NULL, targetscip->reopt, targetcons, SCIP_CONFTYPE_UNKNOWN, FALSE, -SCIPinfinity(targetscip)) );
    1848 }
    1849
    1850 /* release constraint once for the creation capture */
    1851 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    1852 }
    1853 else
    1854 {
    1855 /* if an enforced or checked constraint could not be copied, then the copy is not valid, i.e.,
    1856 * the feasible set may be larger; for other constraints, it should be safe if they are omitted
    1857 * from the copy
    1858 */
    1859 if( SCIPconsIsEnforced(sourceconss[c]) || SCIPconsIsChecked(sourceconss[c]) )
    1860 *valid = FALSE;
    1861 SCIPdebugMsg(sourcescip, "Constraint %s not copied, copy is %svalid\n",
    1862 SCIPconsGetName(sourceconss[c]), *valid ? "" : "not ");
    1863 }
    1864 }
    1865 }
    1866
    1867 if( uselocalvarmap )
    1868 {
    1869 /* free hash map */
    1870 SCIPhashmapFree(&localvarmap);
    1871 }
    1872
    1873 if( uselocalconsmap )
    1874 {
    1875 /* free hash map */
    1876 SCIPhashmapFree(&localconsmap);
    1877 }
    1878
    1879 return SCIP_OKAY;
    1880}
    1881
    1882/** copies all original constraints from the source-SCIP and adds these to the target-SCIP; for mapping the
    1883 * variables between the source and the target SCIP a hash map can be given; if the variable hash
    1884 * map is NULL or necessary variable mapping is missing, the required variables are created in the
    1885 * target-SCIP and added to the hash map, if not NULL; all variables which are created are added to
    1886 * the target-SCIP but not (user) captured; if the constraint hash map is not NULL the mapping
    1887 * between the constraints of the source and target-SCIP is stored
    1888 *
    1889 * @note the constraints are added to the target-SCIP but are not (user) captured in the target SCIP. (If you mix
    1890 * SCIPgetConsCopy() with SCIPcopyConss() you should pay attention to what you add explicitly and what is already
    1891 * added.) You can check whether a constraint is added by calling SCIPconsIsAdded().
    1892 *
    1893 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    1894 * @note Do not change the source SCIP environment during the copying process
    1895 *
    1896 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    1897 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    1898 *
    1899 * @pre This method can be called if sourcescip is in one of the following stages:
    1900 * - \ref SCIP_STAGE_PROBLEM
    1901 * - \ref SCIP_STAGE_TRANSFORMED
    1902 * - \ref SCIP_STAGE_INITPRESOLVE
    1903 * - \ref SCIP_STAGE_PRESOLVING
    1904 * - \ref SCIP_STAGE_EXITPRESOLVE
    1905 * - \ref SCIP_STAGE_PRESOLVED
    1906 * - \ref SCIP_STAGE_INITSOLVE
    1907 * - \ref SCIP_STAGE_SOLVING
    1908 * - \ref SCIP_STAGE_SOLVED
    1909 *
    1910 * @pre This method can be called if targetscip is in one of the following stages:
    1911 * - \ref SCIP_STAGE_PROBLEM
    1912 *
    1913 * @note sourcescip stage does not get changed
    1914 *
    1915 * @note targetscip stage does not get changed
    1916 *
    1917 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    1918 */
    1920 SCIP* sourcescip, /**< source SCIP data structure */
    1921 SCIP* targetscip, /**< target SCIP data structure */
    1922 SCIP_HASHMAP* varmap, /**< a SCIP_HASHMAP mapping variables of the source SCIP to the corresponding
    1923 * variables of the target SCIP, or NULL */
    1924 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    1925 * target constraints, or NULL */
    1926 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    1927 * If TRUE, the modifiable flag of constraints will be copied. */
    1928 SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
    1929 )
    1930{
    1931 SCIP_CONS** sourceconss;
    1932 SCIP_HASHMAP* localvarmap;
    1933 SCIP_HASHMAP* localconsmap;
    1934 SCIP_Bool uselocalvarmap;
    1935 SCIP_Bool uselocalconsmap;
    1936 int nsourceconss;
    1937 int c;
    1938
    1939 assert(sourcescip != NULL);
    1940 assert(targetscip != NULL);
    1941 assert(valid != NULL);
    1942
    1943 /* check stages for both, the source and the target SCIP data structure */
    1944 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    1945 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConss", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    1946
    1947 /* check if we locally need to create a variable or constraint hash map */
    1948 uselocalvarmap = (varmap == NULL);
    1949 uselocalconsmap = (consmap == NULL);
    1950
    1951 if( uselocalvarmap )
    1952 {
    1953 /* create the variable mapping hash map */
    1954 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    1955 }
    1956 else
    1957 localvarmap = varmap;
    1958
    1959 if( uselocalconsmap )
    1960 {
    1961 /* create the constraint mapping hash map */
    1962 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    1963 }
    1964 else
    1965 localconsmap = consmap;
    1966
    1967 sourceconss = SCIPgetOrigConss(sourcescip);
    1968 nsourceconss = SCIPgetNOrigConss(sourcescip);
    1969
    1970 *valid = TRUE;
    1971
    1972 SCIPdebugMsg(sourcescip, "Attempting to copy %d original constraints\n", nsourceconss);
    1973
    1974 /* copy constraints: loop through all (source) constraint handlers */
    1975 for( c = 0; c < nsourceconss; ++c )
    1976 {
    1977 SCIP_CONS* targetcons;
    1978 SCIP_Bool success;
    1979
    1980 /* constraint handlers have to explicitly set the success pointer to TRUE */
    1981 success = FALSE;
    1982
    1983 /* all constraints have to be active */
    1984 assert(sourceconss[c] != NULL);
    1985 assert(SCIPconsIsOriginal(sourceconss[c]));
    1986
    1987 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    1988 targetcons = NULL;
    1989 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconss[c], &targetcons, SCIPconsGetHdlr(sourceconss[c]), localvarmap, localconsmap, NULL,
    1990 SCIPconsIsInitial(sourceconss[c]), SCIPconsIsSeparated(sourceconss[c]),
    1991 SCIPconsIsEnforced(sourceconss[c]), SCIPconsIsChecked(sourceconss[c]),
    1992 SCIPconsIsPropagated(sourceconss[c]), FALSE, SCIPconsIsModifiable(sourceconss[c]),
    1993 SCIPconsIsDynamic(sourceconss[c]), SCIPconsIsRemovable(sourceconss[c]), FALSE, TRUE, &success) );
    1994
    1995 /* add the copied constraint to target SCIP if the copying process was valid */
    1996 if( success )
    1997 {
    1998 assert(targetcons != NULL);
    1999
    2000 if( !enablepricing )
    2001 SCIPconsSetModifiable(targetcons, FALSE);
    2002
    2003 /* add constraint to target SCIP */
    2004 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    2005
    2006 /* release constraint once for the creation capture */
    2007 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    2008 }
    2009 else
    2010 {
    2011 *valid = FALSE;
    2012 SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconss[c]));
    2013 }
    2014 }
    2015
    2016 if( uselocalvarmap )
    2017 {
    2018 /* free hash map */
    2019 SCIPhashmapFree(&localvarmap);
    2020 }
    2021
    2022 if( uselocalconsmap )
    2023 {
    2024 /* free hash map */
    2025 SCIPhashmapFree(&localconsmap);
    2026 }
    2027
    2028 return SCIP_OKAY;
    2029}
    2030
    2031
    2032/** convert all active cuts from cutpool to linear constraints
    2033 *
    2034 * @note Do not change the source SCIP environment during the copying process
    2035 *
    2036 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2037 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2038 *
    2039 * @pre This method can be called if SCIP is in one of the following stages:
    2040 * - \ref SCIP_STAGE_PROBLEM
    2041 * - \ref SCIP_STAGE_INITPRESOLVE
    2042 * - \ref SCIP_STAGE_PRESOLVING
    2043 * - \ref SCIP_STAGE_EXITPRESOLVE
    2044 * - \ref SCIP_STAGE_PRESOLVED
    2045 * - \ref SCIP_STAGE_SOLVING
    2046 * - \ref SCIP_STAGE_EXITSOLVE
    2047 *
    2048 * @note SCIP stage does not get changed
    2049 *
    2050 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2051 */
    2053 SCIP* scip, /**< SCIP data structure */
    2054 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2055 * target variables, or NULL */
    2056 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2057 * target constraints, or NULL */
    2058 SCIP_Bool global, /**< create a global or a local copy? */
    2059 int* ncutsadded /**< pointer to store number of added cuts, or NULL */
    2060 )
    2061{
    2062 assert(scip != NULL);
    2063 assert(scip->set != NULL);
    2064
    2065 /* check stages for the SCIP data structure */
    2066 SCIP_CALL( SCIPcheckStage(scip, "SCIPconvertCutsToConss", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    2067
    2068 /* if we do not have any cuts, nothing can be converted */
    2069 if( scip->set->stage < SCIP_STAGE_SOLVING )
    2070 return SCIP_OKAY;
    2071
    2072 /* create out of all active cuts in cutpool linear constraints in targetscip */
    2073 SCIP_CALL( SCIPcopyCuts(scip, scip, varmap, consmap, global, ncutsadded) );
    2074
    2075 return SCIP_OKAY;
    2076}
    2077
    2078/** copies all active cuts from cutpool of sourcescip to linear constraints in targetscip
    2079 *
    2080 * Cuts that contain variables that are marked as relaxation-only are skipped.
    2081 *
    2082 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2083 * @note Do not change the source SCIP environment during the copying process
    2084 *
    2085 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2086 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2087 *
    2088 * @pre This method can be called if sourcescip is in one of the following stages:
    2089 * - \ref SCIP_STAGE_PROBLEM
    2090 * - \ref SCIP_STAGE_TRANSFORMED
    2091 * - \ref SCIP_STAGE_INITPRESOLVE
    2092 * - \ref SCIP_STAGE_PRESOLVING
    2093 * - \ref SCIP_STAGE_EXITPRESOLVE
    2094 * - \ref SCIP_STAGE_PRESOLVED
    2095 * - \ref SCIP_STAGE_SOLVING
    2096 * - \ref SCIP_STAGE_SOLVED
    2097 * - \ref SCIP_STAGE_EXITSOLVE
    2098 *
    2099 * @pre This method can be called if targetscip is in one of the following stages:
    2100 * - \ref SCIP_STAGE_PROBLEM
    2101 * - \ref SCIP_STAGE_INITPRESOLVE
    2102 * - \ref SCIP_STAGE_PRESOLVING
    2103 * - \ref SCIP_STAGE_EXITPRESOLVE
    2104 * - \ref SCIP_STAGE_PRESOLVED
    2105 * - \ref SCIP_STAGE_SOLVING
    2106 * - \ref SCIP_STAGE_EXITSOLVE
    2107 *
    2108 * @note sourcescip stage does not get changed
    2109 *
    2110 * @note targetscip stage does not get changed
    2111 *
    2112 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2113 */
    2115 SCIP* sourcescip, /**< source SCIP data structure */
    2116 SCIP* targetscip, /**< target SCIP data structure */
    2117 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2118 * target variables, or NULL */
    2119 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2120 * target constraints, or NULL */
    2121 SCIP_Bool global, /**< create a global or a local copy? */
    2122 int* ncutsadded /**< pointer to store number of copied cuts, or NULL */
    2123 )
    2124{
    2125 SCIP_CUT** cuts;
    2126 int ncuts;
    2127 int nlocalcutsadded;
    2128
    2129 assert(sourcescip != NULL);
    2130 assert(targetscip != NULL);
    2131
    2132 /* check stages for both, the source and the target SCIP data structure */
    2133 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyCuts", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
    2134 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyCuts", FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE) );
    2135
    2136 if ( ncutsadded != NULL )
    2137 *ncutsadded = 0;
    2138 nlocalcutsadded = 0;
    2139
    2140 /* if we do not have any cuts, nothing can be converted */
    2141 if( sourcescip->set->stage < SCIP_STAGE_SOLVING )
    2142 return SCIP_OKAY;
    2143
    2144 if( SCIPfindConshdlr(targetscip, "linear") == NULL )
    2145 {
    2146 SCIPdebugMsg(sourcescip, "No linear constraint handler available. Cannot convert cuts.\n");
    2147 return SCIP_OKAY;
    2148 }
    2149
    2150 /* convert cut from global cut pool */
    2151 cuts = SCIPgetPoolCuts(sourcescip);
    2152 ncuts = SCIPgetNPoolCuts(sourcescip);
    2153
    2154 SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
    2155
    2156 SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
    2157
    2158 /* convert delayed cuts from global delayed cut pool */
    2159 cuts = SCIPgetDelayedPoolCuts(sourcescip);
    2160 ncuts = SCIPgetNDelayedPoolCuts(sourcescip);
    2161
    2162 SCIP_CALL( copyCuts(sourcescip, targetscip, cuts, ncuts, varmap, consmap, global, &nlocalcutsadded) );
    2163
    2164 if( ncutsadded != NULL )
    2165 *ncutsadded = nlocalcutsadded;
    2166
    2167 SCIPdebugMsg(sourcescip, "Converted %d active cuts to constraints.\n", nlocalcutsadded);
    2168
    2169 return SCIP_OKAY;
    2170}
    2171
    2172/** copies all active conflicts from the conflict pool of sourcescip and adds them as linear constraints to targetscip
    2173 *
    2174 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2175 * @note Do not change the source SCIP environment during the copying process
    2176 *
    2177 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2178 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2179 *
    2180 * @pre This method can be called if sourcescip is in one of the following stages:
    2181 * - \ref SCIP_STAGE_PROBLEM
    2182 * - \ref SCIP_STAGE_TRANSFORMED
    2183 * - \ref SCIP_STAGE_INITPRESOLVE
    2184 * - \ref SCIP_STAGE_PRESOLVING
    2185 * - \ref SCIP_STAGE_EXITPRESOLVE
    2186 * - \ref SCIP_STAGE_PRESOLVED
    2187 * - \ref SCIP_STAGE_SOLVING
    2188 * - \ref SCIP_STAGE_SOLVED
    2189 * - \ref SCIP_STAGE_EXITSOLVE
    2190 *
    2191 * @pre This method can be called if targetscip is in one of the following stages:
    2192 * - \ref SCIP_STAGE_PROBLEM
    2193 * - \ref SCIP_STAGE_INITPRESOLVE
    2194 * - \ref SCIP_STAGE_PRESOLVING
    2195 * - \ref SCIP_STAGE_EXITPRESOLVE
    2196 * - \ref SCIP_STAGE_PRESOLVED
    2197 * - \ref SCIP_STAGE_SOLVING
    2198 * - \ref SCIP_STAGE_EXITSOLVE
    2199 *
    2200 * @note sourcescip stage does not change
    2201 *
    2202 * @note targetscip stage does not change
    2203 *
    2204 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2205 */
    2207 SCIP* sourcescip, /**< source SCIP data structure */
    2208 SCIP* targetscip, /**< target SCIP data structure */
    2209 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2210 * target variables, or NULL */
    2211 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2212 * target constraints, or NULL */
    2213 SCIP_Bool global, /**< create a global or a local copy? */
    2214 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance?
    2215 * If TRUE, the modifiable flag of constraints will be copied. */
    2216 SCIP_Bool* valid /**< pointer to store whether all constraints were validly copied */
    2217 )
    2218{
    2219 SCIP_CONS** sourceconfs;
    2220 SCIP_HASHMAP* localvarmap;
    2221 SCIP_HASHMAP* localconsmap;
    2222 SCIP_Bool uselocalvarmap;
    2223 SCIP_Bool uselocalconsmap;
    2224 SCIP_Bool success;
    2225 int sourceconfssize;
    2226 int nsourceconfs;
    2227 int c;
    2228
    2229 assert(sourcescip != NULL);
    2230 assert(targetscip != NULL);
    2231
    2232 /* check stages for both, the source and the target SCIP data structure */
    2233 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConflicts", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2234 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConflicts", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
    2235
    2236 /* check if we locally need to create a variable or constraint hash map */
    2237 uselocalvarmap = (varmap == NULL);
    2238 uselocalconsmap = (consmap == NULL);
    2239
    2240 if( uselocalvarmap )
    2241 {
    2242 /* create the variable mapping hash map */
    2243 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    2244 }
    2245 else
    2246 localvarmap = varmap;
    2247
    2248 if( uselocalconsmap )
    2249 {
    2250 /* create the constraint mapping hash map */
    2251 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    2252 }
    2253 else
    2254 localconsmap = consmap;
    2255
    2256 /* get number of conflicts stored in the conflict pool */
    2257 sourceconfssize = SCIPconflictstoreGetNConflictsInStore(sourcescip->conflictstore);
    2258
    2259 /* allocate buffer */
    2260 SCIP_CALL( SCIPallocBufferArray(sourcescip, &sourceconfs, sourceconfssize) );
    2261
    2262 /* get all conflicts stored in the conflict pool */
    2263 SCIP_CALL( SCIPconflictstoreGetConflicts(sourcescip->conflictstore, sourceconfs, sourceconfssize, &nsourceconfs) );
    2264 assert(nsourceconfs <= sourceconfssize);
    2265
    2266 /* copy conflicts */
    2267 for( c = 0; c < nsourceconfs; ++c )
    2268 {
    2269 SCIP_CONS* targetcons;
    2270
    2271 /* all constraints have to be active */
    2272 assert(sourceconfs[c] != NULL);
    2273 assert(SCIPconsIsActive(sourceconfs[c]));
    2274 assert(!SCIPconsIsDeleted(sourceconfs[c]));
    2275 assert(SCIPconsIsConflict(sourceconfs[c]));
    2276
    2277 /* in case of copying the global problem we have to ignore the local constraints which are active */
    2278 if( global && SCIPconsIsLocal(sourceconfs[c]) )
    2279 {
    2280 SCIPdebugMsg(sourcescip, "did not copy local constraint <%s> when creating global copy\n", SCIPconsGetName(sourceconfs[c]));
    2281 continue;
    2282 }
    2283
    2284 /* use the copy constructor of the constraint handler and creates and captures the constraint if possible */
    2285 targetcons = NULL;
    2286 SCIP_CALL( SCIPgetConsCopy(sourcescip, targetscip, sourceconfs[c], &targetcons, SCIPconsGetHdlr(sourceconfs[c]),
    2287 localvarmap, localconsmap, NULL, SCIPconsIsInitial(sourceconfs[c]), SCIPconsIsSeparated(sourceconfs[c]),
    2288 SCIPconsIsEnforced(sourceconfs[c]), SCIPconsIsChecked(sourceconfs[c]),
    2289 SCIPconsIsPropagated(sourceconfs[c]), FALSE, SCIPconsIsModifiable(sourceconfs[c]),
    2290 SCIPconsIsDynamic(sourceconfs[c]), SCIPconsIsRemovable(sourceconfs[c]), FALSE, global, &success) );
    2291
    2292 /* add the copied constraint to target SCIP if the copying process was valid */
    2293 if( success )
    2294 {
    2295 assert(targetcons != NULL);
    2296
    2297 if( !enablepricing )
    2298 SCIPconsSetModifiable(targetcons, FALSE);
    2299
    2300 /* add constraint to target SCIP */
    2301 SCIP_CALL( SCIPaddCons(targetscip, targetcons) );
    2302
    2303 /* release constraint once for the creation capture */
    2304 SCIP_CALL( SCIPreleaseCons(targetscip, &targetcons) );
    2305 }
    2306 else
    2307 {
    2308 *valid = FALSE;
    2309 SCIPdebugMsg(sourcescip, "failed to copy constraint %s\n", SCIPconsGetName(sourceconfs[c]));
    2310 }
    2311 }
    2312
    2313 if( uselocalvarmap )
    2314 {
    2315 /* free hash map */
    2316 SCIPhashmapFree(&localvarmap);
    2317 }
    2318
    2319 if( uselocalconsmap )
    2320 {
    2321 /* free hash map */
    2322 SCIPhashmapFree(&localconsmap);
    2323 }
    2324
    2325 return SCIP_OKAY;
    2326}
    2327
    2328/** copies implications and cliques of sourcescip to targetscip
    2329 *
    2330 * This function should be called for a targetscip in transformed stage. It can save time in presolving of the
    2331 * targetscip, since implications and cliques are copied.
    2332 *
    2333 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2334 * @note Do not change the source SCIP environment during the copying process
    2335 *
    2336 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2337 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2338 *
    2339 * @pre This method can be called if sourcescip is in one of the following stages:
    2340 * - \ref SCIP_STAGE_TRANSFORMED
    2341 * - \ref SCIP_STAGE_INITPRESOLVE
    2342 * - \ref SCIP_STAGE_PRESOLVING
    2343 * - \ref SCIP_STAGE_EXITPRESOLVE
    2344 * - \ref SCIP_STAGE_PRESOLVED
    2345 * - \ref SCIP_STAGE_SOLVING
    2346 * - \ref SCIP_STAGE_SOLVED
    2347 * - \ref SCIP_STAGE_EXITSOLVE
    2348 *
    2349 * @pre This method can be called if targetscip is in one of the following stages:
    2350 * - \ref SCIP_STAGE_TRANSFORMED
    2351 * - \ref SCIP_STAGE_INITPRESOLVE
    2352 * - \ref SCIP_STAGE_PRESOLVING
    2353 * - \ref SCIP_STAGE_EXITPRESOLVE
    2354 * - \ref SCIP_STAGE_PRESOLVED
    2355 * - \ref SCIP_STAGE_INITSOLVE
    2356 * - \ref SCIP_STAGE_SOLVING
    2357 *
    2358 * @note sourcescip stage does not get changed
    2359 *
    2360 * @note targetscip stage does not get changed
    2361 *
    2362 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2363 */
    2365 SCIP* sourcescip, /**< source SCIP data structure */
    2366 SCIP* targetscip, /**< target SCIP data structure */
    2367 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2368 * target variables, or NULL */
    2369 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2370 * target constraints, or NULL */
    2371 SCIP_Bool global, /**< create a global or a local copy? */
    2372 SCIP_Bool* infeasible, /**< pointer to store whether an infeasibility was detected */
    2373 int* nbdchgs, /**< pointer to store the number of performed bound changes, or NULL */
    2374 int* ncopied /**< pointer to store number of copied implications and cliques, or NULL */
    2375 )
    2376{
    2377 SCIP_CLIQUE** cliques;
    2378 SCIP_VAR** sourcevars;
    2379 SCIP_Bool success;
    2380 int nvars;
    2381 int nbinvars;
    2382 int ncliques;
    2383 int j;
    2384 int c;
    2385
    2386 assert( sourcescip != NULL );
    2387 assert( targetscip != NULL );
    2388 assert( sourcescip != targetscip );
    2389 assert( infeasible != NULL );
    2390
    2391 /* check stages for both, the source and the target SCIP data structure */
    2392 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE) );
    2393 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyImplicationsCliques", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
    2394
    2395 if ( ncopied != NULL )
    2396 *ncopied = 0;
    2397 if ( nbdchgs != NULL )
    2398 *nbdchgs = 0;
    2399
    2400 /* get all active variables */
    2401 SCIP_CALL( SCIPgetVarsData(sourcescip, &sourcevars, &nvars, &nbinvars, NULL, NULL, NULL) );
    2402
    2403 /* stop if no possible variables for cliques exist */
    2404 if ( nbinvars == 0 )
    2405 return SCIP_OKAY;
    2406
    2407 /* get cliques */
    2408 ncliques = SCIPgetNCliques(sourcescip);
    2409 if ( ncliques > 0 )
    2410 {
    2411 SCIP_VAR** targetclique;
    2412
    2413 /* get space for target cliques */
    2414 SCIP_CALL( SCIPallocBufferArray(targetscip, &targetclique, nvars) );
    2415 cliques = SCIPgetCliques(sourcescip);
    2416
    2417 /* loop through all cliques */
    2418 for (c = 0; c < ncliques; ++c)
    2419 {
    2420 SCIP_VAR** cliquevars;
    2421 SCIP_Bool* cliquevals;
    2422 int cliquesize;
    2423 int nboundchg = 0;
    2424
    2425 assert( cliques[c] != NULL );
    2426 cliquevals = SCIPcliqueGetValues(cliques[c]);
    2427 cliquevars = SCIPcliqueGetVars(cliques[c]);
    2428 cliquesize = SCIPcliqueGetNVars(cliques[c]);
    2429
    2430 /* get target variables of clique */
    2431 for (j = 0; j < cliquesize; ++j)
    2432 {
    2433 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, cliquevars[j], &targetclique[j], varmap, consmap, global, &success) );
    2434 if ( ! success )
    2435 {
    2436 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(cliquevars[j]));
    2437 SCIPfreeBufferArray(targetscip, &targetclique);
    2438 return SCIP_OKAY;
    2439 }
    2440 }
    2441
    2442 /* create clique */
    2443 SCIP_CALL( SCIPaddClique(targetscip, targetclique, cliquevals, cliquesize, SCIPcliqueIsEquation(cliques[c]),
    2444 infeasible, &nboundchg) );
    2445
    2446 if ( *infeasible )
    2447 {
    2448 SCIPfreeBufferArray(targetscip, &targetclique);
    2449 return SCIP_OKAY;
    2450 }
    2451 if ( ncopied != NULL )
    2452 ++(*ncopied);
    2453 if ( nbdchgs != NULL )
    2454 *nbdchgs += nboundchg;
    2455 }
    2456 SCIPfreeBufferArray(targetscip, &targetclique);
    2457 }
    2458
    2459 /* create binary implications */
    2460 for (j = 0; j < nbinvars; ++j)
    2461 {
    2462 SCIP_VAR* sourcevar;
    2463 SCIP_VAR* targetvar;
    2464 SCIP_Bool d;
    2465
    2466 sourcevar = sourcevars[j];
    2467 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, sourcevar, &targetvar, varmap, consmap, global, &success) );
    2468 if ( ! success )
    2469 {
    2470 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(sourcevar));
    2471 return SCIP_OKAY;
    2472 }
    2473
    2474 /* consider both possible implications */
    2475 for (d = 0; d <= 1; ++d)
    2476 {
    2477 SCIP_BOUNDTYPE* impltypes;
    2478 SCIP_VAR** implvars;
    2479 SCIP_Real* implbounds;
    2480 int nimpls;
    2481 int l;
    2482
    2483 nimpls = SCIPvarGetNImpls(sourcevar, d);
    2484 if ( nimpls == 0 )
    2485 continue;
    2486
    2487 impltypes = SCIPvarGetImplTypes(sourcevar, d);
    2488 implvars = SCIPvarGetImplVars(sourcevar, d);
    2489 implbounds = SCIPvarGetImplBounds(sourcevar, d);
    2490
    2491 /* create implications */
    2492 for (l = 0; l < nimpls; ++l)
    2493 {
    2494 SCIP_VAR* implvar;
    2495 int nboundchg = 0;
    2496
    2497 SCIP_CALL( SCIPgetVarCopy(sourcescip, targetscip, implvars[l], &implvar, varmap, consmap, global, &success) );
    2498 if ( ! success )
    2499 {
    2500 SCIPdebugMsg(sourcescip, "Getting copy for variable <%s> failed.\n", SCIPvarGetName(implvars[l]));
    2501 return SCIP_OKAY;
    2502 }
    2503
    2504 SCIP_CALL( SCIPaddVarImplication(targetscip, targetvar, d, implvar, impltypes[l], implbounds[l], infeasible, &nboundchg) );
    2505 if ( *infeasible )
    2506 return SCIP_OKAY;
    2507 if ( ncopied != NULL )
    2508 ++(*ncopied);
    2509 if ( nbdchgs != NULL )
    2510 *nbdchgs += nboundchg;
    2511 }
    2512 }
    2513 }
    2514
    2515 return SCIP_OKAY;
    2516}
    2517
    2518/** copies parameter settings from sourcescip to targetscip
    2519 *
    2520 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2521 * @note Do not change the source SCIP environment during the copying process
    2522 *
    2523 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2524 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2525 *
    2526 * @pre This method can be called if sourcescip is in one of the following stages:
    2527 * - \ref SCIP_STAGE_PROBLEM
    2528 * - \ref SCIP_STAGE_TRANSFORMED
    2529 * - \ref SCIP_STAGE_INITPRESOLVE
    2530 * - \ref SCIP_STAGE_PRESOLVING
    2531 * - \ref SCIP_STAGE_EXITPRESOLVE
    2532 * - \ref SCIP_STAGE_PRESOLVED
    2533 * - \ref SCIP_STAGE_INITSOLVE
    2534 * - \ref SCIP_STAGE_SOLVING
    2535 * - \ref SCIP_STAGE_SOLVED
    2536 *
    2537 * @pre This method can be called if targetscip is in one of the following stages:
    2538 * - \ref SCIP_STAGE_INIT
    2539 * - \ref SCIP_STAGE_PROBLEM
    2540 * - \ref SCIP_STAGE_FREE
    2541 *
    2542 * @note sourcescip stage does not get changed
    2543 *
    2544 * @note targetscip stage does not get changed
    2545 *
    2546 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2547 */
    2549 SCIP* sourcescip, /**< source SCIP data structure */
    2550 SCIP* targetscip /**< target SCIP data structure */
    2551 )
    2552{
    2553 assert(sourcescip != NULL);
    2554 assert(targetscip != NULL);
    2555 assert(sourcescip->set != NULL);
    2556 assert(targetscip->set != NULL);
    2557
    2558 /* check stages for both, the source and the target SCIP data structure */
    2559 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyParamSettings", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2560 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyParamSettings", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2561
    2562 SCIP_CALL( SCIPsetCopyParams(sourcescip->set, targetscip->set, targetscip->messagehdlr) );
    2563
    2564 return SCIP_OKAY;
    2565}
    2566
    2567/** gets depth of current scip instance (increased by each copy call)
    2568 *
    2569 * @return Depth of subscip of SCIP is returned.
    2570 *
    2571 * @pre This method can be called if SCIP is in one of the following stages:
    2572 * - \ref SCIP_STAGE_PROBLEM
    2573 * - \ref SCIP_STAGE_TRANSFORMING
    2574 * - \ref SCIP_STAGE_TRANSFORMED
    2575 * - \ref SCIP_STAGE_INITPRESOLVE
    2576 * - \ref SCIP_STAGE_PRESOLVING
    2577 * - \ref SCIP_STAGE_EXITPRESOLVE
    2578 * - \ref SCIP_STAGE_PRESOLVED
    2579 * - \ref SCIP_STAGE_INITSOLVE
    2580 * - \ref SCIP_STAGE_SOLVING
    2581 * - \ref SCIP_STAGE_SOLVED
    2582 * - \ref SCIP_STAGE_EXITSOLVE
    2583 * - \ref SCIP_STAGE_FREETRANS
    2584 *
    2585 * @note SCIP stage does not get changed
    2586 *
    2587 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2588 */
    2590 SCIP* scip /**< SCIP data structure */
    2591 )
    2592{
    2593 assert( scip != NULL );
    2594 assert( scip->stat != NULL );
    2595
    2596 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSubscipDepth", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
    2597
    2598 return scip->stat->subscipdepth;
    2599}
    2600
    2601/** sets depth of scip instance
    2602 *
    2603 * @pre This method can be called if SCIP is in one of the following stages:
    2604 * - \ref SCIP_STAGE_PROBLEM
    2605 *
    2606 * @note SCIP stage does not get changed
    2607 *
    2608 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2609 */
    2611 SCIP* scip, /**< SCIP data structure */
    2612 int newdepth /**< new subscip depth */
    2613 )
    2614{
    2615 assert( scip != NULL );
    2616 assert( newdepth > 0 );
    2617
    2619
    2620 assert( scip->stat != NULL );
    2621 scip->stat->subscipdepth = newdepth;
    2622}
    2623
    2624/** copies source SCIP data into target SCIP data structure
    2625 *
    2626 * distinguishes between
    2627 * - local and global copies
    2628 * - copies of the original or transformed problem
    2629 *
    2630 * Allows for constraint compression by specifying a number of source variables
    2631 * and values that should be fixed in the copy.
    2632 */
    2633static
    2635 SCIP* sourcescip, /**< source SCIP data structure */
    2636 SCIP* targetscip, /**< target SCIP data structure */
    2637 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2638 * target variables, or NULL */
    2639 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2640 * target constraints, or NULL */
    2641 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2642 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2643 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    2644 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2645 SCIP_Bool useconscompression, /**< should constraint compression be used when constraints are created? */
    2646 SCIP_Bool global, /**< create a global or a local copy? */
    2647 SCIP_Bool original, /**< copy original or transformed problem? if TRUE, a copy using local bounds is not possible */
    2648 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2649 * plugins will be copied and activated, and the modifiable flag of
    2650 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2651 * there are pricers present */
    2652 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2653 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2654 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2655 SCIP_Bool* valid /**< pointer to store whether the copying was valid or not, or NULL */
    2656 )
    2657{
    2658 SCIP_HASHMAP* localvarmap;
    2659 SCIP_HASHMAP* localconsmap;
    2660 SCIP_Real startcopytime;
    2661 SCIP_Real copytime;
    2662 SCIP_Bool uselocalvarmap;
    2663 SCIP_Bool uselocalconsmap;
    2664 SCIP_Bool consscopyvalid;
    2665 SCIP_Bool benderscopyvalid;
    2666 SCIP_Bool localvalid;
    2667 SCIP_Bool msghdlrquiet;
    2668 char name[SCIP_MAXSTRLEN];
    2669
    2670 assert(sourcescip != NULL);
    2671 assert(targetscip != NULL);
    2672 assert(suffix != NULL);
    2673
    2674 /* copy the original problem if we are in SCIP_STAGE_PROBLEM stage */
    2675 if( SCIPgetStage(sourcescip) == SCIP_STAGE_PROBLEM )
    2676 original = TRUE;
    2677
    2678 /* global must be TRUE for the original problem */
    2679 assert(global || !original);
    2680
    2681 /* get time before start of copy procedure */
    2682 startcopytime = SCIPclockGetTime(sourcescip->stat->copyclock);
    2683
    2684 /* start time measuring */
    2685 SCIPclockStart(sourcescip->stat->copyclock, sourcescip->set);
    2686
    2687 /* copy all plugins */
    2688 SCIP_CALL( SCIPcopyPlugins(sourcescip, targetscip, TRUE, enablepricing, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
    2689 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, passmessagehdlr, &localvalid) );
    2690
    2691 /* in case there are active pricers and pricing is disabled, targetscip will not be a valid copy of sourcescip */
    2692 if( ! enablepricing && SCIPgetNActivePricers(sourcescip) > 0 )
    2693 localvalid = FALSE;
    2694
    2695 SCIPdebugMsg(sourcescip, "Copying plugins was%s valid.\n", localvalid ? "" : " not");
    2696
    2697 uselocalvarmap = (varmap == NULL);
    2698 uselocalconsmap = (consmap == NULL);
    2699
    2700 if( uselocalvarmap )
    2701 {
    2702 /* create the variable mapping hash map */
    2703 SCIP_CALL( SCIPhashmapCreate(&localvarmap, SCIPblkmem(targetscip), SCIPgetNVars(sourcescip)) );
    2704 }
    2705 else
    2706 localvarmap = varmap;
    2707
    2708 if( uselocalconsmap )
    2709 {
    2710 /* create the constraint mapping hash map */
    2711 SCIP_CALL( SCIPhashmapCreate(&localconsmap, SCIPblkmem(targetscip), SCIPgetNConss(sourcescip)) );
    2712 }
    2713 else
    2714 localconsmap = consmap;
    2715
    2716 /* construct name for the target SCIP using the source problem name and the given suffix string */
    2717 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPgetProbName(sourcescip), suffix);
    2718
    2719 /* store the quiet state of the message handler, if existent */
    2720 msghdlrquiet = SCIPmessagehdlrIsQuiet(targetscip->messagehdlr);
    2721
    2722 /* explicitly suppress output when copying parameters */
    2723 SCIPsetMessagehdlrQuiet(targetscip, TRUE);
    2724
    2725 /* copy all settings */
    2726 SCIP_CALL( SCIPcopyParamSettings(sourcescip, targetscip) );
    2727
    2728 /* even when solving exactly, sub-SCIP heuristics should be run in floating-point mode, since the exactsol constraint
    2729 * handler is in place to perform a final repair step
    2730 */
    2731 SCIP_CALL( SCIPenableExactSolving(targetscip, FALSE) );
    2732
    2733 /* restore original quiet state */
    2734 SCIPsetMessagehdlrQuiet(targetscip, msghdlrquiet);
    2735
    2736 /* create problem in the target SCIP copying the source original or transformed problem data */
    2737 if( original )
    2738 {
    2739 SCIP_CALL( SCIPcopyOrigProb(sourcescip, targetscip, localvarmap, localconsmap, name) );
    2740 }
    2741 else
    2742 {
    2743 SCIP_CALL( SCIPcopyProb(sourcescip, targetscip, localvarmap, localconsmap, global, name) );
    2744 }
    2745
    2746 /* copy original or transformed variables and perform fixings if needed */
    2747 SCIP_CALL( copyVars(sourcescip, targetscip, localvarmap, localconsmap, fixedvars, fixedvals, nfixedvars, original, global) );
    2748
    2749 /* if fixed variables are directly specified or inferred from local bounds, enable constraint compression */
    2750 if( useconscompression && (nfixedvars > 0 || !global) )
    2751 {
    2752 SCIP_CALL( SCIPenableConsCompression(targetscip) );
    2753
    2754 SCIPdebugMsg(sourcescip, "SCIPenableConsCompression() with nxfixedvars=%d and global=%u invalidates copy.\n",
    2755 nfixedvars, global);
    2756
    2757 /* domain reductions yield a copy that is no longer guaranteed to be valid */
    2758 localvalid = FALSE;
    2759 }
    2760
    2761 /* copy all (original) constraints */
    2762 if( original )
    2763 {
    2764 SCIP_CALL( SCIPcopyOrigConss(sourcescip, targetscip, localvarmap, localconsmap, enablepricing, &consscopyvalid) );
    2765 }
    2766 else
    2767 {
    2768 SCIP_CALL( SCIPcopyConss(sourcescip, targetscip, localvarmap, localconsmap, global, enablepricing, &consscopyvalid) );
    2769 }
    2770
    2771 SCIPdebugMsg(sourcescip, "Copying%s constraints was%s valid.\n",
    2772 original ? " (original)" : "", consscopyvalid ? "" : " not");
    2773
    2774 localvalid = localvalid && consscopyvalid;
    2775
    2776 /* copy the Benders' decomposition plugins explicitly, because it requires the variable mapping hash map */
    2777 SCIP_CALL( SCIPcopyBenders(sourcescip, targetscip, localvarmap, threadsafe, &benderscopyvalid) );
    2778
    2779 SCIPdebugMsg(sourcescip, "Copying Benders' decomposition plugins was%s valid.\n", benderscopyvalid ? "" : " not");
    2780
    2781 localvalid = localvalid && benderscopyvalid;
    2782
    2783 if( uselocalvarmap )
    2784 {
    2785 /* free hash map */
    2786 SCIPhashmapFree(&localvarmap);
    2787 }
    2788
    2789 if( uselocalconsmap )
    2790 {
    2791 /* free hash map */
    2792 SCIPhashmapFree(&localconsmap);
    2793 }
    2794
    2795 /* stop time measuring */
    2796 SCIPclockStop(sourcescip->stat->copyclock, sourcescip->set);
    2797
    2798 /* get time after copying procedure */
    2799 copytime = SCIPclockGetTime(sourcescip->stat->copyclock) - startcopytime;
    2800
    2801 if( copytime > sourcescip->stat->maxcopytime )
    2802 sourcescip->stat->maxcopytime = copytime;
    2803 if( copytime < sourcescip->stat->mincopytime )
    2804 sourcescip->stat->mincopytime = copytime;
    2805
    2806 /* increase copy counter */
    2807 ++(sourcescip->stat->ncopies);
    2808
    2809 targetscip->concurrent = sourcescip->concurrent;
    2810 SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
    2811 targetscip->syncstore = sourcescip->syncstore;
    2813
    2814 /* return the information about a valid copy to the user */
    2815 if( valid != NULL )
    2816 *valid = localvalid;
    2817
    2818 return SCIP_OKAY;
    2819}
    2820
    2821/** copies source SCIP to target SCIP; the copying process is done in the following order:
    2822 * 1) copy those plugins that have copy callbacks
    2823 * 2) copy the settings for the present parameters
    2824 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    2825 * 4) copy all active variables except those that are marked as relaxation-only
    2826 * 5) copy all constraints
    2827 *
    2828 * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
    2829 * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrig().
    2830 *
    2831 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    2832 *
    2833 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2834 * Also, 'passmessagehdlr' should be set to FALSE.
    2835 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    2836 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    2837 * typically incurs a performance cost.
    2838 * @note Do not change the source SCIP environment during the copying process
    2839 *
    2840 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    2841 *
    2842 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2843 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2844 *
    2845 * @pre This method can be called if sourcescip is in one of the following stages:
    2846 * - \ref SCIP_STAGE_PROBLEM
    2847 * - \ref SCIP_STAGE_TRANSFORMED
    2848 * - \ref SCIP_STAGE_INITPRESOLVE
    2849 * - \ref SCIP_STAGE_PRESOLVING
    2850 * - \ref SCIP_STAGE_EXITPRESOLVE
    2851 * - \ref SCIP_STAGE_PRESOLVED
    2852 * - \ref SCIP_STAGE_INITSOLVE
    2853 * - \ref SCIP_STAGE_SOLVING
    2854 * - \ref SCIP_STAGE_SOLVED
    2855 *
    2856 * @pre This method can be called if targetscip is in one of the following stages:
    2857 * - \ref SCIP_STAGE_INIT
    2858 * - \ref SCIP_STAGE_FREE
    2859 *
    2860 * @note sourcescip stage does not get changed
    2861 *
    2862 * @note targetscip stage does not get changed
    2863 *
    2864 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2865 */
    2867 SCIP* sourcescip, /**< source SCIP data structure */
    2868 SCIP* targetscip, /**< target SCIP data structure */
    2869 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2870 * target variables, or NULL */
    2871 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2872 * target constraints, or NULL */
    2873 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2874 SCIP_Bool global, /**< create a global or a local copy? */
    2875 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2876 * plugins will be copied and activated, and the modifiable flag of
    2877 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2878 * there are pricers present */
    2879 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2880 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2881 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2882 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    2883 )
    2884{
    2885 SCIP_VAR** fixedvars = NULL;
    2886 SCIP_Real* fixedvals = NULL;
    2887 int nfixedvars = 0;
    2888 SCIP_Bool original = FALSE;
    2889 SCIP_Bool useconscompression = FALSE;
    2890
    2891 assert(sourcescip != NULL);
    2892 assert(targetscip != NULL);
    2893 assert(suffix != NULL);
    2894
    2895 /* check stages for both, the source and the target SCIP data structure */
    2896 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopy", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2897 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopy", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2898
    2899 /* copy source SCIP data into target SCIP data structure */
    2900 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    2901 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    2902
    2903 return SCIP_OKAY;
    2904}
    2905
    2906/** copies source SCIP to target SCIP but compresses constraints
    2907 *
    2908 * constraint compression is performed by removing fixed variables immediately
    2909 * during constraint creation if the involved constraint handlers support
    2910 * compression
    2911 *
    2912 * the copying process is done in the following order:
    2913 * 1) copy the plugins
    2914 * 2) copy the settings
    2915 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    2916 * 4) copy all active variables except those that are marked as relaxation-only
    2917 * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
    2918 * b) enable constraint compression
    2919 * 5) copy all constraints
    2920 *
    2921 * The source problem depends on the stage of the \p sourcescip - In SCIP_STAGE_PROBLEM, the original problem is copied,
    2922 * otherwise, the transformed problem is copied. For an explicit copy of the original problem, use SCIPcopyOrigConsCompression().
    2923 *
    2924 * @note: in case that a combination of local bounds and explicit fixing values should be used,
    2925 * the fixing value of a variable is preferred if local bounds and fixing value disagree.
    2926 *
    2927 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    2928 *
    2929 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    2930 * Also, 'passmessagehdlr' should be set to FALSE.
    2931 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    2932 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    2933 * typically incurs a performance cost.
    2934 * @note Do not change the source SCIP environment during the copying process
    2935 *
    2936 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    2937 *
    2938 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    2939 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    2940 *
    2941 * @pre This method can be called if sourcescip is in one of the following stages:
    2942 * - \ref SCIP_STAGE_PROBLEM
    2943 * - \ref SCIP_STAGE_TRANSFORMED
    2944 * - \ref SCIP_STAGE_INITPRESOLVE
    2945 * - \ref SCIP_STAGE_PRESOLVING
    2946 * - \ref SCIP_STAGE_EXITPRESOLVE
    2947 * - \ref SCIP_STAGE_PRESOLVED
    2948 * - \ref SCIP_STAGE_INITSOLVE
    2949 * - \ref SCIP_STAGE_SOLVING
    2950 * - \ref SCIP_STAGE_SOLVED
    2951 *
    2952 * @pre This method can be called if targetscip is in one of the following stages:
    2953 * - \ref SCIP_STAGE_INIT
    2954 * - \ref SCIP_STAGE_FREE
    2955 *
    2956 * @note sourcescip stage does not get changed
    2957 *
    2958 * @note targetscip stage does not get changed
    2959 *
    2960 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    2961 */
    2963 SCIP* sourcescip, /**< source SCIP data structure */
    2964 SCIP* targetscip, /**< target SCIP data structure */
    2965 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    2966 * target variables, or NULL */
    2967 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    2968 * target constraints, or NULL */
    2969 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    2970 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2971 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    2972 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    2973 SCIP_Bool global, /**< create a global or a local copy? */
    2974 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    2975 * plugins will be copied and activated, and the modifiable flag of
    2976 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    2977 * there are pricers present */
    2978 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    2979 * SCIP, otherwise TRUE. This is usually set to FALSE */
    2980 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    2981 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    2982 )
    2983{
    2984 SCIP_Bool original = FALSE;
    2985 SCIP_Bool useconscompression = TRUE;
    2986
    2987 assert(sourcescip != NULL);
    2988 assert(targetscip != NULL);
    2989 assert(suffix != NULL);
    2990
    2991 /* check stages for both, the source and the target SCIP data structure */
    2992 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    2993 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    2994
    2995 /* copy the source problem data */
    2996 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    2997 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    2998
    2999 return SCIP_OKAY;
    3000}
    3001
    3002
    3003/** copies source SCIP original problem to target SCIP; the copying process is done in the following order:
    3004 * 1) copy the plugins
    3005 * 2) copy the settings
    3006 * 3) create problem data in target-SCIP and copy the original problem data of the source-SCIP
    3007 * 4) copy all original variables
    3008 * 5) copy all original constraints
    3009 *
    3010 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    3011 *
    3012 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    3013 * Also, 'passmessagehdlr' should be set to FALSE.
    3014 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    3015 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    3016 * typically incurs a performance cost.
    3017 * @note Do not change the source SCIP environment during the copying process
    3018 *
    3019 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    3020 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    3021 *
    3022 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    3023 *
    3024 * @pre This method can be called if sourcescip is in one of the following stages:
    3025 * - \ref SCIP_STAGE_PROBLEM
    3026 * - \ref SCIP_STAGE_TRANSFORMED
    3027 * - \ref SCIP_STAGE_INITPRESOLVE
    3028 * - \ref SCIP_STAGE_PRESOLVING
    3029 * - \ref SCIP_STAGE_EXITPRESOLVE
    3030 * - \ref SCIP_STAGE_PRESOLVED
    3031 * - \ref SCIP_STAGE_INITSOLVE
    3032 * - \ref SCIP_STAGE_SOLVING
    3033 * - \ref SCIP_STAGE_SOLVED
    3034 *
    3035 * @pre This method can be called if targetscip is in one of the following stages:
    3036 * - \ref SCIP_STAGE_INIT
    3037 * - \ref SCIP_STAGE_FREE
    3038 *
    3039 * @note sourcescip stage does not get changed
    3040 *
    3041 * @note targetscip stage does not get changed
    3042 *
    3043 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3044 */
    3046 SCIP* sourcescip, /**< source SCIP data structure */
    3047 SCIP* targetscip, /**< target SCIP data structure */
    3048 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    3049 * target variables, or NULL */
    3050 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    3051 * target constraints, or NULL */
    3052 const char* suffix, /**< suffix which will be added to the names of the target SCIP, might be empty */
    3053 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    3054 * plugins will be copied and activated, and the modifiable flag of
    3055 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    3056 * there are pricers present */
    3057 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    3058 * SCIP, otherwise TRUE. This is usually set to FALSE */
    3059 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    3060 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    3061 )
    3062{
    3063 SCIP_VAR** fixedvars = NULL;
    3064 SCIP_Real* fixedvals = NULL;
    3065 int nfixedvars = 0;
    3066 SCIP_Bool global = TRUE;
    3067 SCIP_Bool original = TRUE;
    3068 SCIP_Bool useconscompression = FALSE;
    3069
    3070 assert(sourcescip != NULL);
    3071 assert(targetscip != NULL);
    3072 assert(suffix != NULL);
    3073
    3074 /* check stages for both, the source and the target SCIP data structure */
    3075 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    3076 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrig", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    3077
    3078 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    3079 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    3080
    3081 return SCIP_OKAY;
    3082}
    3083
    3084/** copies source SCIP original problem to target SCIP but compresses constraints
    3085 *
    3086 * constraint compression is performed by removing fixed variables immediately
    3087 * during constraint creation if the involved constraint handlers support
    3088 * compression
    3089 *
    3090 * the copying process is done in the following order:
    3091 * 1) copy the plugins
    3092 * 2) copy the settings
    3093 * 3) create problem data in target-SCIP and copy the problem data of the source-SCIP
    3094 * 4) copy all original variables
    3095 * a) fix all variable copies specified by \p fixedvars, \p fixedvals, and \p nfixedvars
    3096 * b) enable constraint compression
    3097 * 5) copy all constraints
    3098 *
    3099 * @note all variables and constraints which are created in the target-SCIP are not (user) captured
    3100 *
    3101 * @note In a multi thread case, you need to lock the copying procedure from outside with a mutex.
    3102 * Also, 'passmessagehdlr' should be set to FALSE.
    3103 * @note the 'threadsafe' parameter should only be set to TRUE if you are absolutely certain that the source and target
    3104 * SCIP instances will be solved in parallel. The usual case is to set this to FALSE, since thread safety
    3105 * typically incurs a performance cost.
    3106 * @note Do not change the source SCIP environment during the copying process
    3107 *
    3108 * @note Reoptimization and exact solving are explicitly disabled in the target-SCIP.
    3109 *
    3110 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
    3111 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
    3112 *
    3113 * @pre This method can be called if sourcescip is in one of the following stages:
    3114 * - \ref SCIP_STAGE_PROBLEM
    3115 * - \ref SCIP_STAGE_TRANSFORMED
    3116 * - \ref SCIP_STAGE_INITPRESOLVE
    3117 * - \ref SCIP_STAGE_PRESOLVING
    3118 * - \ref SCIP_STAGE_EXITPRESOLVE
    3119 * - \ref SCIP_STAGE_PRESOLVED
    3120 * - \ref SCIP_STAGE_INITSOLVE
    3121 * - \ref SCIP_STAGE_SOLVING
    3122 * - \ref SCIP_STAGE_SOLVED
    3123 *
    3124 * @pre This method can be called if targetscip is in one of the following stages:
    3125 * - \ref SCIP_STAGE_INIT
    3126 * - \ref SCIP_STAGE_FREE
    3127 *
    3128 * @note sourcescip stage does not get changed
    3129 *
    3130 * @note targetscip stage does not get changed
    3131 *
    3132 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3133 */
    3135 SCIP* sourcescip, /**< source SCIP data structure */
    3136 SCIP* targetscip, /**< target SCIP data structure */
    3137 SCIP_HASHMAP* varmap, /**< a hashmap to store the mapping of source variables corresponding
    3138 * target variables, or NULL */
    3139 SCIP_HASHMAP* consmap, /**< a hashmap to store the mapping of source constraints to the corresponding
    3140 * target constraints, or NULL */
    3141 const char* suffix, /**< optional suffix for problem name inside the target SCIP */
    3142 SCIP_VAR** fixedvars, /**< source variables whose copies should be fixed in the target SCIP environment, or NULL */
    3143 SCIP_Real* fixedvals, /**< array of fixing values for target SCIP variables, or NULL */
    3144 int nfixedvars, /**< number of source variables whose copies should be fixed in the target SCIP environment, or NULL */
    3145 SCIP_Bool enablepricing, /**< should pricing be enabled in copied SCIP instance? If TRUE, pricer
    3146 * plugins will be copied and activated, and the modifiable flag of
    3147 * constraints will be respected. If FALSE, valid will be set to FALSE, when
    3148 * there are pricers present */
    3149 SCIP_Bool threadsafe, /**< FALSE, if data can be safely shared between the source and target
    3150 * SCIP, otherwise TRUE. This is usually set to FALSE */
    3151 SCIP_Bool passmessagehdlr, /**< should the message handler be passed */
    3152 SCIP_Bool* valid /**< pointer to store whether the copying was valid, or NULL */
    3153 )
    3154{
    3155 SCIP_Bool original = TRUE;
    3156 SCIP_Bool global = TRUE;
    3157 SCIP_Bool useconscompression = TRUE;
    3158
    3159 assert(sourcescip != NULL);
    3160 assert(targetscip != NULL);
    3161 assert(suffix != NULL);
    3162
    3163 /* check stages for both, the source and the target SCIP data structure */
    3164 SCIP_CALL( SCIPcheckStage(sourcescip, "SCIPcopyOrigConsCompression", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
    3165 SCIP_CALL( SCIPcheckStage(targetscip, "SCIPcopyOrigConsCompression", TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE) );
    3166
    3167 /* copy the source problem data */
    3168 SCIP_CALL( doCopy(sourcescip, targetscip, varmap, consmap, suffix, fixedvars, fixedvals, nfixedvars,
    3169 useconscompression, global, original, enablepricing, threadsafe, passmessagehdlr, valid) );
    3170
    3171 SCIP_CALL( SCIPsyncstoreRelease(&targetscip->syncstore) );
    3172 targetscip->syncstore = sourcescip->syncstore;
    3174
    3175 return SCIP_OKAY;
    3176}
    3177
    3178/** return updated time limit for a sub-SCIP */
    3179static
    3181 SCIP* sourcescip, /**< source SCIP data structure */
    3182 SCIP_Real* timelimit /**< pointer to store sub-SCIP time limit */
    3183 )
    3184{
    3185 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/time", timelimit) );
    3186 if( !SCIPisInfinity(sourcescip, *timelimit) )
    3187 (*timelimit) -= SCIPgetSolvingTime(sourcescip);
    3188
    3189 return SCIP_OKAY;
    3190}
    3191
    3192/** set updated time limit for a sub-SCIP */
    3193static
    3195 SCIP* sourcescip, /**< source SCIP data structure */
    3196 SCIP* targetscip /**< target SCIP data structure */
    3197 )
    3198{
    3199 if( SCIPgetParam(targetscip, "limits/softtime") == NULL )
    3200 return SCIP_OKAY;
    3201 else
    3202 {
    3203 SCIP_Real timelimit = -1.0;
    3204
    3205 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/softtime", &timelimit) );
    3206 if( !SCIPisNegative(sourcescip, timelimit) )
    3207 {
    3208 timelimit -= SCIPgetSolvingTime(sourcescip);
    3209 timelimit = MAX(0.0, timelimit);
    3210 }
    3211
    3212 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/softtime", timelimit) );
    3213 }
    3214 return SCIP_OKAY;
    3215}
    3216
    3217/** return updated memory limit for a sub-SCIP */
    3218static
    3220 SCIP* sourcescip, /**< source SCIP data structure */
    3221 SCIP_Real* memorylimit /**< pointer to store sub-SCIP memory limit */
    3222 )
    3223{
    3224 SCIP_CALL( SCIPgetRealParam(sourcescip, "limits/memory", memorylimit) );
    3225
    3226 /* substract the memory already used by the main SCIP and the estimated memory usage of external software */
    3227 if( !SCIPisInfinity(sourcescip, *memorylimit) )
    3228 (*memorylimit) -= (SCIPgetMemUsed(sourcescip) + SCIPgetMemExternEstim(sourcescip))/1048576.0;
    3229
    3230 return SCIP_OKAY;
    3231}
    3232
    3233/** checks if there is enough time and memory left for copying the sourcescip into a sub-SCIP and solve the sub-SCIP
    3234 *
    3235 * This is the case if the time and memory limit that would be passed to the sub-SCIP are larger than 0.0
    3236 *
    3237 * @pre This method can be called if sourcescip is in one of the following stages:
    3238 * - \ref SCIP_STAGE_PROBLEM
    3239 * - \ref SCIP_STAGE_TRANSFORMED
    3240 * - \ref SCIP_STAGE_INITPRESOLVE
    3241 * - \ref SCIP_STAGE_PRESOLVING
    3242 * - \ref SCIP_STAGE_EXITPRESOLVE
    3243 * - \ref SCIP_STAGE_PRESOLVED
    3244 * - \ref SCIP_STAGE_INITSOLVE
    3245 * - \ref SCIP_STAGE_SOLVING
    3246 * - \ref SCIP_STAGE_SOLVED
    3247 *
    3248 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3249 */
    3251 SCIP* sourcescip, /**< source SCIP data structure */
    3252 SCIP_Bool* success /**< pointer to store whether there is time and memory left to copy the
    3253 * problem and run the sub-SCIP */
    3254 )
    3255{
    3256 SCIP_Real timelimit;
    3257
    3258 SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
    3259
    3260 if( sourcescip->set->misc_avoidmemout )
    3261 {
    3262 SCIP_Real memorylimit;
    3263
    3264 /* try to avoid running into memory limit */
    3265 SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
    3266 *success = timelimit > 0.0 && memorylimit > 2.0 * SCIPgetMemExternEstim(sourcescip) / 1048576.0;
    3267 }
    3268 else
    3269 *success = timelimit > 0.0;
    3270
    3271 return SCIP_OKAY;
    3272}
    3273
    3274/** copies limits from source SCIP to target SCIP
    3275 *
    3276 * @note time and memory limit are reduced by the amount already spent in the source SCIP before installing the limit
    3277 * in the target SCIP
    3278 * @note all other limits are disabled and need to be enabled afterwards, if needed
    3279 *
    3280 * @pre This method can be called if sourcescip is in one of the following stages:
    3281 * - \ref SCIP_STAGE_PROBLEM
    3282 * - \ref SCIP_STAGE_TRANSFORMED
    3283 * - \ref SCIP_STAGE_INITPRESOLVE
    3284 * - \ref SCIP_STAGE_PRESOLVING
    3285 * - \ref SCIP_STAGE_EXITPRESOLVE
    3286 * - \ref SCIP_STAGE_PRESOLVED
    3287 * - \ref SCIP_STAGE_INITSOLVE
    3288 * - \ref SCIP_STAGE_SOLVING
    3289 * - \ref SCIP_STAGE_SOLVED
    3290 *
    3291 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
    3292 */
    3294 SCIP* sourcescip, /**< source SCIP data structure */
    3295 SCIP* targetscip /**< target SCIP data structure */
    3296 )
    3297{
    3298 SCIP_Real timelimit;
    3299 SCIP_Real memorylimit;
    3300
    3301 SCIP_CALL( getCopyTimelimit(sourcescip, &timelimit) );
    3302 SCIP_CALL( getCopyMemlimit(sourcescip, &memorylimit) );
    3303
    3304 /* avoid negative limits */
    3305 if( timelimit < 0.0 )
    3306 timelimit = 0.0;
    3307 if( memorylimit < 0.0 )
    3308 memorylimit = 0.0;
    3309
    3310 /* set time and memory limit to the adjusted values */
    3311 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/time", timelimit) );
    3312 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/memory", memorylimit) );
    3313
    3314 /* copy and adjust soft time limit (or disable it) */
    3315 SCIP_CALL( copySofttimelimit(sourcescip, targetscip) );
    3316
    3317 /* disable all other limits */
    3318 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/absgap", 0.0) );
    3319 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/bestsol", -1) );
    3320 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/gap", 0.0) );
    3321 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/nodes", -1LL) );
    3322 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/restarts", -1) );
    3323 SCIP_CALL( SCIPsetIntParam(targetscip, "limits/solutions", -1) );
    3324 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/stallnodes", -1LL) );
    3325 SCIP_CALL( SCIPsetLongintParam(targetscip, "limits/totalnodes", -1LL) );
    3326 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/primal", SCIP_INVALID) );
    3327 SCIP_CALL( SCIPsetRealParam(targetscip, "limits/dual", SCIP_INVALID) );
    3328
    3329 return SCIP_OKAY;
    3330}
    3331
    3332/** sets the working limits as well as common search parameters for the auxiliary problem
    3333 *
    3334 * @note memory and time limits are not affected, and must be set using SCIPcopyLimits() instead
    3335 */
    3337 SCIP* sourcescip, /**< source SCIP data structure */
    3338 SCIP* subscip, /**< target SCIP data structure, often a copy of sourcescip */
    3339 SCIP_Longint nsubnodes, /**< nodelimit for subscip, or -1 for no limit */
    3340 SCIP_Longint nstallnodes, /**< stall node limit for subscip, or -1 for no limit */
    3341 int bestsollimit /**< the limit on the number of best solutions found, or -1 for no limit */
    3342 )
    3343{
    3344 SCIP_Bool useuct;
    3345
    3346 assert(sourcescip != NULL);
    3347 assert(subscip != NULL);
    3348
    3349 /* do not abort subproblem on CTRL-C */
    3350 SCIP_CALL( SCIPsetBoolParam(subscip, "misc/catchctrlc", FALSE) );
    3351
    3352#ifdef SCIP_DEBUG
    3353 /* for debugging, enable full output */
    3354 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 5) );
    3355 SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", 100000000) );
    3356#else
    3357 /* disable statistic timing inside sub SCIP and output to console */
    3358 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", 0) );
    3359 SCIP_CALL( SCIPsetBoolParam(subscip, "timing/statistictiming", FALSE) );
    3360#endif
    3361
    3362 /* set limits for the subproblem */
    3363 SCIP_CALL( SCIPcopyLimits(sourcescip, subscip) );
    3364 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nsubnodes) );
    3365 SCIP_CALL( SCIPsetLongintParam(subscip, "limits/stallnodes", nstallnodes) );
    3366 SCIP_CALL( SCIPsetIntParam(subscip, "limits/bestsol", bestsollimit) );
    3367
    3368 /* forbid recursive call of heuristics and separators solving subMIPs */
    3369 SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
    3370
    3371 /* disable cutting plane separation */
    3373
    3374 /* disable expensive presolving */
    3376
    3377 /* use best estimate node selection */
    3378 if( SCIPfindNodesel(subscip, "estimate") != NULL && !SCIPisParamFixed(subscip, "nodeselection/estimate/stdpriority") )
    3379 {
    3380 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/estimate/stdpriority", INT_MAX/4) );
    3381 }
    3382
    3383 /* activate uct node selection at the top of the tree */
    3384 SCIP_CALL( SCIPgetBoolParam(sourcescip, "heuristics/useuctsubscip", &useuct) );
    3385 if( useuct && SCIPfindNodesel(subscip, "uct") != NULL && !SCIPisParamFixed(subscip, "nodeselection/uct/stdpriority") )
    3386 {
    3387 SCIP_CALL( SCIPsetIntParam(subscip, "nodeselection/uct/stdpriority", INT_MAX/2) );
    3388 }
    3389
    3390 /* use inference branching */
    3391 if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
    3392 {
    3393 SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
    3394 }
    3395
    3396 /* enable conflict analysis, disable analysis of boundexceeding LPs, and restrict conflict pool */
    3397 if( !SCIPisParamFixed(subscip, "conflict/enable") )
    3398 {
    3399 SCIP_CALL( SCIPsetBoolParam(subscip, "conflict/enable", TRUE) );
    3400 }
    3401 if( !SCIPisParamFixed(subscip, "conflict/useboundlp") )
    3402 {
    3403 SCIP_CALL( SCIPsetCharParam(subscip, "conflict/useboundlp", 'o') );
    3404 }
    3405 if( !SCIPisParamFixed(subscip, "conflict/maxstoresize") )
    3406 {
    3407 SCIP_CALL( SCIPsetIntParam(subscip, "conflict/maxstoresize", 100) );
    3408 }
    3409
    3410 /* speed up sub-SCIP by not checking dual LP feasibility */
    3411 SCIP_CALL( SCIPsetBoolParam(subscip, "lp/checkdualfeas", FALSE) );
    3412
    3413 return SCIP_OKAY;
    3414}
    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:6176
    void SCIPconsSetModifiable(SCIP_CONS *cons, SCIP_Bool modifiable)
    Definition: cons.c:6966
    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:365
    #define SCIPdebugSolDataCreate(debugsoldata)
    Definition: debug.h:291
    #define NULL
    Definition: def.h:257
    #define SCIP_MAXSTRLEN
    Definition: def.h:278
    #define SCIP_Longint
    Definition: def.h:150
    #define SCIP_INVALID
    Definition: def.h:187
    #define SCIP_Bool
    Definition: def.h:100
    #define MIN(x, y)
    Definition: def.h:233
    #define SCIP_Real
    Definition: def.h:165
    #define TRUE
    Definition: def.h:102
    #define FALSE
    Definition: def.h:103
    #define MAX(x, y)
    Definition: def.h:229
    #define SCIP_CALL_ABORT(x)
    Definition: def.h:343
    #define SCIPABORT()
    Definition: def.h:336
    #define SCIP_CALL(x)
    Definition: def.h:364
    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:2364
    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:3045
    void SCIPmergeNLPIStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_Bool reset)
    Definition: scip_copy.c:1320
    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:2610
    SCIP_RETCODE SCIPtranslateSubSols(SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
    Definition: scip_copy.c:1438
    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:1225
    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:1168
    SCIP_RETCODE SCIPsetCommonSubscipParams(SCIP *sourcescip, SCIP *subscip, SCIP_Longint nsubnodes, SCIP_Longint nstallnodes, int bestsollimit)
    Definition: scip_copy.c:3336
    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:2866
    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:3134
    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:2962
    SCIP_RETCODE SCIPcopyOrigConss(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool enablepricing, SCIP_Bool *valid)
    Definition: scip_copy.c:1919
    SCIP_RETCODE SCIPcheckCopyLimits(SCIP *sourcescip, SCIP_Bool *success)
    Definition: scip_copy.c:3250
    int SCIPgetSubscipDepth(SCIP *scip)
    Definition: scip_copy.c:2589
    SCIP_RETCODE SCIPmergeVariableStatistics(SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
    Definition: scip_copy.c:1255
    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:1581
    SCIP_RETCODE SCIPcopyCuts(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
    Definition: scip_copy.c:2114
    SCIP_RETCODE SCIPconvertCutsToConss(SCIP *scip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
    Definition: scip_copy.c:2052
    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:1398
    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:1717
    SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:2548
    SCIP_RETCODE SCIPcopyLimits(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:3293
    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:2206
    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:655
    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:4802
    SCIP_CONS ** SCIPconshdlrGetCheckConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4759
    int SCIPgetNConshdlrs(SCIP *scip)
    Definition: scip_cons.c:964
    const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4320
    SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
    Definition: scip_cons.c:940
    int SCIPconshdlrGetNActiveConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4816
    SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
    Definition: cons.c:4739
    SCIP_CONSHDLR ** SCIPgetConshdlrs(SCIP *scip)
    Definition: scip_cons.c:953
    SCIP_Bool SCIPconsIsConflict(SCIP_CONS *cons)
    Definition: cons.c:8542
    SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
    Definition: cons.c:8652
    SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
    Definition: cons.c:8413
    SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
    Definition: cons.c:8562
    SCIP_Bool SCIPconsIsOriginal(SCIP_CONS *cons)
    Definition: cons.c:8692
    SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
    Definition: cons.c:8592
    SCIP_Bool SCIPconsIsDeleted(SCIP_CONS *cons)
    Definition: cons.c:8522
    SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
    Definition: cons.c:8582
    SCIP_Bool SCIPconsIsActive(SCIP_CONS *cons)
    Definition: cons.c:8454
    SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
    Definition: cons.c:8612
    SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
    Definition: cons.c:8632
    const char * SCIPconsGetName(SCIP_CONS *cons)
    Definition: cons.c:8393
    SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
    Definition: cons.c:8642
    SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
    Definition: scip_cons.c:1173
    SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
    Definition: cons.c:8572
    SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
    Definition: scip_cons.c:1138
    SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
    Definition: cons.c:8662
    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:514
    SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
    Definition: scip_sol.c:1250
    SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
    Definition: scip_sol.c:3914
    SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:1473
    int SCIPgetNSols(SCIP *scip)
    Definition: scip_sol.c:2887
    int SCIPsolGetIndex(SCIP_SOL *sol)
    Definition: sol.c:4305
    SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
    Definition: scip_sol.c:1660
    SCIP_SOL ** SCIPgetSols(SCIP *scip)
    Definition: scip_sol.c:2936
    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:4317
    SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:1890
    SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
    Definition: scip_sol.c:1763
    SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
    Definition: scip_sol.c:2003
    SCIP_Bool SCIPisInRestart(SCIP *scip)
    Definition: scip_solve.c:3722
    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:23875
    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:24600
    SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
    Definition: var.c:23418
    SCIP_Real SCIPvarGetAggrConstant(SCIP_VAR *var)
    Definition: var.c:23803
    SCIP_Bool SCIPvarIsImpliedIntegral(SCIP_VAR *var)
    Definition: var.c:23530
    SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
    Definition: var.c:24300
    SCIP_Real SCIPvarGetAggrScalar(SCIP_VAR *var)
    Definition: var.c:23780
    SCIP_CLIQUE ** SCIPgetCliques(SCIP *scip)
    Definition: scip_var.c:9566
    SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
    Definition: var.c:23485
    SCIP_VAR ** SCIPvarGetImplVars(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24617
    const char * SCIPvarGetName(SCIP_VAR *var)
    Definition: var.c:23299
    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:24646
    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:23838
    int SCIPvarGetMultaggrNVars(SCIP_VAR *var)
    Definition: var.c:23826
    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:24266
    SCIP_Bool SCIPvarIsRelaxationOnly(SCIP_VAR *var)
    Definition: var.c:23632
    SCIP_VAR * SCIPvarGetNegationVar(SCIP_VAR *var)
    Definition: var.c:23910
    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:22971
    SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
    Definition: var.c:23704
    SCIP_BOUNDTYPE * SCIPvarGetImplTypes(SCIP_VAR *var, SCIP_Bool varfixing)
    Definition: var.c:24632
    SCIP_Real * SCIPvarGetMultaggrScalars(SCIP_VAR *var)
    Definition: var.c:23850
    SCIP_VAR * SCIPvarGetAggrVar(SCIP_VAR *var)
    Definition: var.c:23768
    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:3043
    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:3033
    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:2634
    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:1358
    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:951
    static SCIP_RETCODE getCopyTimelimit(SCIP *sourcescip, SCIP_Real *timelimit)
    Definition: scip_copy.c:3180
    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:3219
    static SCIP_RETCODE copySofttimelimit(SCIP *sourcescip, SCIP *targetscip)
    Definition: scip_copy.c:3194
    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:1219
    SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
    Definition: set.c:6543
    SCIP_NLPI * SCIPsetFindNlpi(SCIP_SET *set, const char *name)
    Definition: set.c:5487
    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:932
    SCIP_RETCODE SCIPsetCopyParams(SCIP_SET *sourceset, SCIP_SET *targetset, SCIP_MESSAGEHDLR *messagehdlr)
    Definition: set.c:1168
    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:1073
    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:579
    char sepa_cutselrestart
    Definition: struct_set.h:578
    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:2753
    void SCIPvarMergeHistories(SCIP_VAR *targetvar, SCIP_VAR *othervar, SCIP_STAT *stat)
    Definition: var.c:6112
    SCIP_RETCODE SCIPvarCopyExactData(BMS_BLKMEM *blkmem, SCIP_VAR *targetvar, SCIP_VAR *sourcevar, SCIP_Bool negateobj)
    Definition: var.c:2687
    internal methods for problem variables