Mode 9 is infeasible GEKKO

100 views Asked by At

I successfully performed this simulation in mode 6, this is a microalgae model. I want to compare it with mode 9. But mode 9 is always infeasible. Any suggestion? About how can I fix mode 9? I try we different initial conditions but ti doest not work

#%% Bennatia Model Dynamic Optimization 
#v 2.1
from gekko import GEKKO
import numpy as np

#Initialize model
m = GEKKO (remote=True)

#% Parameters 
mu_   = m.Param(value=2, name="u");
rho_m = m.Param(value=9.3, name="rhom");
K_Q   = m.Param(value=1.8, name="KQ");
K_s   = m.Param(value=0.105, name="KS");
S_in  = m.Param(value=100, name="S_in");
K_sI  = m.Param(value=150, name="KsI");
K_iI  = m.Param(value=2000, name="KiI");
mu_I  = m.Param(value=0.6461, name="muI");


# Define Dilution rate as Manipulated variable
D = m.MV(value=0.1, lb=0.001, ub=2);
# Manipulated variable
D.STATUS = 1 # allow optimizer to change
D.DCOST = 0.1 # smooth out D movement
D.DMAX = 0.1   # slow down D
#%% Variables
# Constrains Equations
# x > 0, Q < 8.9969 , Q > 1.8, s > 0, s < 120 
x = m.Var(value=0.2, lb=0 , ub=100, name ='x');
Q = m.Var(value=1.8, lb=1.8 , ub=8.9969, name = 'Q');
s = m.Var(value=0.01, lb=0 , ub=100, name = 's') ;
mu = m.Var(value=0.1, lb=0 , ub=2, name = 'mut');
#time
#t=m.Var(value=0) #for time optimization

tf = 60
nt =15*tf+1
m.time = np.linspace(0,tf,nt)
t = m.Param(value=m.time); # For maximun value

#%% Equations 
# m.Equation(t.dt()  == 1) # For time optimization only
#For implicit form x.dt() Q.dt() s.dt()
m.Equation(mu == mu_*(1 - K_Q/(Q) )*mu_I);
m.Equation(x.dt()  == mu*x - D*x);
m.Equation(Q.dt()  == rho_m*((s)/ ((s)+ K_s)) - mu*Q);
m.Equation(s.dt()  == (S_in - s)*D - rho_m*((s)/ ((s)+ K_s)) * x);

m.Maximize(D*x)
#%% Solver options

m.options.SENSITIVITY = 1   # sensitivity analysis
m.options.IMODE = 9 # Mode 6 is working
m.solve(disp=True,GUI=True)
m.solve();
print(m.path)

I looked into the infeasibilities file but could not grasp the problem. Appreciate any guidance.

2

There are 2 answers

0
John Hedengren On

In Gekko, there are 9 solution modes that are controlled with IMODE:

APMonitor Gekko IMODE

  1. Steady-state simulation (SS)
  2. Model parameter update (MPU)
  3. Real-time optimization (RTO)
  4. Dynamic simulation (SIM)
  5. Moving horizon estimation (EST)
  6. Nonlinear control / dynamic optimization (CTL)
  7. Sequential dynamic simulation (SQS)
  8. Sequential dynamic estimation (SQE)
  9. Sequential dynamic optimization (SQO)

Modes 4 & 7, 5 & 8, and 6 & 9 should give the same solution but they use a different solution method. Modes 6 and 9 are simultaneous and hybrid sequential solution approaches. In general, I don't recommend IMODE=8 and IMODE=9 because they often fail to find a solution. If you are getting a solution with IMODE=6 you can either stop there or else use the solution to initialize the solution for IMODE=9.

0
ldsangr3 On

Thanks for your answer, where can i find something related to this hybrid sequential method, I just want to justify why often fail.