I'm having trouble figuring out how to deal with indexed sets in Pyomo. Let's say I have the following example...
from pyomo.environ import *
m = ConcreteModel()
# Different types of asset to potentially deploy
m.assets = Set(initialize=['A', 'B', 'C'])
# Different teams of each asset available
teams_dict = {'A': ['One', 'Two'], 'B': ['One'], 'C': ['One', 'Two', 'Three']}
m.teams = Set(m.assets, initialize=teams_dict)
If I want to define a variable m.x indexed over both of the above sets, how do I do that? I can't find any examples of this, and my guesses were...
# A binary variable that indicates whether a particular asset is chosen or not
m.x = Var(m.assets, m.teams, within=Binary)
which gives
TypeError: Cannot index a component with an indexed set
and
m.x = Var(m.assets, m.teams[m.assets], within=Binary)
which gives
AttributeError: '_IndexedSetData' object has no attribute '_name'
Any suggestions on how to define this variable properly? The TypeError kind of suggests that it's not possible to index over an indexed set, but that would seem to defeat the point of even having indexed sets, so I'm confused.