我试图用几个ODE模拟一个DAE系统,其中一个(控制器)显示出与模拟时间尺度相比的巨大时滞。我应该如何在Pyomo中实现这一点(不考虑其他软件包,Gekko已经考虑过了,但由于apm.exe source不是作为开源发布的,因此不再考虑我的应用程序的软件包)
目前,我已将问题表述为:
odeu = lambda m, t: tau * m.dudt[t] - (m.spu[t] - m.u[t]) == 0
model.odeu = Constraint(model.t, rule=lambda m, t: odeu(m, t))
我正在努力制作的是: 目前,我已将问题表述为:
odeu = lambda m, t: tau * m.dudt[t] - (m.spu[t-tde] - m.u[t]) == 0
model.odeu = Constraint(model.t, rule=lambda m, t: odeu(m, t))
问题是,Pyomo将对方程进行离散化,并使用奇怪的浮点索引,而不是局部求值(优化所需的,当然,只是对我来说奇怪的浮点索引),因此索引t-tde
不存在
我考虑过在每一步中搜索最接近该点的索引,但这将以指数方式增加我的计算时间
谢谢
几点
首先,这是无效代码。我不确定最后一个段是什么,但是您不能在命名段之后添加位置参数,并且不清楚您试图用
t:ode(m, t)
做什么:Pyomo对集合索引的表达式进行求值,只要它在集合内,您就是GTG。我不确定你所说的“浮点索引”是什么意思。我认为你正在寻找类似这样的东西,其中有一个时间索引和一些偏移量,需要在某些约束中使用:
生成具有适当约束的模型
相关问题 更多 >
编程相关推荐