Skip to content

Commit

Permalink
add test that uses named expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbybp committed Dec 12, 2023
1 parent 682e054 commit c8ed1cd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyomo/contrib/incidence_analysis/tests/test_incidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ def test_incidence_with_fixed_variable(self):
var_set = ComponentSet(variables)
self.assertEqual(var_set, ComponentSet([m.x[1], m.x[3]]))

def test_incidence_with_named_expression(self):
m = pyo.ConcreteModel()
m.x = pyo.Var([1, 2, 3])
m.subexpr = pyo.Expression(pyo.Integers)
m.subexpr[1] = m.x[1] * pyo.exp(m.x[3])
expr = m.x[1] + m.x[1] * m.x[2] + m.subexpr[1]
variables = self._get_incident_variables(expr)
self.assertEqual(ComponentSet(variables), ComponentSet(m.x[:]))


class _TestIncidenceLinearOnly(object):
"""Tests for methods that support linear_only"""
Expand Down

0 comments on commit c8ed1cd

Please sign in to comment.