# GAMS Support Wiki

### Site Tools

solver:solving_a_model_to_optimality

# Solving a model to optimality

In the following, we assume that the GAMS model (or problem) is well scaled and does not cause other numerical issues for the solver.

To see if a model is solved to optimality, see the Solution Report from the Listing file (.lst):

```**** SOLVER STATUS     1 Normal Completion
**** MODEL STATUS      1 Optimal
**** OBJECTIVE VALUE   153.6750```

If the model status is not optimal, then the problem is not solved to optimality by the solver. An optimal solution is when the variable levels result in a best possible objective value, i.e. the variable level for the minimized or maximized variable. A solution satisfies all model constraints and is defined by variable levels that are subject to the solving tolerances that are used in the solver.

#### When model status is not Optimal

The first thing you may want to check is that you have instructed the solver to solve the model to optimality and that the solver does not stop on a limit. You may, for example, instruct the solver to use a zero optimality gap and increase the time limit, by using the following statements before the solve statement:

```Option optcr=0.0;
Option reslim=9E9;```

Note that the solver log file (.log) usually gives hints on why a solver did not solve a model to optimality.

#### Local vs. global NLP/MINLP solver

There are two types of non-linear solvers: local and global. A local solver is, in general, not able to prove that a found solution is globally optimal. However, they may still find a global optimal solution and many times they find a local optimal solution. A local optimal solution means that by doing small changes in the variable levels, it is not possible to find a solution with a better objective value. A global solver is able to find and prove that the final solution is globally optimal, i.e. there does not exist a solution that would result in a better objective value. The computational effort to solve a non-linear problem to global optimality is significantly higher and, therefore, the local solvers are typically used on larger problems, where a global solver is not expected to terminate in reasonable time. Furthermore, it is worth to note, that in some special cases, i.e. model formulations, a local solver can solve a model to global optimality, however, currently this is not reflected in the model status field of the solution report. Furthermore, note that a Quadratically Constrained Program (QCP) is a special type of Non-Linear Programming (NLP), that some solver handles in a specialized way. To see if a solver can solve a model to global optimality, see column Global and look for entries with *, on the following table. 