与MPC在Gekko的自由度警告
我正在尝试使用Gekko和MPC预测控制器的行为。我是控制系统的新手,以前从未与MPC或Gekko合作过。
我想最大程度地减少通风系统中风扇的功率,同时将温度保持在所需的范围内,特别是在图像中显示的范围内:
我已经获得了一个使用Pysindy的方程式描述了通风系统的风扇功率与房间温度之间的关系。它以:
DX/DT = 0.205+0.029Y-0.003XY-0.001X^2,
其中X是室温,Y是风扇功率。
我的代码如下:
# Initialize GEKKO model
m = GEKKO()
m.time = np.linspace(0,144,144)
# Manipulated variable
y = m.MV(value=0,lb=0,ub=100) # *** This is the fan power y ***
y.STATUS = 1
y.DCOST = 0.1
y.DMAX = 20
# Controlled variable
x = m.CV(value=18) #Initial value of control variable. *** This is temperature x ***
x.STATUS = 1
m.option.CV_TYPE = 1 #L1 norm
x.RT_INIT = 1
x.TAU = 20
# Add contraints
temp_u = np.concatenate((19*np.ones(32),22.5*np.ones(80),19*np.ones(32))) # Upper temperature limit
temp_l = np.concatenate((17.5*np.ones(38),21.0*np.ones(68),17.5*np.ones(38))) # Lower temperature limit
T_low = m.Param(value=temp_l)
T_high = m.Param(value=temp_u)
m.Equations([x>=T_low, x<=T_high])
# Equation
m.Equation(x.dt() == 0.205+0.029*y-0.003*x*y-0.001*(x**2))
#MPC Mode
m.options.IMODE = 6
#Solve
m.solve()
我得到以下输出:
apm 77.241.105.43_gk_model4 <br><pre> ----------------------------------------------------------------
APMonitor, Version 1.0.1
APMonitor Optimization Suite
----------------------------------------------------------------
--------- APM Model Size ------------
Each time step contains
Objects : 0
Constants : 0
Variables : 6
Intermediates: 0
Connections : 0
Equations : 3
Residuals : 3
Number of state variables: 2860
Number of total equations: - 2717
Number of slack variables: - 286
---------------------------------------
Degrees of freedom : -143
* Warning: DOF <= 0
**********************************************
Dynamic Control with Interior Point Solver
...
Creating file: infeasibilities.txt
Use command apm_get(server,app,'infeasibilities.txt') to retrieve file
@error: Solution Not Found
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
~\mpc.ipynb Cell 11' in <cell line: 1>()
----> 1 m.solve()
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gekko.py:2185, in GEKKO.solve(self, disp, debug, GUI, **kwargs)
2183 #print APM error message and die
2184 if (debug >= 1) and ('@error' in response):
-> 2185 raise Exception(response)
2187 #load results
2188 def byte2str(byte):
Exception: @error: Solution Not Found
I am trying to predict how a controller behaves given a temperature range using GEKKO and MPC. I am new to control systems and have never worked with either MPC or GEKKO before.
I want to minimize the power of a fan in a ventilation system while keeping the temperature within a desired range, specifically within the range shown in the image:
I have obtained an equation using PySINDy that described the relationship between fan power of a ventilation system and the temperature in the room. It is given as:
dx/dt = 0.205+0.029y-0.003xy-0.001x^2
where x is the room temperature and y is the fan power.
My code is as follows:
# Initialize GEKKO model
m = GEKKO()
m.time = np.linspace(0,144,144)
# Manipulated variable
y = m.MV(value=0,lb=0,ub=100) # *** This is the fan power y ***
y.STATUS = 1
y.DCOST = 0.1
y.DMAX = 20
# Controlled variable
x = m.CV(value=18) #Initial value of control variable. *** This is temperature x ***
x.STATUS = 1
m.option.CV_TYPE = 1 #L1 norm
x.RT_INIT = 1
x.TAU = 20
# Add contraints
temp_u = np.concatenate((19*np.ones(32),22.5*np.ones(80),19*np.ones(32))) # Upper temperature limit
temp_l = np.concatenate((17.5*np.ones(38),21.0*np.ones(68),17.5*np.ones(38))) # Lower temperature limit
T_low = m.Param(value=temp_l)
T_high = m.Param(value=temp_u)
m.Equations([x>=T_low, x<=T_high])
# Equation
m.Equation(x.dt() == 0.205+0.029*y-0.003*x*y-0.001*(x**2))
#MPC Mode
m.options.IMODE = 6
#Solve
m.solve()
I get the following output :
apm 77.241.105.43_gk_model4 <br><pre> ----------------------------------------------------------------
APMonitor, Version 1.0.1
APMonitor Optimization Suite
----------------------------------------------------------------
--------- APM Model Size ------------
Each time step contains
Objects : 0
Constants : 0
Variables : 6
Intermediates: 0
Connections : 0
Equations : 3
Residuals : 3
Number of state variables: 2860
Number of total equations: - 2717
Number of slack variables: - 286
---------------------------------------
Degrees of freedom : -143
* Warning: DOF <= 0
**********************************************
Dynamic Control with Interior Point Solver
...
Creating file: infeasibilities.txt
Use command apm_get(server,app,'infeasibilities.txt') to retrieve file
@error: Solution Not Found
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
~\mpc.ipynb Cell 11' in <cell line: 1>()
----> 1 m.solve()
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gekko.py:2185, in GEKKO.solve(self, disp, debug, GUI, **kwargs)
2183 #print APM error message and die
2184 if (debug >= 1) and ('@error' in response):
-> 2185 raise Exception(response)
2187 #load results
2188 def byte2str(byte):
Exception: @error: Solution Not Found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于那些处于类似位置的人,解决了我自己的问题:
For those in a similar position, solved my own problem with this code: