Scippy

SCIP

Solving Constraint Integer Programs

cons_xor.c File Reference

Detailed Description

Constraint handler for "xor" constraints, $rhs = x_1 \oplus x_2 \oplus \dots \oplus x_n$.

Author
Tobias Achterberg
Stefan Heinz
Marc Pfetsch
Michael Winkler

This constraint handler deals with "xor" constraint. These are constraint of the form:

\[ rhs = x_1 \oplus x_2 \oplus \dots \oplus x_n \]

where $x_i$ is a binary variable for all $i$ and $rhs$ is bool. The variables $x$'s are called operators. This constraint is satisfied if $rhs$ is TRUE and an odd number of the operators are TRUE or if the $rhs$ is FALSE and a even number of operators are TRUE. Hence, if the sum of $rhs$ and operators is even.

Definition in file cons_xor.c.

#include <assert.h>
#include <string.h>
#include "scip/pub_misc.h"
#include "scip/cons_xor.h"
#include "scip/cons_setppc.h"
#include "scip/cons_linear.h"
#include "scip/heur_trysol.h"
#include "scip/debug.h"

Go to the source code of this file.

Macros

#define CONSHDLR_NAME   "xor"
 
#define CONSHDLR_DESC   "constraint handler for xor constraints: r = xor(x1, ..., xn)"
 
#define CONSHDLR_SEPAPRIORITY   +850200
 
#define CONSHDLR_ENFOPRIORITY   -850200
 
#define CONSHDLR_CHECKPRIORITY   -850200
 
#define CONSHDLR_SEPAFREQ   0
 
#define CONSHDLR_PROPFREQ   1
 
#define CONSHDLR_EAGERFREQ   100
 
#define CONSHDLR_MAXPREROUNDS   -1
 
#define CONSHDLR_DELAYSEPA   FALSE
 
#define CONSHDLR_DELAYPROP   FALSE
 
#define CONSHDLR_DELAYPRESOL   FALSE
 
#define CONSHDLR_NEEDSCONS   TRUE
 
#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP
 
#define EVENTHDLR_NAME   "xor"
 
#define EVENTHDLR_DESC   "event handler for xor constraints"
 
#define DEFAULT_PRESOLPAIRWISE   TRUE
 
#define DEFAULT_ADDEXTENDEDFORM   FALSE
 
#define DEFAULT_ADDFLOWEXTENDED   FALSE
 
#define DEFAULT_SEPARATEPARITY   FALSE
 
#define DEFAULT_GAUSSPROPFREQ   5
 
#define HASHSIZE_XORCONS   131101
 
#define DEFAULT_PRESOLUSEHASHING   TRUE
 
#define NMINCOMPARISONS   200000
 
#define MINGAINPERNMINCOMPARISONS   1e-06
 
#define MAXXORCONSSSYSTEM   1000
 
#define MAXXORVARSSYSTEM   1000
 
#define NROWS   4
 

Typedefs

typedef unsigned short Type
 
typedef enum Proprule PROPRULE
 

Enumerations

enum  Proprule {
  PROPRULE_1,
  PROPRULE_2,
  PROPRULE_3,
  PROPRULE_4,
  PROPRULE_INVALID,
  PROPRULE_INVALID = 0,
  PROPRULE_1 = 1,
  PROPRULE_2 = 2,
  PROPRULE_3 = 3,
  PROPRULE_4 = 4,
  PROPRULE_1_CORETIMES = 1,
  PROPRULE_2_EDGEFINDING = 2,
  PROPRULE_3_TTEF = 3,
  PROPRULE_1_RHS = 1,
  PROPRULE_1_LHS = 2,
  PROPRULE_INVALID = 0,
  PROPRULE_1,
  PROPRULE_2,
  PROPRULE_3,
  PROPRULE_4,
  PROPRULE_INVALID,
  PROPRULE_1,
  PROPRULE_2,
  PROPRULE_3,
  PROPRULE_4,
  PROPRULE_0,
  PROPRULE_1,
  PROPRULE_INTLB,
  PROPRULE_INTUB,
  PROPRULE_INVALID
}
 

Functions

static SCIP_RETCODE lockRounding (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
 
static SCIP_RETCODE unlockRounding (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
 
static SCIP_RETCODE conshdlrdataCreate (SCIP *scip, SCIP_CONSHDLRDATA **conshdlrdata, SCIP_EVENTHDLR *eventhdlr)
 
static SCIP_RETCODE conshdlrdataFree (SCIP *scip, SCIP_CONSHDLRDATA **conshdlrdata)
 
static SCIP_RETCODE consdataSwitchWatchedvars (SCIP *scip, SCIP_CONSDATA *consdata, SCIP_EVENTHDLR *eventhdlr, int watchedvar1, int watchedvar2)
 
static SCIP_RETCODE consdataEnsureVarsSize (SCIP *scip, SCIP_CONSDATA *consdata, int num)
 
static SCIP_RETCODE consdataCreate (SCIP *scip, SCIP_CONSDATA **consdata, SCIP_Bool rhs, int nvars, SCIP_VAR **vars, SCIP_VAR *intvar)
 
static SCIP_RETCODE consdataFreeRows (SCIP *scip, SCIP_CONSDATA *consdata)
 
static SCIP_RETCODE consdataFree (SCIP *scip, SCIP_CONSDATA **consdata, SCIP_EVENTHDLR *eventhdlr)
 
static SCIP_RETCODE consdataPrint (SCIP *scip, SCIP_CONSDATA *consdata, FILE *file, SCIP_Bool endline)
 
static SCIP_RETCODE addCoef (SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr, SCIP_VAR *var)
 
static SCIP_RETCODE delCoefPos (SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr, int pos)
 
static void consdataSort (SCIP_CONSDATA *consdata)
 
static SCIP_DECL_HASHGETKEY (hashGetKeyXorcons)
 
static SCIP_DECL_HASHKEYEQ (hashKeyEqXorcons)
 
static SCIP_DECL_HASHKEYVAL (hashKeyValXorcons)
 
static SCIP_RETCODE applyFixings (SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr, int *nchgcoefs)
 
static SCIP_RETCODE addExtendedFlowFormulation (SCIP *scip, SCIP_CONS *cons, int *naddedconss)
 
static SCIP_RETCODE addExtendedAsymmetricFormulation (SCIP *scip, SCIP_CONS *cons, int *naddedconss)
 
static SCIP_RETCODE createRelaxation (SCIP *scip, SCIP_CONS *cons)
 
static SCIP_RETCODE addRelaxation (SCIP *scip, SCIP_CONS *cons)
 
static SCIP_Bool allRowsInLP (SCIP_CONSDATA *consdata)
 
static SCIP_RETCODE checkCons (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checklprows, SCIP_Bool *violated)
 
static SCIP_RETCODE separateCons (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool separateparity, SCIP_Bool *separated, SCIP_Bool *cutoff)
 
static int computeRowEcholonGF2 (SCIP *scip, int m, int n, int *p, int *s, Type **A, Type *b)
 
static void solveRowEcholonGF2 (int m, int n, int r, int *p, int *s, Type **A, Type *b, Type *x)
 
static SCIP_RETCODE checkSystemGF2 (SCIP *scip, SCIP_CONS **conss, int nconss, SCIP_SOL *currentsol, SCIP_RESULT *result)
 
static SCIP_RETCODE addConflictBounds (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *infervar, SCIP_BDCHGIDX *bdchgidx, PROPRULE proprule)
 
static SCIP_RETCODE analyzeConflict (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *infervar, PROPRULE proprule)
 
static SCIP_RETCODE propagateCons (SCIP *scip, SCIP_CONS *cons, SCIP_EVENTHDLR *eventhdlr, SCIP_Bool *cutoff, int *nfixedvars, int *nchgbds)
 
static SCIP_RETCODE resolvePropagation (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *infervar, PROPRULE proprule, SCIP_BDCHGIDX *bdchgidx, SCIP_RESULT *result)
 
static SCIP_RETCODE cliquePresolve (SCIP *scip, SCIP_CONS *cons, int *nfixedvars, int *nchgcoefs, int *ndelconss, int *naddconss, SCIP_Bool *cutoff)
 
static SCIP_RETCODE detectRedundantConstraints (SCIP *scip, BMS_BLKMEM *blkmem, SCIP_CONS **conss, int nconss, int *firstchange, int *nchgcoefs, int *ndelconss, SCIP_Bool *cutoff)
 
static SCIP_RETCODE preprocessConstraintPairs (SCIP *scip, SCIP_CONS **conss, int firstchange, int chkind, SCIP_Bool *cutoff, int *nfixedvars, int *naggrvars, int *ndelconss, int *nchgcoefs)
 
static SCIP_RETCODE createConsXorIntvar (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars, SCIP_VAR *intvar, 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)
 
static SCIP_DECL_CONSHDLRCOPY (conshdlrCopyXor)
 
static SCIP_DECL_CONSFREE (consFreeXor)
 
static SCIP_DECL_CONSEXITSOL (consExitsolXor)
 
static SCIP_DECL_CONSDELETE (consDeleteXor)
 
static SCIP_DECL_CONSTRANS (consTransXor)
 
static SCIP_DECL_CONSINITLP (consInitlpXor)
 
static SCIP_DECL_CONSSEPALP (consSepalpXor)
 
static SCIP_DECL_CONSSEPASOL (consSepasolXor)
 
static SCIP_DECL_CONSENFOLP (consEnfolpXor)
 
static SCIP_DECL_CONSENFOPS (consEnfopsXor)
 
static SCIP_DECL_CONSCHECK (consCheckXor)
 
static SCIP_DECL_CONSPROP (consPropXor)
 
static SCIP_DECL_CONSPRESOL (consPresolXor)
 
static SCIP_DECL_CONSRESPROP (consRespropXor)
 
static SCIP_DECL_CONSLOCK (consLockXor)
 
static SCIP_DECL_CONSPRINT (consPrintXor)
 
static SCIP_DECL_CONSCOPY (consCopyXor)
 
static SCIP_DECL_CONSPARSE (consParseXor)
 
static SCIP_DECL_CONSGETVARS (consGetVarsXor)
 
static SCIP_DECL_CONSGETNVARS (consGetNVarsXor)
 
static SCIP_DECL_EVENTEXEC (eventExecXor)
 
SCIP_RETCODE SCIPincludeConshdlrXor (SCIP *scip)
 
SCIP_RETCODE SCIPcreateConsXor (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars, 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 SCIPcreateConsBasicXor (SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Bool rhs, int nvars, SCIP_VAR **vars)
 
int SCIPgetNVarsXor (SCIP *scip, SCIP_CONS *cons)
 
SCIP_VAR ** SCIPgetVarsXor (SCIP *scip, SCIP_CONS *cons)
 
SCIP_Bool SCIPgetRhsXor (SCIP *scip, SCIP_CONS *cons)
 

Macro Definition Documentation

#define CONSHDLR_DESC   "constraint handler for xor constraints: r = xor(x1, ..., xn)"

Definition at line 49 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_SEPAPRIORITY   +850200

priority of the constraint handler for separation

Definition at line 50 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_ENFOPRIORITY   -850200

priority of the constraint handler for constraint enforcing

Definition at line 51 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_CHECKPRIORITY   -850200

priority of the constraint handler for checking feasibility

Definition at line 52 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_SEPAFREQ   0

frequency for separating cuts; zero means to separate only in the root node

Definition at line 53 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_PROPFREQ   1

frequency for propagating domains; zero means only preprocessing propagation

Definition at line 54 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_EAGERFREQ   100

frequency for using all instead of only the useful constraints in separation, propagation and enforcement, -1 for no eager evaluations, 0 for first only

Definition at line 55 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_MAXPREROUNDS   -1

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

Definition at line 57 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_DELAYSEPA   FALSE

should separation method be delayed, if other separators found cuts?

Definition at line 58 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_DELAYPROP   FALSE

should propagation method be delayed, if other propagators found reductions?

Definition at line 59 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_DELAYPRESOL   FALSE

should presolving method be delayed, if other presolvers found reductions?

Definition at line 60 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_NEEDSCONS   TRUE

should the constraint handler be skipped, if no constraints are available?

Definition at line 61 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP

Definition at line 63 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define EVENTHDLR_NAME   "xor"

Definition at line 65 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define EVENTHDLR_DESC   "event handler for xor constraints"

Definition at line 66 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define DEFAULT_PRESOLPAIRWISE   TRUE

should pairwise constraint comparison be performed in presolving?

Definition at line 68 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define DEFAULT_ADDEXTENDEDFORM   FALSE

should the extended formulation be added in presolving?

Definition at line 69 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define DEFAULT_ADDFLOWEXTENDED   FALSE

should the extended flow formulation be added (nonsymmetric formulation otherwise)?

Definition at line 70 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define DEFAULT_SEPARATEPARITY   FALSE

should parity inequalities be separated?

Definition at line 71 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define DEFAULT_GAUSSPROPFREQ   5

frequency for applying the Gauss propagator

Definition at line 72 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define HASHSIZE_XORCONS   131101

minimal size of hash table in logicor constraint tables

Definition at line 73 of file cons_xor.c.

Referenced by detectRedundantConstraints().

#define DEFAULT_PRESOLUSEHASHING   TRUE

should hash table be used for detecting redundant constraints in advance

Definition at line 74 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

#define NMINCOMPARISONS   200000

number for minimal pairwise presolving comparisons

Definition at line 75 of file cons_xor.c.

Referenced by SCIP_DECL_CONSPRESOL().

#define MINGAINPERNMINCOMPARISONS   1e-06

minimal gain per minimal pairwise presolving comparisons to repeat pairwise comparison round

Definition at line 76 of file cons_xor.c.

Referenced by SCIP_DECL_CONSPRESOL().

#define MAXXORCONSSSYSTEM   1000

maximal number of active constraints for which checking the system over GF2 is performed

Definition at line 77 of file cons_xor.c.

Referenced by checkSystemGF2().

#define MAXXORVARSSYSTEM   1000

maximal number of variables in xor constraints for which checking the system over GF2 is performed

Definition at line 78 of file cons_xor.c.

Referenced by checkSystemGF2().

#define NROWS   4

Definition at line 80 of file cons_xor.c.

Referenced by addRelaxation(), allRowsInLP(), consdataCreate(), consdataFreeRows(), and separateCons().

Typedef Documentation

typedef unsigned short Type

type used for matrix entries in function checkGauss()

Definition at line 88 of file cons_xor.c.

typedef enum Proprule PROPRULE

Definition at line 137 of file cons_xor.c.

Enumeration Type Documentation

enum Proprule
Enumerator:
PROPRULE_1 

left hand side and bounds on z -> lower bound on x

PROPRULE_2 

left hand side and upper bound on x -> bound on z

PROPRULE_3 

right hand side and bounds on z -> upper bound on x

PROPRULE_4 

right hand side and lower bound on x -> bound on z

PROPRULE_INVALID 

propagation was applied without a specific propagation rule

PROPRULE_INVALID 

propagation was applied without a specific propagation rule

PROPRULE_1 

v_i = FALSE => r = FALSE

PROPRULE_2 

r = TRUE => v_i = TRUE for all i

PROPRULE_3 

v_i = TRUE for all i => r = TRUE

PROPRULE_4 

r = FALSE, v_i = TRUE for all i except j => v_j = FALSE

PROPRULE_1_CORETIMES 

core-time propagator

PROPRULE_2_EDGEFINDING 

edge-finder

PROPRULE_3_TTEF 

time-table edeg-finding

PROPRULE_1_RHS 

activity residuals of all other variables tighten bounds of single variable due to the right hand side of the inequality

PROPRULE_1_LHS 

activity residuals of all other variables tighten bounds of single variable due to the left hand side of the inequality

PROPRULE_INVALID 

propagation was applied without a specific propagation rule

PROPRULE_1 

v_i = TRUE => r = TRUE

PROPRULE_2 

r = FALSE => v_i = FALSE for all i

PROPRULE_3 

v_i = FALSE for all i => r = FALSE

PROPRULE_4 

r = TRUE, v_i = FALSE for all i except j => v_j = TRUE

PROPRULE_INVALID 

propagation was applied without a specific propagation rule

PROPRULE_1 

left hand side and bounds on y -> lower bound on x

PROPRULE_2 

left hand side and upper bound on x -> bound on y

PROPRULE_3 

right hand side and bounds on y -> upper bound on x

PROPRULE_4 

right hand side and lower bound on x -> bound on y

PROPRULE_0 

all variables are fixed => fix integral variable

PROPRULE_1 

all except one variable fixed => fix remaining variable

PROPRULE_INTLB 

lower bound propagation of integral variable

PROPRULE_INTUB 

upper bound propagation of integral variable

PROPRULE_INVALID 

propagation was applied without a specific propagation rule

Definition at line 129 of file cons_xor.c.

Function Documentation

static SCIP_RETCODE lockRounding ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR var 
)
static

installs rounding locks for the given variable in the given xor constraint

Parameters
scipSCIP data structure
consxor constraint
varvariable of constraint entry

Definition at line 146 of file cons_xor.c.

References SCIP_CALL, SCIP_OKAY, SCIPlockVarCons(), and TRUE.

Referenced by addCoef(), and createRelaxation().

static SCIP_RETCODE unlockRounding ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR var 
)
static

removes rounding locks for the given variable in the given xor constraint

Parameters
scipSCIP data structure
consxor constraint
varvariable of constraint entry

Definition at line 160 of file cons_xor.c.

References SCIP_CALL, SCIP_OKAY, SCIPunlockVarCons(), and TRUE.

Referenced by delCoefPos().

static SCIP_RETCODE conshdlrdataCreate ( SCIP scip,
SCIP_CONSHDLRDATA **  conshdlrdata,
SCIP_EVENTHDLR eventhdlr 
)
static

creates constraint handler data

Parameters
scipSCIP data structure
conshdlrdatapointer to store the constraint handler data
eventhdlrevent handler

Definition at line 174 of file cons_xor.c.

References NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocMemory.

Referenced by SCIPincludeConshdlrXor().

static SCIP_RETCODE conshdlrdataFree ( SCIP scip,
SCIP_CONSHDLRDATA **  conshdlrdata 
)
static

frees constraint handler data

Parameters
scipSCIP data structure
conshdlrdatapointer to the constraint handler data

Definition at line 194 of file cons_xor.c.

References NULL, SCIP_OKAY, and SCIPfreeMemory.

Referenced by SCIP_DECL_CONSFREE().

static SCIP_RETCODE consdataSwitchWatchedvars ( SCIP scip,
SCIP_CONSDATA consdata,
SCIP_EVENTHDLR eventhdlr,
int  watchedvar1,
int  watchedvar2 
)
static

stores the given variable numbers as watched variables, and updates the event processing

Parameters
scipSCIP data structure
consdataxor constraint data
eventhdlrevent handler to call for the event processing
watchedvar1new first watched variable
watchedvar2new second watched variable

Definition at line 209 of file cons_xor.c.

References NULL, SCIP_CALL, SCIP_EVENTTYPE_BOUNDCHANGED, SCIP_OKAY, SCIPcatchVarEvent(), and SCIPdropVarEvent().

Referenced by consdataFree(), delCoefPos(), and propagateCons().

static SCIP_RETCODE consdataEnsureVarsSize ( SCIP scip,
SCIP_CONSDATA consdata,
int  num 
)
static

ensures, that the vars array can store at least num entries

Parameters
scipSCIP data structure
consdatalinear constraint data
numminimum number of entries to store

Definition at line 273 of file cons_xor.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), and SCIPreallocBlockMemoryArray.

Referenced by addCoef().

static SCIP_RETCODE consdataCreate ( SCIP scip,
SCIP_CONSDATA **  consdata,
SCIP_Bool  rhs,
int  nvars,
SCIP_VAR **  vars,
SCIP_VAR intvar 
)
static

creates constraint data for xor constraint

Parameters
scipSCIP data structure
consdatapointer to store the constraint data
rhsright hand side of the constraint
nvarsnumber of variables in the xor operation
varsvariables in xor operation
intvarartificial integer variable for linear relaxation

Definition at line 297 of file cons_xor.c.

References FALSE, NROWS, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPcaptureVar(), SCIPduplicateBlockMemoryArray, SCIPgetTransformedVar(), SCIPgetTransformedVars(), SCIPisTransformed(), and TRUE.

Referenced by createConsXorIntvar(), SCIP_DECL_CONSTRANS(), and SCIPcreateConsXor().

static SCIP_RETCODE consdataFreeRows ( SCIP scip,
SCIP_CONSDATA consdata 
)
static

releases LP row of constraint data

Parameters
scipSCIP data structure
consdataconstraint data

Definition at line 354 of file cons_xor.c.

References NROWS, NULL, SCIP_CALL, SCIP_OKAY, and SCIPreleaseRow().

Referenced by consdataFree(), and SCIP_DECL_CONSEXITSOL().

static SCIP_RETCODE consdataFree ( SCIP scip,
SCIP_CONSDATA **  consdata,
SCIP_EVENTHDLR eventhdlr 
)
static

frees constraint data for xor constraint

Parameters
scipSCIP data structure
consdatapointer to the constraint data
eventhdlrevent handler to call for the event processing

Definition at line 376 of file cons_xor.c.

References consdataFreeRows(), consdataSwitchWatchedvars(), NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemory, SCIPfreeBlockMemoryArray, SCIPisEQ(), SCIPisTransformed(), SCIPreleaseVar(), and SCIPvarGetLbGlobal().

Referenced by SCIP_DECL_CONSDELETE().

static SCIP_RETCODE consdataPrint ( SCIP scip,
SCIP_CONSDATA consdata,
FILE *  file,
SCIP_Bool  endline 
)
static

prints xor constraint to file stream

Parameters
scipSCIP data structure
consdataxor constraint data
fileoutput file (or NULL for standard output)
endlineshould an endline be set?

Definition at line 437 of file cons_xor.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPinfoMessage(), SCIPwriteVarsList(), and TRUE.

Referenced by applyFixings(), and SCIP_DECL_CONSPRINT().

static SCIP_RETCODE addCoef ( SCIP scip,
SCIP_CONS cons,
SCIP_EVENTHDLR eventhdlr,
SCIP_VAR var 
)
static

adds coefficient to xor constraint

Parameters
scipSCIP data structure
conslinear constraint
eventhdlrevent handler to call for the event processing
varvariable to add to the constraint

Definition at line 463 of file cons_xor.c.

References consdataEnsureVarsSize(), lockRounding(), NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDCALL, SCIP_OKAY, SCIPconsGetData(), SCIPconsIsTransformed(), SCIPerrorMessage, SCIPgetTransformedVar(), SCIPvarIsTransformed(), and TRUE.

Referenced by applyFixings(), and preprocessConstraintPairs().

static SCIP_RETCODE delCoefPos ( SCIP scip,
SCIP_CONS cons,
SCIP_EVENTHDLR eventhdlr,
int  pos 
)
static

deletes coefficient at given position from xor constraint data

Parameters
scipSCIP data structure
consxor constraint
eventhdlrevent handler to call for the event processing
posposition of coefficient to delete

Definition at line 511 of file cons_xor.c.

References consdataSwitchWatchedvars(), FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), SCIPconsIsTransformed(), SCIPvarIsTransformed(), TRUE, and unlockRounding().

Referenced by applyFixings().

static void consdataSort ( SCIP_CONSDATA consdata)
static

sorts and constraint's variables by non-decreasing variable index

Parameters
consdataconstraint data

Definition at line 564 of file cons_xor.c.

References NULL, SCIP_Bool, SCIPsortedvecFindPtr(), SCIPsortPtr(), SCIPvarCompareActiveAndNegated(), and TRUE.

Referenced by applyFixings(), detectRedundantConstraints(), preprocessConstraintPairs(), and SCIP_DECL_HASHKEYEQ().

static SCIP_DECL_HASHGETKEY ( hashGetKeyXorcons  )
static

gets the key of the given element

Definition at line 646 of file cons_xor.c.

static SCIP_DECL_HASHKEYEQ ( hashKeyEqXorcons  )
static

returns TRUE iff both keys are equal; two constraints are equal if they have the same variables

Definition at line 654 of file cons_xor.c.

References consdataSort(), FALSE, NULL, SCIPconsGetData(), SCIPvarCompare(), SCIPvarCompareActiveAndNegated(), and TRUE.

static SCIP_DECL_HASHKEYVAL ( hashKeyValXorcons  )
static

returns the hash value of the key

Definition at line 696 of file cons_xor.c.

References NULL, SCIP_VARSTATUS_FIXED, SCIP_VARSTATUS_NEGATED, SCIPconsGetData(), SCIPvarGetIndex(), SCIPvarGetStatus(), and SCIPvarIsActive().

static SCIP_RETCODE applyFixings ( SCIP scip,
SCIP_CONS cons,
SCIP_EVENTHDLR eventhdlr,
int *  nchgcoefs 
)
static

deletes all fixed variables and all pairs equal variables variables

Parameters
scipSCIP data structure
consxor constraint
eventhdlrevent handler to call for the event processing
nchgcoefspointer to add up the number of changed coefficients

Definition at line 731 of file cons_xor.c.

References addCoef(), consdataPrint(), consdataSort(), delCoefPos(), MIN, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPconsGetData(), SCIPconsGetName(), SCIPdebug, SCIPdebugMessage, SCIPgetBinvarRepresentative(), SCIPisEQ(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetNegationVar(), SCIPvarGetProbvar(), SCIPvarGetUbGlobal(), SCIPvarIsBinary(), SCIPvarIsNegated(), and TRUE.

Referenced by detectRedundantConstraints(), preprocessConstraintPairs(), and SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE addExtendedFlowFormulation ( SCIP scip,
SCIP_CONS cons,
int *  naddedconss 
)
static

adds extended flow formulation

The extended flow formulation is built as follows: Let $x_1, \dots, x_k$ be the variables contained in the given XOR constraint. We construct a two layered flow network. The upper layer is called the north layer and the lower is called the south layer. For each $x_i,\; i = 2, \ldots, k-1$, we add arcs that stay in the north and south layer (denoted by 'nn' and 'ss', respectively), as well as arcs that change the layers (denoted by 'ns' and 'sn'). For $x_1$, we only add two arcs from the source to the two layers. The source is located on the north layer. For $x_k$, we add two arcs connecting the two layers to the sink. Depending on the rhs of the constraint the sink is located on the north or south layer. A change in the layers corresponds to a parity change, i.e., the corresponding variable $x_i$ is 1 (and 0 otherwise).

Parameters
scipSCIP data structure
consconstraint to check
naddedconssnumber of added constraints

Definition at line 860 of file cons_xor.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_IMPLINT, SCIPaddCons(), SCIPaddVar(), SCIPaggregateVars(), SCIPallocBlockMemoryArray, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsInitial(), SCIPconsIsModifiable(), SCIPconsIsRemovable(), SCIPcreateConsLinear(), SCIPcreateVar(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPlockVarCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarIsTransformed(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE addExtendedAsymmetricFormulation ( SCIP scip,
SCIP_CONS cons,
int *  naddedconss 
)
static

adds extended asymmetric formulation

The extended asymmetric formulation is constructed as follows: Let $x_1, \dots, x_k$ be the variables contained in the given XOR constraint. We introduce variables $p_1, \ldots, p_k$ with the following constraints: $p_1 = x_1$, $p_k = 1$, and for $i = 2, \ldots, k-1$:

\[ \begin{array}{ll} p_i & \leq p_{i-1} + x_i\\ p_i & \leq 2 - (p_{i-1} + x_i)\\ p_i & \geq p_{i-1} - x_i\\ p_i & \geq x_i - p_{i-1}. \end{array} \]

This formulation is described in

Robert D. Carr and Goran Konjevod
Polyhedral combinatorics
In Harvey Greenberg, editor, Tutorials on emerging methodologies and applications in Operations Research,
Chapter 2, pages (2-1)-(2-48). Springer, 2004.

Parameters
scipSCIP data structure
consconstraint to check
naddedconssnumber of added constraints

Definition at line 1165 of file cons_xor.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_IMPLINT, SCIPaddCons(), SCIPaddVar(), SCIPaggregateVars(), SCIPallocBlockMemoryArray, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsInitial(), SCIPconsIsModifiable(), SCIPconsIsRemovable(), SCIPcreateConsLinear(), SCIPcreateVar(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPinfinity(), SCIPlockVarCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarIsTransformed(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE createRelaxation ( SCIP scip,
SCIP_CONS cons 
)
static

creates LP row corresponding to xor constraint: x1 + ... + xn - 2q == rhs with internal integer variable q; in the special case of 3 variables and c = 0, the following linear system is created:

  • x - y - z <= 0
  • x + y - z <= 0
  • x - y + z <= 0
  • x + y + z <= 2 in the special case of 3 variables and c = 1, the following linear system is created:
  • x + y + z <= 1
  • x - y + z <= 1
  • x + y - z <= 1
  • x - y - z <= -1
Parameters
scipSCIP data structure
consconstraint to check

Definition at line 1344 of file cons_xor.c.

References lockRounding(), NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_INTEGER, SCIPaddVar(), SCIPaddVarsToRowSameCoef(), SCIPaddVarToRow(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsRemovable(), SCIPcreateEmptyRowCons(), SCIPcreateVar(), SCIPdebugAddSolVal, SCIPdebugGetSolVal, SCIPinfinity(), and SCIPsnprintf().

Referenced by addRelaxation(), and separateCons().

static SCIP_RETCODE addRelaxation ( SCIP scip,
SCIP_CONS cons 
)
static

adds linear relaxation of or constraint to the LP

Parameters
scipSCIP data structure
consconstraint to check

Definition at line 1459 of file cons_xor.c.

References createRelaxation(), FALSE, NROWS, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPaddCut(), SCIPconsGetData(), and SCIProwIsInLP().

Referenced by SCIP_DECL_CONSINITLP().

static SCIP_Bool allRowsInLP ( SCIP_CONSDATA consdata)
static

returns whether all rows of the LP relaxation are in the current LP

Parameters
consdataconstraint data

Definition at line 1490 of file cons_xor.c.

References FALSE, NROWS, NULL, SCIProwIsInLP(), and TRUE.

Referenced by checkCons().

static SCIP_RETCODE checkCons ( SCIP scip,
SCIP_CONS cons,
SCIP_SOL sol,
SCIP_Bool  checklprows,
SCIP_Bool violated 
)
static

checks xor constraint for feasibility of given solution: returns TRUE iff constraint is feasible

Parameters
scipSCIP data structure
consconstraint to check
solsolution to check, NULL for current solution
checklprowsshould LP rows be checked?
violatedpointer to store whether the constraint is violated

Definition at line 1512 of file cons_xor.c.

References allRowsInLP(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPgetSolVal(), SCIPincConsAge(), SCIPisFeasIntegral(), SCIPresetConsAge(), and TRUE.

Referenced by SCIP_DECL_CONSCHECK(), SCIP_DECL_CONSENFOLP(), and SCIP_DECL_CONSENFOPS().

static SCIP_RETCODE separateCons ( SCIP scip,
SCIP_CONS cons,
SCIP_SOL sol,
SCIP_Bool  separateparity,
SCIP_Bool separated,
SCIP_Bool cutoff 
)
static

separates current LP solution

Consider a XOR-constraint

\[ x_1 \oplus x_2 \oplus \dots \oplus x_n = b \]

with $b \in \{0,1\}$ and a solution $x^*$ to be cut off. Small XOR constraints are handled by adding the inequalities of the convex hull.

The separation of larger XOR constraints has been described by
Xiaojie Zhang and Paul H. Siegel
"Adaptive Cut Generation Algorithm for Improved Linear Programming Decoding of Binary Linear Codes"
IEEE Transactions on Information Theory, vol. 58, no. 10, 2012

We separate the inequalities

\[ \sum_{j \in S} (1 - x_j) + \sum_{j \notin S} x_j \geq 1 \]

with $|S| \equiv (b+1) \mbox{ mod } 2$ as follows. That these inequalities are valid can be seen as follows: Let $x$ be a feasible solution and suppose that the inequality is violated for some $S$. Then $x_j = 1$ for all $j \in S$ and $x_j = 0$ for all $j \notin S$. Thus we should have

\[ \oplus_{j \in S} x_j = |S| \mbox{ mod } 2 = b+1 \mbox{ mod } 2, \]

which is not equal to $b$ as required by the XOR-constraint.

Let $L= \{j \;:\; x^*_j > \frac{1}{2}\}$. Suppose that $|L|$ has not the same parity as $b$ rhs. Then

\[ \sum_{j \in L} (1 - x_j) + \sum_{j \notin L} x_j \geq 1 \]

is the only inequality that can be violated. We rewrite the inequality as

\[ \sum_{j \in L} x_j - \sum_{j \notin L} x_j \leq |L| - 1. \]

These inequalities are added.

Otherwise let $k = \mbox{argmin}\{x^*_j \;:\; j \in L\}$ and check the inequality for $L \setminus \{k\}$ and similarly for $k = \mbox{argmax}\{x^*_j \;:\; j \in L\}$.

Parameters
scipSCIP data structure
consconstraint to check
solprimal CIP solution, NULL for current LP solution
separateparityshould parity inequalities be separated?
separatedpointer to store whether a cut was found
cutoffwhether a cutoff has been detected

Definition at line 1607 of file cons_xor.c.

References createRelaxation(), FALSE, NROWS, NULL, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddCut(), SCIPaddVarToRow(), SCIPcacheRowExtensions(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPcreateEmptyRowCons(), SCIPdebug, SCIPdebugMessage, SCIPflushRowExtensions(), SCIPgetRowLPActivity(), SCIPgetRowSolFeasibility(), SCIPgetSolVal(), SCIPinfinity(), SCIPisEfficacious(), SCIPisFeasGT(), SCIPisFeasNegative(), SCIPisGT(), SCIPprintRow(), SCIPreleaseRow(), SCIProwIsInLP(), SCIPsnprintf(), and TRUE.

Referenced by SCIP_DECL_CONSENFOLP(), SCIP_DECL_CONSSEPALP(), and SCIP_DECL_CONSSEPASOL().

static int computeRowEcholonGF2 ( SCIP scip,
int  m,
int  n,
int *  p,
int *  s,
Type **  A,
Type b 
)
static

Transform linear system $A x = b$ into row echolon form via the Gauss algorithm with row pivoting over GF2

Returns
the rank of A

Here, $A \in R^{m \times n},\; b \in R^m$. On exit, the vector p contains a permutation of the row indices used for pivoting and the function returns the rank r of A. For each row $i = 1, \ldots, r$, the entry s[i] contains the column index of the first nonzero in row i.

Parameters
scipSCIP data structure
mnumber of rows
nnumber of columns
prow permutation
ssteps indicators of the row echolon form
Amatrix
brhs

Definition at line 1820 of file cons_xor.c.

References NULL, and SCIPisStopped().

Referenced by checkSystemGF2().

static void solveRowEcholonGF2 ( int  m,
int  n,
int  r,
int *  p,
int *  s,
Type **  A,
Type b,
Type x 
)
static

Construct solution from matrix in row echolon form over GF2

Compute solution of $A x = b$, which is already in row echolon form (

See Also
computeRowEcholonGF2())
Parameters
mnumber of rows
nnumber of columns
rrank of matrix
prow permutation
ssteps indicators of the row echolon form
Amatrix
brhs
xsolution vector on exit

Definition at line 1929 of file cons_xor.c.

References NULL.

Referenced by checkSystemGF2().

static SCIP_RETCODE checkSystemGF2 ( SCIP scip,
SCIP_CONS **  conss,
int  nconss,
SCIP_SOL currentsol,
SCIP_RESULT result 
)
static

solve equation system over GF 2 by Gauss algorithm and create solution out of it or return cutoff

Collect all information in xor constraints into a linear system over GF2. Then solve the system by computing a row echolon form. If the system is infeasible, the current node is infeasible. Otherwise, we can compute a solution for the xor constraints given. We check whether this gives a solution for the whole problem.

We sort the columns with respect to the product of the objective coefficients and 1 minus the current LP solution value. The idea is that columns that are likely to provide the steps in the row echolon form should appear towards the front of the matrix. The smaller the product, the more it makes sense to set the variable to 1 (because the solution value is already close to 1 and the objective function is small).

Note that this function is called from propagation where usually no solution is available. However, the solution is only used for sorting the columns. Thus, the procedure stays correct even with nonsense solutions.

Parameters
scipSCIP data structure
conssxor constraints
nconssnumber of xor constraints
currentsolcurrent solution (maybe NULL)
resultresult of propagation (possibly cutoff, no change if primal solution has been tried)

Definition at line 1993 of file cons_xor.c.

References BMSclearMemoryArray, computeRowEcholonGF2(), FALSE, MAXXORCONSSSYSTEM, MAXXORVARSSYSTEM, NULL, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_MULTAGGR, SCIP_VARTYPE_BINARY, SCIPallocBufferArray, SCIPblkmem(), SCIPcalcHashtableSize(), SCIPcheckSol(), SCIPcomputeVarLbLocal(), SCIPcomputeVarUbLocal(), SCIPconsGetData(), SCIPconsGetName(), SCIPcreateSol(), SCIPdebug, SCIPdebugMessage, SCIPfindHeur(), SCIPfreeBufferArray, SCIPfreeSol(), SCIPgetNVars(), SCIPgetSolVal(), SCIPgetVars(), SCIPhashmapCreate(), SCIPhashmapExists(), SCIPhashmapFree(), SCIPhashmapGetImage(), SCIPhashmapInsert(), SCIPheurPassSolAddSol(), SCIPinfoMessage(), SCIPisGE(), SCIPisLE(), SCIPisStopped(), SCIPprintSol(), SCIPsetSolVal(), SCIPsortRealIntPtr(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetObj(), SCIPvarGetStatus(), SCIPvarGetType(), SCIPvarGetUbGlobal(), SCIPvarIsActive(), SCIPvarIsNegated(), solveRowEcholonGF2(), and TRUE.

Referenced by SCIP_DECL_CONSPROP().

static SCIP_RETCODE addConflictBounds ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR infervar,
SCIP_BDCHGIDX bdchgidx,
PROPRULE  proprule 
)
static

for each variable in the xor constraint, add it to conflict set; for integral variable add corresponding bound

Parameters
scipSCIP data structure
consconstraint that inferred the bound change
infervarvariable that was deduced, or NULL (not equal to integral variable)
bdchgidxbound change index (time stamp of bound change), or NULL for current time
proprulepropagation rule

Definition at line 2386 of file cons_xor.c.

References FALSE, NULL, PROPRULE_0, PROPRULE_1, PROPRULE_INTLB, PROPRULE_INTUB, PROPRULE_INVALID, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPABORT, SCIPaddConflictBinvar(), SCIPaddConflictLb(), SCIPaddConflictUb(), SCIPconsGetData(), SCIPconsGetName(), SCIPerrorMessage, SCIPisEQ(), SCIPvarGetLbAtIndex(), SCIPvarGetUbAtIndex(), and TRUE.

Referenced by analyzeConflict(), and resolvePropagation().

static SCIP_RETCODE analyzeConflict ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR infervar,
PROPRULE  proprule 
)
static

analyzes conflicting assignment on given constraint, and adds conflict constraint to problem

Parameters
scipSCIP data structure
consxor constraint that detected the conflict
infervarvariable that was deduced, or NULL (not equal to integral variable)
proprulepropagation rule

Definition at line 2494 of file cons_xor.c.

References addConflictBounds(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_STAGE_SOLVING, SCIPanalyzeConflictCons(), SCIPgetStage(), SCIPinitConflictAnalysis(), SCIPinProbing(), and SCIPisConflictAnalysisApplicable().

Referenced by propagateCons().

static SCIP_RETCODE propagateCons ( SCIP scip,
SCIP_CONS cons,
SCIP_EVENTHDLR eventhdlr,
SCIP_Bool cutoff,
int *  nfixedvars,
int *  nchgbds 
)
static

propagates constraint with the following rules: (0) all variables are fixed => can fix integral variable (1) all except one variable fixed => fix remaining variable and integral variable (2) depending on the amount of fixed binary variables we can tighten the integral variable (3) depending on the lower bound of the integral variable one can fix variables to 1 (4) depending on the upper bound of the integral variable one can fix variables to 0

Parameters
scipSCIP data structure
consxor constraint to be processed
eventhdlrevent handler to call for the event processing
cutoffpointer to store TRUE, if the node can be cut off
nfixedvarspointer to add up the number of fixed variables
nchgbdspointer to add up the number of found domain reductions

Definition at line 2525 of file cons_xor.c.

References analyzeConflict(), consdataSwitchWatchedvars(), FALSE, NULL, PROPRULE_0, PROPRULE_1, PROPRULE_INTLB, PROPRULE_INTUB, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdelConsLocal(), SCIPincConsAge(), SCIPinferBinvarCons(), SCIPinferVarLbCons(), SCIPinferVarUbCons(), SCIPinRepropagation(), SCIPisEQ(), SCIPisFeasEQ(), SCIPisFeasIntegral(), SCIPresetConsAge(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetUbLocal(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL(), and SCIP_DECL_CONSPROP().

static SCIP_RETCODE resolvePropagation ( SCIP scip,
SCIP_CONS cons,
SCIP_VAR infervar,
PROPRULE  proprule,
SCIP_BDCHGIDX bdchgidx,
SCIP_RESULT result 
)
static

resolves a conflict on the given variable by supplying the variables needed for applying the corresponding propagation rules (see propagateCons())

Parameters
scipSCIP data structure
consconstraint that inferred the bound change
infervarvariable that was deduced
proprulepropagation rule that deduced the value
bdchgidxbound change index (time stamp of bound change), or NULL for current time
resultpointer to store the result of the propagation conflict resolving call

Definition at line 2923 of file cons_xor.c.

References addConflictBounds(), NULL, SCIP_CALL, SCIP_OKAY, SCIP_SUCCESS, and SCIPdebugMessage.

Referenced by SCIP_DECL_CONSRESPROP().

static SCIP_RETCODE cliquePresolve ( SCIP scip,
SCIP_CONS cons,
int *  nfixedvars,
int *  nchgcoefs,
int *  ndelconss,
int *  naddconss,
SCIP_Bool cutoff 
)
static

try to use clique information to delete a part of the xor constraint or even fix variables

Parameters
scipSCIP data structure
consconstraint that inferred the bound change
nfixedvarspointer to add up the number of found domain reductions
nchgcoefspointer to add up the number of deleted entries
ndelconsspointer to add up the number of deleted constraints
naddconsspointer to add up the number of added constraints
cutoffpointer to store TRUE, if the node can be cut off

Definition at line 2944 of file cons_xor.c.

References FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIPaddCoefSetppc(), SCIPaddCons(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpart(), SCIPdebug, SCIPdebugMessage, SCIPdelCons(), SCIPfixVar(), SCIPgetNegatedVar(), SCIPprintCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarIsActive(), SCIPvarsHaveCommonClique(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE detectRedundantConstraints ( SCIP scip,
BMS_BLKMEM blkmem,
SCIP_CONS **  conss,
int  nconss,
int *  firstchange,
int *  nchgcoefs,
int *  ndelconss,
SCIP_Bool cutoff 
)
static

compares each constraint with all other constraints for possible redundancy and removes or changes constraint accordingly; in contrast to preprocessConstraintPairs(), it uses a hash table

Parameters
scipSCIP data structure
blkmemblock memory
conssconstraint set
nconssnumber of constraints in constraint set
firstchangepointer to store first changed constraint
nchgcoefspointer to add up the number of changed coefficients
ndelconsspointer to count number of deleted constraints
cutoffpointer to store TRUE, if a cutoff was found

Definition at line 3195 of file cons_xor.c.

References applyFixings(), consdataSort(), HASHSIZE_XORCONS, MAX, NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcHashtableSize(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetPos(), SCIPconshdlrGetData(), SCIPconsIsActive(), SCIPconsIsModifiable(), SCIPdelCons(), SCIPhashtableCreate(), SCIPhashtableFree(), SCIPhashtableInsert(), SCIPhashtableRetrieve(), SCIPupdateConsFlags(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE preprocessConstraintPairs ( SCIP scip,
SCIP_CONS **  conss,
int  firstchange,
int  chkind,
SCIP_Bool cutoff,
int *  nfixedvars,
int *  naggrvars,
int *  ndelconss,
int *  nchgcoefs 
)
static

compares constraint with all prior constraints for possible redundancy or aggregation, and removes or changes constraint accordingly

Parameters
scipSCIP data structure
conssconstraint set
firstchangefirst constraint that changed since last pair preprocessing round
chkindindex of constraint to check against all prior indices upto startind
cutoffpointer to store TRUE, if a cutoff was found
nfixedvarspointer to add up the number of found domain reductions
naggrvarspointer to count number of aggregated variables
ndelconsspointer to count number of deleted constraints
nchgcoefspointer to add up the number of changed coefficients

Definition at line 3306 of file cons_xor.c.

References addCoef(), applyFixings(), consdataSort(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPaggregateVars(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsActive(), SCIPconsIsModifiable(), SCIPdebugMessage, SCIPdebugPrintCons, SCIPdelCons(), SCIPdoNotAggr(), SCIPerrorMessage, SCIPfixVar(), SCIPisStopped(), SCIPvarCompareActiveAndNegated(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetProbvar(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

static SCIP_RETCODE createConsXorIntvar ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_Bool  rhs,
int  nvars,
SCIP_VAR **  vars,
SCIP_VAR intvar,
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 
)
static

creates and captures a xor constraint x_0 xor ... xor x_{k-1} = rhs with a given artificial integer variable for the linear relaxation

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
rhsright hand side of the constraint
nvarsnumber of operator variables in the constraint
varsarray with operator variables of constraint
intvarartificial integer variable for linear relaxation
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 3729 of file cons_xor.c.

References consdataCreate(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPcreateCons(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by SCIP_DECL_CONSCOPY().

static SCIP_DECL_CONSHDLRCOPY ( conshdlrCopyXor  )
static

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

Definition at line 3790 of file cons_xor.c.

References CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIPconshdlrGetName(), SCIPincludeConshdlrXor(), and TRUE.

static SCIP_DECL_CONSFREE ( consFreeXor  )
static

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

Definition at line 3806 of file cons_xor.c.

References conshdlrdataFree(), NULL, SCIP_CALL, SCIP_OKAY, SCIPconshdlrGetData(), and SCIPconshdlrSetData().

static SCIP_DECL_CONSEXITSOL ( consExitsolXor  )
static

solving process deinitialization method of constraint handler (called before branch and bound process data is freed)

Definition at line 3823 of file cons_xor.c.

References consdataFreeRows(), SCIP_CALL, SCIP_OKAY, and SCIPconsGetData().

static SCIP_DECL_CONSDELETE ( consDeleteXor  )
static

frees specific constraint data

Definition at line 3841 of file cons_xor.c.

References consdataFree(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPconshdlrGetData().

static SCIP_DECL_CONSTRANS ( consTransXor  )
static
static SCIP_DECL_CONSINITLP ( consInitlpXor  )
static

LP initialization method of constraint handler (called before the initial LP relaxation at a node is solved)

Definition at line 3882 of file cons_xor.c.

References addRelaxation(), SCIP_CALL, SCIP_OKAY, and SCIPconsIsInitial().

static SCIP_DECL_CONSSEPALP ( consSepalpXor  )
static

separation method of constraint handler for LP solutions

Definition at line 3898 of file cons_xor.c.

References NULL, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_DIDNOTFIND, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), and separateCons().

static SCIP_DECL_CONSSEPASOL ( consSepasolXor  )
static

separation method of constraint handler for arbitrary primal solutions

Definition at line 3929 of file cons_xor.c.

References NULL, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_DIDNOTFIND, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), and separateCons().

static SCIP_DECL_CONSENFOLP ( consEnfolpXor  )
static

constraint enforcing method of constraint handler for LP solutions

Definition at line 3960 of file cons_xor.c.

References checkCons(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_FEASIBLE, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), and separateCons().

static SCIP_DECL_CONSENFOPS ( consEnfopsXor  )
static

constraint enforcing method of constraint handler for pseudo solutions

Definition at line 3997 of file cons_xor.c.

References checkCons(), NULL, SCIP_Bool, SCIP_CALL, SCIP_FEASIBLE, SCIP_INFEASIBLE, SCIP_OKAY, and TRUE.

static SCIP_DECL_CONSCHECK ( consCheckXor  )
static

feasibility check method of constraint handler for integral solutions

Definition at line 4020 of file cons_xor.c.

References checkCons(), NULL, SCIP_Bool, SCIP_CALL, SCIP_FEASIBLE, SCIP_INFEASIBLE, SCIP_OKAY, SCIPconsGetData(), SCIPgetSolVal(), SCIPinfoMessage(), and SCIPprintCons().

static SCIP_DECL_CONSPROP ( consPropXor  )
static

domain propagation method of constraint handler

Definition at line 4063 of file cons_xor.c.

References checkSystemGF2(), FALSE, NULL, propagateCons(), SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_DIDNOTFIND, SCIP_OKAY, SCIP_REDUCEDDOM, SCIPconshdlrGetData(), SCIPgetDepth(), and SCIPinProbing().

static SCIP_DECL_CONSRESPROP ( consRespropXor  )
static

propagation conflict resolving method of constraint handler

Definition at line 4314 of file cons_xor.c.

References resolvePropagation(), SCIP_CALL, and SCIP_OKAY.

static SCIP_DECL_CONSLOCK ( consLockXor  )
static

variable rounding lock method of constraint handler

Definition at line 4324 of file cons_xor.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPaddVarLocks(), and SCIPconsGetData().

static SCIP_DECL_CONSPRINT ( consPrintXor  )
static

constraint display method of constraint handler

Definition at line 4350 of file cons_xor.c.

References consdataPrint(), FALSE, NULL, SCIP_CALL, SCIP_OKAY, and SCIPconsGetData().

static SCIP_DECL_CONSPARSE ( consParseXor  )
static
static SCIP_DECL_CONSGETVARS ( consGetVarsXor  )
static

constraint method of constraint handler which returns the variables (if possible)

Definition at line 4533 of file cons_xor.c.

References BMScopyMemoryArray, FALSE, NULL, SCIP_OKAY, SCIPconsGetData(), and TRUE.

static SCIP_DECL_CONSGETNVARS ( consGetNVarsXor  )
static

constraint method of constraint handler which returns the number of variable (if possible)

Definition at line 4575 of file cons_xor.c.

References NULL, SCIP_OKAY, SCIPconsGetData(), and TRUE.

static SCIP_DECL_EVENTEXEC ( eventExecXor  )
static

Definition at line 4599 of file cons_xor.c.

References FALSE, NULL, and SCIP_OKAY.

SCIP_RETCODE SCIPcreateConsXor ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_Bool  rhs,
int  nvars,
SCIP_VAR **  vars,
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 xor constraint x_0 xor ... xor x_{k-1} = rhs

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
rhsright hand side of the constraint
nvarsnumber of operator variables in the constraint
varsarray with operator variables of constraint
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 4699 of file cons_xor.c.

References consdataCreate(), CONSHDLR_NAME, NULL, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPcreateCons(), SCIPerrorMessage, and SCIPfindConshdlr().

Referenced by CREATE_CONSTRAINT(), SCIP_DECL_CONSPARSE(), SCIPcreateConsBasicXor(), and tryUpgradingXor().

SCIP_RETCODE SCIPcreateConsBasicXor ( SCIP scip,
SCIP_CONS **  cons,
const char *  name,
SCIP_Bool  rhs,
int  nvars,
SCIP_VAR **  vars 
)

creates and captures a xor constraint x_0 xor ... xor x_{k-1} = rhs with all constraint flags set to their default values

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
rhsright hand side of the constraint
nvarsnumber of operator variables in the constraint
varsarray with operator variables of constraint

Definition at line 4757 of file cons_xor.c.

References FALSE, SCIP_CALL, SCIP_OKAY, SCIPcreateConsXor(), and TRUE.

int SCIPgetNVarsXor ( SCIP scip,
SCIP_CONS cons 
)

gets number of variables in xor constraint

Parameters
scipSCIP data structure
consconstraint data

Definition at line 4773 of file cons_xor.c.

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

SCIP_VAR** SCIPgetVarsXor ( SCIP scip,
SCIP_CONS cons 
)

gets array of variables in xor constraint

Parameters
scipSCIP data structure
consconstraint data

Definition at line 4794 of file cons_xor.c.

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

SCIP_Bool SCIPgetRhsXor ( SCIP scip,
SCIP_CONS cons 
)

gets the right hand side of the xor constraint

Parameters
scipSCIP data structure
consconstraint data

Definition at line 4815 of file cons_xor.c.

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

Referenced by SCIP_DECL_CONSCOPY().