I'm currently trying out the GEKKO MHE mode. I have two specified manipulated variables and controlled variables in the model, and one parameter that I'm looking to estimate via MHE. When I currently run the model, I get an equation definition error, saying that
Equation without an equality (=) or inequality (>,<) -267.25544516-267.28925105-267.21324717-267.21191109-264.56454462 STOPPING...
The model was initialized as:
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
n = 17
m = GEKKO(remote=False)
m.time = np.linspace(0,8,n)
c1_in_arr = np.load('c1_in_arr.npy')
c2_in_arr = np.load('c2_in_arr.npy')
V1_measured = np.load('V1_measured.npy')
V2_measured = np.load('V2_measured.npy')
#mmanipulated variables, feeding in the arrays for them
m.C1_in = m.MV(value=c1_in_arr)
m.C2_in = m.MV(value=c2_in_arr)
#estimated variables, feeding in the upper and lower bounds for them
m.C1_eff = m.FV(value = 0.98, lb = 0.95, ub = 1.0)
#controlled variables, feeding in the measurements for them
m.V1 = m.CV(value=V1_measured)
m.V2 = m.CV(value=V2_measured)
mdot_1 = m.Var()
mdot_2 = m.Var()
m.Equation(mdot_1== 1.52*m.C1_eff*m.C1_in)
m.Equation(mdot_2==-0.668*mdot_1 + 1.33*m.C1_eff*m.C2_in)
df_c = pd.read_csv('Values_C.csv',index_col=0)
Hhat_C1 = m.Var()
Hhat_C1 = m.Var()
M_m = 125
mdot_m = 75
mdot_s = 46
m.Equations([Hhat_C1 == -0.606 + 0.0057 * mdot_1,
Hhat_C2 == -3.933 + 0.00096 * mdot_1])
C1_m = m.Var(value = 200)
C2_m = m.Var(value = 150)
m.Equations([C1_m.dt() == mdot_1 - C1_m/M_m*mdot_m,
C2_m.dt() == mdot_2 - C2_m/M_s*mdot_s)
m.Equation(m.V1==0.8*C1_m/M_m)
m.Equation(m.V2 == 0.78*C1_m/C2_m)
m.options.IMODE = 5
#setting the solver settings to MHE
m.options.EV_TYPE = 1
#setting the solver for the MHE to calculate the parameters based on the sum of absolute errors
m.C1_in.STATUS = 0
m.C2_in.STATUS = 0
m.SiO2_in.STATUS = 0
m.C1_eff.STATUS = 1
m.V1.STATUS = 1
m.V2.STATUS = 1
m.C1_in.FSTATUS = 1
m.C2_in.FSTATUS = 1
m.C1_eff.FSTATUS = 0
m.V1.FSTATUS = 1
m.V2.FSTATUS = 1
m.C1_eff.DMAX = 1.0
m.V1.MEAS_GAP = 0.001
m.V2.MEAS_GAP = 0.001
m.open_folder()
m.solve(disp = False)
When I open the GEKKO folder prior to solving, the infeasibilities file is also not present in the folder.
The model is able to run without error when the MVs and CVs are initialized as just the first variable of the "measurement" array
ex. m.C1_in = m.MV(value=c1_in_arr[0])
however, the provided parameter estimate is then incorrect.
I think that this error may be due to the way my MVs and CVs are being treated within the model. Is there a way to pinpoint which equation is causing this error, or if it's due to the MV/CV initialization?
Thank you!