In GEKKO, what cause error "Restoration phase is called at point that is almost feasible, with constraint violation 8.305823e-009. Abort."

Viewed 27

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

1 Answers

The Restoration Phase error is from the IPOPT solver (default) in Gekko. This error sometimes appears when too much accuracy is requested or there is poor scaling and the solver has trouble finding a feasible solution. Here are a few things to consider:

Solver Tolerance

Set the solver and objective tolerance to avoid too much requested accuracy. The default is 1e-6 for both the residuals and objective tolerance. Try setting the tolerance to 1e-5.

m.options.RTOL=1e-6
m.options.OTOL=1e-6

Change Solver

Try using APOPT or BPOPT solvers instead of the default (IPOPT). This can help to identify infeasible equations or resolve the error.

m.options.SOLVER=1  # 1=APOPT, 2=BPOPT, 3=IPOPT

Scale Equation(s)

If the values in the equations are large then the requested accuracy may exceed machine precision. For example, if typical values of m.Unit1_Feed and other variables are in the range of 1e6 then try:

s = 1e-6
m.Equation(s*m.Flare==s*(m.Rundown-(m.Unit1_Feed+m.Unit2_Feed+m.Fuel)))

This does not change the equation but does improve the ease of finding a numerical solution when the 1st derivatives of the functions are closer to 1.0. Gekko and APMonitor automatically apply scaling to fix this issue based on the initial guess value. Scaling of equations is generally not needed if good initial guesses are given.

Related