Skip to content

Commit b807e20

Browse files
committed
Merge remote-tracking branch 'origin/v92-bugfix' into v9-minor
2 parents 9579481 + 4f1b2d9 commit b807e20

File tree

6 files changed

+105
-1
lines changed

6 files changed

+105
-1
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Fixed bugs
4949
----------
5050

5151
- avoid hashmap key error in removal of doubletons and singletons in dual presolve of setppc constraints by skipping tripleton locks
52+
- when upgrading to xor constraint require parity variable to be enforced integral
5253

5354
Build system
5455
------------

src/scip/cons_and.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,6 +5115,7 @@ SCIP_RETCODE SCIPcreateConsAnd(
51155115
SCIP_CONSHDLRDATA* conshdlrdata;
51165116
SCIP_CONSDATA* consdata;
51175117
SCIP_Bool infeasible;
5118+
int i;
51185119

51195120
/* find the AND-constraint handler */
51205121
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
@@ -5124,6 +5125,23 @@ SCIP_RETCODE SCIPcreateConsAnd(
51245125
return SCIP_PLUGINNOTFOUND;
51255126
}
51265127

5128+
/* check whether resultant variable is binary */
5129+
if( !SCIPvarIsBinary(resvar) )
5130+
{
5131+
SCIPerrorMessage("resultant <%s> is not binary\n", SCIPvarGetName(resvar));
5132+
return SCIP_INVALIDDATA;
5133+
}
5134+
5135+
/* check whether all variables are binary */
5136+
for( i = 0; i < nvars; ++i )
5137+
{
5138+
if( !SCIPvarIsBinary(vars[i]) )
5139+
{
5140+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
5141+
return SCIP_INVALIDDATA;
5142+
}
5143+
}
5144+
51275145
conshdlrdata = SCIPconshdlrGetData(conshdlr);
51285146
assert(conshdlrdata != NULL);
51295147

src/scip/cons_logicor.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5445,6 +5445,7 @@ SCIP_RETCODE SCIPcreateConsLogicor(
54455445
{
54465446
SCIP_CONSHDLR* conshdlr;
54475447
SCIP_CONSDATA* consdata;
5448+
int i;
54485449

54495450
assert(scip != NULL);
54505451

@@ -5456,6 +5457,16 @@ SCIP_RETCODE SCIPcreateConsLogicor(
54565457
return SCIP_INVALIDCALL;
54575458
}
54585459

5460+
/* check whether all variables are binary */
5461+
for( i = 0; i < nvars; ++i )
5462+
{
5463+
if( !SCIPvarIsBinary(vars[i]) )
5464+
{
5465+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
5466+
return SCIP_INVALIDDATA;
5467+
}
5468+
}
5469+
54595470
/* create the constraint specific data */
54605471
SCIP_CALL( consdataCreate(scip, &consdata, nvars, vars) );
54615472

src/scip/cons_or.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,7 @@ SCIP_RETCODE SCIPcreateConsOr(
22442244
SCIP_CONSHDLR* conshdlr;
22452245
SCIP_CONSHDLRDATA* conshdlrdata;
22462246
SCIP_CONSDATA* consdata;
2247+
int i;
22472248

22482249
/* find the or constraint handler */
22492250
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
@@ -2253,6 +2254,23 @@ SCIP_RETCODE SCIPcreateConsOr(
22532254
return SCIP_PLUGINNOTFOUND;
22542255
}
22552256

2257+
/* check whether resultant variable is binary */
2258+
if( !SCIPvarIsBinary(resvar) )
2259+
{
2260+
SCIPerrorMessage("resultant <%s> is not binary\n", SCIPvarGetName(resvar));
2261+
return SCIP_INVALIDDATA;
2262+
}
2263+
2264+
/* check whether all variables are binary */
2265+
for( i = 0; i < nvars; ++i )
2266+
{
2267+
if( !SCIPvarIsBinary(vars[i]) )
2268+
{
2269+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
2270+
return SCIP_INVALIDDATA;
2271+
}
2272+
}
2273+
22562274
conshdlrdata = SCIPconshdlrGetData(conshdlr);
22572275
assert(conshdlrdata != NULL);
22582276

src/scip/cons_setppc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7090,6 +7090,7 @@ SCIP_RETCODE createConsSetppc(
70907090
SCIP_CONSHDLR* conshdlr;
70917091
SCIP_CONSDATA* consdata;
70927092
SCIP_CONSHDLRDATA* conshdlrdata;
7093+
int i;
70937094

70947095
assert(scip != NULL);
70957096

@@ -7101,6 +7102,16 @@ SCIP_RETCODE createConsSetppc(
71017102
return SCIP_INVALIDCALL;
71027103
}
71037104

7105+
/* check whether all variables are binary */
7106+
for( i = 0; i < nvars; ++i )
7107+
{
7108+
if( !SCIPvarIsBinary(vars[i]) )
7109+
{
7110+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
7111+
return SCIP_INVALIDDATA;
7112+
}
7113+
}
7114+
71047115
/* create the constraint specific data */
71057116
if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
71067117
{

src/scip/cons_xor.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)