Skip to content

Commit 6e947dd

Browse files
committed
Merge remote-tracking branch 'origin/v9-minor'
2 parents 7a4e364 + b807e20 commit 6e947dd

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
@@ -330,6 +330,7 @@ Fixed bugs
330330
----------
331331

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

334335
Build system
335336
------------

src/scip/cons_and.c

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

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

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

src/scip/cons_logicor.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5450,6 +5450,7 @@ SCIP_RETCODE SCIPcreateConsLogicor(
54505450
{
54515451
SCIP_CONSHDLR* conshdlr;
54525452
SCIP_CONSDATA* consdata;
5453+
int i;
54535454

54545455
assert(scip != NULL);
54555456

@@ -5461,6 +5462,16 @@ SCIP_RETCODE SCIPcreateConsLogicor(
54615462
return SCIP_INVALIDCALL;
54625463
}
54635464

5465+
/* check whether all variables are binary */
5466+
for( i = 0; i < nvars; ++i )
5467+
{
5468+
if( !SCIPvarIsBinary(vars[i]) )
5469+
{
5470+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
5471+
return SCIP_INVALIDDATA;
5472+
}
5473+
}
5474+
54645475
/* create the constraint specific data */
54655476
SCIP_CALL( consdataCreate(scip, &consdata, nvars, vars) );
54665477

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
@@ -7095,6 +7095,7 @@ SCIP_RETCODE createConsSetppc(
70957095
SCIP_CONSHDLR* conshdlr;
70967096
SCIP_CONSDATA* consdata;
70977097
SCIP_CONSHDLRDATA* conshdlrdata;
7098+
int i;
70987099

70997100
assert(scip != NULL);
71007101

@@ -7106,6 +7107,16 @@ SCIP_RETCODE createConsSetppc(
71067107
return SCIP_INVALIDCALL;
71077108
}
71087109

7110+
/* check whether all variables are binary */
7111+
for( i = 0; i < nvars; ++i )
7112+
{
7113+
if( !SCIPvarIsBinary(vars[i]) )
7114+
{
7115+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
7116+
return SCIP_INVALIDDATA;
7117+
}
7118+
}
7119+
71097120
/* create the constraint specific data */
71107121
if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
71117122
{

src/scip/cons_xor.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4521,7 +4521,7 @@ SCIP_RETCODE createConsXorIntvar(
45214521
SCIP_Bool rhs, /**< right hand side of the constraint */
45224522
int nvars, /**< number of operator variables in the constraint */
45234523
SCIP_VAR** vars, /**< array with operator variables of constraint */
4524-
SCIP_VAR* intvar, /**< artificial integer variable for linear relaxation */
4524+
SCIP_VAR* intvar, /**< integer variable for linear relaxation or NULL if artificial */
45254525
SCIP_Bool initial, /**< should the LP relaxation of constraint be in the initial LP?
45264526
* Usually set to TRUE. Set to FALSE for 'lazy constraints'. */
45274527
SCIP_Bool separate, /**< should the constraint be separated during LP processing?
@@ -4549,6 +4549,8 @@ SCIP_RETCODE createConsXorIntvar(
45494549
{
45504550
SCIP_CONSHDLR* conshdlr;
45514551
SCIP_CONSDATA* consdata;
4552+
SCIP_VARTYPE intvartype;
4553+
int i;
45524554

45534555
/* find the xor constraint handler */
45544556
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
@@ -4558,6 +4560,28 @@ SCIP_RETCODE createConsXorIntvar(
45584560
return SCIP_PLUGINNOTFOUND;
45594561
}
45604562

4563+
/* check whether int variable is integral */
4564+
if( intvar != NULL )
4565+
{
4566+
intvartype = SCIPvarGetType(intvar);
4567+
4568+
if( intvartype != SCIP_VARTYPE_BINARY && intvartype != SCIP_VARTYPE_INTEGER )
4569+
{
4570+
SCIPerrorMessage("intvar <%s> is not enforced integral\n", SCIPvarGetName(intvar));
4571+
return SCIP_INVALIDDATA;
4572+
}
4573+
}
4574+
4575+
/* check whether all variables are binary */
4576+
for( i = 0; i < nvars; ++i )
4577+
{
4578+
if( !SCIPvarIsBinary(vars[i]) )
4579+
{
4580+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
4581+
return SCIP_INVALIDDATA;
4582+
}
4583+
}
4584+
45614585
/* create constraint data */
45624586
SCIP_CALL( consdataCreate(scip, &consdata, rhs, nvars, vars, intvar) );
45634587

@@ -4628,6 +4652,7 @@ SCIP_DECL_LINCONSUPGD(linconsUpgdXor)
46284652
{
46294653
SCIP_VAR** xorvars;
46304654
SCIP_VAR* parityvar = NULL;
4655+
SCIP_VARTYPE parityvartype;
46314656
SCIP_Bool postwo = FALSE;
46324657
int cnt = 0;
46334658
int j;
@@ -4640,6 +4665,15 @@ SCIP_DECL_LINCONSUPGD(linconsUpgdXor)
46404665
if( SCIPisEQ(scip, REALABS(vals[j]), 2.0) )
46414666
{
46424667
parityvar = vars[j];
4668+
parityvartype = SCIPvarGetType(parityvar);
4669+
4670+
/* parity variable requires enforced integrality */
4671+
if( parityvartype != SCIP_VARTYPE_BINARY && parityvartype != SCIP_VARTYPE_INTEGER )
4672+
{
4673+
parityvar = NULL;
4674+
break;
4675+
}
4676+
46434677
postwo = (vals[j] > 0.0);
46444678
}
46454679
else if( !SCIPisEQ(scip, REALABS(vals[j]), 1.0) )
@@ -6014,6 +6048,7 @@ SCIP_RETCODE SCIPcreateConsXor(
60146048
{
60156049
SCIP_CONSHDLR* conshdlr;
60166050
SCIP_CONSDATA* consdata;
6051+
int i;
60176052

60186053
/* find the xor constraint handler */
60196054
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
@@ -6023,6 +6058,16 @@ SCIP_RETCODE SCIPcreateConsXor(
60236058
return SCIP_PLUGINNOTFOUND;
60246059
}
60256060

6061+
/* check whether all variables are binary */
6062+
for( i = 0; i < nvars; ++i )
6063+
{
6064+
if( !SCIPvarIsBinary(vars[i]) )
6065+
{
6066+
SCIPerrorMessage("operand <%s> is not binary\n", SCIPvarGetName(vars[i]));
6067+
return SCIP_INVALIDDATA;
6068+
}
6069+
}
6070+
60266071
/* create constraint data */
60276072
SCIP_CALL( consdataCreate(scip, &consdata, rhs, nvars, vars, NULL) );
60286073

0 commit comments

Comments
 (0)