Scippy

SCIP

Solving Constraint Integer Programs

scip_copy.c File Reference

Detailed Description

public methods for problem copies

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

Definition in file scip_copy.c.

#include <ctype.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include "lpi/lpi.h"
#include "nlpi/exprinterpret.h"
#include "nlpi/nlpi.h"
#include "scip/benders.h"
#include "scip/benderscut.h"
#include "scip/branch.h"
#include "scip/branch_nodereopt.h"
#include "scip/clock.h"
#include "scip/compr.h"
#include "scip/concsolver.h"
#include "scip/concurrent.h"
#include "scip/conflict.h"
#include "scip/conflictstore.h"
#include "scip/cons.h"
#include "scip/cons_linear.h"
#include "scip/cutpool.h"
#include "scip/cuts.h"
#include "scip/debug.h"
#include "scip/def.h"
#include "scip/dialog.h"
#include "scip/dialog_default.h"
#include "scip/disp.h"
#include "scip/event.h"
#include "scip/heur.h"
#include "scip/heur_ofins.h"
#include "scip/heur_reoptsols.h"
#include "scip/heur_trivialnegation.h"
#include "scip/heuristics.h"
#include "scip/history.h"
#include "scip/implics.h"
#include "scip/interrupt.h"
#include "scip/lp.h"
#include "scip/mem.h"
#include "scip/message_default.h"
#include "scip/misc.h"
#include "scip/nlp.h"
#include "scip/nodesel.h"
#include "scip/paramset.h"
#include "scip/presol.h"
#include "scip/presolve.h"
#include "scip/pricer.h"
#include "scip/pricestore.h"
#include "scip/primal.h"
#include "scip/prob.h"
#include "scip/prop.h"
#include "scip/reader.h"
#include "scip/relax.h"
#include "scip/reopt.h"
#include "scip/retcode.h"
#include "scip/scipbuildflags.h"
#include "scip/scipcoreplugins.h"
#include "scip/scipgithash.h"
#include "scip/sepa.h"
#include "scip/sepastore.h"
#include "scip/set.h"
#include "scip/sol.h"
#include "scip/solve.h"
#include "scip/stat.h"
#include "scip/syncstore.h"
#include "scip/table.h"
#include "scip/tree.h"
#include "scip/var.h"
#include "scip/visual.h"
#include "xml/xml.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_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_pricer.h"
#include "scip/scip_prob.h"
#include "scip/scip_solve.h"
#include "scip/scip_solvingstats.h"
#include "scip/scip_timing.h"
#include "scip/scip_var.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_var.h"
#include "scip/struct_scip.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 copypropagators, SCIP_Bool copyheuristics, SCIP_Bool copyeventhdlrs, SCIP_Bool copynodeselectors, SCIP_Bool copybranchrules, SCIP_Bool copydisplays, SCIP_Bool copydialogs, SCIP_Bool copytables, SCIP_Bool copynlpis, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
 
SCIP_RETCODE SCIPcopyBenders (SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, 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)
 
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 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 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 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 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 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)
 

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 145 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 178 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(), 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 434 of file scip_copy.c.

References Scip::conflictstore, Scip::mem, Scip::messagehdlr, NULL, Scip::origprimal, Scip::origprob, SCIP_Mem::probmem, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_STAGE_INIT, SCIP_STAGE_PROBLEM, SCIPblkmem(), SCIPconflictstoreCreate(), 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 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, fixed and aggregated variables do not get copied

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 963 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(), and SCIPvarGetType().

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

◆ 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  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
passmessagehdlrshould the message handler be passed
validpointer to store whether the copying was valid or not, or NULL

Definition at line 2399 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 2906 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 2920 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 2945 of file scip_copy.c.

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

Referenced by SCIPcheckCopyLimits(), and SCIPcopyLimits().