Skip to content

Commit f0deb93

Browse files
committed
Merge branch 'add_isfinite_checks' into 'master'
add SCIPisFinite() checks for constraint parameters Closes #3792 See merge request integer/scip!3816
2 parents 51adc97 + ccf06f1 commit f0deb93

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/scip/cons_bounddisjunction.c

+4
Original file line numberDiff line numberDiff line change
@@ -3360,6 +3360,10 @@ SCIP_RETCODE SCIPcreateConsBounddisjunction(
33603360
for( v1 = 0; v1 < nvars; v1++ )
33613361
{
33623362
int v2;
3363+
3364+
/* check that the bounds are sensible, i.e., not nan or inf */
3365+
assert( SCIPisFinite(bounds[v1]) );
3366+
33633367
for( v2 = v1+1; v2 < nvars; v2++ )
33643368
{
33653369
assert(vars[v1] != vars[v2] || (SCIPboundtypeOpposite(boundtypes[v1]) == boundtypes[v2]

src/scip/cons_cardinality.c

+9
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,15 @@ SCIP_RETCODE SCIPcreateConsCardinality(
36473647

36483648
modifiable = FALSE;
36493649

3650+
#ifndef NDEBUG
3651+
/* Check that the weights are sensible (not nan or inf); although not strictly needed, such values are likely a mistake. */
3652+
if ( nvars > 0 && weights != NULL )
3653+
{
3654+
for (v = 0; v < nvars; ++v)
3655+
assert( SCIPisFinite(weights[v]) );
3656+
}
3657+
#endif
3658+
36503659
/* find the cardinality constraint handler */
36513660
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
36523661
if( conshdlr == NULL )

src/scip/cons_linear.c

+6
Original file line numberDiff line numberDiff line change
@@ -17897,8 +17897,14 @@ SCIP_RETCODE SCIPcreateConsLinear(
1789717897
return SCIP_PLUGINNOTFOUND;
1789817898
}
1789917899

17900+
/* check that the given lhs/rhs are sensible, i.e., not nan or inf */
17901+
assert( SCIPisFinite(lhs) );
17902+
assert( SCIPisFinite(rhs) );
17903+
1790017904
for( j = 0; j < nvars; ++j )
1790117905
{
17906+
/* check that the given coefficients are sensible, i.e., not nan or inf */
17907+
assert( SCIPisFinite(vals[j]) );
1790217908
if( SCIPisInfinity(scip, REALABS(vals[j])) )
1790317909
{
1790417910
SCIPerrorMessage("coefficient of variable <%s> is infinite.\n", SCIPvarGetName(vars[j]));

src/scip/cons_varbound.c

+5
Original file line numberDiff line numberDiff line change
@@ -5421,6 +5421,11 @@ SCIP_RETCODE SCIPcreateConsVarbound(
54215421
SCIP_CONSHDLRDATA* conshdlrdata;
54225422
SCIP_CONSDATA* consdata;
54235423

5424+
/* check that the given parameters are sensible, i.e., not nan or inf */
5425+
assert( SCIPisFinite(vbdcoef) );
5426+
assert( SCIPisFinite(lhs) );
5427+
assert( SCIPisFinite(rhs) );
5428+
54245429
/* find the variable bound constraint handler */
54255430
conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
54265431
if( conshdlr == NULL )

0 commit comments

Comments
 (0)