Skip to content

Commit d485ca8

Browse files
committed
Merge remote-tracking branch 'origin/v9-minor'
2 parents ca427b6 + ca39fc0 commit d485ca8

File tree

2 files changed

+206
-42
lines changed

2 files changed

+206
-42
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ Fixed bugs
349349
- fixed update of consssorted flags in a variable expressions data when adding an additional constraint using this variable
350350
- corrected computation of number of variables affected by symmetry
351351
- fixed computation of symmetry group size
352-
- correct equality comparisons in checkRedundancySide() of cons_varbound.c to ensure pair redundancy
352+
- correct comparison conditions in checkRedundancySide() of cons_varbound.c to ensure pair redundancy
353353

354354
Build system
355355
------------

src/scip/cons_varbound.c

Lines changed: 205 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,7 @@ void checkRedundancySide(
19461946
assert(sideequal != NULL);
19471947
assert(cons0sidered != NULL);
19481948
assert(cons1sidered != NULL);
1949+
assert(coef0 * coef1 > 0.0);
19491950

19501951
*cons0sidered = SCIPisInfinity(scip, islhs ? -side0 : side0);
19511952
*cons1sidered = SCIPisInfinity(scip, islhs ? -side1 : side1);
@@ -1963,33 +1964,100 @@ void checkRedundancySide(
19631964
}
19641965

19651966
lbvar = SCIPvarGetLbGlobal(var);
1967+
assert(!SCIPisInfinity(scip, lbvar));
19661968
ubvar = SCIPvarGetUbGlobal(var);
1969+
assert(!SCIPisInfinity(scip, -ubvar));
19671970
lbvbdvar = SCIPvarGetLbGlobal(vbdvar);
1971+
assert(!SCIPisInfinity(scip, lbvbdvar));
19681972
ubvbdvar = SCIPvarGetUbGlobal(vbdvar);
1973+
assert(!SCIPisInfinity(scip, -ubvbdvar));
19691974

19701975
/* if both constraints have this side */
19711976
if( !*redundant0 && !*redundant1 )
19721977
{
19731978
/* calculate extreme values, which are reached by setting the other variable to their lower/upper bound */
1974-
boundxlb1 = side0 - lbvbdvar*coef0;
1975-
boundxlb2 = side1 - lbvbdvar*coef1;
1976-
boundylb1 = (side0 - lbvar)/coef0;
1977-
boundylb2 = (side1 - lbvar)/coef1;
1978-
1979-
boundxub1 = side0 - ubvbdvar*coef0;
1980-
boundxub2 = side1 - ubvbdvar*coef1;
1981-
boundyub1 = (side0 - ubvar)/coef0;
1982-
boundyub2 = (side1 - ubvar)/coef1;
1979+
if( SCIPisInfinity(scip, -lbvbdvar) )
1980+
{
1981+
if( coef0 > 0.0 )
1982+
{
1983+
boundxlb1 = SCIPinfinity(scip);
1984+
boundxlb2 = SCIPinfinity(scip);
1985+
}
1986+
else
1987+
{
1988+
boundxlb1 = -SCIPinfinity(scip);
1989+
boundxlb2 = -SCIPinfinity(scip);
1990+
}
1991+
}
1992+
else
1993+
{
1994+
boundxlb1 = side0 - lbvbdvar * coef0;
1995+
boundxlb2 = side1 - lbvbdvar * coef1;
1996+
}
1997+
if( SCIPisInfinity(scip, -lbvar) )
1998+
{
1999+
if( coef0 > 0.0 )
2000+
{
2001+
boundylb1 = SCIPinfinity(scip);
2002+
boundylb2 = SCIPinfinity(scip);
2003+
}
2004+
else
2005+
{
2006+
boundylb1 = -SCIPinfinity(scip);
2007+
boundylb2 = -SCIPinfinity(scip);
2008+
}
2009+
}
2010+
else
2011+
{
2012+
boundylb1 = (side0 - lbvar) / coef0;
2013+
boundylb2 = (side1 - lbvar) / coef1;
2014+
}
2015+
if( SCIPisInfinity(scip, ubvbdvar) )
2016+
{
2017+
if( coef0 > 0.0 )
2018+
{
2019+
boundxub1 = -SCIPinfinity(scip);
2020+
boundxub2 = -SCIPinfinity(scip);
2021+
}
2022+
else
2023+
{
2024+
boundxub1 = SCIPinfinity(scip);
2025+
boundxub2 = SCIPinfinity(scip);
2026+
}
2027+
}
2028+
else
2029+
{
2030+
boundxub1 = side0 - ubvbdvar * coef0;
2031+
boundxub2 = side1 - ubvbdvar * coef1;
2032+
}
2033+
if( SCIPisInfinity(scip, ubvar) )
2034+
{
2035+
if( coef0 > 0.0 )
2036+
{
2037+
boundyub1 = -SCIPinfinity(scip);
2038+
boundyub2 = -SCIPinfinity(scip);
2039+
}
2040+
else
2041+
{
2042+
boundyub1 = SCIPinfinity(scip);
2043+
boundyub2 = SCIPinfinity(scip);
2044+
}
2045+
}
2046+
else
2047+
{
2048+
boundyub1 = (side0 - ubvar) / coef0;
2049+
boundyub2 = (side1 - ubvar) / coef1;
2050+
}
19832051

19842052
if( islhs )
19852053
{
1986-
boundvaluex1 = MAX(boundxlb1, boundxlb2);
1987-
boundvaluex2 = MAX(boundxub1, boundxub2);
2054+
boundvaluex1 = MAX(boundxlb1, boundxlb2);
2055+
boundvaluex2 = MAX(boundxub1, boundxub2);
19882056
}
19892057
else
19902058
{
1991-
boundvaluex1 = MIN(boundxlb1, boundxlb2);
1992-
boundvaluex2 = MIN(boundxub1, boundxub2);
2059+
boundvaluex1 = MIN(boundxlb1, boundxlb2);
2060+
boundvaluex2 = MIN(boundxub1, boundxub2);
19932061
}
19942062

19952063
/* calculate important values for variables */
@@ -2023,8 +2091,32 @@ void checkRedundancySide(
20232091
}
20242092

20252093
/* calculate resulting values of variable y by setting x to valuex1 */
2026-
valuey1 = (side0 - valuex1)/coef0;
2027-
valuey2 = (side1 - valuex1)/coef1;
2094+
if( SCIPisInfinity(scip, ABS(valuex1)) )
2095+
{
2096+
/* only consider sides if coefficients are equal */
2097+
if( SCIPisEQ(scip, coef0, coef1) )
2098+
{
2099+
valuey1 = side0 / coef0;
2100+
valuey2 = side1 / coef1;
2101+
}
2102+
/* only consider original coefficients if otherwise x approaches plus infinity */
2103+
else if( valuex1 > 0.0 )
2104+
{
2105+
valuey1 = coef0;
2106+
valuey2 = coef1;
2107+
}
2108+
/* only consider swapped coefficients if otherwise x approaches minus infinity */
2109+
else
2110+
{
2111+
valuey1 = coef1;
2112+
valuey2 = coef0;
2113+
}
2114+
}
2115+
else
2116+
{
2117+
valuey1 = (side0 - valuex1) / coef0;
2118+
valuey2 = (side1 - valuex1) / coef1;
2119+
}
20282120

20292121
/* determine redundancy of one constraints side */
20302122
if( SCIPisEQ(scip, valuey1, valuey2) )
@@ -2045,8 +2137,32 @@ void checkRedundancySide(
20452137
}
20462138

20472139
/* calculate resulting values of variable y by setting x to valuex2 */
2048-
valuey1 = (side0 - valuex2)/coef0;
2049-
valuey2 = (side1 - valuex2)/coef1;
2140+
if( SCIPisInfinity(scip, ABS(valuex2)) )
2141+
{
2142+
/* only consider sides if coefficients are equal */
2143+
if( SCIPisEQ(scip, coef0, coef1) )
2144+
{
2145+
valuey1 = side0 / coef0;
2146+
valuey2 = side1 / coef1;
2147+
}
2148+
/* only consider original coefficients if otherwise x approaches plus infinity */
2149+
else if( valuex2 > 0.0 )
2150+
{
2151+
valuey1 = coef0;
2152+
valuey2 = coef1;
2153+
}
2154+
/* only consider swapped coefficients if otherwise x approaches minus infinity */
2155+
else
2156+
{
2157+
valuey1 = coef1;
2158+
valuey2 = coef0;
2159+
}
2160+
}
2161+
else
2162+
{
2163+
valuey1 = (side0 - valuex2) / coef0;
2164+
valuey2 = (side1 - valuex2) / coef1;
2165+
}
20502166

20512167
/* determine redundancy of one constraints side by checking for the first valuex2 */
20522168
if( coef0 > 0.0 )
@@ -2110,16 +2226,16 @@ void checkRedundancySide(
21102226
/* calculate feasibility domain values for variable y concerning these both constraints */
21112227
if( coef0 > 0.0 )
21122228
{
2113-
if( islhs )
2114-
{
2115-
boundvaluey1 = MAX(boundylb1, boundylb2);
2116-
boundvaluey2 = MAX(boundyub1, boundyub2);
2117-
}
2118-
else
2119-
{
2120-
boundvaluey1 = MIN(boundylb1, boundylb2);
2121-
boundvaluey2 = MIN(boundyub1, boundyub2);
2122-
}
2229+
if( islhs )
2230+
{
2231+
boundvaluey1 = MAX(boundylb1, boundylb2);
2232+
boundvaluey2 = MAX(boundyub1, boundyub2);
2233+
}
2234+
else
2235+
{
2236+
boundvaluey1 = MIN(boundylb1, boundylb2);
2237+
boundvaluey2 = MIN(boundyub1, boundyub2);
2238+
}
21232239

21242240
valuey1 = MIN(boundvaluey1, ubvbdvar);
21252241
valuey1 = MAX(valuey1, lbvbdvar);
@@ -2131,16 +2247,16 @@ void checkRedundancySide(
21312247
}
21322248
else
21332249
{
2134-
if( islhs )
2135-
{
2136-
boundvaluey1 = MIN(boundylb1, boundylb2);
2137-
boundvaluey2 = MIN(boundyub1, boundyub2);
2138-
}
2139-
else
2140-
{
2141-
boundvaluey1 = MAX(boundylb1, boundylb2);
2142-
boundvaluey2 = MAX(boundyub1, boundyub2);
2143-
}
2250+
if( islhs )
2251+
{
2252+
boundvaluey1 = MIN(boundylb1, boundylb2);
2253+
boundvaluey2 = MIN(boundyub1, boundyub2);
2254+
}
2255+
else
2256+
{
2257+
boundvaluey1 = MAX(boundylb1, boundylb2);
2258+
boundvaluey2 = MAX(boundyub1, boundyub2);
2259+
}
21442260

21452261
valuey1 = MAX(boundvaluey1, lbvbdvar);
21462262
valuey1 = MIN(valuey1, ubvbdvar);
@@ -2152,8 +2268,32 @@ void checkRedundancySide(
21522268
}
21532269

21542270
/* calculate resulting values of variable x by setting y to valuey1 */
2155-
valuex1 = side0 - valuey1*coef0;
2156-
valuex2 = side1 - valuey1*coef1;
2271+
if( SCIPisInfinity(scip, ABS(valuey1)) )
2272+
{
2273+
/* only consider sides if coefficients are equal */
2274+
if( SCIPisEQ(scip, coef0, coef1) )
2275+
{
2276+
valuex1 = side0;
2277+
valuex2 = side1;
2278+
}
2279+
/* only consider swapped coefficients if otherwise y approaches plus infinity */
2280+
else if( valuey1 > 0.0 )
2281+
{
2282+
valuex1 = coef1;
2283+
valuex2 = coef0;
2284+
}
2285+
/* only consider original coefficients if otherwise y approaches minus infinity */
2286+
else
2287+
{
2288+
valuex1 = coef0;
2289+
valuex2 = coef1;
2290+
}
2291+
}
2292+
else
2293+
{
2294+
valuex1 = side0 - valuey1 * coef0;
2295+
valuex2 = side1 - valuey1 * coef1;
2296+
}
21572297

21582298
/* determine redundancy of one constraints side by checking for the first valuey1 */
21592299
if( *sideequal )
@@ -2181,8 +2321,32 @@ void checkRedundancySide(
21812321
}
21822322

21832323
/* calculate resulting values of variable x by setting y to valuey2 */
2184-
valuex1 = side0 - valuey2*coef0;
2185-
valuex2 = side1 - valuey2*coef1;
2324+
if( SCIPisInfinity(scip, ABS(valuey2)) )
2325+
{
2326+
/* only consider sides if coefficients are equal */
2327+
if( SCIPisEQ(scip, coef0, coef1) )
2328+
{
2329+
valuex1 = side0;
2330+
valuex2 = side1;
2331+
}
2332+
/* only consider swapped coefficients if otherwise y approaches plus infinity */
2333+
else if( valuey2 > 0.0 )
2334+
{
2335+
valuex1 = coef1;
2336+
valuex2 = coef0;
2337+
}
2338+
/* only consider original coefficients if otherwise y approaches minus infinity */
2339+
else
2340+
{
2341+
valuex1 = coef0;
2342+
valuex2 = coef1;
2343+
}
2344+
}
2345+
else
2346+
{
2347+
valuex1 = side0 - valuey2 * coef0;
2348+
valuex2 = side1 - valuey2 * coef1;
2349+
}
21862350

21872351
/* determine redundancy of one constraints side by checking for the second valuey2 */
21882352
if( *sideequal )

0 commit comments

Comments
 (0)