Detailed Description
PADM primal heuristic based on ideas published in the paper "A Decomposition Heuristic for Mixed-Integer Supply Chain Problems" by Martin Schmidt, Lars Schewe, and Dieter Weninger.
The penalty alternating direction method (PADM) heuristic is a construction heuristic which additionally needs a user decomposition with linking variables only.
PADM splits the problem into several sub-SCIPs according to the decomposition, whereby the linking variables get copied and the difference is penalized. Then the sub-SCIPs are solved on an alternating basis until they arrive at the same values of the linking variables (ADM-loop). If they don't reconcile after a couple of iterations, the penalty parameters are increased (penalty-loop) and the sub-SCIPs are solved again on an alternating basis.
Definition in file heur_padm.c.
#include <assert.h>
#include <string.h>
#include "blockmemshell/memory.h"
#include "scip/cons_linear.h"
#include "scip/debug.h"
#include "scip/heur_padm.h"
#include "scip/heuristics.h"
#include "scip/pub_cons.h"
#include "scip/pub_event.h"
#include "scip/pub_tree.h"
#include "scip/pub_heur.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_misc_select.h"
#include "scip/pub_sol.h"
#include "scip/pub_var.h"
#include "scip/scipdefplugins.h"
#include "scip/scip_branch.h"
#include "scip/scip_cons.h"
#include "scip/scip_copy.h"
#include "scip/scip_dcmp.h"
#include "scip/scip_event.h"
#include "scip/scip_general.h"
#include "scip/scip_heur.h"
#include "scip/scip_lp.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_prob.h"
#include "scip/scip_randnumgen.h"
#include "scip/scip_sol.h"
#include "scip/scip_solve.h"
#include "scip/scip_solvingstats.h"
#include "scip/scip_table.h"
#include "scip/scip_timing.h"
#include "scip/scip_tree.h"
#include "scip/scip_var.h"
Go to the source code of this file.
Data Structures | |
struct | Block |
struct | set |
struct | blockinfo |
Macros | |
#define | HEUR_NAME "padm" |
#define | HEUR_DESC "penalty alternating direction method primal heuristic" |
#define | HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS |
#define | HEUR_PRIORITY 70000 |
#define | HEUR_FREQ 0 |
#define | HEUR_FREQOFS 0 |
#define | HEUR_MAXDEPTH -1 |
#define | HEUR_TIMING SCIP_HEURTIMING_BEFORENODE | SCIP_HEURTIMING_AFTERNODE |
#define | HEUR_USESSUBSCIP TRUE |
#define | COUPLINGSIZE 3 |
#define | DEFAULT_MINNODES 50LL |
#define | DEFAULT_MAXNODES 5000LL |
#define | DEFAULT_NODEFAC 0.8 |
#define | DEFAULT_ADMIT 4 |
#define | DEFAULT_PENALTYIT 100 |
#define | DEFAULT_GAP 2.0 |
Typedefs | |
typedef struct Problem | PROBLEM |
typedef struct Block | BLOCK |
typedef struct set | SET |
typedef struct blockinfo | BLOCKINFO |
Functions | |
static | SCIP_DECL_HASHKEYEQ (indexesEqual) |
static | SCIP_DECL_HASHKEYVAL (indexesHashval) |
static SCIP_RETCODE | initBlock (PROBLEM *problem) |
static SCIP_RETCODE | freeBlock (BLOCK *block) |
static SCIP_RETCODE | initProblem (SCIP *scip, PROBLEM **problem, int nblocks) |
static SCIP_RETCODE | freeProblem (PROBLEM **problem, int nblocks) |
static SCIP_RETCODE | createSubscip (SCIP *scip, SCIP **subscip) |
static SCIP_RETCODE | copyToSubscip (SCIP *scip, SCIP *subscip, const char *name, SCIP_CONS **conss, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, int nconss, SCIP_Bool *success) |
static SCIP_RETCODE | blockCreateSubscip (BLOCK *block, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, SCIP_CONS **conss, int nconss, SCIP_Bool *success) |
static SCIP_RETCODE | createAndSplitProblem (SCIP *scip, SCIP_CONS **sortedconss, int *blockstartsconss, int nblocks, PROBLEM **problem, SCIP_Bool *success) |
static SCIP_RETCODE | assignLinking (SCIP *scip, const SCIP_DECOMP *decomp, SCIP_DECOMP *newdecomp, SCIP_VAR **vars, SCIP_CONS **sortedconss, int *varlabels, int *conslabels, int nvars, int nconss) |
static SCIP_RETCODE | reuseSolution (SCIP *subscip, BLOCK *block) |
static SCIP_RETCODE | scalePenalties (PROBLEM *problem, SET *linkvartoblocks, SET *blocktolinkvars, SCIP_HASHTABLE *htable, SCIP_Real maxpenalty) |
static SCIP_RETCODE | getTimeLeft (SCIP *scip, SCIP_Real *time) |
static | SCIP_DECL_HEURCOPY (heurCopyPADM) |
static | SCIP_DECL_HEURFREE (heurFreePADM) |
static | SCIP_DECL_HEUREXEC (heurExecPADM) |
SCIP_RETCODE | SCIPincludeHeurPADM (SCIP *scip) |
Macro Definition Documentation
◆ HEUR_NAME
#define HEUR_NAME "padm" |
Definition at line 75 of file heur_padm.c.
Referenced by SCIP_DECL_HEURCOPY(), and SCIPincludeHeurPADM().
◆ HEUR_DESC
#define HEUR_DESC "penalty alternating direction method primal heuristic" |
Definition at line 76 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_DISPCHAR
#define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS |
Definition at line 77 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_PRIORITY
#define HEUR_PRIORITY 70000 |
Definition at line 78 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_FREQ
#define HEUR_FREQ 0 |
Definition at line 79 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_FREQOFS
#define HEUR_FREQOFS 0 |
Definition at line 80 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_MAXDEPTH
#define HEUR_MAXDEPTH -1 |
Definition at line 81 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_TIMING
#define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE | SCIP_HEURTIMING_AFTERNODE |
Definition at line 82 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ HEUR_USESSUBSCIP
#define HEUR_USESSUBSCIP TRUE |
does the heuristic use a secondary SCIP instance?
Definition at line 83 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ COUPLINGSIZE
#define COUPLINGSIZE 3 |
Definition at line 85 of file heur_padm.c.
Referenced by reuseSolution(), and SCIP_DECL_HEUREXEC().
◆ DEFAULT_MINNODES
#define DEFAULT_MINNODES 50LL |
Definition at line 86 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ DEFAULT_MAXNODES
#define DEFAULT_MAXNODES 5000LL |
Definition at line 87 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ DEFAULT_NODEFAC
#define DEFAULT_NODEFAC 0.8 |
Definition at line 88 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ DEFAULT_ADMIT
#define DEFAULT_ADMIT 4 |
Definition at line 89 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ DEFAULT_PENALTYIT
#define DEFAULT_PENALTYIT 100 |
Definition at line 90 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
◆ DEFAULT_GAP
#define DEFAULT_GAP 2.0 |
Definition at line 91 of file heur_padm.c.
Referenced by SCIPincludeHeurPADM().
Typedef Documentation
◆ PROBLEM
typedef struct Problem PROBLEM |
data related to one problem (see below)
Definition at line 98 of file heur_padm.c.
◆ BLOCK
◆ SET
◆ BLOCKINFO
Function Documentation
◆ SCIP_DECL_HASHKEYEQ()
|
static |
returns TRUE iff both keys are equal
Definition at line 148 of file heur_padm.c.
References blockinfo::block, FALSE, blockinfo::linkvaridx, blockinfo::otherblock, and TRUE.
◆ SCIP_DECL_HASHKEYVAL()
|
static |
returns the hash value of the key
Definition at line 165 of file heur_padm.c.
References blockinfo::block, blockinfo::linkvaridx, blockinfo::otherblock, SCIP_Bool, SCIP_Longint, SCIP_Real, SCIPhashFour, and SCIPrealHashCode().
◆ initBlock()
|
static |
initializes one block
- Parameters
-
problem problem structure
Definition at line 196 of file heur_padm.c.
References Block::couplingcons, Block::ncoupling, Block::nsubvars, NULL, Block::number, Block::problem, SCIP_OKAY, Block::size, Block::slacksneg, Block::slackspos, Block::subscip, and Block::subvars.
Referenced by createAndSplitProblem().
◆ freeBlock()
|
static |
frees component structure
- Parameters
-
block block structure
Definition at line 225 of file heur_padm.c.
References Block::ncoupling, NULL, Block::problem, SCIP_CALL, SCIP_OKAY, SCIPfree(), SCIPfreeBufferArray, Block::subscip, and Block::subvars.
Referenced by freeProblem().
◆ initProblem()
|
static |
initializes subproblem structure
- Parameters
-
scip SCIP data structure problem pointer to problem structure nblocks number of blocks
Definition at line 248 of file heur_padm.c.
References NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPdebugMessage, SCIPduplicateMemoryArray, SCIPgetProbName(), and SCIPsnprintf().
Referenced by createAndSplitProblem().
◆ freeProblem()
|
static |
frees subproblem structure
- Parameters
-
problem pointer to problem to free nblocks number of blocks in decomposition
Definition at line 278 of file heur_padm.c.
References freeBlock(), NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, and SCIPfreeMemoryArray.
Referenced by createAndSplitProblem(), and SCIP_DECL_HEUREXEC().
◆ createSubscip()
|
static |
creates a sub-SCIP for the given variables and constraints
- Parameters
-
scip main SCIP data structure subscip pointer to store created sub-SCIP
Definition at line 314 of file heur_padm.c.
References FALSE, SCIP_CALL, SCIP_OKAY, SCIPcopyLimits(), SCIPcreate(), SCIPincludeDefaultPlugins(), SCIPsetBoolParam(), SCIPsetIntParam(), SCIPsetSubscipsOff(), and TRUE.
Referenced by blockCreateSubscip().
◆ copyToSubscip()
|
static |
copies the given constraints and the corresponding variables to the given sub-SCIP
- Parameters
-
scip source SCIP subscip target SCIP name name for copied problem conss constraints to copy varmap hashmap used for the copy process of variables consmap hashmap used for the copy process of constraints nconss number of constraints to copy success pointer to store whether copying was successful
Definition at line 347 of file heur_padm.c.
References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPaddCons(), SCIPconsGetHdlr(), SCIPconsIsActive(), SCIPconsIsChecked(), SCIPconsIsDeleted(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPcopyProb(), SCIPgetConsCopy(), SCIPreleaseCons(), and TRUE.
Referenced by blockCreateSubscip().
◆ blockCreateSubscip()
|
static |
creates the subscip for a given block
- Parameters
-
block block structure varmap variable hashmap used to improve performance consmap constraint hashmap used to improve performance conss constraints contained in this block nconss number of constraints contained in this block success pointer to store whether the copying process was successful
Definition at line 400 of file heur_padm.c.
References copyToSubscip(), createSubscip(), FALSE, Block::nsubvars, NULL, Block::number, Block::problem, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPdebugMsg, SCIPfree(), SCIPgetNBinVars(), SCIPgetNIntVars(), SCIPgetNOrigBinVars(), SCIPgetNOrigIntVars(), SCIPgetNOrigVars(), SCIPgetNVars(), SCIPgetOrigVars(), SCIPsnprintf(), Block::size, Block::subscip, Block::subvars, and TRUE.
Referenced by createAndSplitProblem().
◆ createAndSplitProblem()
|
static |
creates problem structure and split it into blocks
- Parameters
-
scip SCIP data structure sortedconss array of (checked) constraints sorted by blocks blockstartsconss start points of blocks in sortedconss array nblocks number of blocks problem pointer to store problem structure success pointer to store whether the process was successful
Definition at line 471 of file heur_padm.c.
References b, blockCreateSubscip(), freeProblem(), initBlock(), initProblem(), NULL, SCIP_CALL, SCIP_OKAY, SCIPblkmem(), SCIPgetNVars(), SCIPhashmapCreate(), SCIPhashmapFree(), and TRUE.
Referenced by SCIP_DECL_HEUREXEC().
◆ assignLinking()
|
static |
copies labels to newdecomp and assigns linking constraints if possible
- Parameters
-
scip SCIP data structure decomp decomposition newdecomp decomposition with (partially) assigned linking constraints vars array of variables sortedconss sorted array of constraints varlabels array of variable labels conslabels sorted array of constraint labels nvars number of variables nconss number of constraints
Definition at line 534 of file heur_padm.c.
References NULL, SCIP_CALL, SCIP_DECOMP_LINKCONS, SCIP_OKAY, SCIPassignDecompLinkConss(), SCIPcomputeDecompStats(), SCIPcomputeDecompVarsLabels(), SCIPdebugMsg, SCIPdecompGetConsLabels(), SCIPdecompGetVarsLabels(), SCIPdecompSetConsLabels(), SCIPdecompSetVarsLabels(), SCIPsortIntPtr(), and TRUE.
Referenced by SCIP_DECL_HEUREXEC().
◆ reuseSolution()
|
static |
computes feasible solution from last stored solution of the block
- Parameters
-
subscip SCIP data structure block block structure
Definition at line 588 of file heur_padm.c.
References Block::couplingcons, COUPLINGSIZE, Block::ncoupling, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPaddSolFree(), SCIPallocBufferArray, SCIPcreateOrigSol(), SCIPdebugMsg, SCIPfreeBufferArray, SCIPgetConsVars(), SCIPgetLhsLinear(), SCIPgetNSols(), SCIPgetNVars(), SCIPgetRhsLinear(), SCIPgetSolOrigObj(), SCIPgetSols(), SCIPgetSolVal(), SCIPgetSolVals(), SCIPgetVars(), SCIPisEQ(), SCIPsetSolVal(), SCIPsetSolVals(), Block::slacksneg, and Block::slackspos.
Referenced by SCIP_DECL_HEUREXEC().
◆ scalePenalties()
|
static |
rescales the penalty parameters
A sigmoid function is a function with an "S"-shaped graph, e.g. S(x) = x/(1+|x|). In order to avoid numerical instabilities due to large penalty parameters we rescale them using the sigmoid function S(x) = (x - shift)/(flatness + |x - shift|) * (range/2) + offset. The parameters are mapped into the more controllable interval [lowestslack, range + lowestslack].
- Parameters
-
problem block structure linkvartoblocks linking variable to blocks set blocktolinkvars block to linking variable set htable hashtable containing blockinfo maxpenalty maximum penalty parameter
Definition at line 688 of file heur_padm.c.
References b, blockinfo::block, set::indexes, blockinfo::linkvaridx, NULL, blockinfo::otherblock, REALABS, SCIP_OKAY, SCIP_Real, SCIPhashtableRetrieve(), set::size, blockinfo::slacknegobjcoeff, and blockinfo::slackposobjcoeff.
Referenced by SCIP_DECL_HEUREXEC().
◆ getTimeLeft()
|
static |
returns the available time limit that is left
- Parameters
-
scip SCIP data structure time pointer to store remaining time
Definition at line 751 of file heur_padm.c.
References MAX, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPgetRealParam(), SCIPgetSolvingTime(), SCIPinfinity(), and SCIPisInfinity().
Referenced by SCIP_DECL_HEUREXEC().
◆ SCIP_DECL_HEURCOPY()
|
static |
copy method for primal heuristic plugins (called when SCIP copies plugins)
Definition at line 778 of file heur_padm.c.
References HEUR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIPheurGetName(), and SCIPincludeHeurPADM().
◆ SCIP_DECL_HEURFREE()
|
static |
destructor of primal heuristic to free user data (called when SCIP is exiting)
Definition at line 793 of file heur_padm.c.
References NULL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPheurGetData(), and SCIPheurSetData().
◆ SCIP_DECL_HEUREXEC()
|
static |
execution method of primal heuristic
Definition at line 809 of file heur_padm.c.
References assignLinking(), b, blockinfo::block, Block::couplingcons, blockinfo::couplingCons, COUPLINGSIZE, createAndSplitProblem(), EPSEQ, FALSE, freeProblem(), getTimeLeft(), set::indexes, blockinfo::linkvar, blockinfo::linkvaridx, blockinfo::linkvarval, MAX, Block::ncoupling, nnodes, Block::nsubvars, NULL, SCIP_Decomp::original, blockinfo::otherblock, pow(), Block::problem, REALABS, reuseSolution(), scalePenalties(), SCIP_Bool, SCIP_CALL, SCIP_DECOMP_LINKCONS, SCIP_DECOMP_LINKVAR, SCIP_DEFAULT_EPSILON, SCIP_DIDNOTFIND, SCIP_DIDNOTRUN, SCIP_FOUNDSOL, SCIP_HEURTIMING_AFTERNODE, SCIP_HEURTIMING_BEFORENODE, SCIP_Longint, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_REAL_MIN, SCIP_STATUS_GAPLIMIT, SCIP_STATUS_NODELIMIT, SCIP_STATUS_OPTIMAL, SCIP_STATUS_TIMELIMIT, SCIP_STATUS_UNBOUNDED, SCIP_VARTYPE_CONTINUOUS, SCIPaddCons(), SCIPaddVar(), SCIPallocBufferArray, SCIPblkmem(), SCIPceil(), SCIPchgLhsLinear(), SCIPchgRhsLinear(), SCIPchgVarObj(), SCIPcopyLimits(), SCIPcreateConsBasicLinear(), SCIPcreateDecomp(), SCIPcreateSol(), SCIPcreateVarBasic(), SCIPdebugMsg, SCIPdecompGetConsLabels(), SCIPdecompGetNBlocks(), SCIPdecompGetVarsLabels(), SCIPdecompUseBendersLabels(), SCIPduplicateBufferArray, SCIPfindVar(), SCIPfreeBufferArray, SCIPfreeDecomp(), SCIPfreeTransform(), SCIPgetBestSol(), SCIPgetConss(), SCIPgetDecomps(), SCIPgetMemExternEstim(), SCIPgetMemUsed(), SCIPgetNConss(), SCIPgetNNodes(), SCIPgetNOrigConss(), SCIPgetNOrigVars(), SCIPgetNSols(), SCIPgetNVars(), SCIPgetOrigConss(), SCIPgetOrigVars(), SCIPgetRealParam(), SCIPgetSolOrigObj(), SCIPgetSolVal(), SCIPgetSolVals(), SCIPgetSolvingTime(), SCIPgetStatus(), SCIPgetVars(), SCIPhashtableCreate(), SCIPhashtableFree(), SCIPhashtableGetNElements(), SCIPhashtableRetrieve(), SCIPhashtableSafeInsert(), SCIPheurGetData(), SCIPinfinity(), SCIPisEQ(), SCIPisGT(), SCIPisInfinity(), SCIPreleaseCons(), SCIPreleaseVar(), SCIPround(), SCIPsetLongintParam(), SCIPsetRealParam(), SCIPsetSolVal(), SCIPsnprintf(), SCIPsolve(), SCIPsortIntPtr(), SCIPtrySolFree(), SCIPvarGetLbLocal(), SCIPvarGetLbOriginal(), SCIPvarGetLPSol(), SCIPvarGetName(), SCIPvarGetObj(), SCIPvarGetType(), SCIPvarGetUbLocal(), SCIPwriteOrigProblem(), SCIPwriteTransProblem(), Block::size, set::size, blockinfo::slacknegobjcoeff, blockinfo::slacknegvar, blockinfo::slackposobjcoeff, blockinfo::slackposvar, Block::slacksneg, Block::slackspos, Block::subscip, Block::subvars, and TRUE.