我使用pyomo开发了一个能量优化模型,但是当我添加风力涡轮机约束时出现了一些误差: return Sys.Power_WT_Unit[i]== 0.5*(Sys.WindSpeed[i]**3)
。
它说
DeveloperError:内部Pyomo实现错误:'派生组件 IndexedConstraint无法定义_default()。'"
ERROR: Rule failed when generating expression for constraint Power_WT_Unit with index 1:
DeveloperError: Internal Pyomo implementation error:
'Derived component IndexedConstraint failed to define _default().'
Please report this to the Pyomo Developers. ERROR: Constructing component 'Power_WT_Unit' from data=None failed:
DeveloperError: Internal Pyomo implementation error:
'Derived component IndexedConstraint failed to define _default().'
Please report this to the Pyomo Developers. Traceback (most recent call last):
File "<ipython-input-7-f74e8c884272>", line 1, in <module>
runfile('C:/Users/Koo/Documents/GitHub/EIS-Opt_Ver20180127/EIS-Opt.py', wdir='C:/Users/Koo/Documents/GitHub/EIS-Opt_Ver20180127')
File "D:\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "D:\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/Koo/Documents/GitHub/EIS-Opt_Ver20180127/EIS-Opt.py", line 23, in <module>
instance = SysResolution(Sys) # Add Constraints and solving the problem
File "SysResolution.py", line 75, in SysResolution
instance = Sys.create_instance(datapath) # load parameters
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\PyomoModel.py", line 714, in create_instance
report_timing=report_timing )
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\PyomoModel.py", line 785, in load
report_timing=report_timing)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\PyomoModel.py", line 861, in _load_model_data
self._initialize_component(modeldata, namespaces, component_name, profile_memory)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\PyomoModel.py", line 920, in _initialize_component
declaration.construct(data)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\constraint.py", line 761, in construct
ndx)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\misc.py", line 61, in apply_indexed_rule
return rule(model, index)
File "Constraints.py", line 147, in Power_WT_Unit
return Sys.Power_WT_Unit[i]== 0.5*(Sys.WindSpeed[i]**3)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\indexed_component.py", line 493, in __getitem__
return self._default(ndx)
File "D:\Anaconda2\lib\site-packages\pyomo\core\base\indexed_component.py", line 656, in _default
% (self.__class__.__name__,))
DeveloperError: Internal Pyomo implementation error: 'Derived component IndexedConstraint failed to define _default().'
请向Pyomo开发者报告。
答案 0 :(得分:0)
This error was reported in https://github.com/Pyomo/pyomo/issues/9 and fixed in https://github.com/Pyomo/pyomo/pull/133. The fix will be included in the Pyomo 5.4 release.
That said, there is something suspect in your model: the root cause appears to be that Sys.Power_WT_Unit
is declared as a Constraint in your model, but you are using it within an expression. The actual error is probably because the rule that is firing is trying to retrieve the i'th index of Power_WT_Unit
before that component was (fully) constructed.