Scippy

SCIP

Solving Constraint Integer Programs

heur_padm.c File Reference

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.

Author
Dieter Weninger
Katrin Halbig

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

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

typedef struct Block BLOCK

data related to one block

◆ SET

typedef struct set SET

set data structure

◆ BLOCKINFO

typedef struct blockinfo BLOCKINFO

data of one linking variable related to one block

Function Documentation

◆ SCIP_DECL_HASHKEYEQ()

static SCIP_DECL_HASHKEYEQ ( indexesEqual  )
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 SCIP_DECL_HASHKEYVAL ( indexesHashval  )
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 SCIP_RETCODE initBlock ( PROBLEM problem)
static

initializes one block

Parameters
problemproblem 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 SCIP_RETCODE freeBlock ( BLOCK block)
static

frees component structure

Parameters
blockblock 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 SCIP_RETCODE initProblem ( SCIP scip,
PROBLEM **  problem,
int  nblocks 
)
static

initializes subproblem structure

Parameters
scipSCIP data structure
problempointer to problem structure
nblocksnumber 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 SCIP_RETCODE freeProblem ( PROBLEM **  problem,
int  nblocks 
)
static

frees subproblem structure

Parameters
problempointer to problem to free
nblocksnumber 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 SCIP_RETCODE createSubscip ( SCIP scip,
SCIP **  subscip 
)
static

creates a sub-SCIP for the given variables and constraints

Parameters
scipmain SCIP data structure
subscippointer 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 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

copies the given constraints and the corresponding variables to the given sub-SCIP

Parameters
scipsource SCIP
subsciptarget SCIP
namename for copied problem
conssconstraints to copy
varmaphashmap used for the copy process of variables
consmaphashmap used for the copy process of constraints
nconssnumber of constraints to copy
successpointer 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 SCIP_RETCODE blockCreateSubscip ( BLOCK block,
SCIP_HASHMAP varmap,
SCIP_HASHMAP consmap,
SCIP_CONS **  conss,
int  nconss,
SCIP_Bool success 
)
static

creates the subscip for a given block

Parameters
blockblock structure
varmapvariable hashmap used to improve performance
consmapconstraint hashmap used to improve performance
conssconstraints contained in this block
nconssnumber of constraints contained in this block
successpointer 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 SCIP_RETCODE createAndSplitProblem ( SCIP scip,
SCIP_CONS **  sortedconss,
int *  blockstartsconss,
int  nblocks,
PROBLEM **  problem,
SCIP_Bool success 
)
static

creates problem structure and split it into blocks

Parameters
scipSCIP data structure
sortedconssarray of (checked) constraints sorted by blocks
blockstartsconssstart points of blocks in sortedconss array
nblocksnumber of blocks
problempointer to store problem structure
successpointer 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 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

copies labels to newdecomp and assigns linking constraints if possible

Parameters
scipSCIP data structure
decompdecomposition
newdecompdecomposition with (partially) assigned linking constraints
varsarray of variables
sortedconsssorted array of constraints
varlabelsarray of variable labels
conslabelssorted array of constraint labels
nvarsnumber of variables
nconssnumber 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()

◆ scalePenalties()

static SCIP_RETCODE scalePenalties ( PROBLEM problem,
SET linkvartoblocks,
SET blocktolinkvars,
SCIP_HASHTABLE htable,
SCIP_Real  maxpenalty 
)
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
problemblock structure
linkvartoblockslinking variable to blocks set
blocktolinkvarsblock to linking variable set
htablehashtable containing blockinfo
maxpenaltymaximum 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 SCIP_RETCODE getTimeLeft ( SCIP scip,
SCIP_Real time 
)
static

returns the available time limit that is left

Parameters
scipSCIP data structure
timepointer 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 SCIP_DECL_HEURCOPY ( heurCopyPADM  )
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 SCIP_DECL_HEURFREE ( heurFreePADM  )
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 SCIP_DECL_HEUREXEC ( heurExecPADM  )
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.