For the latex printer, I am unable to extract set information from a constraint object using identify_components
Rationale
This is necessary for printing individual constraints using the latex printer
Description
The following code:
import pyomo.environ as pyo
from pyomo.common.collections.component_set import ComponentSet
from pyomo.core.expr.template_expr import templatize_constraint
from pyomo.core.expr.visitor import identify_components
from pyomo.core.base.set import _SetData, _SetDataBase
m = pyo.ConcreteModel(name='basicFormulation')
m.I = pyo.Set(initialize=[1, 2, 3, 4, 5])
m.c = pyo.Param(m.I, initialize=1.0, mutable=True)
m.u = pyo.Var(m.I * m.I)
m.v = pyo.Var(m.I)
def ruleMaker(m, j):
return sum(m.c[i]*m.v[i] + m.u[i, j] ** 2 for i in m.I) <= 0
m.constraint = pyo.Constraint(m.I, rule=ruleMaker)
temp_comp, temp_indexes = templatize_constraint(m.constraint)
setList = []
for s in identify_components(temp_comp, [_SetData]) :
if s not in ComponentSet(setList):
setList.append(s)
print([s.__str__() for s in setList])
prints:
[]
and should print:
[I]
Similar code for variables and parameters works fine.
Summary
For the latex printer, I am unable to extract set information from a constraint object using
identify_components
Rationale
This is necessary for printing individual constraints using the latex printer
Description
The following code:
prints:
and should print:
Similar code for variables and parameters works fine.
Additional information
N/A