Vytvářím pyomo omezení tak, že Eout_pv[t] <= PV_gen[t] na každou hodnotu t.
V mém kódu níže, nejprve jsem se vytvořit sady, parametry, proměnné. Pak jsem vytvořit omezení.
model.T = Set(initialize=df.index.tolist(), ordered=True)
model.PV_gen = Param(model.T, initialize=df.pv_gen.tolist())
model.Eout_pv = Var(model.T, bounds=(0, 100))
def pv_export(model, t):
return model.Eout_pv[t] <= model.PV_gen[t]
model.pv_export = Constraint(model.T, rule=pv_export)
Když jsem spuštění tohoto, dostanu zprávu "AttributeError: 'seznam' objekt nemá žádný atribut 'is_expression_type'"
Byl bych velmi vděčný za každou pomoc
Plné chybová zpráva níže
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-47-3de19250551e> in <module>
2
3 start_time = time.time()
----> 4 output_df = optimize_year(df, first_model_period, last_model_period, result_time_step)
5 print("--- %s seconds ---" % (time.time() - start_time))
<ipython-input-47-a84557fa2321> in optimize_year(df, first_model_period, last_model_period, time_step)
72 return model.Eout_pv[t] <= model.PV_gen[t]
73
---> 74 model.pv_export = Constraint(model.T, rule=pv_export)
75
76 def total_export(model, t):
C:\ProgramFiles2\Anaconda\lib\site-packages\pyomo\core\base\block.py in __setattr__(self, name, val)
541 # Pyomo components are added with the add_component method.
542 #
--> 543 self.add_component(name, val)
544 else:
545 #
C:\ProgramFiles2\Anaconda\lib\site-packages\pyomo\core\base\block.py in add_component(self, name, val)
1079 _blockName, str(data))
1080 try:
-> 1081 val.construct(data)
1082 except:
1083 err = sys.exc_info()[1]
C:\ProgramFiles2\Anaconda\lib\site-packages\pyomo\core\base\constraint.py in construct(self, data)
774 for ndx in self._index:
775 try:
--> 776 tmp = apply_indexed_rule(self,
777 _init_rule,
778 _self_parent,
C:\ProgramFiles2\Anaconda\lib\site-packages\pyomo\core\base\misc.py in apply_indexed_rule(obj, rule, model, index, options)
59 return rule(model)
60 else:
---> 61 return rule(model, index)
62 else:
63 if index.__class__ is tuple:
<ipython-input-47-a84557fa2321> in pv_export(model, t)
70 def pv_export(model, t):
71 "Maximum PV export within a single period"
---> 72 return model.Eout_pv[t] <= model.PV_gen[t]
73
74 model.pv_export = Constraint(model.T, rule=pv_export)
pyomo\core\expr\numvalue.pyx in pyomo.core.expr.numvalue.NumericValue.__le__()
pyomo\core\expr\logical_expr.pyx in pyomo.core.expr.logical_expr._generate_relational_expression()
AttributeError: 'list' object has no attribute 'is_expression_type'