@@ -4501,7 +4501,7 @@ SCIP_RETCODE createConsXorIntvar(
45014501 SCIP_Bool rhs , /**< right hand side of the constraint */
45024502 int nvars , /**< number of operator variables in the constraint */
45034503 SCIP_VAR * * vars , /**< array with operator variables of constraint */
4504- SCIP_VAR * intvar , /**< artificial integer variable for linear relaxation */
4504+ SCIP_VAR * intvar , /**< integer variable for linear relaxation or NULL if artificial */
45054505 SCIP_Bool initial , /**< should the LP relaxation of constraint be in the initial LP?
45064506 * Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
45074507 SCIP_Bool separate , /**< should the constraint be separated during LP processing?
@@ -4529,6 +4529,8 @@ SCIP_RETCODE createConsXorIntvar(
45294529{
45304530 SCIP_CONSHDLR * conshdlr ;
45314531 SCIP_CONSDATA * consdata ;
4532+ SCIP_VARTYPE intvartype ;
4533+ int i ;
45324534
45334535 /* find the xor constraint handler */
45344536 conshdlr = SCIPfindConshdlr (scip , CONSHDLR_NAME );
@@ -4538,6 +4540,28 @@ SCIP_RETCODE createConsXorIntvar(
45384540 return SCIP_PLUGINNOTFOUND ;
45394541 }
45404542
4543+ /* check whether int variable is integral */
4544+ if ( intvar != NULL )
4545+ {
4546+ intvartype = SCIPvarGetType (intvar );
4547+
4548+ if ( intvartype != SCIP_VARTYPE_BINARY && intvartype != SCIP_VARTYPE_INTEGER )
4549+ {
4550+ SCIPerrorMessage ("intvar <%s> is not enforced integral\n" , SCIPvarGetName (intvar ));
4551+ return SCIP_INVALIDDATA ;
4552+ }
4553+ }
4554+
4555+ /* check whether all variables are binary */
4556+ for ( i = 0 ; i < nvars ; ++ i )
4557+ {
4558+ if ( !SCIPvarIsBinary (vars [i ]) )
4559+ {
4560+ SCIPerrorMessage ("operand <%s> is not binary\n" , SCIPvarGetName (vars [i ]));
4561+ return SCIP_INVALIDDATA ;
4562+ }
4563+ }
4564+
45414565 /* create constraint data */
45424566 SCIP_CALL ( consdataCreate (scip , & consdata , rhs , nvars , vars , intvar ) );
45434567
@@ -4608,6 +4632,7 @@ SCIP_DECL_LINCONSUPGD(linconsUpgdXor)
46084632 {
46094633 SCIP_VAR * * xorvars ;
46104634 SCIP_VAR * parityvar = NULL ;
4635+ SCIP_VARTYPE parityvartype ;
46114636 SCIP_Bool postwo = FALSE;
46124637 int cnt = 0 ;
46134638 int j ;
@@ -4620,6 +4645,15 @@ SCIP_DECL_LINCONSUPGD(linconsUpgdXor)
46204645 if ( SCIPisEQ (scip , REALABS (vals [j ]), 2.0 ) )
46214646 {
46224647 parityvar = vars [j ];
4648+ parityvartype = SCIPvarGetType (parityvar );
4649+
4650+ /* parity variable requires enforced integrality */
4651+ if ( parityvartype != SCIP_VARTYPE_BINARY && parityvartype != SCIP_VARTYPE_INTEGER )
4652+ {
4653+ parityvar = NULL ;
4654+ break ;
4655+ }
4656+
46234657 postwo = (vals [j ] > 0.0 );
46244658 }
46254659 else if ( !SCIPisEQ (scip , REALABS (vals [j ]), 1.0 ) )
@@ -5994,6 +6028,7 @@ SCIP_RETCODE SCIPcreateConsXor(
59946028{
59956029 SCIP_CONSHDLR * conshdlr ;
59966030 SCIP_CONSDATA * consdata ;
6031+ int i ;
59976032
59986033 /* find the xor constraint handler */
59996034 conshdlr = SCIPfindConshdlr (scip , CONSHDLR_NAME );
@@ -6003,6 +6038,16 @@ SCIP_RETCODE SCIPcreateConsXor(
60036038 return SCIP_PLUGINNOTFOUND ;
60046039 }
60056040
6041+ /* check whether all variables are binary */
6042+ for ( i = 0 ; i < nvars ; ++ i )
6043+ {
6044+ if ( !SCIPvarIsBinary (vars [i ]) )
6045+ {
6046+ SCIPerrorMessage ("operand <%s> is not binary\n" , SCIPvarGetName (vars [i ]));
6047+ return SCIP_INVALIDDATA ;
6048+ }
6049+ }
6050+
60066051 /* create constraint data */
60076052 SCIP_CALL ( consdataCreate (scip , & consdata , rhs , nvars , vars , NULL ) );
60086053
0 commit comments