2

I tried solving a equation with 11 intermediates to fit a constrained parameter.every intermediate and solution depends on that single parameter.But I'm getting a error code as -2.I don't know what error code -2 means.ultimately it shows solution not found and I used IMODE=2 for the operation

John Hedengren
  • 12,068
  • 1
  • 21
  • 25
  • This is one of the errors that is returned from the IPOPT solver when it can't find a solution. Could you modify your question to include your code or include a simple example that demonstrates the same issue? – John Hedengren Nov 27 '22 at 15:21

1 Answers1

2

The error code -2 comes from the IPOPT solver for problems where the solver could not solve the equations (achieve equation feasibility), let alone optimize the objective. Here are a couple examples that produce an error code:

Unbounded Solution (Error Code -1)

m = GEKKO()
y = m.Var(value=2,lb=0)
m.Equation(y**2>=1)
m.Maximize(y)
m.solve(disp=True)
EXIT: Maximum Number of Iterations Exceeded.
 
 An error occured.
 The error code is           -1

Infeasible Solution (Error Code 2)

m = GEKKO()
y = m.Var(value=2,lb=2)
m.Equation(y**2<=1)
m.Maximize(y)
m.solve(disp=True)
EXIT: Converged to a point of local infeasibility. Problem may be infeasible.
 
 An error occured.
 The error code is            2

Here is a list of error codes from IPOPT from the documentation.

✅ Solve_Succeeded:

Console Message: EXIT: Optimal Solution Found.

This message indicates that Ipopt found a (locally) optimal point within the desired tolerances.

✅❌ Solved_To_Acceptable_Level:

Console Message: EXIT: Solved To Acceptable Level.

This indicates that the algorithm did not converge to the "desired" tolerances, but that it was able to obtain a point satisfying the "acceptable" tolerance level as specified by the acceptable_tol options. This may happen if the desired tolerances are too small for the current problem.

✅❌ Feasible_Point_Found:

Console Message: EXIT: Feasible point for square problem found.

This message is printed if the problem is "square" (i.e., it has as many equality constraints as free variables) and Ipopt found a point that is feasible w.r.t. constr_viol_tol. It may, however, not be feasible w.r.t. tol.

❌ Infeasible_Problem_Detected:

Console Message: EXIT: Converged to a point of local infeasibility. Problem may be infeasible.

The restoration phase converged to a point that is a minimizer for the constraint violation (in the ℓ1-norm), but is not feasible for the original problem. This indicates that the problem may be infeasible (or at least that the algorithm is stuck at a locally infeasible point). The returned point (the minimizer of the constraint violation) might help you to find which constraint is causing the problem. If you believe that the NLP is feasible, it might help to start the optimization from a different point.

❌ Search_Direction_Becomes_Too_Small:

Console Message: EXIT: Search Direction is becoming Too Small.

This indicates that Ipopt is calculating very small step sizes and is making very little progress. This could happen if the problem has been solved to the best numerical accuracy possible given the current scaling.

❌ Diverging_Iterates:

Console Message: EXIT: Iterates divering; problem might be unbounded.

This message is printed if the max-norm of the iterates becomes larger than the value of the option diverging_iterates_tol. This can happen if the problem is unbounded below and the iterates are diverging.

❌ User_Requested_Stop:

Console Message: EXIT: Stopping optimization at current point as requested by user.

This message is printed if the user call-back method Ipopt::TNLP::intermediate_callback returned false.

❌ Maximum_Iterations_Exceeded:

Console Message: EXIT: Maximum Number of Iterations Exceeded.

This indicates that Ipopt has exceeded the maximum number of iterations as specified by the option max_iter.

❌ Maximum_WallTime_Exceeded:

Console Message: EXIT: Maximum wallclock time exceeded.

This indicates that Ipopt has exceeded the maximum number of wallclock seconds as specified by the option max_wall_time.

❌ Maximum_CpuTime_Exceeded:

Console Message: EXIT: Maximum CPU time exceeded.

This indicates that Ipopt has exceeded the maximum number of CPU seconds as specified by the option max_cpu_time.

❌ Restoration_Failed:

Console Message: EXIT: Restoration Failed!

This indicates that the restoration phase failed to find a feasible point that was acceptable to the filter line search for the original problem. This could happen if the problem is highly degenerate, does not satisfy the constraint qualification, or if your NLP code provides incorrect derivative information.

❌ Error_In_Step_Computation:

Console Output: EXIT: Error in step computation!

This message is printed if Ipopt is unable to compute a step towards a new iterate and the current iterate is not acceptable for the specified tolerances.

A possible reason is that a search direction could not be computed despite several attempts to modify the iteration matrix. Usually, the value of the regularization parameter then becomes too large. One situation where this can happen is when values in the Hessian are invalid (NaN or Inf). You can check whether this is true by using the option check_derivatives_for_naninf.

Another reason is that the feasibility restoration phase could not be activated because the current iterate is not infeasible. Reasons for this again include that the problem is highly degenerate, badly scaled, does not satisfy the constraint qualification, or that your NLP code provides incorrect derivative information. Before Ipopt 3.14, this resulted in a Restoration_Failed status code with message "Restoration phase is called at almost feasible point..."

❌ Invalid_Option:

Console Message: (details about the particular error will be output to the console)

This indicates that there was some problem specifying the options. See the specific message for details. This return code is also used when a linear solver is choosen that was not linked in and a library that contains this linear solver could not be loaded.

❌ Not_Enough_Degrees_Of_Freedom:

Console Message: EXIT: Problem has too few degrees of freedom.

This indicates that your problem, as specified, has too few degrees of freedom. This can happen if you have too many equality constraints, or if you fix too many variables (Ipopt removes fixed variables by default, see also the option fixed_variable_treatment).

❌ Invalid_Problem_Definition:

Console Message: EXIT: Problem has inconsistent variable bounds or constraint sides.

This indicates that either there was an exception of some sort when building the IpoptProblem structure in the C or Fortran interface or bounds specified for variables or constraints were inconsistent (lower bound larger than upper bound, left-hand-side larger than right-hand-side). Likely there is an error in your model or the main routine.

❌ Unrecoverable_Exception:

Console Message: (details about the particular error will be output to the console)

This indicates that Ipopt has thrown an exception that does not have an internal return code. See the specific message for details.

❌ NonIpopt_Exception_Thrown:

Console Message: Unknown Exception caught in Ipopt

An unknown exception was caught in Ipopt. This exception could have originated from your model or any linked in third party code. See also Ipopt::IpoptApplication::RethrowNonIpoptException.

❌ Insufficient_Memory:

Console Message: EXIT: Not enough memory.

An error occurred while trying to allocate memory. The problem may be too large for your current memory and swap configuration.

❌ Console Message: EXIT: Integer type too small for required memory.

A linear solver requires more working space than what can be communicated to it via the used integer type.

❌ Internal_Error:

Console: EXIT: INTERNAL ERROR: Unknown SolverReturn value - Notify IPOPT Authors.

An unknown internal error has occurred. Please notify the authors of Ipopt via the mailing list.

John Hedengren
  • 12,068
  • 1
  • 21
  • 25
  • 1
    But I'm getting some warning message like; Console: Warning: Cutting back alpha due to evaluation error – Aravind kumar Dec 03 '22 at 19:47
  • That’s also an IPOPT message. Here are more details on the Interior Point algorithm. https://apmonitor.com/me575/index.php/Main/InteriorPointMethod For more detailed help, please post another question with your code. – John Hedengren Dec 04 '22 at 00:36
  • 1
    The "Cutting back alpha due to evaluation error" message usually comes up when Ipopt tries to iterate into an area where some functions cannot be evaluated, e.g., a log(x) with <= 0. Sometimes this can be avoided by setting proper variable bounds. The "cutting back alpha" refers to Ipopt using a shorter step from the current iterate to the next one than it would have liked, due to the longer step leading to a point that cannot be evaluated. – stefan Jan 31 '23 at 02:34