SCIP Doxygen Documentation
Loading...
Searching...
No Matches

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 "blockmemshell/memory.h"
#include "scip/cons_linear.h"
#include "scip/cons_setppc.h"
#include "scip/cons_xor.h"
#include "scip/debug.h"
#include "scip/heur_trysol.h"
#include "scip/pub_cons.h"
#include "scip/pub_event.h"
#include "scip/pub_lp.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include "scip/pub_misc_sort.h"
#include "scip/pub_var.h"
#include "scip/scip_conflict.h"
#include "scip/scip_cons.h"
#include "scip/scip_copy.h"
#include "scip/scip_cut.h"
#include "scip/scip_event.h"
#include "scip/scip_general.h"
#include "scip/scip_heur.h"
#include "scip/scip_lp.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_prob.h"
#include "scip/scip_probing.h"
#include "scip/scip_sol.h"
#include "scip/scip_tree.h"
#include "scip/scip_var.h"
#include "scip/symmetry_graph.h"
#include "symmetry/struct_symmetry.h"
#include <string.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_NEEDSCONS   TRUE
#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP
#define CONSHDLR_PRESOLTIMING   SCIP_PRESOLTIMING_ALWAYS
#define EVENTHDLR_NAME   "xor"
#define EVENTHDLR_DESC   "event handler for xor constraints"
#define LINCONSUPGD_PRIORITY   +600000
#define DEFAULT_PRESOLPAIRWISE   TRUE
#define DEFAULT_ADDEXTENDEDFORM   FALSE
#define DEFAULT_ADDFLOWEXTENDED   FALSE
#define DEFAULT_SEPARATEPARITY   FALSE
#define DEFAULT_GAUSSPROPFREQ   5
#define HASHSIZE_XORCONS   500
#define DEFAULT_PRESOLUSEHASHING   TRUE
#define NMINCOMPARISONS   200000
#define MINGAINPERNMINCOMPARISONS   1e-06
#define MAXXORCONSSSYSTEM   1000
#define MAXXORVARSSYSTEM   1000
#define NROWS   5

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 void 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 setIntvar (SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var)
static SCIP_RETCODE addCoef (SCIP *scip, SCIP_CONS *cons, 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, int *naggrvars, int *naddconss, SCIP_Bool *cutoff)
static SCIP_RETCODE addExtendedFlowFormulation (SCIP *scip, SCIP_CONS *cons, int *naggrvars, int *naddedconss)
static SCIP_RETCODE addExtendedAsymmetricFormulation (SCIP *scip, SCIP_CONS *cons, int *naggrvars, int *naddedconss)
static SCIP_RETCODE createRelaxation (SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE addRelaxation (SCIP *scip, SCIP_CONS *cons, SCIP_Bool *infeasible)
static SCIP_Bool allRowsInLP (SCIP_CONSDATA *consdata)
static SCIP_RETCODE checkCons (SCIP *scip, SCIP_CONS *cons, SCIP_SOL *sol, SCIP_Bool checklprows, SCIP_Bool printreason, 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 computeRowEchelonGF2 (SCIP *scip, int m, int n, int *p, int *s, Type **A, Type *b)
static void solveRowEchelonGF2 (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 *nfixedvars, int *naggrvars, int *ndelconss, int *naddconss, 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 *naddconss, 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_LINCONSUPGD (linconsUpgdXor)
static SCIP_RETCODE addSymmetryInformation (SCIP *scip, SYM_SYMTYPE symtype, SCIP_CONS *cons, SYM_GRAPH *graph, SCIP_Bool *success)
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_CONSENFORELAX (consEnforelaxXor)
static SCIP_DECL_CONSENFOPS (consEnfopsXor)
static SCIP_DECL_CONSCHECK (consCheckXor)
static SCIP_DECL_CONSPROP (consPropXor)
static SCIP_DECL_CONSINITPRE (consInitpreXor)
static SCIP_DECL_CONSEXITPRE (consExitpreXor)
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_CONSGETPERMSYMGRAPH (consGetPermsymGraphXor)
static SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH (consGetSignedPermsymGraphXor)
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_VARSCIPgetIntVarXor (SCIP *scip, SCIP_CONS *cons)
SCIP_Bool SCIPgetRhsXor (SCIP *scip, SCIP_CONS *cons)

Macro Definition Documentation

◆ CONSHDLR_NAME

#define CONSHDLR_NAME   "xor"

Definition at line 89 of file cons_xor.c.

◆ CONSHDLR_DESC

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

Definition at line 90 of file cons_xor.c.

◆ CONSHDLR_SEPAPRIORITY

#define CONSHDLR_SEPAPRIORITY   +850200

priority of the constraint handler for separation

Definition at line 91 of file cons_xor.c.

◆ CONSHDLR_ENFOPRIORITY

#define CONSHDLR_ENFOPRIORITY   -850200

priority of the constraint handler for constraint enforcing

Definition at line 92 of file cons_xor.c.

◆ CONSHDLR_CHECKPRIORITY

#define CONSHDLR_CHECKPRIORITY   -850200

priority of the constraint handler for checking feasibility

Definition at line 93 of file cons_xor.c.

◆ CONSHDLR_SEPAFREQ

#define CONSHDLR_SEPAFREQ   0

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

Definition at line 94 of file cons_xor.c.

◆ CONSHDLR_PROPFREQ

#define CONSHDLR_PROPFREQ   1

frequency for propagating domains; zero means only preprocessing propagation

Definition at line 95 of file cons_xor.c.

◆ CONSHDLR_EAGERFREQ

#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 96 of file cons_xor.c.

◆ CONSHDLR_MAXPREROUNDS

#define CONSHDLR_MAXPREROUNDS   -1

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

Definition at line 98 of file cons_xor.c.

◆ CONSHDLR_DELAYSEPA

#define CONSHDLR_DELAYSEPA   FALSE

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

Definition at line 99 of file cons_xor.c.

◆ CONSHDLR_DELAYPROP

#define CONSHDLR_DELAYPROP   FALSE

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

Definition at line 100 of file cons_xor.c.

◆ CONSHDLR_NEEDSCONS

#define CONSHDLR_NEEDSCONS   TRUE

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

Definition at line 101 of file cons_xor.c.

◆ CONSHDLR_PROP_TIMING

#define CONSHDLR_PROP_TIMING   SCIP_PROPTIMING_BEFORELP

Definition at line 103 of file cons_xor.c.

◆ CONSHDLR_PRESOLTIMING

#define CONSHDLR_PRESOLTIMING   SCIP_PRESOLTIMING_ALWAYS

Definition at line 104 of file cons_xor.c.

◆ EVENTHDLR_NAME

#define EVENTHDLR_NAME   "xor"

Definition at line 106 of file cons_xor.c.

◆ EVENTHDLR_DESC

#define EVENTHDLR_DESC   "event handler for xor constraints"

Definition at line 107 of file cons_xor.c.

◆ LINCONSUPGD_PRIORITY

#define LINCONSUPGD_PRIORITY   +600000

priority of the constraint handler for upgrading of linear constraints

Definition at line 109 of file cons_xor.c.

◆ DEFAULT_PRESOLPAIRWISE

#define DEFAULT_PRESOLPAIRWISE   TRUE

should pairwise constraint comparison be performed in presolving?

Definition at line 111 of file cons_xor.c.

◆ DEFAULT_ADDEXTENDEDFORM

#define DEFAULT_ADDEXTENDEDFORM   FALSE

should the extended formulation be added in presolving?

Definition at line 112 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

◆ DEFAULT_ADDFLOWEXTENDED

#define DEFAULT_ADDFLOWEXTENDED   FALSE

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

Definition at line 113 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

◆ DEFAULT_SEPARATEPARITY

#define DEFAULT_SEPARATEPARITY   FALSE

should parity inequalities be separated?

Definition at line 114 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

◆ DEFAULT_GAUSSPROPFREQ

#define DEFAULT_GAUSSPROPFREQ   5

frequency for applying the Gauss propagator

Definition at line 115 of file cons_xor.c.

Referenced by SCIPincludeConshdlrXor().

◆ HASHSIZE_XORCONS

#define HASHSIZE_XORCONS   500

minimal size of hash table in logicor constraint tables

Definition at line 116 of file cons_xor.c.

Referenced by detectRedundantConstraints().

◆ DEFAULT_PRESOLUSEHASHING

#define DEFAULT_PRESOLUSEHASHING   TRUE

should hash table be used for detecting redundant constraints in advance

Definition at line 117 of file cons_xor.c.

◆ NMINCOMPARISONS

#define NMINCOMPARISONS   200000

number for minimal pairwise presolving comparisons

Definition at line 118 of file cons_xor.c.

◆ MINGAINPERNMINCOMPARISONS

#define MINGAINPERNMINCOMPARISONS   1e-06

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

Definition at line 119 of file cons_xor.c.

◆ MAXXORCONSSSYSTEM

#define MAXXORCONSSSYSTEM   1000

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

Definition at line 120 of file cons_xor.c.

Referenced by checkSystemGF2().

◆ MAXXORVARSSYSTEM

#define MAXXORVARSSYSTEM   1000

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

Definition at line 121 of file cons_xor.c.

Referenced by checkSystemGF2().

◆ NROWS

#define NROWS   5

Typedef Documentation

◆ Type

typedef unsigned short Type

type used for matrix entries in function checkGauss()

Definition at line 131 of file cons_xor.c.

Enumeration Type Documentation

◆ Proprule

enum Proprule
Enumerator
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 172 of file cons_xor.c.

Function Documentation

◆ lockRounding()

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 189 of file cons_xor.c.

References assert(), SCIP_CALL, SCIP_LOCKTYPE_CONFLICT, SCIP_OKAY, SCIPconsIsLockedType(), SCIPlockVarCons(), TRUE, and var.

Referenced by addCoef(), createRelaxation(), and setIntvar().

◆ unlockRounding()

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 205 of file cons_xor.c.

References assert(), SCIP_CALL, SCIP_LOCKTYPE_CONFLICT, SCIP_OKAY, SCIPconsIsLockedType(), SCIPunlockVarCons(), TRUE, and var.

Referenced by delCoefPos(), and setIntvar().

◆ conshdlrdataCreate()

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 221 of file cons_xor.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocBlockMemory.

Referenced by SCIPincludeConshdlrXor().

◆ conshdlrdataFree()

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

frees constraint handler data

Parameters
scipSCIP data structure
conshdlrdatapointer to the constraint handler data

Definition at line 241 of file cons_xor.c.

References assert(), NULL, and SCIPfreeBlockMemory.

Referenced by SCIP_DECL_CONSFREE().

◆ consdataSwitchWatchedvars()

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 254 of file cons_xor.c.

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

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

◆ consdataEnsureVarsSize()

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 318 of file cons_xor.c.

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

Referenced by addCoef().

◆ consdataCreate()

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 342 of file cons_xor.c.

References assert(), CONSHDLR_NAME, FALSE, NROWS, NULL, nvars, r, SCIP_Bool, SCIP_CALL, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, SCIP_STAGE_PRESOLVING, SCIPallocBlockMemory, SCIPcaptureVar(), SCIPcatchVarEvent(), SCIPconshdlrGetData(), SCIPduplicateBlockMemoryArray, SCIPfindConshdlr(), SCIPgetStage(), SCIPgetTransformedVar(), SCIPgetTransformedVars(), SCIPisTransformed(), TRUE, and vars.

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

◆ consdataFreeRows()

SCIP_RETCODE consdataFreeRows ( SCIP * scip,
SCIP_CONSDATA * consdata )
static

releases LP row of constraint data

Parameters
scipSCIP data structure
consdataconstraint data

Definition at line 417 of file cons_xor.c.

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

Referenced by consdataFree(), and SCIP_DECL_CONSEXITSOL().

◆ consdataFree()

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 439 of file cons_xor.c.

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

Referenced by SCIP_DECL_CONSDELETE().

◆ consdataPrint()

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 500 of file cons_xor.c.

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

Referenced by applyFixings(), and SCIP_DECL_CONSPRINT().

◆ setIntvar()

SCIP_RETCODE setIntvar ( SCIP * scip,
SCIP_CONS * cons,
SCIP_VAR * var )
static

sets intvar of an xor constraint

Parameters
scipSCIP data structure
consxor constraint
varvariable to add to the constraint

Definition at line 534 of file cons_xor.c.

References assert(), lockRounding(), NULL, SCIP_Bool, SCIP_CALL, SCIP_INVALIDCALL, SCIP_OKAY, SCIPcaptureVar(), SCIPconsGetData(), SCIPconsIsTransformed(), SCIPerrorMessage, SCIPgetTransformedVar(), SCIPreleaseVar(), SCIPvarIsTransformed(), TRUE, unlockRounding(), and var.

Referenced by applyFixings(), and preprocessConstraintPairs().

◆ addCoef()

◆ delCoefPos()

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 652 of file cons_xor.c.

References assert(), consdataSwitchWatchedvars(), FALSE, NULL, nvars, SCIP_CALL, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, SCIP_STAGE_EXITPRESOLVE, SCIP_STAGE_INITPRESOLVE, SCIP_STAGE_PRESOLVING, SCIPconsGetData(), SCIPconsIsTransformed(), SCIPdropVarEvent(), SCIPgetStage(), SCIPvarIsTransformed(), TRUE, and unlockRounding().

Referenced by applyFixings().

◆ consdataSort()

void consdataSort ( SCIP_CONSDATA * consdata)
static

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

Parameters
consdataconstraint data

Definition at line 713 of file cons_xor.c.

References assert(), NULL, SCIPsortPtr(), SCIPvarCompareActiveAndNegated(), and TRUE.

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

◆ SCIP_DECL_HASHGETKEY()

SCIP_DECL_HASHGETKEY ( hashGetKeyXorcons )
static

gets the key of the given element

Definition at line 797 of file cons_xor.c.

◆ SCIP_DECL_HASHKEYEQ()

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 805 of file cons_xor.c.

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

◆ SCIP_DECL_HASHKEYVAL()

SCIP_DECL_HASHKEYVAL ( hashKeyValXorcons )
static

◆ applyFixings()

SCIP_RETCODE applyFixings ( SCIP * scip,
SCIP_CONS * cons,
SCIP_EVENTHDLR * eventhdlr,
int * nchgcoefs,
int * naggrvars,
int * naddconss,
SCIP_Bool * cutoff )
static

◆ addExtendedFlowFormulation()

SCIP_RETCODE addExtendedFlowFormulation ( SCIP * scip,
SCIP_CONS * cons,
int * naggrvars,
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
naggrvarspointer to add up the number of aggregated variables
naddedconssnumber of added constraints

Definition at line 1152 of file cons_xor.c.

References assert(), FALSE, i, 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(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPlockVarCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarIsTransformed(), TRUE, and vars.

Referenced by SCIP_DECL_CONSPRESOL().

◆ addExtendedAsymmetricFormulation()

SCIP_RETCODE addExtendedAsymmetricFormulation ( SCIP * scip,
SCIP_CONS * cons,
int * naggrvars,
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
naggrvarspointer to add up the number of aggregated variables
naddedconssnumber of added constraints

Definition at line 1461 of file cons_xor.c.

References assert(), FALSE, i, 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(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPinfinity(), SCIPlockVarCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarIsTransformed(), TRUE, and vars.

Referenced by SCIP_DECL_CONSPRESOL().

◆ createRelaxation()

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 1642 of file cons_xor.c.

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

Referenced by addRelaxation(), and separateCons().

◆ addRelaxation()

SCIP_RETCODE addRelaxation ( SCIP * scip,
SCIP_CONS * cons,
SCIP_Bool * infeasible )
static

adds linear relaxation of or constraint to the LP

Parameters
scipSCIP data structure
consconstraint to check
infeasiblepointer to store whether infeasibility was detected

Definition at line 1775 of file cons_xor.c.

References assert(), createRelaxation(), FALSE, NROWS, NULL, r, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPaddRow(), SCIPconsGetData(), and SCIProwIsInLP().

Referenced by SCIP_DECL_CONSINITLP().

◆ allRowsInLP()

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 1807 of file cons_xor.c.

References assert(), FALSE, NROWS, NULL, r, SCIP_Bool, SCIProwIsInLP(), and TRUE.

Referenced by checkCons().

◆ checkCons()

SCIP_RETCODE checkCons ( SCIP * scip,
SCIP_CONS * cons,
SCIP_SOL * sol,
SCIP_Bool checklprows,
SCIP_Bool printreason,
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
checklprowsDo constraints represented by rows in the current LP have to be checked?
printreasonShould the reason for the violation be printed?
violatedpointer to store whether the constraint is violated

Definition at line 1829 of file cons_xor.c.

References allRowsInLP(), assert(), FALSE, i, MAX, NULL, REALABS, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPconsGetData(), SCIPgetSolVal(), SCIPincConsAge(), SCIPinfoMessage(), SCIPisFeasPositive(), SCIPprintCons(), SCIPresetConsAge(), SCIPupdateSolConsViolation(), sol, and TRUE.

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

◆ separateCons()

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 1975 of file cons_xor.c.

References assert(), createRelaxation(), cutoff, FALSE, NROWS, NULL, r, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPaddRow(), SCIPaddVarToRow(), SCIPcacheRowExtensions(), SCIPconsGetData(), SCIPconsGetName(), SCIPcreateEmptyRowCons(), SCIPdebug, SCIPdebugMsg, SCIPflushRowExtensions(), SCIPgetRowLPActivity(), SCIPgetRowSolFeasibility(), SCIPgetSolVal(), SCIPinfinity(), SCIPisEfficacious(), SCIPisFeasNegative(), SCIPisGT(), SCIPprintRow(), SCIPreleaseRow(), SCIProwIsInLP(), SCIPsnprintf(), sol, and TRUE.

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

◆ computeRowEchelonGF2()

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

Transform linear system \(A x = b\) into row echelon 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 echelon form
Amatrix
brhs

Definition at line 2188 of file cons_xor.c.

References assert(), b, h, i, NULL, and SCIPisStopped().

Referenced by checkSystemGF2().

◆ solveRowEchelonGF2()

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

Construct solution from matrix in row echelon form over GF2

Compute solution of \(A x = b\), which is already in row echelon form (

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

Definition at line 2297 of file cons_xor.c.

References assert(), b, i, NULL, r, and x.

Referenced by checkSystemGF2().

◆ checkSystemGF2()

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 echelon 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 echelon 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 2358 of file cons_xor.c.

References assert(), b, BMSclearMemoryArray, computeRowEchelonGF2(), FALSE, i, MAXXORCONSSSYSTEM, MAXXORVARSSYSTEM, NULL, nvars, result, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_FIXED, SCIP_VARSTATUS_MULTAGGR, SCIPallocBufferArray, SCIPblkmem(), SCIPcheckSol(), SCIPcomputeVarLbLocal(), SCIPcomputeVarUbLocal(), SCIPconsGetData(), SCIPconsGetName(), SCIPcreateSol(), SCIPdebug, SCIPdebugMsg, SCIPfindHeur(), SCIPfreeBufferArray, SCIPfreeSol(), SCIPgetNVars(), SCIPgetSolVal(), SCIPgetVars(), SCIPhashmapCreate(), SCIPhashmapExists(), SCIPhashmapFree(), SCIPhashmapGetImageInt(), SCIPhashmapInsertInt(), SCIPheurPassSolAddSol(), SCIPinfoMessage(), SCIPisEQ(), SCIPisGE(), SCIPisLE(), SCIPisStopped(), SCIPprintSol(), SCIPsetSolVal(), SCIPsortRealIntPtr(), SCIPtightenVarLb(), SCIPtightenVarUb(), SCIPvarGetAggrConstant(), SCIPvarGetAggrScalar(), SCIPvarGetAggrVar(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetObj(), SCIPvarGetStatus(), SCIPvarGetUbGlobal(), SCIPvarIsActive(), SCIPvarIsBinary(), SCIPvarIsNegated(), sol, solveRowEchelonGF2(), TRUE, var, vars, and x.

Referenced by SCIP_DECL_CONSPROP().

◆ addConflictBounds()

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 2844 of file cons_xor.c.

References assert(), FALSE, i, NULL, nvars, PROPRULE_0, PROPRULE_1, PROPRULE_INTLB, PROPRULE_INTUB, PROPRULE_INVALID, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIPABORT, SCIPaddConflictBinvar(), SCIPaddConflictLb(), SCIPaddConflictUb(), SCIPconsGetData(), SCIPconsGetName(), SCIPerrorMessage, SCIPgetVarLbAtIndex(), SCIPgetVarUbAtIndex(), SCIPisEQ(), TRUE, and vars.

Referenced by analyzeConflict(), and resolvePropagation().

◆ analyzeConflict()

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 2952 of file cons_xor.c.

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

Referenced by propagateCons().

◆ propagateCons()

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 2983 of file cons_xor.c.

References analyzeConflict(), assert(), consdataSwitchWatchedvars(), cutoff, FALSE, i, NULL, nvars, PROPRULE_0, PROPRULE_1, PROPRULE_INTLB, PROPRULE_INTUB, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_MULTAGGR, SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsModifiable(), SCIPdebugMsg, SCIPdelConsLocal(), SCIPincConsAge(), SCIPinferBinvarCons(), SCIPinferVarLbCons(), SCIPinferVarUbCons(), SCIPinRepropagation(), SCIPisEQ(), SCIPisFeasEQ(), SCIPisFeasIntegral(), SCIPresetConsAge(), SCIPvarGetLbLocal(), SCIPvarGetName(), SCIPvarGetStatus(), SCIPvarGetUbLocal(), TRUE, and vars.

Referenced by SCIP_DECL_CONSPRESOL(), and SCIP_DECL_CONSPROP().

◆ resolvePropagation()

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 3404 of file cons_xor.c.

References addConflictBounds(), assert(), NULL, result, SCIP_CALL, SCIP_OKAY, SCIP_SUCCESS, and SCIPdebugMsg.

Referenced by SCIP_DECL_CONSRESPROP().

◆ cliquePresolve()

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 3425 of file cons_xor.c.

References assert(), cutoff, FALSE, NULL, nvars, SCIP_Bool, SCIP_CALL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_VARSTATUS_FIXED, SCIP_VARSTATUS_NEGATED, SCIPaddCoefSetppc(), SCIPaddCons(), SCIPconsGetData(), SCIPconsGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsSetpart(), SCIPdebug, SCIPdebugMsg, SCIPdelCons(), SCIPfixVar(), SCIPgetNegatedVar(), SCIPprintCons(), SCIPreleaseCons(), SCIPsnprintf(), SCIPvarGetName(), SCIPvarGetNegationVar(), SCIPvarGetStatus(), SCIPvarIsActive(), SCIPvarsHaveCommonClique(), TRUE, var, and vars.

Referenced by SCIP_DECL_CONSPRESOL().

◆ detectRedundantConstraints()

SCIP_RETCODE detectRedundantConstraints ( SCIP * scip,
BMS_BLKMEM * blkmem,
SCIP_CONS ** conss,
int nconss,
int * firstchange,
int * nchgcoefs,
int * nfixedvars,
int * naggrvars,
int * ndelconss,
int * naddconss,
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
nfixedvarspointer to add up the number of found domain reductions
naggrvarspointer to add up the number of aggregated variables
ndelconsspointer to count number of deleted constraints
naddconsspointer to count number of added constraints
cutoffpointer to store TRUE, if a cutoff was found

Definition at line 3719 of file cons_xor.c.

References applyFixings(), assert(), c, consdataSort(), cutoff, HASHSIZE_XORCONS, MAX, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPaggregateVars(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetPos(), SCIPconshdlrGetData(), SCIPconsIsActive(), SCIPconsIsModifiable(), SCIPdelCons(), SCIPfixVar(), SCIPhashtableCreate(), SCIPhashtableFree(), SCIPhashtableInsert(), SCIPhashtableRetrieve(), SCIPswapPointers(), SCIPupdateConsFlags(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

◆ preprocessConstraintPairs()

SCIP_RETCODE preprocessConstraintPairs ( SCIP * scip,
SCIP_CONS ** conss,
int firstchange,
int chkind,
SCIP_Bool * cutoff,
int * nfixedvars,
int * naggrvars,
int * ndelconss,
int * naddconss,
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
naddconsspointer to count number of added constraints
nchgcoefspointer to add up the number of changed coefficients

Definition at line 3916 of file cons_xor.c.

References addCoef(), applyFixings(), assert(), c, consdataSort(), cutoff, FALSE, NULL, nvars, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIPABORT, SCIPaddCons(), SCIPaggregateVars(), SCIPconsGetData(), SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetData(), SCIPconsIsActive(), SCIPconsIsDynamic(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateConsLinear(), SCIPdebugMsg, SCIPdebugPrintCons, SCIPdelCons(), SCIPdoNotAggr(), SCIPerrorMessage, SCIPfixVar(), SCIPisStopped(), SCIPreleaseCons(), SCIPsnprintf(), SCIPupdateConsFlags(), SCIPvarCompareActiveAndNegated(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetProbvar(), SCIPvarIsActive(), setIntvar(), and TRUE.

Referenced by SCIP_DECL_CONSPRESOL().

◆ createConsXorIntvar()

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 4497 of file cons_xor.c.

References consdataCreate(), CONSHDLR_NAME, NULL, nvars, propagate, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_PLUGINNOTFOUND, SCIPcreateCons(), SCIPerrorMessage, SCIPfindConshdlr(), and vars.

Referenced by SCIP_DECL_CONSCOPY(), SCIP_DECL_CONSPARSE(), and SCIP_DECL_LINCONSUPGD().

◆ SCIP_DECL_LINCONSUPGD()

SCIP_DECL_LINCONSUPGD ( linconsUpgdXor )
static

tries to upgrade a linear constraint into an xor constraint

Assuming all variables are binary and have coefficients with an absolute value 1, except for an integer (or binary) variable \(z\) which has coefficient \(a \in \{-2,2\}\) with absolute value 2 and appears only in this constraint, we can transform:

\[ \begin{array}{ll} & -\sum_{i \in I} x_i + \sum_{j \in J} x_j + a \cdot z = r \\ \Leftrightarrow & \sum_{i \in I} \bar{x}_i + \sum_{j \in J} x_j + a \cdot z = r + |I| \\ \Leftrightarrow & \sum_{i \in I} \bar{x}_i + \sum_{j \in J} x_j - 2 \cdot y = (r + |I|) \text{ mod } 2, \end{array} \]

where

\[ y = \begin{cases} \left\lfloor \frac{r + |I|}{2} \right\rfloor + z & \text{if }a = -2\\ \left\lfloor \frac{r + |I|}{2} \right\rfloor - z & \text{if }a = 2. \end{cases} \]

If \(a = -2\) and \(z \in [\ell_z, u_z]\), then \(y \in [\ell_y, u_y]\), where \(\ell_y = \left\lfloor \frac{r + |I|}{2} \right\rfloor + \ell_z\) and \(u_y = \left\lfloor \frac{r + |I|}{2} \right\rfloor + u_z\).

If \(a = 2\), then \(\ell_y = \left\lfloor \frac{r + |I|}{2} \right\rfloor - u_z\) and \(u_y = \left\lfloor \frac{r + |I|}{2} \right\rfloor - \ell_z\).

Then consider the resulting XOR-constraint

\[ \bigoplus_{i \in I} \bar{x}_i \oplus \bigoplus_{j \in j} x_j = (r + |I|) \text{ mod } 2. \]

If \(\ell_y \leq 0\) and \(u_y \geq (|I| + |J|)/2\), then the XOR constraint is a reformulation of the above transformed constraint, otherwise it is a relaxation because the bounds on the \(y\)-variable may disallow too many (or too few) operators set to 1. Therefore, the XOR constraint handler verifies in this case that the linear equation holds, ie., that the \(y\)-variable has the correct value.

Definition at line 4592 of file cons_xor.c.

References assert(), createConsXorIntvar(), FALSE, NULL, nvars, REALABS, SCIP_Bool, SCIP_CALL, SCIP_LOCKTYPE_MODEL, SCIP_MAXSTRLEN, SCIP_OKAY, SCIP_Real, SCIP_VARSTATUS_AGGREGATED, SCIP_VARSTATUS_NEGATED, SCIP_VARTYPE_BINARY, SCIP_VARTYPE_INTEGER, SCIPaddVar(), SCIPaggregateVars(), SCIPallocBufferArray, SCIPconsGetHdlr(), SCIPconsGetName(), SCIPconshdlrGetName(), SCIPconsIsChecked(), SCIPconsIsDynamic(), SCIPconsIsEnforced(), SCIPconsIsInitial(), SCIPconsIsLocal(), SCIPconsIsModifiable(), SCIPconsIsPropagated(), SCIPconsIsRemovable(), SCIPconsIsSeparated(), SCIPconsIsStickingAtNode(), SCIPcreateVar(), SCIPdebug, SCIPdebugMsg, SCIPdebugPrintCons, SCIPfeasFloor(), SCIPfloor(), SCIPfreeBufferArray, SCIPgetNegatedVar(), SCIPisEQ(), SCIPisFeasIntegral(), SCIPisFeasLE(), SCIPisIntegral(), SCIPisZero(), SCIPprintVar(), SCIPreleaseVar(), SCIPsnprintf(), SCIPvarGetAggrConstant(), SCIPvarGetAggrScalar(), SCIPvarGetAggrVar(), SCIPvarGetLbGlobal(), SCIPvarGetName(), SCIPvarGetNegatedVar(), SCIPvarGetNLocksDownType(), SCIPvarGetNLocksUpType(), SCIPvarGetStatus(), SCIPvarGetUbGlobal(), SCIPvarIsActive(), SCIPvarIsBinary(), SCIPvarIsInitial(), SCIPvarIsRemovable(), TRUE, and vars.

◆ addSymmetryInformation()

SCIP_RETCODE addSymmetryInformation ( SCIP * scip,
SYM_SYMTYPE symtype,
SCIP_CONS * cons,
SYM_GRAPH * graph,
SCIP_Bool * success )
static

adds symmetry information of constraint to a symmetry detection graph

Parameters
scipSCIP pointer
symtypetype of symmetries that need to be added
consconstraint
graphsymmetry detection graph
successpointer to store whether symmetry information could be added

Definition at line 4785 of file cons_xor.c.

References assert(), FALSE, i, MAX, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPaddSymgraphConsnode(), SCIPaddSymgraphEdge(), SCIPaddSymgraphOpnode(), SCIPaddSymgraphVarAggregation(), SCIPallocBufferArray, SCIPconsGetData(), SCIPfreeBufferArray, SCIPgetRhsXor(), SCIPgetSymActiveVariables(), SCIPisTransformed(), SYM_CONSOPTYPE_XORINT, TRUE, and vars.

Referenced by SCIP_DECL_CONSGETPERMSYMGRAPH(), and SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH().

◆ SCIP_DECL_CONSHDLRCOPY()

SCIP_DECL_CONSHDLRCOPY ( conshdlrCopyXor )
static

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

Definition at line 4861 of file cons_xor.c.

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

◆ SCIP_DECL_CONSFREE()

SCIP_DECL_CONSFREE ( consFreeXor )
static

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

Definition at line 4877 of file cons_xor.c.

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

◆ SCIP_DECL_CONSEXITSOL()

SCIP_DECL_CONSEXITSOL ( consExitsolXor )
static

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

Definition at line 4894 of file cons_xor.c.

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

◆ SCIP_DECL_CONSDELETE()

SCIP_DECL_CONSDELETE ( consDeleteXor )
static

◆ SCIP_DECL_CONSTRANS()

◆ SCIP_DECL_CONSINITLP()

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 4964 of file cons_xor.c.

References addRelaxation(), assert(), FALSE, i, NULL, SCIP_CALL, SCIP_OKAY, and SCIPconsIsInitial().

◆ SCIP_DECL_CONSSEPALP()

SCIP_DECL_CONSSEPALP ( consSepalpXor )
static

separation method of constraint handler for LP solutions

Definition at line 4984 of file cons_xor.c.

References assert(), c, cutoff, NULL, result, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_DIDNOTFIND, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), and separateCons().

◆ SCIP_DECL_CONSSEPASOL()

SCIP_DECL_CONSSEPASOL ( consSepasolXor )
static

separation method of constraint handler for arbitrary primal solutions

Definition at line 5015 of file cons_xor.c.

References assert(), c, cutoff, NULL, result, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_DIDNOTFIND, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), separateCons(), and sol.

◆ SCIP_DECL_CONSENFOLP()

SCIP_DECL_CONSENFOLP ( consEnfolpXor )
static

constraint enforcing method of constraint handler for LP solutions

Definition at line 5046 of file cons_xor.c.

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

◆ SCIP_DECL_CONSENFORELAX()

SCIP_DECL_CONSENFORELAX ( consEnforelaxXor )
static

constraint enforcing method of constraint handler for relaxation solutions

Definition at line 5083 of file cons_xor.c.

References assert(), checkCons(), cutoff, FALSE, i, NULL, result, SCIP_Bool, SCIP_CALL, SCIP_CUTOFF, SCIP_FEASIBLE, SCIP_OKAY, SCIP_SEPARATED, SCIPconshdlrGetData(), separateCons(), and sol.

◆ SCIP_DECL_CONSENFOPS()

SCIP_DECL_CONSENFOPS ( consEnfopsXor )
static

constraint enforcing method of constraint handler for pseudo solutions

Definition at line 5120 of file cons_xor.c.

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

◆ SCIP_DECL_CONSCHECK()

SCIP_DECL_CONSCHECK ( consCheckXor )
static

feasibility check method of constraint handler xor

Definition at line 5142 of file cons_xor.c.

References checkCons(), i, result, SCIP_Bool, SCIP_CALL, SCIP_FEASIBLE, SCIP_INFEASIBLE, SCIP_OKAY, and sol.

◆ SCIP_DECL_CONSPROP()

SCIP_DECL_CONSPROP ( consPropXor )
static

◆ SCIP_DECL_CONSINITPRE()

SCIP_DECL_CONSINITPRE ( consInitpreXor )
static

presolving initialization method of constraint handler (called when presolving is about to begin)

Definition at line 5210 of file cons_xor.c.

References assert(), c, NULL, SCIP_CALL, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, SCIPcatchVarEvent(), SCIPconsGetData(), and SCIPconshdlrGetData().

◆ SCIP_DECL_CONSEXITPRE()

SCIP_DECL_CONSEXITPRE ( consExitpreXor )
static

presolving deinitialization method of constraint handler (called after presolving has been finished)

Definition at line 5239 of file cons_xor.c.

References assert(), c, NULL, SCIP_CALL, SCIP_EVENTTYPE_VARFIXED, SCIP_OKAY, SCIPconsGetData(), SCIPconshdlrGetData(), SCIPconsIsDeleted(), and SCIPdropVarEvent().

◆ SCIP_DECL_CONSPRESOL()

◆ SCIP_DECL_CONSRESPROP()

SCIP_DECL_CONSRESPROP ( consRespropXor )
static

propagation conflict resolving method of constraint handler

Definition at line 5485 of file cons_xor.c.

References resolvePropagation(), result, SCIP_CALL, and SCIP_OKAY.

◆ SCIP_DECL_CONSLOCK()

SCIP_DECL_CONSLOCK ( consLockXor )
static

variable rounding lock method of constraint handler

Definition at line 5495 of file cons_xor.c.

References assert(), i, NULL, SCIP_CALL, SCIP_LOCKTYPE_MODEL, SCIP_OKAY, SCIPaddVarLocksType(), and SCIPconsGetData().

◆ SCIP_DECL_CONSPRINT()

SCIP_DECL_CONSPRINT ( consPrintXor )
static

constraint display method of constraint handler

Definition at line 5523 of file cons_xor.c.

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

◆ SCIP_DECL_CONSCOPY()

◆ SCIP_DECL_CONSPARSE()

◆ SCIP_DECL_CONSGETVARS()

SCIP_DECL_CONSGETVARS ( consGetVarsXor )
static

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

Definition at line 5759 of file cons_xor.c.

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

◆ SCIP_DECL_CONSGETNVARS()

SCIP_DECL_CONSGETNVARS ( consGetNVarsXor )
static

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

Definition at line 5801 of file cons_xor.c.

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

◆ SCIP_DECL_CONSGETPERMSYMGRAPH()

SCIP_DECL_CONSGETPERMSYMGRAPH ( consGetPermsymGraphXor )
static

constraint handler method which returns the permutation symmetry detection graph of a constraint

Definition at line 5822 of file cons_xor.c.

References addSymmetryInformation(), SCIP_CALL, SCIP_OKAY, and SYM_SYMTYPE_PERM.

◆ SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH()

SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH ( consGetSignedPermsymGraphXor )
static

constraint handler method which returns the signed permutation symmetry detection graph of a constraint

Definition at line 5831 of file cons_xor.c.

References addSymmetryInformation(), SCIP_CALL, SCIP_OKAY, and SYM_SYMTYPE_SIGNPERM.

◆ SCIP_DECL_EVENTEXEC()

SCIP_DECL_EVENTEXEC ( eventExecXor )
static