@@ -1918,6 +1918,74 @@ func TestScalarConstraint_ImpliesThisIsAlsoSatisfied10(t *testing.T) {
19181918 }
19191919}
19201920
1921+ /*
1922+ TestScalarConstraint_ImpliesThisIsAlsoSatisfied11
1923+ Description:
1924+
1925+ Tests the ImpliesThisIsAlsoSatisfied() method of a scalar constraint.
1926+ This test attempts to catch a bug where the method would note that some
1927+ constraints imply others that they should not actually imply.
1928+ In this case, it seems like we have constraints where, if you compare
1929+ the constants on the right hand side, then they might seem to imply one
1930+ another: (1 <= 2), but when you consider the left hand side's
1931+ coefficients, you see that they do NOT actually imply one another.
1932+ In this case, we have:
1933+ 2 x <= 1 and
1934+ 10 x <= 2
1935+ as the input constraints. The first constraint does NOT imply the second.
1936+ */
1937+ func TestScalarConstraint_ImpliesThisIsAlsoSatisfied11 (t * testing.T ) {
1938+ // Constants
1939+ x := symbolic .NewVariable ()
1940+
1941+ // Create constraint
1942+ sc := x .Multiply (2 ).LessEq (1.0 )
1943+
1944+ // Create a second constraint
1945+ sc2 := x .Multiply (10 ).LessEq (2.0 )
1946+
1947+ // Verify that the first constraint does NOT imply the second
1948+ if sc .ImpliesThisIsAlsoSatisfied (sc2 ) {
1949+ t .Errorf (
1950+ "Expected sc.ImpliesThisIsAlsoSatisfied(sc2) to be false; received true" ,
1951+ )
1952+ }
1953+ }
1954+
1955+ /*
1956+ TestScalarConstraint_ImpliesThisIsAlsoSatisfied12
1957+ Description:
1958+
1959+ Tests the ImpliesThisIsAlsoSatisfied() method of a scalar constraint.
1960+ This test attempts to catch a bug where the method would note that some
1961+ constraints imply others that they should not actually imply.
1962+ In this case, it seems like we have constraints where, if you compare
1963+ the constants on the right hand side, then they might seem to imply one
1964+ another: (-2 >= -4), but when you consider the left hand side's
1965+ coefficients, you see that they do NOT actually imply one another.
1966+ In this case, we have:
1967+ -2 x <= 2 and
1968+ -10 x <= 4
1969+ as the input constraints. The first constraint does NOT imply the second.
1970+ */
1971+ func TestScalarConstraint_ImpliesThisIsAlsoSatisfied12 (t * testing.T ) {
1972+ // Constants
1973+ x := symbolic .NewVariable ()
1974+
1975+ // Create constraint
1976+ sc := x .Multiply (- 2 ).LessEq (2.0 )
1977+
1978+ // Create a second constraint
1979+ sc2 := x .Multiply (- 10 ).LessEq (4.0 )
1980+
1981+ // Verify that the first constraint does NOT imply the second
1982+ if sc .ImpliesThisIsAlsoSatisfied (sc2 ) {
1983+ t .Errorf (
1984+ "Expected sc.ImpliesThisIsAlsoSatisfied(sc2) to be false; received true" ,
1985+ )
1986+ }
1987+ }
1988+
19211989/*
19221990TestScalarConstraint_AsSimplifiedConstraint1
19231991Description:
0 commit comments