Hello,
I try to implement a robust energystsystem optimization using oemofand rsome. While programming this I faced the follwing problem:
The constraints for the buses are implmented in the bus.py. Here in the Busblock class the create function states:
def _create(self, group=None):
"""Creates the balance constraints for the class:`BusBlock` block.
Parameters
----------
group : list
List of oemof bus (b) object for which the bus balance is created
e.g. group = [b1, b2, b3, .....]
"""
if group is None:
return None
m = self.parent_block()
ins = {}
outs = {}
for n in group:
ins[n] = [i for i in n.inputs]
outs[n] = [o for o in n.outputs]
def _busbalance_rule(block):
for t in m.TIMESTEPS:
for g in group:
lhs = sum(m.flow[i, g, t] for i in ins[g])
rhs = sum(m.flow[g, o, t] for o in outs[g])
expr = lhs == rhs
# no inflows no outflows yield: 0 == 0 which is True
if expr is not True:
block.balance.add((g, t), expr)
self.balance = Constraint(group, m.TIMESTEPS, noruleinit=True)
self.balance_build = BuildAction(rule=_busbalance_rule)
here it is referend to the parent block of self (m=self.parent_block()). This i want to recrate outsite of the BusBlock class. Given a bus b i want the parent block of the BusBlock object.
I trieded it using the constraint_group() function on b,but here only the class is returned not an object of the class. Wenn I tried converting this into an object using this code:
m = b.constraint_group()
n=m()
Then n was None.
Does anyone have an idea?