Skip to content

Commit 5e2fb23

Browse files
committed
Merge branch '3939-fix-lpi_spx2-cpp-2310-scip_retcode-sciplpigetsides-scip_lpi-int-int-double-double-assertion-0' into 'v92-bugfix'
Resolve "lpi_spx2.cpp:2310: SCIP_RETCODE SCIPlpiGetSides(SCIP_LPI *, int, int, double *, double *): Assertion `0 <= firstrow && firstrow <= lastrow && lastrow < lpi->spx->numRowsReal()' failed" See merge request integer/scip!3908
2 parents ae46bf7 + a447478 commit 5e2fb23

File tree

13 files changed

+677
-309
lines changed

13 files changed

+677
-309
lines changed

check/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ set(pairs_Issue
517517
"instances/Issue/3932.cip\;+infinity\;reduced_tolerance"
518518
"instances/Issue/3934.cip\;-5007\;conflict_off_reduced_presolving_subrestart"
519519
"instances/Issue/3935.cip\;-24793.9840277416\;default"
520+
"instances/Issue/3939.cip\;-24000\;lexdual"
520521
"instances/Issue/3940.cip\;-2549.22\;unscaled_tolerance"
521522
"instances/Issue/3942.cip\;0\;default"
522523
)

check/instances/Issue/3939.cip

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
STATISTICS
2+
Problem name : instance
3+
Variables : 3 (0 binary, 2 integer, 0 implicit integer, 1 continuous)
4+
Constraints : 0 initial, 2 maximal
5+
OBJECTIVE
6+
Sense : minimize
7+
VARIABLES
8+
[integer] <x0>: obj=-28, original bounds=[-200,200]
9+
[integer] <x2>: obj=55, original bounds=[-200,200]
10+
[continuous] <x1>: obj=-76, original bounds=[-200,200]
11+
CONSTRAINTS
12+
[linear] <_C2>: +63.7<x0>[I] +62.68<x2>[I] +42.25<x1>[C] <= -1551.61;
13+
[linear] <_C3>: -10.93<x0>[I] -68.73<x2>[I] -70.88<x1>[C] <= -3174.7;
14+
END

src/lpi/lpi_clp.cpp

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,17 @@ SCIP_RETCODE SCIPlpiDelCols(
840840
int lastcol /**< last column to be deleted */
841841
)
842842
{
843-
SCIPdebugMessage("calling SCIPlpiDelCols()\n");
844-
845843
assert(lpi != NULL);
846844
assert(lpi->clp != NULL);
847-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
845+
assert(firstcol >= 0);
846+
assert(lastcol < lpi->clp->numberColumns());
847+
assert(firstcol <= lastcol + 1);
848+
849+
SCIPdebugMessage("calling SCIPlpiDelCols()\n");
850+
851+
// handle empty range
852+
if( firstcol > lastcol )
853+
return SCIP_OKAY;
848854

849855
invalidateSolution(lpi);
850856

@@ -989,11 +995,17 @@ SCIP_RETCODE SCIPlpiDelRows(
989995
int lastrow /**< last row to be deleted */
990996
)
991997
{
992-
SCIPdebugMessage("calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
993-
994998
assert(lpi != NULL);
995999
assert(lpi->clp != NULL);
996-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1000+
assert(firstrow >= 0);
1001+
assert(lastrow < lpi->clp->numberRows());
1002+
assert(firstrow <= lastrow + 1);
1003+
1004+
SCIPdebugMessage("calling SCIPlpiDelRows() (number: %d)\n", lastrow-firstrow+1);
1005+
1006+
// handle empty range
1007+
if( firstrow > lastrow )
1008+
return SCIP_OKAY;
9971009

9981010
invalidateSolution(lpi);
9991011

@@ -1483,13 +1495,15 @@ SCIP_RETCODE SCIPlpiGetCols(
14831495
SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
14841496
)
14851497
{
1486-
SCIPdebugMessage("calling SCIPlpiGetCols()\n");
1487-
14881498
assert(lpi != NULL);
14891499
assert(lpi->clp != NULL);
1490-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
14911500
assert((lb != NULL && ub != NULL) || (lb == NULL && ub == NULL));
14921501
assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1502+
assert(firstcol >= 0);
1503+
assert(lastcol < lpi->clp->numberColumns());
1504+
assert(firstcol <= lastcol + 1);
1505+
1506+
SCIPdebugMessage("calling SCIPlpiGetCols()\n");
14931507

14941508
ClpSimplex* clp = lpi->clp;
14951509

@@ -1547,13 +1561,15 @@ SCIP_RETCODE SCIPlpiGetRows(
15471561
SCIP_Real* val /**< buffer to store values of constraint matrix entries, or NULL */
15481562
)
15491563
{
1550-
SCIPdebugMessage("calling SCIPlpiGetRows()\n");
1551-
15521564
assert(lpi != NULL);
15531565
assert(lpi->clp != NULL);
1554-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
15551566
assert((lhs != NULL && rhs != NULL) || (lhs == NULL && rhs == NULL));
15561567
assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1568+
assert(firstrow >= 0);
1569+
assert(lastrow < lpi->clp->numberRows());
1570+
assert(firstrow <= lastrow + 1);
1571+
1572+
SCIPdebugMessage("calling SCIPlpiGetRows()\n");
15571573

15581574
ClpSimplex* clp = lpi->clp;
15591575
if ( lhs != NULL )
@@ -1612,6 +1628,9 @@ SCIP_RETCODE SCIPlpiGetColNames(
16121628
assert(namestorage != NULL || namestoragesize == 0);
16131629
assert(namestoragesize >= 0);
16141630
assert(storageleft != NULL);
1631+
assert(firstcol >= 0);
1632+
assert(lastcol < lpi->clp->numberColumns());
1633+
assert(firstcol <= lastcol + 1);
16151634

16161635
SCIPerrorMessage("SCIPlpiGetColNames() has not been implemented yet.\n");
16171636

@@ -1636,6 +1655,9 @@ SCIP_RETCODE SCIPlpiGetRowNames(
16361655
assert(namestorage != NULL || namestoragesize == 0);
16371656
assert(namestoragesize >= 0);
16381657
assert(storageleft != NULL);
1658+
assert(firstrow >= 0);
1659+
assert(lastrow < lpi->clp->numberRows());
1660+
assert(firstrow <= lastrow + 1);
16391661

16401662
SCIPerrorMessage("SCIPlpiGetRowNames() has not been implemented yet.\n");
16411663

@@ -1690,12 +1712,14 @@ SCIP_RETCODE SCIPlpiGetObj(
16901712
SCIP_Real* vals /**< array to store objective coefficients */
16911713
)
16921714
{
1693-
SCIPdebugMessage("calling SCIPlpiGetObj()\n");
1694-
16951715
assert(lpi != NULL);
16961716
assert(lpi->clp != NULL);
1697-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
16981717
assert(vals != NULL);
1718+
assert(firstcol >= 0);
1719+
assert(lastcol < lpi->clp->numberColumns());
1720+
assert(firstcol <= lastcol + 1);
1721+
1722+
SCIPdebugMessage("calling SCIPlpiGetObj()\n");
16991723

17001724
const double* obj = lpi->clp->getObjCoefficients(); // Here we can use the const versions (see SCIPchgObj)
17011725

@@ -1714,11 +1738,13 @@ SCIP_RETCODE SCIPlpiGetBounds(
17141738
SCIP_Real* ubs /**< array to store upper bound values, or NULL */
17151739
)
17161740
{
1717-
SCIPdebugMessage("calling SCIPlpiGetBounds()\n");
1718-
17191741
assert(lpi != NULL);
17201742
assert(lpi->clp != NULL);
1721-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < lpi->clp->numberColumns());
1743+
assert(firstcol >= 0);
1744+
assert(lastcol < lpi->clp->numberColumns());
1745+
assert(firstcol <= lastcol + 1);
1746+
1747+
SCIPdebugMessage("calling SCIPlpiGetBounds()\n");
17221748

17231749
if ( lbs != 0 )
17241750
{
@@ -1745,11 +1771,13 @@ SCIP_RETCODE SCIPlpiGetSides(
17451771
SCIP_Real* rhss /**< array to store right hand side values, or NULL */
17461772
)
17471773
{
1748-
SCIPdebugMessage("calling SCIPlpiGetSides()\n");
1749-
17501774
assert(lpi != NULL);
17511775
assert(lpi->clp != NULL);
1752-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < lpi->clp->numberRows());
1776+
assert(firstrow >= 0);
1777+
assert(lastrow < lpi->clp->numberRows());
1778+
assert(firstrow <= lastrow + 1);
1779+
1780+
SCIPdebugMessage("calling SCIPlpiGetSides()\n");
17531781

17541782
if ( lhss != 0 )
17551783
{

src/lpi/lpi_cpx.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,10 +1377,16 @@ SCIP_RETCODE SCIPlpiDelCols(
13771377
assert(lpi != NULL);
13781378
assert(lpi->cpxlp != NULL);
13791379
assert(lpi->cpxenv != NULL);
1380-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
1380+
assert(firstcol >= 0);
1381+
assert(lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
1382+
assert(firstcol <= lastcol + 1);
13811383

13821384
SCIPdebugMessage("deleting %d columns from CPLEX\n", lastcol - firstcol + 1);
13831385

1386+
/* handle empty range */
1387+
if( firstcol > lastcol )
1388+
return SCIP_OKAY;
1389+
13841390
invalidateSolution(lpi);
13851391

13861392
CHECK_ZERO( lpi->messagehdlr, CPXdelcols(lpi->cpxenv, lpi->cpxlp, firstcol, lastcol) );
@@ -1489,10 +1495,16 @@ SCIP_RETCODE SCIPlpiDelRows(
14891495
assert(lpi != NULL);
14901496
assert(lpi->cpxlp != NULL);
14911497
assert(lpi->cpxenv != NULL);
1492-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
1498+
assert(firstrow >= 0);
1499+
assert(lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
1500+
assert(firstrow <= lastrow + 1);
14931501

14941502
SCIPdebugMessage("deleting %d rows from CPLEX\n", lastrow - firstrow + 1);
14951503

1504+
/* handle empty range */
1505+
if( firstrow > lastrow )
1506+
return SCIP_OKAY;
1507+
14961508
invalidateSolution(lpi);
14971509

14981510
CHECK_ZERO( lpi->messagehdlr, CPXdelrows(lpi->cpxenv, lpi->cpxlp, firstrow, lastrow) );
@@ -1929,9 +1941,11 @@ SCIP_RETCODE SCIPlpiGetCols(
19291941
assert(lpi != NULL);
19301942
assert(lpi->cpxlp != NULL);
19311943
assert(lpi->cpxenv != NULL);
1932-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
19331944
assert((lb != NULL && ub != NULL) || (lb == NULL && ub == NULL));
19341945
assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1946+
assert(firstcol >= 0);
1947+
assert(lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
1948+
assert(firstcol <= lastcol + 1);
19351949

19361950
SCIPdebugMessage("getting columns %d to %d\n", firstcol, lastcol);
19371951

@@ -1977,9 +1991,11 @@ SCIP_RETCODE SCIPlpiGetRows(
19771991
assert(lpi != NULL);
19781992
assert(lpi->cpxlp != NULL);
19791993
assert(lpi->cpxenv != NULL);
1980-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
19811994
assert((lhs == NULL && rhs == NULL) || (rhs != NULL && lhs != NULL));
19821995
assert((nnonz != NULL && beg != NULL && ind != NULL && val != NULL) || (nnonz == NULL && beg == NULL && ind == NULL && val == NULL));
1996+
assert(firstrow >= 0);
1997+
assert(lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
1998+
assert(firstrow <= lastrow + 1);
19831999

19842000
SCIPdebugMessage("getting rows %d to %d\n", firstrow, lastrow);
19852001

@@ -2038,7 +2054,9 @@ SCIP_RETCODE SCIPlpiGetColNames(
20382054
assert(namestorage != NULL || namestoragesize == 0);
20392055
assert(namestoragesize >= 0);
20402056
assert(storageleft != NULL);
2041-
assert(0 <= firstcol && firstcol <= lastcol && lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
2057+
assert(firstcol >= 0);
2058+
assert(lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
2059+
assert(firstcol <= lastcol + 1);
20422060

20432061
SCIPdebugMessage("getting column names %d to %d\n", firstcol, lastcol);
20442062

@@ -2072,7 +2090,9 @@ SCIP_RETCODE SCIPlpiGetRowNames(
20722090
assert(namestorage != NULL || namestoragesize == 0);
20732091
assert(namestoragesize >= 0);
20742092
assert(storageleft != NULL);
2075-
assert(0 <= firstrow && firstrow <= lastrow && lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
2093+
assert(firstrow >= 0);
2094+
assert(lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
2095+
assert(firstrow <= lastrow + 1);
20762096

20772097
SCIPdebugMessage("getting row names %d to %d\n", firstrow, lastrow);
20782098

@@ -2116,8 +2136,10 @@ SCIP_RETCODE SCIPlpiGetObj(
21162136
assert(lpi != NULL);
21172137
assert(lpi->cpxlp != NULL);
21182138
assert(lpi->cpxenv != NULL);
2119-
assert(firstcol <= lastcol);
21202139
assert(vals != NULL);
2140+
assert(firstcol >= 0);
2141+
assert(lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
2142+
assert(firstcol <= lastcol + 1);
21212143

21222144
SCIPdebugMessage("getting objective values %d to %d\n", firstcol, lastcol);
21232145

@@ -2138,7 +2160,9 @@ SCIP_RETCODE SCIPlpiGetBounds(
21382160
assert(lpi != NULL);
21392161
assert(lpi->cpxlp != NULL);
21402162
assert(lpi->cpxenv != NULL);
2141-
assert(firstcol <= lastcol);
2163+
assert(firstcol >= 0);
2164+
assert(lastcol < CPXgetnumcols(lpi->cpxenv, lpi->cpxlp));
2165+
assert(firstcol <= lastcol + 1);
21422166

21432167
SCIPdebugMessage("getting bounds %d to %d\n", firstcol, lastcol);
21442168

@@ -2171,7 +2195,9 @@ SCIP_RETCODE SCIPlpiGetSides(
21712195
assert(lpi != NULL);
21722196
assert(lpi->cpxlp != NULL);
21732197
assert(lpi->cpxenv != NULL);
2174-
assert(firstrow <= lastrow);
2198+
assert(firstrow >= 0);
2199+
assert(lastrow < CPXgetnumrows(lpi->cpxenv, lpi->cpxlp));
2200+
assert(firstrow <= lastrow + 1);
21752201

21762202
SCIPdebugMessage("getting row sides %d to %d\n", firstrow, lastrow);
21772203

0 commit comments

Comments
 (0)