Scippy

SCIP

Solving Constraint Integer Programs

cons_linking.h File Reference

Detailed Description

constraint handler for linking binary variables to an integer variable

Author
Stefan Heinz
Jens Schulz

The constraints handler stores linking constraints between an integer variable and an array of binary variables. Such a linking constraint has the form:

\[ y = \sum_{i=1}^n {c_i * x_i} \]

with integer variable $ y $, binary variables $ x_1, \dots, x_n $ and offset $b \in Q$, and with the additional side condition that exactly one binary variable has to be one (set partitioning condition).

This constraint can be created only with the integer variable. In this case the binary variables are only created on demand. That is, whenever someone asks for the binary variables. Therefore, such constraints can be used to get a "binary representation" of the domain of the integer variable which will be dynamically created.

Definition in file cons_linking.h.

#include "scip/scip.h"

Go to the source code of this file.

Functions

SCIP_RETCODE SCIPincludeConshdlrLinking (SCIP *scip)
 
SCIP_RETCODE SCIPcreateConsLinking (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *intvar, SCIP_VAR **binvars, int *vals, int nbinvars, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
 
SCIP_RETCODE SCIPcreateConsBasicLinking (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *intvar, SCIP_VAR **binvars, int *vals, int nbinvars)
 
SCIP_Bool SCIPexistsConsLinking (SCIP *scip, SCIP_VAR *intvar)
 
SCIP_CONSSCIPgetConsLinking (SCIP *scip, SCIP_VAR *intvar)
 
SCIP_VARSCIPgetIntvarLinking (SCIP *scip, SCIP_CONS *cons)
 
SCIP_RETCODE SCIPgetBinvarsLinking (SCIP *scip, SCIP_CONS *cons, SCIP_VAR ***binvars, int *nbinvars)
 
int SCIPgetNBinvarsLinking (SCIP *scip, SCIP_CONS *cons)
 
int * SCIPgetValsLinking (SCIP *scip, SCIP_CONS *cons)
 

Function Documentation

SCIP_RETCODE SCIPcreateConsLinking ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_VAR intvar,
SCIP_VAR **  binvars,
int *  vals,
int  nbinvars,
SCIP_Bool  initial,
SCIP_Bool  separate,
SCIP_Bool  enforce,
SCIP_Bool  check,
SCIP_Bool  propagate,
SCIP_Bool  local,
SCIP_Bool  modifiable,
SCIP_Bool  dynamic,
SCIP_Bool  removable,
SCIP_Bool  stickingatnode 
)

creates and captures a linking constraint

Note
the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
intvarinteger variable which should be linked
binvarsbinary variables, or NULL
valscoefficients of the binary variables
nbinvarsnumber of binary variables
initialshould the LP relaxation of constraint be in the initial LP? Usually set to TRUE. Set to FALSE for 'lazy constraints'.
separateshould the constraint be separated during LP processing? Usually set to TRUE.
enforceshould the constraint be enforced during node processing? TRUE for model constraints, FALSE for additional, redundant constraints.
checkshould the constraint be checked for feasibility? TRUE for model constraints, FALSE for additional, redundant constraints.
propagateshould the constraint be propagated during node processing? Usually set to TRUE.
localis constraint only valid locally? Usually set to FALSE. Has to be set to TRUE, e.g., for branching constraints.
modifiableis constraint modifiable (subject to column generation)? Usually set to FALSE. In column generation applications, set to TRUE if pricing adds coefficients to this constraint.
dynamicis constraint subject to aging? Usually set to FALSE. Set to TRUE for own cuts which are separated as constraints.
removableshould the relaxation be removed from the LP due to aging or cleanup? Usually set to FALSE. Set to TRUE for 'lazy constraints' and 'user cuts'.
stickingatnodeshould the constraint always be kept at the node where it was added, even if it may be moved to a more global node? Usually set to FALSE. Set to TRUE to for constraints that represent node data.

Definition at line 3219 of file cons_linking.c.

References consdataCreate(), CONSHDLR_NAME, getHashmapKey(), HASHSIZE_BINVARSCONS, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPblkmem(), SCIPconshdlrGetData(), SCIPcreateCons(), SCIPdebugMessage, SCIPerrorMessage, SCIPfindConshdlr(), SCIPgetStage(), SCIPhashmapCreate(), SCIPhashmapExists(), SCIPhashmapInsert(), SCIPisInfinity(), SCIPvarGetLbGlobal(), SCIPvarGetName(), and SCIPvarGetUbGlobal().

Referenced by consdataCollectLinkingCons(), SCIP_DECL_CONSCOPY(), SCIP_DECL_CONSPARSE(), and SCIPcreateConsBasicLinking().

SCIP_RETCODE SCIPcreateConsBasicLinking ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_VAR intvar,
SCIP_VAR **  binvars,
int *  vals,
int  nbinvars 
)

creates and captures a linking constraint in its most basic version, i. e., all constraint flags are set to their basic value as explained for the method SCIPcreateConsLinking(); all flags can be set via SCIPsetConsFLAGNAME-methods in scip.h

See also
SCIPcreateConsLinking() for information about the basic constraint flag configuration
Note
the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()

creates and captures a linking constraint in its most basic version, i. e., all constraint flags are set to their basic value as explained for the method SCIPcreateConsLinking(); all flags can be set via SCIPsetCons<Flagname>-methods in scip.h

See also
SCIPcreateConsLinking() for information about the basic constraint flag configuration
Note
the constraint gets captured, hence at one point you have to release it using the method SCIPreleaseCons()
Parameters
scipSCIP data structure
conspointer to hold the created constraint
namename of constraint
intvarinteger variable which should be linked
binvarsbinary variables, or NULL
valscoefficients of the binary variables
nbinvarsnumber of binary variables

Definition at line 3305 of file cons_linking.c.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPcreateConsLinking(), and TRUE.

SCIP_Bool SCIPexistsConsLinking ( SCIP scip,
SCIP_VAR intvar 
)

checks if for the given integer variable a linking constraint exists

Parameters
scipSCIP data structure
intvarinteger variable which should be linked

Definition at line 3324 of file cons_linking.c.

References CONSHDLR_NAME, getHashmapKey(), NULL, SCIPconshdlrGetData(), SCIPfindConshdlr(), and SCIPhashmapExists().

Referenced by collectBinaryVars(), and consdataCollectLinkingCons().

SCIP_CONS* SCIPgetConsLinking ( SCIP scip,
SCIP_VAR intvar 
)

returns the linking constraint belonging the given integer variable or NULL if it does not exist yet

returns the linking constraint belonging to the given integer variable or NULL if it does not exist yet

Parameters
scipSCIP data structure
intvarinteger variable which should be linked

Definition at line 3342 of file cons_linking.c.

References CONSHDLR_NAME, getHashmapKey(), NULL, SCIPconshdlrGetData(), SCIPfindConshdlr(), and SCIPhashmapGetImage().

Referenced by collectBinaryVars(), consdataCollectLinkingCons(), and consdataCreate().

SCIP_VAR* SCIPgetIntvarLinking ( SCIP scip,
SCIP_CONS cons 
)

returns the integer variable of the linking constraint

Parameters
scipSCIP data structure
conslinking constraint

Definition at line 3363 of file cons_linking.c.

References CONSHDLR_NAME, NULL, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.

SCIP_RETCODE SCIPgetBinvarsLinking ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR ***  binvars,
int *  nbinvars 
)

returns the binary variables of the linking constraint

Parameters
scipSCIP data structure
conslinking constraint
binvarspointer to store the binary variables array pointer
nbinvarspointer to store the number of returned binary variables

Definition at line 3385 of file cons_linking.c.

References consdataCreateBinvars(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetData(), SCIPconshdlrGetName(), and SCIPerrorMessage.

Referenced by collectBinaryVars(), and createCoverCutsTimepoint().

int SCIPgetNBinvarsLinking ( SCIP scip,
SCIP_CONS cons 
)

returns the number of binary variables of the linking constraint

Parameters
scipSCIP data structure
conslinking constraint

Definition at line 3429 of file cons_linking.c.

References CONSHDLR_NAME, NULL, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.

int* SCIPgetValsLinking ( SCIP scip,
SCIP_CONS cons 
)

returns the coefficients of the binary variables

Parameters
scipSCIP data structure
conslinking constraint

Definition at line 3450 of file cons_linking.c.

References CONSHDLR_NAME, NULL, SCIPABORT, SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconshdlrGetName(), and SCIPerrorMessage.

Referenced by collectBinaryVars(), and createCoverCutsTimepoint().