Scippy

SCIP

Solving Constraint Integer Programs

heur_distributiondiving.c File Reference

Detailed Description

Diving heuristic that chooses fixings w.r.t. changes in the solution density after Pryor and Chinneck.

Author
Gregor Hendel

Definition in file heur_distributiondiving.c.

#include <assert.h>
#include <string.h>
#include "scip/heur_distributiondiving.h"
#include "scip/branch_distribution.h"
#include "pub_dive.h"

Go to the source code of this file.

Macros

#define HEUR_NAME   "distributiondiving"
 
#define HEUR_DESC   "Diving heuristic that chooses fixings w.r.t. changes in the solution density"
 
#define HEUR_DISPCHAR   'e'
 
#define HEUR_PRIORITY   -1003300
 
#define HEUR_FREQ   10
 
#define HEUR_FREQOFS   3
 
#define HEUR_MAXDEPTH   -1
 
#define HEUR_TIMING   SCIP_HEURTIMING_AFTERLPPLUNGE
 
#define HEUR_USESSUBSCIP   FALSE
 
#define EVENT_DISTRIBUTION   SCIP_EVENTTYPE_BOUNDCHANGED
 
#define EVENTHDLR_NAME   "eventhdlr_distributiondiving"
 
#define DIVESET_DIVETYPES   SCIP_DIVETYPE_INTEGRALITY
 
#define SQUARED(x)   ((x) * (x))
 
#define DEFAULT_MINRELDEPTH   0.0
 
#define DEFAULT_MAXRELDEPTH   1.0
 
#define DEFAULT_MAXLPITERQUOT   0.05
 
#define DEFAULT_MAXLPITEROFS   1000
 
#define DEFAULT_MAXDIVEUBQUOT   0.8
 
#define DEFAULT_MAXDIVEAVGQUOT   0.0
 
#define DEFAULT_MAXDIVEUBQUOTNOSOL   0.1
 
#define DEFAULT_MAXDIVEAVGQUOTNOSOL   0.0
 
#define DEFAULT_BACKTRACK   TRUE
 
#define DEFAULT_LPRESOLVEDOMCHGQUOT   0.15
 
#define DEFAULT_LPSOLVEFREQ   0
 
#define DEFAULT_ONLYLPBRANCHCANDS   TRUE
 
#define SCOREPARAM_VALUES   "lhwvd"
 
#define SCOREPARAM_VALUESLEN   5
 
#define DEFAULT_SCOREPARAM   'r'
 

Functions

static SCIP_RETCODE heurdataEnsureArraySize (SCIP *scip, SCIP_HEURDATA *heurdata, int maxindex)
 
static void heurdataUpdateCurrentBounds (SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR *var)
 
static void rowCalculateGauss (SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_ROW *row, SCIP_Real *mu, SCIP_Real *sigma2, int *rowinfinitiesdown, int *rowinfinitiesup)
 
static SCIP_RETCODE calcBranchScore (SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR *var, SCIP_Real lpsolval, SCIP_Real *upscore, SCIP_Real *downscore, char scoreparam)
 
static SCIP_RETCODE heurdataFreeArrays (SCIP *scip, SCIP_HEURDATA *heurdata)
 
static void heurdataAddBoundChangeVar (SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR *var)
 
static SCIP_VARheurdataPopBoundChangeVar (SCIP *scip, SCIP_HEURDATA *heurdata)
 
static SCIP_RETCODE varProcessBoundChanges (SCIP *scip, SCIP_HEURDATA *heurdata, SCIP_VAR *var)
 
static SCIP_DECL_EVENTFREE (eventFreeDistributiondiving)
 
static SCIP_DECL_HEURCOPY (heurCopyDistributiondiving)
 
static SCIP_DECL_HEURFREE (heurFreeDistributiondiving)
 
static SCIP_DECL_HEURINIT (heurInitDistributiondiving)
 
static SCIP_DECL_HEUREXIT (heurExitDistributiondiving)
 
static SCIP_DECL_DIVESETGETSCORE (divesetGetScoreDistributiondiving)
 
static SCIP_DECL_HEUREXEC (heurExecDistributiondiving)
 
static SCIP_DECL_EVENTEXEC (eventExecDistribution)
 
SCIP_RETCODE SCIPincludeHeurDistributiondiving (SCIP *scip)
 

Macro Definition Documentation

#define HEUR_NAME   "distributiondiving"

Definition at line 30 of file heur_distributiondiving.c.

#define HEUR_DESC   "Diving heuristic that chooses fixings w.r.t. changes in the solution density"

Definition at line 31 of file heur_distributiondiving.c.

#define HEUR_DISPCHAR   'e'

Definition at line 32 of file heur_distributiondiving.c.

#define HEUR_PRIORITY   -1003300

Definition at line 33 of file heur_distributiondiving.c.

#define HEUR_FREQ   10

Definition at line 34 of file heur_distributiondiving.c.

#define HEUR_FREQOFS   3

Definition at line 35 of file heur_distributiondiving.c.

#define HEUR_MAXDEPTH   -1

Definition at line 36 of file heur_distributiondiving.c.

#define HEUR_TIMING   SCIP_HEURTIMING_AFTERLPPLUNGE

Definition at line 37 of file heur_distributiondiving.c.

#define HEUR_USESSUBSCIP   FALSE

does the heuristic use a secondary SCIP instance?

Definition at line 38 of file heur_distributiondiving.c.

#define EVENT_DISTRIBUTION   SCIP_EVENTTYPE_BOUNDCHANGED

the event type to be handled by this event handler

Definition at line 39 of file heur_distributiondiving.c.

Referenced by heurdataEnsureArraySize(), and heurdataFreeArrays().

#define EVENTHDLR_NAME   "eventhdlr_distributiondiving"

Definition at line 40 of file heur_distributiondiving.c.

#define DIVESET_DIVETYPES   SCIP_DIVETYPE_INTEGRALITY

bit mask that represents all supported dive types

Definition at line 41 of file heur_distributiondiving.c.

#define SQUARED (   x)    ((x) * (x))
#define DEFAULT_MINRELDEPTH   0.0

minimal relative depth to start diving

Definition at line 48 of file heur_distributiondiving.c.

#define DEFAULT_MAXRELDEPTH   1.0

maximal relative depth to start diving

Definition at line 49 of file heur_distributiondiving.c.

#define DEFAULT_MAXLPITERQUOT   0.05

maximal fraction of diving LP iterations compared to node LP iterations

Definition at line 50 of file heur_distributiondiving.c.

#define DEFAULT_MAXLPITEROFS   1000

additional number of allowed LP iterations

Definition at line 51 of file heur_distributiondiving.c.

#define DEFAULT_MAXDIVEUBQUOT   0.8

maximal quotient (curlowerbound - lowerbound)/(cutoffbound - lowerbound) where diving is performed (0.0: no limit)

Definition at line 52 of file heur_distributiondiving.c.

#define DEFAULT_MAXDIVEAVGQUOT   0.0

maximal quotient (curlowerbound - lowerbound)/(avglowerbound - lowerbound) where diving is performed (0.0: no limit)

Definition at line 55 of file heur_distributiondiving.c.

#define DEFAULT_MAXDIVEUBQUOTNOSOL   0.1

maximal UBQUOT when no solution was found yet (0.0: no limit)

Definition at line 58 of file heur_distributiondiving.c.

#define DEFAULT_MAXDIVEAVGQUOTNOSOL   0.0

maximal AVGQUOT when no solution was found yet (0.0: no limit)

Definition at line 59 of file heur_distributiondiving.c.

#define DEFAULT_BACKTRACK   TRUE

use one level of backtracking if infeasibility is encountered?

Definition at line 60 of file heur_distributiondiving.c.

#define DEFAULT_LPRESOLVEDOMCHGQUOT   0.15

percentage of immediate domain changes during probing to trigger LP resolve

Definition at line 61 of file heur_distributiondiving.c.

#define DEFAULT_LPSOLVEFREQ   0

LP solve frequency for diving heuristics

Definition at line 62 of file heur_distributiondiving.c.

#define DEFAULT_ONLYLPBRANCHCANDS   TRUE

should only LP branching candidates be considered instead of the slower but more general constraint handler diving variable selection?

Definition at line 63 of file heur_distributiondiving.c.

#define SCOREPARAM_VALUES   "lhwvd"

the score;largest 'd'ifference, 'l'owest cumulative probability,'h'ighest c.p., 'v'otes lowest c.p., votes highest c.p.('w'), 'r'evolving

Definition at line 67 of file heur_distributiondiving.c.

#define SCOREPARAM_VALUESLEN   5

Definition at line 70 of file heur_distributiondiving.c.

#define DEFAULT_SCOREPARAM   'r'

default scoring parameter to guide the diving

Definition at line 71 of file heur_distributiondiving.c.

Function Documentation

static SCIP_RETCODE heurdataEnsureArraySize ( SCIP scip,
SCIP_HEURDATA heurdata,
int  maxindex 
)
static

ensure that maxindex + 1 rows can be represented in data arrays; memory gets reallocated with 10% extra space to save some time for future allocations

Parameters
scipSCIP data structure
heurdataheuristic data
maxindexrow index at hand (size must be at least this large)

Definition at line 109 of file heur_distributiondiving.c.

References EVENT_DISTRIBUTION, heurdataUpdateCurrentBounds(), NULL, SCIP_CALL, SCIP_INVALID, SCIP_OKAY, SCIP_STAGE_SOLVING, SCIPallocBufferArray, SCIPcatchVarEvent(), SCIPfeasCeil(), SCIPgetNVars(), SCIPgetStage(), SCIPgetVars(), SCIPreallocBufferArray, SCIPvarGetProbindex(), and SCIPvarIsActive().

Referenced by calcBranchScore(), and varProcessBoundChanges().

static void heurdataUpdateCurrentBounds ( SCIP scip,
SCIP_HEURDATA heurdata,
SCIP_VAR var 
)
static

update the variables current lower and upper bound

Parameters
scipSCIP data structure
heurdataheuristic data
varthe variable to update current bounds

Definition at line 198 of file heur_distributiondiving.c.

References NULL, rowCalculateGauss(), SCIP_Real, SCIPisFeasLE(), SCIPvarGetLbLocal(), SCIPvarGetProbindex(), and SCIPvarGetUbLocal().

Referenced by heurdataEnsureArraySize(), rowCalculateGauss(), and varProcessBoundChanges().

static void rowCalculateGauss ( SCIP scip,
SCIP_HEURDATA heurdata,
SCIP_ROW row,
SCIP_Real mu,
SCIP_Real sigma2,
int *  rowinfinitiesdown,
int *  rowinfinitiesup 
)
static

calculates the initial mean and variance of the row activity normal distribution.

The mean value $ \mu $ is given by $ \mu = \sum_i=1^n c_i * (lb_i +ub_i) / 2 $ where $n $ is the number of variables, and $ c_i, lb_i, ub_i $ are the variable coefficient and bounds, respectively. With the same notation, the variance $ \sigma^2 $ is given by $ \sigma^2 = \sum_i=1^n c_i^2 * \sigma^2_i $, with the variance being $ \sigma^2_i = ((ub_i - lb_i + 1)^2 - 1) / 12 $ for integer variables and $ \sigma^2_i = (ub_i - lb_i)^2 / 12 $ for continuous variables.

Parameters
scipSCIP data structure
heurdatathe heuristic rule data
rowthe row for which the gaussian normal distribution has to be calculated
mupointer to store the mean value of the gaussian normal distribution
sigma2pointer to store the variance value of the gaussian normal distribution
rowinfinitiesdownpointer to store the number of variables with infinite bounds to DECREASE activity
rowinfinitiesuppointer to store the number of variables with infinite bounds to INCREASE activity

Definition at line 231 of file heur_distributiondiving.c.

References calcBranchScore(), heurdataUpdateCurrentBounds(), NULL, SCIP_INVALID, SCIP_Real, SCIPcolGetVar(), SCIPdebug, SCIPdebugMessage, SCIPisFeasLE(), SCIPisFeasNegative(), SCIPisInfinity(), SCIPprintRow(), SCIProwGetCols(), SCIProwGetConstant(), SCIProwGetName(), SCIProwGetNNonz(), SCIProwGetVals(), SCIPvarCalcDistributionParameters(), SCIPvarGetLbLocal(), SCIPvarGetProbindex(), SCIPvarGetType(), SCIPvarGetUbLocal(), and SQUARED.

Referenced by calcBranchScore(), and heurdataUpdateCurrentBounds().

static SCIP_RETCODE calcBranchScore ( SCIP scip,
SCIP_HEURDATA heurdata,
SCIP_VAR var,
SCIP_Real  lpsolval,
SCIP_Real upscore,
SCIP_Real downscore,
char  scoreparam 
)
static

calculate the branching score of a variable, depending on the chosen score parameter

Parameters
scipcurrent SCIP
heurdatabranch rule data
varcandidate variable
lpsolvalcurrent fractional LP-relaxation solution value
upscorepointer to store the variable score when branching on it in upward direction
downscorepointer to store the variable score when branching on it in downward direction
scoreparamthe score parameter of this heuristic

Definition at line 344 of file heur_distributiondiving.c.

References FALSE, heurdataEnsureArraySize(), heurdataFreeArrays(), MAX, NULL, rowCalculateGauss(), SCIP_Bool, SCIP_CALL, SCIP_INVALID, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_COLUMN, SCIPcolGetNNonz(), SCIPcolGetRows(), SCIPcolGetVals(), SCIPdebugMessage, SCIPfeasCeil(), SCIPfeasFloor(), SCIPgetRowLPFeasibility(), SCIPisFeasLT(), SCIPisInfinity(), SCIPisIntegral(), SCIPisNegative(), SCIPisSumPositive(), SCIProwCalcProbability(), SCIProwGetIndex(), SCIProwGetName(), SCIPupdateDistributionScore(), SCIPvarCalcDistributionParameters(), SCIPvarGetCol(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetStatus(), SCIPvarGetType(), SCIPvarGetUbLocal(), SCIPvarIsBinary(), and SQUARED.

Referenced by rowCalculateGauss().

static SCIP_RETCODE heurdataFreeArrays ( SCIP scip,
SCIP_HEURDATA heurdata 
)
static

free heuristic data

Parameters
scipSCIP data structure
heurdataheuristic data

Definition at line 547 of file heur_distributiondiving.c.

References EVENT_DISTRIBUTION, heurdataAddBoundChangeVar(), NULL, SCIP_CALL, SCIP_OKAY, SCIPdropVarEvent(), SCIPfreeBufferArray, SCIPgetNVars(), SCIPgetVars(), and SCIPvarGetProbindex().

Referenced by calcBranchScore().

static void heurdataAddBoundChangeVar ( SCIP scip,
SCIP_HEURDATA heurdata,
SCIP_VAR var 
)
static

add variable to the bound change event queue; skipped if variable is already in there, or if variable has no row currently watched

Parameters
scipSCIP data structure
heurdataheuristic data
varthe variable whose bound changes need to be processed

Definition at line 601 of file heur_distributiondiving.c.

References heurdataPopBoundChangeVar(), NULL, SCIP_INVALID, and SCIPvarGetProbindex().

Referenced by heurdataFreeArrays().

static SCIP_VAR* heurdataPopBoundChangeVar ( SCIP scip,
SCIP_HEURDATA heurdata 
)
static

returns the next unprocessed variable (last in, first out) with pending bound changes, or NULL

Parameters
scipSCIP data structure
heurdataheuristic data

Definition at line 647 of file heur_distributiondiving.c.

References NULL, SCIPvarGetProbindex(), and varProcessBoundChanges().

Referenced by heurdataAddBoundChangeVar().

static SCIP_RETCODE varProcessBoundChanges ( SCIP scip,
SCIP_HEURDATA heurdata,
SCIP_VAR var 
)
static
static SCIP_DECL_EVENTFREE ( eventFreeDistributiondiving  )
static

destructor of event handler to free user data (called when SCIP is exiting)

Definition at line 801 of file heur_distributiondiving.c.

Referenced by varProcessBoundChanges().

static SCIP_DECL_HEURCOPY ( heurCopyDistributiondiving  )
static

copy method for primal heuristic plugins (called when SCIP copies plugins)

Definition at line 820 of file heur_distributiondiving.c.

static SCIP_DECL_HEURFREE ( heurFreeDistributiondiving  )
static

destructor of primal heuristic to free user data (called when SCIP is exiting)

Definition at line 834 of file heur_distributiondiving.c.

static SCIP_DECL_HEURINIT ( heurInitDistributiondiving  )
static

initialization method of primal heuristic (called after problem was transformed)

Definition at line 854 of file heur_distributiondiving.c.

static SCIP_DECL_HEUREXIT ( heurExitDistributiondiving  )
static

deinitialization method of primal heuristic (called before transformed problem is freed)

Definition at line 874 of file heur_distributiondiving.c.

static SCIP_DECL_DIVESETGETSCORE ( divesetGetScoreDistributiondiving  )
static

scoring callback for distribution diving. best candidate maximizes the distribution score

Definition at line 893 of file heur_distributiondiving.c.

static SCIP_DECL_HEUREXEC ( heurExecDistributiondiving  )
static

execution method of primal heuristic

Definition at line 964 of file heur_distributiondiving.c.

static SCIP_DECL_EVENTEXEC ( eventExecDistribution  )
static

event execution method of distribution branching which handles bound change events of variables

Definition at line 1010 of file heur_distributiondiving.c.

SCIP_RETCODE SCIPincludeHeurDistributiondiving ( SCIP scip)

creates the distributiondiving heuristic and includes it in SCIP

Parameters
scipSCIP data structure

Definition at line 1034 of file heur_distributiondiving.c.

Referenced by SCIPincludeDefaultPlugins().