Loading...
Searching...
No Matches
benders_gcg.c
Go to the documentation of this file.
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
58#define BENDERS_SHAREAUXVARS FALSE /**< should this Benders' share the highest priority Benders' aux vars */
118 assert(GCGoriginalVarIsLinking(GCGpricingVarGetOrigvars(probvars[i])[0]) || (GCGvarGetBlock(GCGpricingVarGetOrigvars(probvars[i])[0]) == probnumber));
122 SCIPdebugMessage("pricingobj var <%s> %f\n", SCIPvarGetName(probvars[i]), varGetObj(probvars[i]));
128/** sets the pricing problem variable values for the original problem using the decomposed problem solution
129 * There is a mapping between the original problem and the variables from the pricing problems. This mapping is used to
130 * identify the variables of the original problem corresponding to the pricing problem variables.
132 * An artificial solution can be constructed, which is indicated by the vals array provided as NULL. An artifical
133 * solution sets the original problem variables corresponding to pricing problems variables to their bounds. An
134 * artificial solution is created if branching candidates need to be found. Branching candidates only come from the
135 * master problem, so the variable values of the pricing problem variables does not affect the branching variable
173 /* all variables should be associated with a single original variable. This is because no reformulation has
175 * TODO: This appears not to be true. Need to find out why multiple original problem variables are associated
181 /* for all variables that are from the subproblems, they are set to their bounds if the solution is being
201 /* identifying whether the variable is a master problem variable. The variable is a master problem variable if
202 * there is a mapping from the subproblem to the master problem. If a mapping exists, then the variable value
213 SCIPdebugMsg(masterprob, "setting the value of <%s> (dw variable <%s>) to %g in the original solution.\n",
227/** sets the master problem values for the original problem using the decomposed problem solution */
256 /* the master problem also contains variables that were not created by GCG, in particular the auxiliary variables
270 /* all master variables should be associated with a single original variable. This is because no reformulation has
276 SCIPdebugMsg(masterprob, "setting the value of <%s> (master variable <%s>) to %g in the original solution.\n",
334 SCIP_CALL( setOriginalProblemMasterValues(origprob, masterprob, benders, origsol, vars, vals, nvars) );
345 /* it is only possible to use the subproblem solutions if the subproblems are enabled. The subproblems are
362 /* the branching candidates come from the master problem solution. However, we need a full solution to pass to the
363 * original problem to find the branching candidate. So the subproblem variables are set to their bounds, creating
366 * It may occur that the subproblem has not been solved yet, this can happen if the subproblem is independent.
372 SCIP_CALL( setOriginalProblemPricingValues(origprob, masterprob, benders, origsol, vars, NULL, nvars, &success) );
380 SCIP_CALL( setOriginalProblemPricingValues(origprob, masterprob, benders, origsol, vars, vals, nvars, &success) );
391 /* if the values were not set correctly, then the solution is not updated. This should only happen when the timelimit
405 /* if the solution is NULL, then the solution comes from the relaxation. Thus, it should be stored in the
406 * bendersdata. When it is not NULL, then solution comes from a heuristic. So this solution should be passed to the
468 SCIP_CALL( SCIPmergeBendersSubproblemIntoMaster(masterprob, benders, varmap, consmap, probnumber) );
487/** performs a merge of subproblems into the master problem. The subproblems are merged into the master problem if the
488 * infeasibility can not be resolved through the addition of cuts. This could be because the appropriate cuts are not
489 * available in the Benders' decomposition framework, or that the subproblem has been infeasible for a set number of
509 /* adding the priority merge candidates. If there are no priority candidates, then the first merge candidate is
536/* TODO: Implement all necessary Benders' decomposition methods. The methods with an #ifdef SCIP_DISABLED_CODE ... #else #define ... are optional */
557/** presolving initialization method of constraint handler (called when presolving is about to begin) */
575 SCIP_CALL( GCGaddDataAuxiliaryVar(bendersdata->gcg, SCIPbendersGetAuxiliaryVar(benders, i), i) );
587/** solving process deinitialization method of Benders' decomposition (called before branch and bound process data is freed) */
609/** mapping method between the master problem variables and the subproblem variables of Benders' decomposition */
620 /* if there is no corresponding master variable for the input variable, then NULL is returned */
630 /* checking whether the original variable is associated with any master problem variables. This is identified by
632 * NOTE: previously, only the linking variables were master variables. As such, the following check was to find
633 * only the original variables corresponding to linking variables. Since linking constraints, and their associated
648 /* checking whether the original variable is associated with any master problem variables. This is identified by
650 * NOTE: previously, only the linking variables were master variables. As such, the following check was to find
651 * only the original variables corresponding to linking variables. Since linking constraints, and their associated
654 /* checking whether the original variable is associated with any master problem variables. This is identified by
657 * If the pricing variable is requested, then there are two options. The first is that the pricing variable is a
658 * linking variable. The second is that the pricing variable has been directly copied to the master problem since
697 SCIP_CALL( mergeSubproblemsIntoMaster(scip, benders, mergecands, npriomergecands, nmergecands, merged) );
711/** the method for creating the Benders' decomposition subproblem. This method is called during the initialization stage
714 * This method must create the SCIP instance for the subproblem and add the required variables and constraints. In
715 * addition, the settings required for the solving the problem must be set here. However, some settings will be
716 * overridden by the standard solving method included in the Benders' decomposition framework. If a special solving
730 SCIP_CALL( SCIPaddBendersSubproblem(scip, benders, GCGgetPricingprob(bendersdata->gcg, probnumber)) );
733 * This is required because the variables are added to the pricing problems with a zero coefficient. In the DW
765 SCIP_CALL( SCIPincludeBendersBasic(bendersmasterprob, &benders, BENDERS_NAME, BENDERS_DESC, BENDERS_PRIORITY,
static SCIP_DECL_BENDERSPOSTSOLVE(bendersPostsolveGcg)
Definition benders_gcg.c:676
static SCIP_RETCODE createOriginalProblemSolution(SCIP *masterprob, SCIP_BENDERS *benders, SCIP_SOL *sol, SCIP_Bool artificial)
Definition benders_gcg.c:288
static SCIP_RETCODE setOriginalProblemPricingValues(SCIP *origprob, SCIP *masterprob, SCIP_BENDERS *benders, SCIP_SOL *origsol, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Bool *success)
Definition benders_gcg.c:139
static SCIP_DECL_BENDERSEXITSOL(bendersExitsolGcg)
Definition benders_gcg.c:589
static SCIP_RETCODE mergeSubproblemsIntoMaster(SCIP *masterprob, SCIP_BENDERS *benders, int *mergecands, int npriomergecands, int nmergecands, SCIP_Bool *merged)
Definition benders_gcg.c:493
static SCIP_RETCODE setSubproblemObjs(SCIP_BENDERS *benders, int probnumber)
Definition benders_gcg.c:96
static SCIP_RETCODE mergeSubproblemIntoMaster(SCIP *masterprob, SCIP_BENDERS *benders, int probnumber)
Definition benders_gcg.c:443
static SCIP_RETCODE setOriginalProblemMasterValues(SCIP *origprob, SCIP *masterprob, SCIP_BENDERS *benders, SCIP_SOL *origsol, SCIP_VAR **vars, SCIP_Real *vals, int nvars)
Definition benders_gcg.c:229
static SCIP_DECL_BENDERSCREATESUB(bendersCreatesubGcg)
Definition benders_gcg.c:720
static SCIP_DECL_BENDERSINITPRE(bendersInitpreGcg)
Definition benders_gcg.c:559
GCG Benders' decomposition.
SCIP_RETCODE SCIPincludeBendersDefaultCuts(SCIP *scip, SCIP_BENDERS *benders)
#define SCIP_Bool
#define SCIP_Real
#define TRUE
#define FALSE
GCG interface methods.
SCIP_VAR ** GCGlinkingVarGetPricingVars(SCIP_VAR *var)
Definition gcgvar.c:488
SCIP_VAR ** GCGoriginalVarGetMastervars(SCIP_VAR *var)
Definition gcgvar.c:666
SCIP_VAR * GCGoriginalVarGetPricingVar(SCIP_VAR *var)
Definition gcgvar.c:281
SCIP_RETCODE GCGaddDataAuxiliaryVar(GCG *gcg, SCIP_VAR *auxiliaryvar, int probnumber)
Definition gcgvar.c:1709
SCIP_RETCODE GCGcopyPricingvarDataToMastervar(GCG *gcg, SCIP_VAR *pricingvar, SCIP_VAR *mastervar)
Definition gcgvar.c:443
SCIP_SOL * GCGbendersGetRelaxSol(SCIP_BENDERS *benders)
Definition benders_gcg.c:783
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
#define SCIPdebugMsg
SCIP_RETCODE SCIPsetBendersFree(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSFREE((*bendersfree)))
SCIP_RETCODE SCIPsetBendersExitsol(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSEXITSOL((*bendersexitsol)))
SCIP_RETCODE SCIPaddBendersSubproblem(SCIP *scip, SCIP_BENDERS *benders, SCIP *subproblem)
SCIP_RETCODE SCIPsetBendersInitpre(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSINITPRE((*bendersinitpre)))
SCIP_VAR * SCIPbendersGetAuxiliaryVar(SCIP_BENDERS *benders, int probnumber)
SCIP_RETCODE SCIPsetBendersPostsolve(SCIP *scip, SCIP_BENDERS *benders, SCIP_DECL_BENDERSPOSTSOLVE((*benderspostsolve)))
SCIP_Bool SCIPbendersSubproblemIsEnabled(SCIP_BENDERS *benders, int probnumber)
SCIP_RETCODE SCIPgetBendersMasterVar(SCIP *scip, SCIP_BENDERS *benders, SCIP_VAR *var, SCIP_VAR **mappedvar)
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)
SCIP_BENDERSDATA * SCIPbendersGetData(SCIP_BENDERS *benders)
const char * SCIPbendersGetName(SCIP_BENDERS *benders)
int SCIPbendersGetNSubproblems(SCIP_BENDERS *benders)
SCIP * SCIPbendersSubproblem(SCIP_BENDERS *benders, int probnumber)
SCIP_RETCODE SCIPmergeBendersSubproblemIntoMaster(SCIP *scip, SCIP_BENDERS *benders, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, int probnumber)
SCIP_VAR * SCIPbenderGetMasterAuxiliaryVar(SCIP_BENDERS *benders)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIPfreeBufferArray(scip, &cycles)
#define NULL
Definition class_conspartition.cpp:44
public methods for GCG variables
GCG relaxator.
various SCIP helper methods
Definition benders_gcg.c:68
struct SCIP_Benders SCIP_BENDERS
SCIP_BENDERSENFOTYPE_LP
SCIP_BENDERSENFOTYPE_CHECK
struct SCIP_BendersData SCIP_BENDERSDATA
struct SCIP_HashMap SCIP_HASHMAP
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STAGE_PROBLEM
struct SCIP_Sol SCIP_SOL
struct SCIP_Var SCIP_VAR