Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

public methods for problem copies

Author
Tobias Achterberg
Timo Berthold
Gerald Gamrath
Leona Gottwald
Stefan Heinz
Gregor Hendel
Thorsten Koch
Alexander Martin
Marc Pfetsch
Michael Winkler
Kati Wolter

Definition in file scip_copy.c.

#include "blockmemshell/memory.h"
#include "scip/benders.h"
#include "scip/clock.h"
#include "scip/conflictstore.h"
#include "scip/cons.h"
#include "scip/cons_linear.h"
#include "scip/dcmp.h"
#include "scip/debug.h"
#include "scip/primal.h"
#include "scip/prob.h"
#include "scip/pub_cons.h"
#include "scip/pub_cutpool.h"
#include "scip/pub_implics.h"
#include "scip/pub_lp.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_nlpi.h"
#include "scip/pub_sol.h"
#include "scip/pub_var.h"
#include "scip/scip_branch.h"
#include "scip/scip_cons.h"
#include "scip/scip_copy.h"
#include "scip/scip_cut.h"
#include "scip/scip_general.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_nodesel.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_pricer.h"
#include "scip/scip_prob.h"
#include "scip/scip_sol.h"
#include "scip/scip_solve.h"
#include "scip/scip_solvingstats.h"
#include "scip/scip_timing.h"
#include "scip/scip_var.h"
#include "scip/set.h"
#include "scip/stat.h"
#include "scip/struct_mem.h"
#include "scip/struct_scip.h"
#include "scip/struct_set.h"
#include "scip/struct_stat.h"
#include "scip/struct_var.h"
#include "scip/syncstore.h"
#include "scip/var.h"

Go to the source code of this file.

Functions

static SCIP_Bool takeCut (SCIP *scip, SCIP_CUT *cut, char cutsel)
 
static SCIP_RETCODE copyCuts (SCIP *sourcescip, SCIP *targetscip, SCIP_CUT **cuts, int ncuts, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
 
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 copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copyexprhdlrs, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
 
SCIP_RETCODE SCIPcopyBenders (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_Bool threadsafe, SCIP_Bool *valid)
 
static SCIP_RETCODE copyProb (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool original, SCIP_Bool global, const char *name)
 
SCIP_RETCODE SCIPcopyProb (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, const char *name)
 
SCIP_RETCODE SCIPcopyOrigProb (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *name)
 
SCIP_RETCODE SCIPenableConsCompression (SCIP *scip)
 
SCIP_Bool SCIPisConsCompressionEnabled (SCIP *scip)
 
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)
 
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)
 
SCIP_RETCODE SCIPcopyVars (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars, SCIP_Bool global)
 
SCIP_RETCODE SCIPcopyOrigVars (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_VAR **fixedvars, SCIP_Real *fixedvals, int nfixedvars)
 
SCIP_RETCODE SCIPmergeVariableStatistics (SCIP *sourcescip, SCIP *targetscip, SCIP_VAR **sourcevars, SCIP_VAR **targetvars, int nvars)
 
void SCIPmergeNLPIStatistics (SCIP *sourcescip, SCIP *targetscip, SCIP_Bool reset)
 
static SCIP_RETCODE translateSubSol (SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_VAR **subvars, SCIP_Real *solvals)
 
SCIP_RETCODE SCIPtranslateSubSol (SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_SOL **newsol)
 
SCIP_RETCODE SCIPtranslateSubSols (SCIP *scip, SCIP *subscip, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_Bool *success, int *solindex)
 
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)
 
SCIP_RETCODE SCIPcopyConss (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
 
SCIP_RETCODE SCIPcopyOrigConss (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool enablepricing, SCIP_Bool *valid)
 
SCIP_RETCODE SCIPconvertCutsToConss (SCIP *scip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
 
SCIP_RETCODE SCIPcopyCuts (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, int *ncutsadded)
 
SCIP_RETCODE SCIPcopyConflicts (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool enablepricing, SCIP_Bool *valid)
 
SCIP_RETCODE SCIPcopyImplicationsCliques (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_Bool global, SCIP_Bool *infeasible, int *nbdchgs, int *ncopied)
 
SCIP_RETCODE SCIPcopyParamSettings (SCIP *sourcescip, SCIP *targetscip)
 
int SCIPgetSubscipDepth (SCIP *scip)
 
void SCIPsetSubscipDepth (SCIP *scip, int newdepth)
 
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)
 
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)
 
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)
 
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)
 
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)
 
static SCIP_RETCODE getCopyTimelimit (SCIP *sourcescip, SCIP_Real *timelimit)
 
static SCIP_RETCODE copySofttimelimit (SCIP *sourcescip, SCIP *targetscip)
 
static SCIP_RETCODE getCopyMemlimit (SCIP *sourcescip, SCIP_Real *memorylimit)
 
SCIP_RETCODE SCIPcheckCopyLimits (SCIP *sourcescip, SCIP_Bool *success)
 
SCIP_RETCODE SCIPcopyLimits (SCIP *sourcescip, SCIP *targetscip)
 
SCIP_RETCODE SCIPsetCommonSubscipParams (SCIP *sourcescip, SCIP *subscip, SCIP_Longint nsubnodes, SCIP_Longint nstallnodes, int bestsollimit)
 

Function Documentation

◆ takeCut()

static SCIP_Bool takeCut ( SCIP scip,
SCIP_CUT cut,
char  cutsel 
)
static

returns true if the cut matches the selection criterium for copying

Parameters
scipSCIP data structure
cuta cut
cutselcut selection for sub SCIPs ('a'ge, activity 'q'uotient)

Definition at line 93 of file scip_copy.c.

References FALSE, NULL, SCIP_Bool, SCIPABORT, SCIPcutGetAge(), SCIPcutGetLPActivityQuot(), SCIPcutGetRow(), SCIPerrorMessage, SCIProwIsInLP(), SCIP_Set::sepa_minactivityquot, and Scip::set.

Referenced by copyCuts().

◆ copyCuts()

static SCIP_RETCODE copyCuts ( SCIP sourcescip,
SCIP targetscip,
SCIP_CUT **  cuts,
int  ncuts,
SCIP_HASHMAP varmap,
SCIP_HASHMAP consmap,
SCIP_Bool  global,
int *  ncutsadded 
)
static

copy active and tight cuts from one SCIP instance to linear constraints of another SCIP instance

Parameters
sourcescipsource SCIP data structure
targetsciptarget SCIP data structure
cutscuts to copy
ncutsnumber of cuts to copy
varmapa hashmap to store the mapping of source variables corresponding target variables, or NULL
consmapa hashmap to store the mapping of source constraints to the corresponding target constraints, or NULL
globalcreate a global or a local copy?
ncutsaddedpointer to store number of copied cuts

Definition at line 126 of file scip_copy.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddCons(), SCIPallocBufferArray, SCIPcolGetVar(), SCIPconsGetName(), SCIPcreateConsLinear(), SCIPcutGetRow(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPfreeBufferArray, SCIPgetNRuns(), SCIPgetVarCopy(), SCIPisInRestart(), SCIPreleaseCons(), SCIProwGetCols(), SCIProwGetConstant(), SCIProwGetLhs(), SCIProwGetName(), SCIProwGetNNonz(), SCIProwGetRhs(), SCIProwGetVals(), SCIProwIsLocal(), SCIProwIsModifiable(), SCIPsnprintf(), SCIPvarIsRelaxationOnly(), SCIP_Set::sepa_cutselrestart, SCIP_Set::sepa_cutselsubscip, Scip::set, takeCut(), and TRUE.

Referenced by SCIPcopyCuts().

◆ copyProb()

static SCIP_RETCODE copyProb ( SCIP sourcescip,
SCIP targetscip,
SCIP_HASHMAP varmap,
SCIP_HASHMAP consmap,
SCIP_Bool  original,
SCIP_Bool  global,
const char *  name 
)
static

create a problem by copying the problem data of the source SCIP

Parameters
sourcescipsource SCIP data structure
targetsciptarget SCIP data structure
varmapa hashmap to store the mapping of source variables corresponding target variables, or NULL
consmapa hashmap to store the mapping of source constraints to the corresponding target constraints, or NULL
originalshould the original problem be copied?
globalcreate a global or a local copy? (set to TRUE for original copy)
nameproblem name of target

Definition at line 400 of file scip_copy.c.

References Scip::conflictstore, SCIP_Set::debugsoldata, Scip::decompstore, Scip::mem, Scip::messagehdlr, NULL, Scip::origprimal, Scip::origprob, SCIP_Mem::probmem, SCIP_Bool, SCIP_CALL, SCIP_DECOMPSTORE_CAPA, SCIP_OKAY, SCIP_STAGE_INIT, SCIP_STAGE_PROBLEM, SCIPblkmem(), SCIPconflictstoreCreate(), SCIPdebugSolDataCreate, SCIPdecompstoreCreate(), SCIPfreeProb(), SCIPgetNConss(), SCIPgetNVars(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPisTransformed(), SCIPprimalCreate(), SCIPprobCopy(), SCIPstatCreate(), Scip::set, SCIP_Set::stage, Scip::stat, SCIP_Stat::subscipdepth, and Scip::transprob.

Referenced by SCIPcopyOrigProb(), and SCIPcopyProb().

◆ copyVars()

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 
)
static

copies all original or active variables from source-SCIP except those that are marked as relaxation-only, fixed, or aggregated and adds these variable to the target-SCIP

the mapping between these variables are stored in the variable hashmap target-SCIP has to be in problem creation stage

Parameters
sourcescipsource SCIP data structure
targetsciptarget SCIP data structure
varmapa hashmap to store the mapping of source variables to the corresponding target variables, or NULL
consmapa hashmap to store the mapping of source constraints to the corresponding target constraints, or NULL
fixedvarssource variables whose copies should be fixed in the target SCIP environment, or NULL
fixedvalsarray of fixing values for target SCIP variables, or NULL
nfixedvarsnumber of source variables whose copies should be fixed in the target SCIP environment, or NULL
originalshould original variables be copied?
globalshould global or local bounds be used? (for original=FALSE)

Definition at line 946 of file scip_copy.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_CONTINUOUS, SCIP_VARTYPE_IMPLINT, SCIP_VARTYPE_INTEGER, SCIPblkmem(), SCIPerrorMessage, SCIPfixVar(), SCIPgetFixedVars(), SCIPgetNBinVars(), SCIPgetNConss(), SCIPgetNContVars(), SCIPgetNFixedVars(), SCIPgetNImplVars(), SCIPgetNIntVars(), SCIPgetNVars(), SCIPgetOrigVarsData(), SCIPgetVarCopy(), SCIPgetVarsData(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPvarGetType(), and SCIPvarIsRelaxationOnly().

Referenced by doCopy(), SCIPcopyOrigVars(), and SCIPcopyVars().

◆ translateSubSol()

static SCIP_RETCODE translateSubSol ( SCIP scip,
SCIP subscip,
SCIP_SOL subsol,
SCIP_VAR **  subvars,
SCIP_Real solvals 
)
static

provides values of a solution from a subscip according to the variable in the main scip

Given a subscip solution, fills an array with solution values, matching the variables given by SCIPgetVars(). Variables that are relaxation-only in the master SCIP are set to 0 or the bound closest to 0. Such variables are represented as NULL entry in the subvars array.

Parameters
scipSCIP data structure of the original problem
subscipSCIP data structure of the subproblem
subsolsolution of the subproblem
subvarsthe variables from the subproblem in the same order as the main scip
solvalsarray where to set values taken from subsol, must have length at least SCIPgetNVars(scip)

Definition at line 1368 of file scip_copy.c.

References MAX, MIN, NULL, SCIP_CALL, SCIP_OKAY, SCIPgetSolVal(), SCIPgetVarsData(), SCIPvarGetLbLocal(), and SCIPvarGetUbLocal().

Referenced by SCIPtranslateSubSol(), and SCIPtranslateSubSols().

◆ doCopy()

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 
)
static

copies source SCIP data into target SCIP data structure

distinguishes between

  • local and global copies
  • copies of the original or transformed problem

Allows for constraint compression by specifying a number of source variables and values that should be fixed in the copy.

Parameters
sourcescipsource SCIP data structure
targetsciptarget SCIP data structure
varmapa hashmap to store the mapping of source variables corresponding target variables, or NULL
consmapa hashmap to store the mapping of source constraints to the corresponding target constraints, or NULL
suffixoptional suffix for problem name inside the target SCIP
fixedvarssource variables whose copies should be fixed in the target SCIP environment, or NULL
fixedvalsarray of fixing values for target SCIP variables, or NULL
nfixedvarsnumber of source variables whose copies should be fixed in the target SCIP environment, or NULL
useconscompressionshould constraint compression be used when constraints are created?
globalcreate a global or a local copy?
originalcopy original or transformed problem? if TRUE, a copy using local bounds is not possible
enablepricingshould pricing be enabled in copied SCIP instance? If TRUE, pricer plugins will be copied and activated, and the modifiable flag of constraints will be respected. If FALSE, valid will be set to FALSE, when there are pricers present
threadsafeFALSE, if data can be safely shared between the source and target SCIP, otherwise TRUE. This is usually set to FALSE
passmessagehdlrshould the message handler be passed
validpointer to store whether the copying was valid or not, or NULL

Definition at line 2650 of file scip_copy.c.

References Scip::concurrent, SCIP_Stat::copyclock, copyVars(), FALSE, SCIP_Stat::maxcopytime, Scip::messagehdlr, SCIP_Stat::mincopytime, SCIP_Stat::ncopies, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_STAGE_PROBLEM, SCIPblkmem(), SCIPclockGetTime(), SCIPclockStart(), SCIPclockStop(), SCIPcopyBenders(), SCIPcopyConss(), SCIPcopyOrigConss(), SCIPcopyOrigProb(), SCIPcopyParamSettings(), SCIPcopyPlugins(), SCIPcopyProb(), SCIPdebugMsg, SCIPenableConsCompression(), SCIPgetNActivePricers(), SCIPgetNConss(), SCIPgetNVars(), SCIPgetProbName(), SCIPgetStage(), SCIPhashmapCreate(), SCIPhashmapFree(), SCIPmessagehdlrIsQuiet(), SCIPsetMessagehdlrQuiet(), SCIPsnprintf(), SCIPsyncstoreCapture(), SCIPsyncstoreRelease(), Scip::set, Scip::stat, Scip::syncstore, and TRUE.

Referenced by SCIPcopy(), SCIPcopyConsCompression(), SCIPcopyOrig(), and SCIPcopyOrigConsCompression().

◆ getCopyTimelimit()

static SCIP_RETCODE getCopyTimelimit ( SCIP sourcescip,
SCIP_Real timelimit 
)
static

return updated time limit for a sub-SCIP

Parameters
sourcescipsource SCIP data structure
timelimitpointer to store sub-SCIP time limit

Definition at line 3183 of file scip_copy.c.

References SCIP_CALL, SCIP_OKAY, SCIPgetRealParam(), SCIPgetSolvingTime(), and SCIPisInfinity().

Referenced by SCIPcheckCopyLimits(), and SCIPcopyLimits().

◆ copySofttimelimit()

static SCIP_RETCODE copySofttimelimit ( SCIP sourcescip,
SCIP targetscip 
)
static

set updated time limit for a sub-SCIP

Parameters
sourcescipsource SCIP data structure
targetsciptarget SCIP data structure

Definition at line 3197 of file scip_copy.c.

References MAX, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPgetParam(), SCIPgetRealParam(), SCIPgetSolvingTime(), SCIPisNegative(), and SCIPsetRealParam().

Referenced by SCIPcopyLimits().

◆ getCopyMemlimit()

static SCIP_RETCODE getCopyMemlimit ( SCIP sourcescip,
SCIP_Real memorylimit 
)
static

return updated memory limit for a sub-SCIP

Parameters
sourcescipsource SCIP data structure
memorylimitpointer to store sub-SCIP memory limit

Definition at line 3222 of file scip_copy.c.

References SCIP_CALL, SCIP_OKAY, SCIPgetMemExternEstim(), SCIPgetMemUsed(), SCIPgetRealParam(), and SCIPisInfinity().

Referenced by SCIPcheckCopyLimits(), and SCIPcopyLimits().