Scippy

SCIP

Solving Constraint Integer Programs

presol_dualinfer.c File Reference

Detailed Description

dual inference presolver

Author
Dieter Weninger

This presolver exploits dual information for primal variable fixings: a) The first method is an enhanced dual fixing technique. b) The second method does dual bound strengthening on continuous primal variables and applies complementary slackness (yA-c)_i > 0 => x_i = 0 for fixing primal variables at their lower bound.

Definition in file presol_dualinfer.c.

#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "scip/cons_knapsack.h"
#include "scip/cons_linear.h"
#include "scip/cons_logicor.h"
#include "scip/cons_setppc.h"
#include "scip/cons_varbound.h"
#include "presol_dualinfer.h"

Go to the source code of this file.

Macros

#define PRESOL_NAME   "dualinfer"
 
#define PRESOL_DESC   "exploit dual informations for variable fixings"
 
#define PRESOL_PRIORITY   20010000
 
#define PRESOL_MAXROUNDS   0
 
#define PRESOL_DELAY   TRUE
 
#define MAX_LOOPS   7
 

Typedefs

typedef enum Fixingdirection FIXINGDIRECTION
 
typedef struct ConstraintMatrix CONSTRAINTMATRIX
 

Enumerations

enum  Fixingdirection {
  FIXATLB = -1,
  NOFIX = 0,
  FIXATUB = 1,
  FIXATLB = -1,
  NOFIX = 0,
  FIXATUB = 1
}
 

Functions

static SCIP_RETCODE getActiveVariables (SCIP *scip, SCIP_VAR ***vars, SCIP_Real **scalars, int *nvars, SCIP_Real *constant)
 
static SCIP_RETCODE addRow (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs)
 
static SCIP_RETCODE addConstraint (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Real lhs, SCIP_Real rhs)
 
static SCIP_RETCODE setColumnMajorFormat (SCIP *scip, CONSTRAINTMATRIX *matrix)
 
static SCIP_RETCODE calcActivityBounds (SCIP *scip, CONSTRAINTMATRIX *matrix)
 
static SCIP_RETCODE initMatrix (SCIP *scip, CONSTRAINTMATRIX **matrixptr, SCIP_Bool *initialized)
 
static void freeMatrix (SCIP *scip, CONSTRAINTMATRIX **matrix)
 
static SCIP_Bool isRowRedundant (SCIP *scip, CONSTRAINTMATRIX *matrix, int row)
 
static void initShadowPrices (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real *lowershadow, SCIP_Real *uppershadow)
 
static SCIP_RETCODE singletonColumns (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real *lowershadow, SCIP_Real *uppershadow, int *nfitsinglecols)
 
static void costCalculation (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real *lowershadow, SCIP_Real *uppershadow, SCIP_Real *lowercosts, SCIP_Real *uppercosts)
 
static void fixColumns (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real *lowercosts, SCIP_Real *uppercosts, int *npossiblefixings, FIXINGDIRECTION *varstofix)
 
static SCIP_RETCODE costFixing (SCIP *scip, CONSTRAINTMATRIX *matrix, FIXINGDIRECTION *varstofix, int *nfitsinglecols, int *npossiblefixings)
 
static SCIP_Real getMaxColActWithoutRow (SCIP *scip, CONSTRAINTMATRIX *matrix, int col, int withoutrow, SCIP_Real *lbdual, SCIP_Real *ubdual)
 
static SCIP_Real getMinColActWithoutRow (SCIP *scip, CONSTRAINTMATRIX *matrix, int col, int withoutrow, SCIP_Real *lbdual, SCIP_Real *ubdual)
 
static void calcColActivityResiduals (SCIP *scip, CONSTRAINTMATRIX *matrix, int col, int row, SCIP_Real val, SCIP_Real *lbdual, SCIP_Real *ubdual, SCIP_Real *mincolact, SCIP_Real *maxcolact, int *maxcolactinf, int *mincolactinf, SCIP_Real *mincolresact, SCIP_Real *maxcolresact)
 
static void calcColActivity (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real *lbdual, SCIP_Real *ubdual, int startcol, int stopcol, SCIP_Bool *excludevar, SCIP_Real *mincolact, SCIP_Real *maxcolact, int *maxcolactinf, int *mincolactinf)
 
static void updateDualBounds (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real objval, SCIP_Real val, int row, SCIP_Real mincolresact, SCIP_Real *lbdual, SCIP_Real *ubdual, int *boundchanges, SCIP_Bool *updateinfcnt)
 
static void infCounterUpdate (SCIP *scip, CONSTRAINTMATRIX *matrix, SCIP_Real val, int row, SCIP_Real *lbdual, SCIP_Real *ubdual, SCIP_Bool *excludevar, SCIP_Real *mincolact, SCIP_Real *maxcolact, int *maxcolactinf, int *mincolactinf)
 
static SCIP_RETCODE dualBoundStrengthening (SCIP *scip, CONSTRAINTMATRIX *matrix, FIXINGDIRECTION *varstofix, int *nfitsinglecols, int *npossiblefixings)
 
static SCIP_DECL_PRESOLCOPY (presolCopyDualinfer)
 
static SCIP_DECL_PRESOLEXEC (presolExecDualinfer)
 
SCIP_RETCODE SCIPincludePresolDualinfer (SCIP *scip)
 

Macro Definition Documentation

#define PRESOL_NAME   "dualinfer"

Definition at line 44 of file presol_dualinfer.c.

Referenced by SCIP_DECL_PRESOLCOPY(), and SCIPincludePresolDualinfer().

#define PRESOL_DESC   "exploit dual informations for variable fixings"

Definition at line 45 of file presol_dualinfer.c.

Referenced by SCIPincludePresolDualinfer().

#define PRESOL_PRIORITY   20010000

priority of the presolver (>= 0: before, < 0: after constraint handlers)

Definition at line 46 of file presol_dualinfer.c.

Referenced by SCIPincludePresolDualinfer().

#define PRESOL_MAXROUNDS   0

maximal number of presolving rounds the presolver participates in (-1: no limit)

Definition at line 47 of file presol_dualinfer.c.

Referenced by SCIPincludePresolDualinfer().

#define PRESOL_DELAY   TRUE

should presolver be delayed, if other presolvers found reductions?

Definition at line 48 of file presol_dualinfer.c.

Referenced by SCIPincludePresolDualinfer().

#define MAX_LOOPS   7

maximal number of dual bound strengthening loops

Definition at line 50 of file presol_dualinfer.c.

Referenced by dualBoundStrengthening().

Typedef Documentation

Definition at line 65 of file presol_dualinfer.c.

typedef struct ConstraintMatrix CONSTRAINTMATRIX

Definition at line 102 of file presol_dualinfer.c.

Enumeration Type Documentation

type of fixing direction

Enumerator:
FIXATLB 

fix variable at lower bound

NOFIX 

do not fix variable

FIXATUB 

fix variable at upper bound

FIXATLB 
NOFIX 
FIXATUB 

Definition at line 59 of file presol_dualinfer.c.

Function Documentation

static SCIP_RETCODE getActiveVariables ( SCIP scip,
SCIP_VAR ***  vars,
SCIP_Real **  scalars,
int *  nvars,
SCIP_Real constant 
)
static

transforms given variables, scalars, and constant to the corresponding active variables, scalars, and constant

Parameters
scipSCIP data structure
varsvars array to get active variables for
scalarsscalars a_1, ..., a_n in linear sum a_1*x_1 + ... + a_n*x_n + c
nvarspointer to number of variables and values in vars and vals array
constantpointer to constant c in linear sum a_1*x_1 + ... + a_n*x_n + c

Definition at line 106 of file presol_dualinfer.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPgetProbvarLinearSum(), SCIPreallocBufferArray, and TRUE.

Referenced by addConstraint().

static SCIP_RETCODE addRow ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SCIP_Real  lhs,
SCIP_Real  rhs 
)
static

add one row to the constraint matrix

Parameters
scipSCIP data structure
matrixconstraint matrix
varsvariables of this row
valscoefficients of this row
nvarsnumber of variables of this row
lhsleft hand side
rhsright hand side

Definition at line 141 of file presol_dualinfer.c.

References NULL, SCIP_OKAY, SCIP_Real, SCIPinfinity(), SCIPisInfinity(), SCIPvarGetProbindex(), and TRUE.

Referenced by addConstraint().

static SCIP_RETCODE addConstraint ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_VAR **  vars,
SCIP_Real vals,
int  nvars,
SCIP_Real  lhs,
SCIP_Real  rhs 
)
static

add one constraint to matrix

Parameters
scipcurrent scip instance
matrixconstraint matrix
varsvariables of this constraint
valsvariable coefficients of this constraint
nvarsnumber of variables
lhsleft hand side
rhsright hand side

Definition at line 207 of file presol_dualinfer.c.

References addRow(), getActiveVariables(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPduplicateBufferArray, SCIPfreeBufferArray, SCIPisInfinity(), and SCIPisLE().

Referenced by initMatrix().

static SCIP_RETCODE setColumnMajorFormat ( SCIP scip,
CONSTRAINTMATRIX matrix 
)
static

transform row major format into column major format

Parameters
scipcurrent scip instance
matrixconstraint matrix

Definition at line 286 of file presol_dualinfer.c.

References BMSclearMemoryArray, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, and SCIPfreeBufferArray.

Referenced by initMatrix().

static SCIP_RETCODE calcActivityBounds ( SCIP scip,
CONSTRAINTMATRIX matrix 
)
static

calculate min/max activity per row

Parameters
scipcurrent scip instance
matrixconstraint matrix

Definition at line 353 of file presol_dualinfer.c.

References NULL, SCIP_OKAY, SCIP_Real, SCIPinfinity(), and SCIPisInfinity().

Referenced by initMatrix().

static SCIP_RETCODE initMatrix ( SCIP scip,
CONSTRAINTMATRIX **  matrixptr,
SCIP_Bool initialized 
)
static
static void freeMatrix ( SCIP scip,
CONSTRAINTMATRIX **  matrix 
)
static

frees the constraint matrix

Parameters
scipcurrent SCIP instance
matrixconstraint matrix object

Definition at line 754 of file presol_dualinfer.c.

References NULL, SCIPfreeBuffer, SCIPfreeBufferArray, SCIPfreeBufferArrayNull, and SCIPfreeMemoryArray.

Referenced by SCIP_DECL_PRESOLEXEC().

static SCIP_Bool isRowRedundant ( SCIP scip,
CONSTRAINTMATRIX matrix,
int  row 
)
static

return if row is redundant or not

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
rowrow to be checked for redundancy

Definition at line 829 of file presol_dualinfer.c.

References NULL, and SCIPisFeasLE().

Referenced by costCalculation().

static void initShadowPrices ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real lowershadow,
SCIP_Real uppershadow 
)
static

initialize shadow prices

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
lowershadowlower shadow prices
uppershadowupper shadow prices

Definition at line 845 of file presol_dualinfer.c.

References NULL, and SCIPinfinity().

Referenced by costFixing().

static SCIP_RETCODE singletonColumns ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real lowershadow,
SCIP_Real uppershadow,
int *  nfitsinglecols 
)
static

search for singleton columns and update shadow prices

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
lowershadowlower shadows
uppershadowupper shadows
nfitsinglecolsnumber of fitting singleton columns

Definition at line 868 of file presol_dualinfer.c.

References NULL, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPisInfinity(), SCIPvarGetObj(), SCIPvarGetType(), and SCIPvarGetUbGlobal().

Referenced by costFixing().

static void costCalculation ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real lowershadow,
SCIP_Real uppershadow,
SCIP_Real lowercosts,
SCIP_Real uppercosts 
)
static

calculate min/max costs per column

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
lowershadowlower shadows
uppershadowupper shadows
lowercostslower shadow costs
uppercostsupper shadow costs

Definition at line 925 of file presol_dualinfer.c.

References FALSE, isRowRedundant(), NULL, SCIP_Bool, SCIP_Real, SCIPinfinity(), and SCIPisInfinity().

Referenced by costFixing().

static void fixColumns ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real lowercosts,
SCIP_Real uppercosts,
int *  npossiblefixings,
FIXINGDIRECTION varstofix 
)
static

fix variables at their bounds out of the min/max costs

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
lowercostslower shadow costs
uppercostsupper shadow costs
npossiblefixingsnumber of possible fixings
varstofixarray holding information for later upper/lower bound fixing

Definition at line 1008 of file presol_dualinfer.c.

References FIXATLB, FIXATUB, NULL, SCIP_Real, SCIPisInfinity(), SCIPvarGetLbGlobal(), SCIPvarGetObj(), and SCIPvarGetUbGlobal().

Referenced by costFixing().

static SCIP_RETCODE costFixing ( SCIP scip,
CONSTRAINTMATRIX matrix,
FIXINGDIRECTION varstofix,
int *  nfitsinglecols,
int *  npossiblefixings 
)
static

dual cost fixing

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
varstofixarray holding information for later upper/lower bound fixing
nfitsinglecolsnumber of continuous singleton columns
npossiblefixingsnumber of possible fixings

Definition at line 1059 of file presol_dualinfer.c.

References costCalculation(), fixColumns(), initShadowPrices(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPfreeBufferArray, and singletonColumns().

Referenced by SCIP_DECL_PRESOLEXEC().

static SCIP_Real getMaxColActWithoutRow ( SCIP scip,
CONSTRAINTMATRIX matrix,
int  col,
int  withoutrow,
SCIP_Real lbdual,
SCIP_Real ubdual 
)
static

calculate maximal column activity from one continuous variable without one row

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
colcolumn index
withoutrowexclude row index
lbduallower bounds of dual variables
ubdualupper bounds of dual variables

Definition at line 1101 of file presol_dualinfer.c.

References NULL, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPisInfinity(), and SCIPvarGetType().

Referenced by calcColActivityResiduals().

static SCIP_Real getMinColActWithoutRow ( SCIP scip,
CONSTRAINTMATRIX matrix,
int  col,
int  withoutrow,
SCIP_Real lbdual,
SCIP_Real ubdual 
)
static

calculate minimal column activity from one continuous variable without one row

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
colcolumn index
withoutrowexclude row index
lbduallower bounds of dual variables
ubdualupper bounds of dual variables

Definition at line 1157 of file presol_dualinfer.c.

References NULL, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPisInfinity(), and SCIPvarGetType().

Referenced by calcColActivityResiduals().

static void calcColActivityResiduals ( SCIP scip,
CONSTRAINTMATRIX matrix,
int  col,
int  row,
SCIP_Real  val,
SCIP_Real lbdual,
SCIP_Real ubdual,
SCIP_Real mincolact,
SCIP_Real maxcolact,
int *  maxcolactinf,
int *  mincolactinf,
SCIP_Real mincolresact,
SCIP_Real maxcolresact 
)
static

calculate minimal/maximal column residual activities

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
colcolumn index
rowrow index
valmatrix coefficient
lbduallower bounds of dual variables
ubdualupper bounds of dual variables
mincolactminimal column activities
maxcolactmaximal column activities
maxcolactinfnumber of (positive) infinite contributions to maximal column activity
mincolactinfnumber of (negative) infinite contributions to minimal column activity
mincolresactminimal column residual activity
maxcolresactmaximal column residual activity

Definition at line 1213 of file presol_dualinfer.c.

References getMaxColActWithoutRow(), getMinColActWithoutRow(), NULL, SCIP_VARTYPE_CONTINUOUS, SCIPinfinity(), SCIPisInfinity(), and SCIPvarGetType().

Referenced by dualBoundStrengthening().

static void calcColActivity ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real lbdual,
SCIP_Real ubdual,
int  startcol,
int  stopcol,
SCIP_Bool excludevar,
SCIP_Real mincolact,
SCIP_Real maxcolact,
int *  maxcolactinf,
int *  mincolactinf 
)
static

calculate minimal/maximal column activity on continuous variables

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
lbduallower bounds of dual variables
ubdualupper bounds of dual variables
startcolstart column index
stopcolstop column index
excludevarindicating if variable is within an equation or ranged row
mincolactminimal column activities
maxcolactmaximal column activities
maxcolactinfnumber of (positive) inifite contributions to maximal column activity
mincolactinfnumber of (negative) infinite contributions to minimal column activity

Definition at line 1316 of file presol_dualinfer.c.

References FALSE, NULL, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPinfinity(), SCIPisInfinity(), SCIPisPositive(), SCIPvarGetLbGlobal(), SCIPvarGetType(), SCIPvarGetUbGlobal(), and TRUE.

Referenced by dualBoundStrengthening(), and infCounterUpdate().

static void updateDualBounds ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real  objval,
SCIP_Real  val,
int  row,
SCIP_Real  mincolresact,
SCIP_Real lbdual,
SCIP_Real ubdual,
int *  boundchanges,
SCIP_Bool updateinfcnt 
)
static

update bounds on dual variables

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
objvalobjective function value
valmatrix coefficient
rowrow index
mincolresactminimal column residual activity
lbdualdual lower bounds
ubdualdual upper bounds
boundchangesnumber of bound changes
updateinfcntflag indicating to update infinity counters

Definition at line 1427 of file presol_dualinfer.c.

References FALSE, NULL, SCIP_Real, SCIPisInfinity(), and TRUE.

Referenced by dualBoundStrengthening().

static void infCounterUpdate ( SCIP scip,
CONSTRAINTMATRIX matrix,
SCIP_Real  val,
int  row,
SCIP_Real lbdual,
SCIP_Real ubdual,
SCIP_Bool excludevar,
SCIP_Real mincolact,
SCIP_Real maxcolact,
int *  maxcolactinf,
int *  mincolactinf 
)
static

update minimal/maximal column activity infinity counters

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
valmatrix coefficient
rowrow index
lbduallower bounds of dual variables
ubdualupper bounds of dual variables
excludevarindicating if variable is within an equation or ranged row
mincolactminimal column activities
maxcolactmaximal column activities
maxcolactinfnumber of (positive) infinity contributions to maximal column activity
mincolactinfnumber of (negative) infinity contributions to minimal column activity

Definition at line 1491 of file presol_dualinfer.c.

References calcColActivity(), NULL, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, and SCIPvarGetType().

Referenced by dualBoundStrengthening().

static SCIP_RETCODE dualBoundStrengthening ( SCIP scip,
CONSTRAINTMATRIX matrix,
FIXINGDIRECTION varstofix,
int *  nfitsinglecols,
int *  npossiblefixings 
)
static

dual bound strengthening on continuous variables

Parameters
scipSCIP main data structure
matrixmatrix containing the constraints
varstofixarray holding information for later upper/lower bound fixing
nfitsinglecolsnumber of continuous singleton columns
npossiblefixingsfound number of possible fixings

Definition at line 1601 of file presol_dualinfer.c.

References calcColActivity(), calcColActivityResiduals(), FALSE, FIXATLB, infCounterUpdate(), MAX_LOOPS, NOFIX, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_CONTINUOUS, SCIPallocBufferArray, SCIPfreeBufferArray, SCIPinfinity(), SCIPisInfinity(), SCIPisLT(), SCIPisNegative(), SCIPvarGetLbGlobal(), SCIPvarGetObj(), SCIPvarGetType(), SCIPvarGetUbGlobal(), TRUE, and updateDualBounds().

Referenced by SCIP_DECL_PRESOLEXEC().

static SCIP_DECL_PRESOLCOPY ( presolCopyDualinfer  )
static

copy method for constraint handler plugins (called when SCIP copies plugins)

Definition at line 1811 of file presol_dualinfer.c.

References NULL, PRESOL_NAME, SCIP_CALL, SCIP_OKAY, SCIPincludePresolDualinfer(), and SCIPpresolGetName().

SCIP_RETCODE SCIPincludePresolDualinfer ( SCIP scip)

creates the dual inference presolver and includes it in SCIP

Parameters
scipSCIP data structure

Definition at line 1959 of file presol_dualinfer.c.

References NULL, PRESOL_DELAY, PRESOL_DESC, PRESOL_MAXROUNDS, PRESOL_NAME, PRESOL_PRIORITY, SCIP_CALL, SCIP_OKAY, SCIPincludePresolBasic(), and SCIPsetPresolCopy().

Referenced by SCIP_DECL_PRESOLCOPY(), and SCIPincludeDefaultPlugins().