Skip to content

Commit 81a42eb

Browse files
authored
Merge branch 'main' into xpress_slack_bug
2 parents 8b8f6e5 + 92a9d3b commit 81a42eb

File tree

6 files changed

+67
-5
lines changed

6 files changed

+67
-5
lines changed

.github/workflows/test_branches.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ jobs:
519519
$BARON_DIR = "${env:TPL_DIR}/baron"
520520
echo "$BARON_DIR" | `
521521
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
522-
$URL = "https://www.minlp.com/downloads/xecs/baron/current/"
522+
$URL = "https://minlp.com/downloads/xecs/baron/current/"
523523
if ( "${{matrix.TARGET}}" -eq "win" ) {
524524
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
525525
$URL += "baron-win64.exe"

.github/workflows/test_pr_and_main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ jobs:
562562
$BARON_DIR = "${env:TPL_DIR}/baron"
563563
echo "$BARON_DIR" | `
564564
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
565-
$URL = "https://www.minlp.com/downloads/xecs/baron/current/"
565+
$URL = "https://minlp.com/downloads/xecs/baron/current/"
566566
if ( "${{matrix.TARGET}}" -eq "win" ) {
567567
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
568568
$URL += "baron-win64.exe"

pyomo/contrib/incidence_analysis/scc_solver.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ def generate_strongly_connected_components(
6666
)
6767
)
6868

69-
assert len(variables) == len(constraints)
69+
if len(variables) != len(constraints):
70+
nvar = len(variables)
71+
ncon = len(constraints)
72+
raise RuntimeError(
73+
"generate_strongly_connected_components only supports systems with the"
74+
f" same numbers of variables and equality constraints. Got {nvar}"
75+
f" variables and {ncon} constraints."
76+
)
7077
if igraph is None:
7178
igraph = IncidenceGraphInterface()
7279

@@ -78,6 +85,8 @@ def generate_strongly_connected_components(
7885
subsets, include_fixed=include_fixed
7986
):
8087
# TODO: How does len scale for reference-to-list?
88+
# If this assert fails, it may be due to a bug in block_triangularize
89+
# or generate_subsystem_block.
8190
assert len(block.vars) == len(block.cons)
8291
yield (block, inputs)
8392

pyomo/contrib/incidence_analysis/tests/test_scc_solver.py

+17
Original file line numberDiff line numberDiff line change
@@ -501,5 +501,22 @@ def test_with_inequalities(self):
501501
self.assertEqual(m.x[3].value, 1.0)
502502

503503

504+
@unittest.skipUnless(scipy_available, "SciPy is not available")
505+
@unittest.skipUnless(networkx_available, "NetworkX is not available")
506+
class TestExceptions(unittest.TestCase):
507+
def test_nonsquare_system(self):
508+
m = pyo.ConcreteModel()
509+
m.x = pyo.Var([1, 2], initialize=1)
510+
m.eq = pyo.Constraint(expr=m.x[1] + m.x[2] == 1)
511+
512+
msg = "Got 2 variables and 1 constraints"
513+
with self.assertRaisesRegex(RuntimeError, msg):
514+
list(
515+
generate_strongly_connected_components(
516+
constraints=[m.eq], variables=[m.x[1], m.x[2]]
517+
)
518+
)
519+
520+
504521
if __name__ == "__main__":
505522
unittest.main()

pyomo/core/kernel/conic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def as_domain(cls, r, x):
632632
b = block()
633633
b.r = variable_tuple([variable(lb=0) for i in range(len(r))])
634634
b.x = variable()
635-
b.c = _build_linking_constraints(list(r) + [x], list(b.r) + [x])
635+
b.c = _build_linking_constraints(list(r) + [x], list(b.r) + [b.x])
636636
b.q = cls(r=b.r, x=b.x)
637637
return b
638638

@@ -934,7 +934,7 @@ def as_domain(cls, r, x):
934934
b = block()
935935
b.r = variable_tuple([variable(lb=0) for i in range(len(r))])
936936
b.x = variable()
937-
b.c = _build_linking_constraints(list(r) + [x], list(b.r) + [x])
937+
b.c = _build_linking_constraints(list(r) + [x], list(b.r) + [b.x])
938938
b.q = cls(r=b.r, x=b.x)
939939
return b
940940

pyomo/core/tests/unit/kernel/test_conic.py

+36
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
primal_power,
3636
dual_exponential,
3737
dual_power,
38+
primal_geomean,
39+
dual_geomean,
3840
)
3941

4042

@@ -784,6 +786,40 @@ def test_as_domain(self):
784786
x[1].value = None
785787

786788

789+
# These mosek 10 constraints can't be evaluated, pprinted, checked for convexity,
790+
# pickled, etc., so I won't use the _conic_tester_base for them
791+
class Test_primal_geomean(unittest.TestCase):
792+
def test_as_domain(self):
793+
b = primal_geomean.as_domain(r=[2, 3], x=6)
794+
self.assertIs(type(b), block)
795+
self.assertIs(type(b.q), primal_geomean)
796+
self.assertIs(type(b.r), variable_tuple)
797+
self.assertIs(type(b.x), variable)
798+
self.assertIs(type(b.c), constraint_tuple)
799+
self.assertExpressionsEqual(b.c[0].body, b.r[0])
800+
self.assertExpressionsEqual(b.c[0].rhs, 2)
801+
self.assertExpressionsEqual(b.c[1].body, b.r[1])
802+
self.assertExpressionsEqual(b.c[1].rhs, 3)
803+
self.assertExpressionsEqual(b.c[2].body, b.x)
804+
self.assertExpressionsEqual(b.c[2].rhs, 6)
805+
806+
807+
class Test_dual_geomean(unittest.TestCase):
808+
def test_as_domain(self):
809+
b = dual_geomean.as_domain(r=[2, 3], x=6)
810+
self.assertIs(type(b), block)
811+
self.assertIs(type(b.q), dual_geomean)
812+
self.assertIs(type(b.r), variable_tuple)
813+
self.assertIs(type(b.x), variable)
814+
self.assertIs(type(b.c), constraint_tuple)
815+
self.assertExpressionsEqual(b.c[0].body, b.r[0])
816+
self.assertExpressionsEqual(b.c[0].rhs, 2)
817+
self.assertExpressionsEqual(b.c[1].body, b.r[1])
818+
self.assertExpressionsEqual(b.c[1].rhs, 3)
819+
self.assertExpressionsEqual(b.c[2].body, b.x)
820+
self.assertExpressionsEqual(b.c[2].rhs, 6)
821+
822+
787823
class TestMisc(unittest.TestCase):
788824
def test_build_linking_constraints(self):
789825
c = _build_linking_constraints([], [])

0 commit comments

Comments
 (0)