我有一个形式的连续时间 Pyomo 模型:
from pyomo.environ import *
from pyomo.dae import *
m = ConcreteModel()
m.t = ContinuousSet(bounds=(0,150))
m.T = Param(default=150)
m.S = Var(m.t, bounds=(0,None))
m.Sdot = DerivativeVar(m.S)
discretizer = TransformationFactory('dae.collocation')
discretizer.apply_to(m,nfe=100,ncp=3,scheme='LAGRANGE-RADAU')
m.obj = Objective(expr=m.S[122],sense=maximize)
但是,当我运行上面的代码时,我收到以下错误:
KeyError: "Error accessing indexed component: Index '120' is not valid for array component 'S'"
看着list(m.t)
,我看到,果然,122 不包括作为离散化点:
..., 121.73257700000001, 122.467423, ...
如何指定要包含在离散化中的点?