Python 中的随机最优控制问题
Stochastic optimal control problems in Python
有人知道解决随机最优控制问题的 python 程序包吗?
我发现 Gekko 可以解决控制问题,但我找不到将其用于随机问题的方法。
下面是使用 Gekko 的 stochastic model predictive control 的最小示例,其中参数 K 是随机选择的。模型的 10 个实例被共同优化以最小化 40(目标)的平方误差。
import numpy as np
from gekko import GEKKO
import matplotlib.pyplot as plt
# uncertain parameter
n = 10
K = np.random.rand(n)+1.0
m = GEKKO()
m.time = np.linspace(0,20,41)
# manipulated variable
p = m.MV(value=0, lb=0, ub=100)
p.STATUS = 1
p.DCOST = 0.1
p.DMAX = 20
# controlled variable
v = m.Array(m.CV,n)
for i in range(n):
v[i].STATUS = 1
v[i].SP = 40
v[i].TAU = 5
m.Equation(10*v[i].dt() == -v[i] + K[i]*p)
# solve optimal control problem
m.options.IMODE = 6
m.options.CV_TYPE = 2
m.solve()
# plot results
plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',LineWidth=2)
plt.ylabel('MV')
plt.subplot(2,1,2)
plt.plot([0,m.time[-1]],[40,40],'k-',LineWidth=3)
for i in range(n):
plt.plot(m.time,v[i].value,':',LineWidth=2)
plt.ylabel('CV')
plt.xlabel('Time')
plt.show()
Gekko paper (see Section 4) gives an overview of other optimal control packages as well. Some of them may have stochastic optimization capabilities. I also found the StoDynProg Python package for solving stochastic optimal control problems but it hasn't been updated for a while and I don't have experience with it. Victor Zavala shared work on stochastic optimal control of gas networks and Fengqi You shared work on optimization under uncertainty 也可能提供他们使用的灵感和工具集。
有人知道解决随机最优控制问题的 python 程序包吗?
我发现 Gekko 可以解决控制问题,但我找不到将其用于随机问题的方法。
下面是使用 Gekko 的 stochastic model predictive control 的最小示例,其中参数 K 是随机选择的。模型的 10 个实例被共同优化以最小化 40(目标)的平方误差。
import numpy as np
from gekko import GEKKO
import matplotlib.pyplot as plt
# uncertain parameter
n = 10
K = np.random.rand(n)+1.0
m = GEKKO()
m.time = np.linspace(0,20,41)
# manipulated variable
p = m.MV(value=0, lb=0, ub=100)
p.STATUS = 1
p.DCOST = 0.1
p.DMAX = 20
# controlled variable
v = m.Array(m.CV,n)
for i in range(n):
v[i].STATUS = 1
v[i].SP = 40
v[i].TAU = 5
m.Equation(10*v[i].dt() == -v[i] + K[i]*p)
# solve optimal control problem
m.options.IMODE = 6
m.options.CV_TYPE = 2
m.solve()
# plot results
plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',LineWidth=2)
plt.ylabel('MV')
plt.subplot(2,1,2)
plt.plot([0,m.time[-1]],[40,40],'k-',LineWidth=3)
for i in range(n):
plt.plot(m.time,v[i].value,':',LineWidth=2)
plt.ylabel('CV')
plt.xlabel('Time')
plt.show()
Gekko paper (see Section 4) gives an overview of other optimal control packages as well. Some of them may have stochastic optimization capabilities. I also found the StoDynProg Python package for solving stochastic optimal control problems but it hasn't been updated for a while and I don't have experience with it. Victor Zavala shared work on stochastic optimal control of gas networks and Fengqi You shared work on optimization under uncertainty 也可能提供他们使用的灵感和工具集。