benders_default.c
Go to the documentation of this file.
30 * The default Benders' decomposition plugin is provided to simplify the interaction the Benders' decomposition
31 * framework within SCIP. This plugin is included in the SCIP package by default. Using the default Benders'
36 * where "master problem" is a SCIP instance of the master problem, "array of subproblems" is an array of SCIP instances
37 * that are the Benders' decomposition subproblems and "number of subproblems" is an integer indicating the number of
40 * A key feature of the default Benders' decomposition plugin is the automatic generation of the variable mapping
43 * In the traditional application of Benders' decomposition, master problem variables are fixed to a solution value and
44 * modify the RHS of the second stage constraints. The implementation within SCIP requires that a variable is created
45 * in the subproblem for every master problem variable that appears in the subproblem constraints. This variable MUST
46 * have the same name as the corresponding variable in the master problem. This name is used to automatically generate
51/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
67#define BENDERS_SHAREAUXVARS FALSE /**< should this Benders' share the highest priority Benders' aux vars */
78 SCIP_HASHMAP* mastervartosubindex;/**< hash map from the master variable to an index for the subproblemn variables */
79 SCIP_HASHMAP* subvartomastervar; /**< hashmap from the subproblem variable to the master variable */
80 SCIP_VAR*** subproblemvars; /**< the subproblem variables corresponding to master problem variables */
123/** Creates the variable mappings between the master problem and the corresponding variable in the subproblem.
125 * TODO: add the functionality to allow the user to provide an array of hashmaps for mapping between the master problem
159 SCIP_CALL( SCIPhashmapCreate(&bendersdata->subvartomastervar, SCIPblkmem(scip), nvars*nsubproblems) );
166 /* this loop stores a mapping between the master problem variables and their counterpart in the subproblems. For each
167 * master problem variable, the variable name is used to search for any corresponding variables in each of the
168 * subproblems. If a corresponding variable exists, then a mapping is inserted into subvartomastervar and
181 * NOTE: This retrieved variable is the original variable. It may be a bug in regards to other parts of the code.
182 * The process maps the subproblem variable to the original master variable. It was original supposed to be a
197 /* find the corresponding subproblem variable for a given master problem variable using the variable name. */
242 * NOTE: this method uses the same subproblems as the main SCIP. In a parallel setting, this will not be thread safe.
269 SCIP_CALL( SCIPcopyOrig(bendersdata->subproblems[i], subproblems[i], NULL, NULL, "", TRUE, FALSE, FALSE,
315 /* should have been freed in bendersExitDefault (if mappingcreated), or not been created at the first place */
353/** deinitialization method of Benders' decomposition (called before transformed problem is freed and the Benders'
393/** mapping method between the master problem variables and the subproblem variables of Benders' decomposition */
413 /* The variable needs to be transformed back into an original variable. If the variable is already original, then
429 /* The variable needs to be transformed back into an original variable. If the variable is already original, then
435 * NOTE: Currently the original variable is being used. This may not be correct and should be the transformed
446/** the method for creating the Benders' decomposition subproblem. This method is called during the initialisation stage
449 * This method must create the SCIP instance for the subproblem and add the required variables and constraints. In
450 * addition, the settings required for the solving the problem must be set here. However, some settings will be
451 * overridden by the standard solving method included in the Benders' decomposition framework. If a special solving
478 * @note Every variable that appears in the subproblem constraints must be created in the corresponding subproblem with
481 * @note The default Benders' decomposition implementation relies on unique variable names in the master problem and in
482 * each of the subproblems. This is required because a variable mapping is made between the master problem variables and
506 SCIPerrorMessage("The number of restarts is fixed to %d. The default Benders' decomposition requires the number"
540 SCIP_CALL( SCIPincludeBendersBasic(scip, &benders, BENDERS_NAME, BENDERS_DESC, BENDERS_PRIORITY, BENDERS_CUTLP,
541 BENDERS_CUTPSEUDO, BENDERS_CUTRELAX, BENDERS_SHAREAUXVARS, bendersGetvarDefault, bendersCreatesubDefault,
static SCIP_DECL_BENDERSEXIT(bendersExitDefault)
Definition: benders_default.c:357
static SCIP_RETCODE createVariableMappings(SCIP *scip, SCIP_BENDERS *benders)
Definition: benders_default.c:130
static SCIP_DECL_BENDERSFREE(bendersFreeDefault)
Definition: benders_default.c:303
static SCIP_DECL_BENDERSGETVAR(bendersGetvarDefault)
Definition: benders_default.c:396
static SCIP_DECL_BENDERSINIT(bendersInitDefault)
Definition: benders_default.c:342
static SCIP_RETCODE createBendersData(SCIP *scip, SCIP **subproblems, SCIP_BENDERSDATA **bendersdata, int nsubproblems)
Definition: benders_default.c:97
static SCIP_DECL_BENDERSCREATESUB(bendersCreatesubDefault)
Definition: benders_default.c:455
static SCIP_DECL_BENDERSCOPY(bendersCopyDefault)
Definition: benders_default.c:232
default Benders' decomposition plugin
SCIP_RETCODE SCIPincludeBendersDefaultCuts(SCIP *scip, SCIP_BENDERS *benders)
Definition: bendersdefcuts.c:37
SCIP_RETCODE SCIPcreateBendersDefault(SCIP *scip, SCIP **subproblems, int nsubproblems)
Definition: benders_default.c:485
SCIP_RETCODE SCIPincludeBendersDefault(SCIP *scip)
Definition: benders_default.c:524
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:3050
int SCIPhashmapGetImageInt(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3281
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3261
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3156
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3074
SCIP_RETCODE SCIPhashmapInsertInt(SCIP_HASHMAP *hashmap, void *origin, int image)
Definition: misc.c:3192
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:219
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:487
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
Definition: scip_param.c:269
SCIP_RETCODE SCIPsetBendersFree(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSFREE((*bendersfree)))
Definition: scip_benders.c:221
SCIP_RETCODE SCIPsetBendersCopy(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSCOPY((*benderscopy)))
Definition: scip_benders.c:197
SCIP_RETCODE SCIPaddBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP *subproblem)
Definition: scip_benders.c:746
SCIP_BENDERS * SCIPfindBenders(SCIP *scip, const char *name)
Definition: scip_benders.c:493
SCIP_RETCODE SCIPactivateBenders(SCIP *scip, SCIP_BENDERS *benders, int nsubproblems)
Definition: scip_benders.c:555
SCIP_RETCODE SCIPincludeBendersBasic(SCIP *scip, SCIP_BENDERS **bendersptr, const char *name, const char *desc, int priority, SCIP_Bool cutlp, SCIP_Bool cutpseudo, SCIP_Bool cutrelax, SCIP_Bool shareauxvars, SCIP_DECL_BENDERSGETVAR((*bendersgetvar)), SCIP_DECL_BENDERSCREATESUB((*benderscreatesub)), SCIP_BENDERSDATA *bendersdata)
Definition: scip_benders.c:151
SCIP_RETCODE SCIPsetBendersExit(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSEXIT((*bendersexit)))
Definition: scip_benders.c:269
SCIP_BENDERSDATA * SCIPbendersGetData(SCIP_BENDERS *benders)
Definition: benders.c:5749
SCIP_RETCODE SCIPsetBendersInit(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSINIT((*bendersinit)))
Definition: scip_benders.c:245
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
Definition: var.c:12774
Definition: objbenders.h:44
public methods for Benders' decomposition
public methods for message output
public data structures and miscellaneous methods
public methods for problem variables
SCIP callable library.
Definition: struct_benders.h:58
Definition: struct_misc.h:138
Definition: struct_var.h:208
Definition: struct_scip.h:70