--
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.
For more options, visit https://groups.google.com/d/optout.
The VarList / ConstraintList components are actually very thin wrappers around normal Var / Constraint containers. The easiest way to mock up a simple equivalent for Block with:
model.blockList = Block(Any)
The “Any” set will admit any index, so you can add a new block (in a manner similar to ConstraintList) with something like:
b = model.blockList[len(model.blockList)]
…that is, you will get blocks indexed by a list of integers starting with 0.
Alternatively, you can do a nearly identical replication of ConstraintList with an explicit Set:
model.blockList_index = Set()
model.blockList = Block(model.blockList_index)
To add a new block, you first need to add the new index to the underlying set:
def add(model):
i = len(model.blockList) + 1 # 1-indexed like ConstraintList
model.blockList_index.add(i)
return model.blockList[i]
john