I instantiated a Simulation object (GEKKO IMODE=4) and a Controller object (GEKKO IMODE=6) and run them iteratively in a loop whereby the controller sets the independent variables in the Simulator object and reads the State variable from the Simulator in the next cycle. The intent is to evaluate controller response due to various types of model error and later demonstrate the use of an Estimator object for adaptive control.
The controller runs fine for 37 iterations but then the solution fails with the error "Restoration phase is called a point that is almost feasible, with constraint violation 8.305823e-009. Abort." I tried SCALING=2 and then I reach 42 iterations before the same error message (albeit with a different numerical value for constraint violation. Changing some tuning parameters such as DMAX on MV's further pushed the error out to later iterations.
I only have two Equality constraints:
m.Equation(m.TankLevel.dt()==m.Balance)
m.Equation(m.Flare==m.Rundown-(m.Unit1_Feed+m.Unit2_Feed+m.Fuel))
Since the error message appeared to me as a numerical precision issue, I changed the last Equality constraint into an inequality constraint
m.Equation(m.Flare<=m.Rundown-(m.Unit1_Feed+m.Unit2_Feed+m.Fuel)+10e-8)
that seemed to sort the problem out.
What is the underlying reason for the error and should I have addressed it in a different way?
GEKKO 1.0.5, APMonitor 1.0.0