model.A = pyo.Set(initialize=[0, 1, 2])model.B = pyo.Set(initialize=['left', 'right', 'center'])and also an expression:model.my_expression = pyo.Expression(model.A, model.B, rule=some_rule)
Is there some way to programmatically retrieve the names and order of the indexing sets (specifically, the list ['A', 'B']) from the my_expression object?
Right now, _implicit_subsets is probably the best thing to use. I believe that is what Bethany is using in Pyomo.dae as well.
That said, we are in the middle of an overhaul of the Set system, and one of the goals is to make the APIs more consistent and to provide new public APIs that better meet user’s needs. One of the approaches I am looking at is a “product_subsets” method, so you could do:
model.my_expression.index_set().subsets()
That said, it will expand the arguments regardless of how you created the product set. That is:
m.A = Set()
m.B = Set()
m.ex1 = Expression(m.A, m.B, rule=some_rule)
m.ex1.index_set().subsets() # == [ m.A, m.B ]
m.C = m.A * m.B
m.ex2 = Expression(m.C, rule=some_rule)
m.ex2.index_set().subsets() # == [ m.A, m.B ]
Also, because of other changes, it is *possible* that _implicit_subsets may go away in the relatively near future (although probably no sooner than January)
john
--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pyomo-forum...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyomo-forum/995e9899-52f6-4953-9d3e-1e8a059ccb4d%40googlegroups.com.