## APM.SOLVER - APMonitor Option

## Main.OptionApmSolver History

Hide minor edits - Show changes to output

Changed line 84 from:

The selection of the linear solver in IPOPT affects the speed and sometimes the ability of IPOPT to solve the problem, especially for ill-conditioned problems. IPOPT is available through the default public server. However, IPOPT and certain linear solvers are not currently available (track issue on GitHub) for local solution without an internet connection.

to:

The selection of the linear solver in IPOPT affects the speed and sometimes the ability of IPOPT to solve the problem, especially for ill-conditioned problems. IPOPT is available through the default public server. However, IPOPT and certain linear solvers are not currently available ([[https://github.com/BYU-PRISM/GEKKO/issues/50|track issue on GitHub]]) for local solution without an internet connection.

Changed line 35 from:

m = GEKKO(server='https://byu.apmonitor.com')

to:

m = GEKKO(remote=True,server='https://byu.apmonitor.com')

Changed line 41 from:

m = GEKKO(server='https://byu.apmonitor.com')

to:

m = GEKKO(remote=True,server='https://byu.apmonitor.com')

Changed lines 74-94 from:

Refer to [[https://coin-or.github.io/Ipopt/OPTIONS.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' ~~solver~~

to:

Refer to [[https://coin-or.github.io/Ipopt/OPTIONS.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver. The IPOPT solver links to free and open-source (e.g. MUMPS) linear solvers or others that require a license (e.g. HSL MA57).

(:source lang=python:)

from gekko import GEKKO

m = GEKKO(remote=True)

m.options.SOLVER=3 # Select IPOPT

m.solver_options = ['linear_solver ma57',\

'mu_strategy adaptive']

(:sourceend:)

The selection of the linear solver in IPOPT affects the speed and sometimes the ability of IPOPT to solve the problem, especially for ill-conditioned problems. IPOPT is available through the default public server. However, IPOPT and certain linear solvers are not currently available (track issue on GitHub) for local solution without an internet connection.

(:source lang=python:)

from gekko import GEKKO

m = GEKKO(remote=False)

m.options.SOLVER=3 # Select IPOPT

m.solver_options = ['linear_solver mumps',\

'mu_strategy adaptive']

(:sourceend:)

When switching to a local solution, the solver selection will switch to one that is available (e.g. APOPT) or else use IPOPT but with a linear solver that can be distributed freely. This change of solvers sometimes leads to a different solution when using ''remote=False''.

(:source lang=python:)

from gekko import GEKKO

m = GEKKO(remote=True)

m.options.SOLVER=3 # Select IPOPT

m.solver_options = ['linear_solver ma57',\

'mu_strategy adaptive']

(:sourceend:)

The selection of the linear solver in IPOPT affects the speed and sometimes the ability of IPOPT to solve the problem, especially for ill-conditioned problems. IPOPT is available through the default public server. However, IPOPT and certain linear solvers are not currently available (track issue on GitHub) for local solution without an internet connection.

(:source lang=python:)

from gekko import GEKKO

m = GEKKO(remote=False)

m.options.SOLVER=3 # Select IPOPT

m.solver_options = ['linear_solver mumps',\

'mu_strategy adaptive']

(:sourceend:)

When switching to a local solution, the solver selection will switch to one that is available (e.g. APOPT) or else use IPOPT but with a linear solver that can be distributed freely. This change of solvers sometimes leads to a different solution when using ''remote=False''.

Changed line 74 from:

Refer to [[https://~~www.~~coin-or.~~org~~/Ipopt/~~documentation/node40~~.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver

to:

Refer to [[https://coin-or.github.io/Ipopt/OPTIONS.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver

Changed line 60 from:

{$gap=\frac{obj_i-obj_r}{\max(\frac{\~~|~~obj_i\~~|~~+\~~|~~obj_r\~~|~~}{2},1)}$}

to:

{$gap=\frac{obj_i-obj_r}{\max \left( \frac{\lvert obj_i\rvert+\lvert obj_r\rvert}{2},1 \right)}$}

Changed line 60 from:

{$gap=\frac{obj_i-obj_r}{\max(\frac{\~~abs(~~obj_i~~)+~~\~~abs(~~obj_r~~)~~}{2},1)}$}

to:

{$gap=\frac{obj_i-obj_r}{\max(\frac{\|obj_i\|+\|obj_r\|}{2},1)}$}

Changed line 60 from:

{$gap=\frac{obj_i-obj_r}{\max((~~abs(~~obj_i)+abs(obj_r)~~)/~~2,1)}$}

to:

{$gap=\frac{obj_i-obj_r}{\max(\frac{\abs(obj_i)+\abs(obj_r)}{2},1)}$}

Changed lines 58-61 from:

* '''minlp_gap_tol 1.0e-2''' - gap is the spread between the lowest candidate leaf (obj_r=non-integer solution) and the best integer solution (obj_i). When the gap is below the minlp_gap_tol, the best integer solution is returned. The gap is defined as~~ ~~gap=~~(~~obj_i-obj_r~~)/~~max((abs(obj_i)+abs(obj_r))/2,1)~~. ~~

to:

* '''minlp_gap_tol 1.0e-2''' - gap is the spread between the lowest candidate leaf (obj_r=non-integer solution) and the best integer solution (obj_i). When the gap is below the minlp_gap_tol, the best integer solution is returned. The gap is defined as

{$gap=\frac{obj_i-obj_r}{\max((abs(obj_i)+abs(obj_r))/2,1)}$}

{$gap=\frac{obj_i-obj_r}{\max((abs(obj_i)+abs(obj_r))/2,1)}$}

Changed line 71 from:

Refer to[[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver

to:

Refer to [[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver

Deleted lines 31-32:

Added lines 67-68:

Refer to [[https://apopt.com/download.php|Options for apopt.opt]] for additional details for the '''APOPT''' solver.

Added lines 70-73:

Refer to[[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver

!!!! Additional APMonitor Options

Changed line 55 from:

* minlp_maximum_iterations 10000 - maximum number of nlp solutions from the branch and bound method. A successful solution is returned if there is an integer solution upon reaching the maximum number of iterations. Otherwise, the solution is not considered to be successful and an error message is returned with the failed solution.

to:

* '''minlp_maximum_iterations 10000''' - maximum number of nlp solutions from the branch and bound method. A successful solution is returned if there is an integer solution upon reaching the maximum number of iterations. Otherwise, the solution is not considered to be successful and an error message is returned with the failed solution.

Added lines 68-69:

!!!! IPOPT Options

Added lines 50-67:

!!!! APOPT Options

The APOPT solver has a number of options that are available for tuning the solver performance. Some of the available options and default values are listed below:

* minlp_maximum_iterations 10000 - maximum number of nlp solutions from the branch and bound method. A successful solution is returned if there is an integer solution upon reaching the maximum number of iterations. Otherwise, the solution is not considered to be successful and an error message is returned with the failed solution.

* '''minlp_max_iter_with_int_sol 500''' - maximum number of nlp solutions when a candidate integer solution is found

* '''minlp_as_nlp 1''' - solve minlp problem as a continuous nlp problem, ignoring integer constraints

* '''minlp_branch_method 3''' - 1=depth first (find integer solution faster), 2=breadth first, 3=lowest objective leaf, 4=highest objective leaf

* '''minlp_gap_tol 1.0e-2''' - gap is the spread between the lowest candidate leaf (obj_r=non-integer solution) and the best integer solution (obj_i). When the gap is below the minlp_gap_tol, the best integer solution is returned. The gap is defined as gap=(obj_i-obj_r)/max((abs(obj_i)+abs(obj_r))/2,1).

* '''minlp_integer_tol 1.0e-2''' - amount that a candidate solution variable can deviate from an integer solution and still be considered an integer.

* '''minlp_integer_max 2.0e9''' - maximum value to be considered as an integer. Values over 2147483647 or below -2147483648 not stored correctly with an internal integer variable type because of the number of bits used to store an integer.

* '''minlp_integer_leaves 1''' - add additional integer leaves, 0=off, 1=integer leaves with inequality on branching, 2=integer leaves with equality constraint on branching.

* '''minlp_print_level 1''' - print level (0-10). Development version has additional advanced diagnostics.

* '''nlp_maximum_iterations 500''' - maximum number of iterations for each nlp sub-problem. Reducing the nlp maximum iterations can improve the solution speed because less computational time is spent on candidate solutions that may not converge

* '''objective_convergence_tolerance 1.0e-6''' - convergence tolerance for the objective function. Values lower than 1.0e-10 sometimes run into covergence problems because of numerical scaling and cannot achieve the requested accuracy.

* '''constraint_convergence_tolerance 1.0e-6''' - convergence tolerance for the constraints. A lower convergence tolerance typically adds only a couple additional iterations to the solution but the solution also does not change significantly.

Added lines 40-48:

(:sourceend:)

(:source lang=python:)

m = GEKKO(server='https://byu.apmonitor.com')

# multiple options as one list

m.solver_options = ['minlp_gap_tol 1.0e-2',\

'minlp_maximum_iterations 10000',\

'minlp_max_iter_with_int_sol 500']

m.options.solver = 1

(:source lang=python:)

m = GEKKO(server='https://byu.apmonitor.com')

# multiple options as one list

m.solver_options = ['minlp_gap_tol 1.0e-2',\

'minlp_maximum_iterations 10000',\

'minlp_max_iter_with_int_sol 500']

m.options.solver = 1

Added lines 33-40:

In the [[https://gekko.readthedocs.io/en/latest/|GEKKO Optimization Suite]] the solver options are changed directly within Python.

(:source lang=python:)

m = GEKKO(server='https://byu.apmonitor.com')

m.solver_options = ['linear_solver ma57']

m.options.solver = 3

(:sourceend:)

Changed line 32 from:

Refer to [[https://apopt.com/download.php|Options for apopt.opt]] for additional details for the '''APOPT''' solver and [[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt~~ file~~]] for additional details for the '''IPOPT''' solver.

to:

Refer to [[https://apopt.com/download.php|Options for apopt.opt]] for additional details for the '''APOPT''' solver and [[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt]] for additional details for the '''IPOPT''' solver.

Added lines 14-32:

Options for solvers can be set using configuration parameters such as [[Main/OptionApmMaxIter|MAX_ITER]] or else by creating an options file such as '''ipopt.opt''' or '''apopt.opt'''. Below is an example of setting options for the [[https://apopt.com|APOPT solver]] for a mixed integer nonlinear programming solution. The ''File...End File'' section creates a new '''apopt.opt''' file when APMonitor compiles the model file.

File apopt.opt

minlp_maximum_iterations 10000

minlp_max_iter_with_int_sol 500

minlp_as_nlp 1

minlp_branch_method 3

minlp_gap_tol 1.0e-2

minlp_integer_tol 1.0e-2

minlp_integer_max 2.0e9

minlp_integer_leaves 1

minlp_print_level 1

nlp_maximum_iterations 500

objective_convergence_tolerance 1.0e-6

constraint_convergence_tolerance 1.0e-6

End File

Refer to [[https://apopt.com/download.php|Options for apopt.opt]] for additional details for the '''APOPT''' solver and [[https://www.coin-or.org/Ipopt/documentation/node40.html|Options for ipopt.opt file]] for additional details for the '''IPOPT''' solver.

Changed lines 5-6 from:

%width=50px%Attach:apm.png

to:

%width=50px%Attach:apm.png [[Main/DbsGlobal|Global Options]] | %width=30px%Attach:fv.png %width=30px%Attach:mv.png %width=30px%Attach:sv.png %width=30px%Attach:cv.png[[Main/DbsVariable|Local Options]]

Added lines 14-15:

See also [[Main/OptionApmMaxIter|MAX_ITER]], [[Main/OptionApmMaxTime|MAX_TIME]]

Added lines 1-13:

(:title APM.SOLVER - APMonitor Option:)

(:keywords APM.SOLVER, Optimization, Estimation, Option, Configure, Default, Description:)

(:description Solver options: 0 = Benchmark All Solvers, 1-5 = Available Solvers Depending on License:)

%width=50px%Attach:apm.png

Type: Integer, Input

Default Value: 3

Description: Solver options

0 = Benchmark All Solvers

1-5 = Available Solvers Depends on License

SOLVER selects the solver to use in an attempt to find a solution. There are free solvers: 1: APOPT, 2: BPOPT, 3: IPOPT distributed with the public version of the software. There are additional solvers that are not included with the public version and require a commercial license. IPOPT is generally the best for problems with large numbers of degrees of freedom or when starting without a good initial guess. BPOPT has been found to be the best for systems biology applications. APOPT is generally the best when warm-starting from a prior solution or when the number of degrees of freedom (Number of Variables - Number of Equations) is less than 2000. APOPT is also the only solver that handles Mixed Integer problems. Use option 0 to compare all available solvers.

(:keywords APM.SOLVER, Optimization, Estimation, Option, Configure, Default, Description:)

(:description Solver options: 0 = Benchmark All Solvers, 1-5 = Available Solvers Depending on License:)

%width=50px%Attach:apm.png

Type: Integer, Input

Default Value: 3

Description: Solver options

0 = Benchmark All Solvers

1-5 = Available Solvers Depends on License

SOLVER selects the solver to use in an attempt to find a solution. There are free solvers: 1: APOPT, 2: BPOPT, 3: IPOPT distributed with the public version of the software. There are additional solvers that are not included with the public version and require a commercial license. IPOPT is generally the best for problems with large numbers of degrees of freedom or when starting without a good initial guess. BPOPT has been found to be the best for systems biology applications. APOPT is generally the best when warm-starting from a prior solution or when the number of degrees of freedom (Number of Variables - Number of Equations) is less than 2000. APOPT is also the only solver that handles Mixed Integer problems. Use option 0 to compare all available solvers.