Reference

Contents

Index

JSOSuite.optimizers — Constant
optimizers

DataFrame with the JSO-compliant solvers and their properties.

For each solver, the following are available:

  • name::String: name of the solver;
  • name_solver::Symbol: name of the solver structure for in-place solve, :not_implemented if not implemented;
  • name_parameters::Symbol: name of the parameter structure, :not_implemented if not implemented;
  • name_pkg::String: name of the package implementing this solver or its NLPModel wrapper;
  • solve_function::Symbol: name of the function;
  • is_available::Bool: true if the solver is available;
  • bounds::Bool: true if the solver can handle bound constraints;
  • equalities::Bool: true if the solver can handle equality constraints;
  • inequalities::Bool: true if the solver can handle inequality constraints;
  • specialized_nls::Bool: true if the solver has a specialized variant for nonlinear least squares;
  • can_solve_nlp::Bool: true if the solver can solve general problems. Some may only solve nonlinear least squares;
  • nonlinear_obj::Bool: true if the solver can handle nonlinear objective;
  • nonlinear_con::Bool: true if the solver can handle nonlinear constraints;
  • double_precision_only::Bool: true if the solver only handles double precision (Float64);
  • highest_derivative::Int: order of the highest derivative used by the algorithm.
source
JSOSuite.bmark_solvers — Function
bmark_solvers(problems, solver_names::Vector{String}; kwargs...)
bmark_solvers(problems, solver_names::Vector{String}, solvers::Dict{Symbol, Function}; kwargs...)

Wrapper to the function SolverBenchmark.bmark_solvers.

Arguments

  • problems: The set of problems to pass to the solver, as an iterable ofAbstractNLPModel;
  • solver_names::Vector{String}: The names of the benchmarked solvers. They should be valid JSOSuite names, see JSOSuite.solvers.name for a list;
  • solvers::solvers::Dict{Symbol, Function}: A dictionary of additional solvers to benchmark.

Output

A Dict{Symbol, DataFrame} of statistics.

Keyword Arguments

The following keywords available are passed to the JSOSuite solvers:

  • atol: absolute tolerance;
  • rtol: relative tolerance;
  • max_time: maximum number of seconds;
  • max_eval: maximum number of cons + obj evaluations;
  • verbose::Int = 0: if > 0, display iteration details every verbose iteration.

All the remaining keyword arguments are passed to the function SolverBenchmark.bmark_solvers.

Examples

using ADNLPModels, JSOSuite, Logging, SolverBenchmark
nlps = (
  ADNLPModel(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
  ADNLPModel(x -> 4 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
)
names = ["LBFGS", "TRON"] # see `JSOSuite.optimizers.name` for the complete list
stats = with_logger(NullLogger()) do
  bmark_solvers(nlps, names, atol = 1e-3, colstats = [:name, :nvar, :ncon, :status])
end
keys(stats)

The second example shows how to add you own solver to the benchmark.

using ADNLPModels, JSOSolvers, JSOSuite, Logging, SolverBenchmark
nlps = (
  ADNLPModel(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
  ADNLPModel(x -> 4 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0]),
)
names = ["LBFGS", "TRON"] # see `JSOSuite.optimizers.name` for the complete list
other_solvers = Dict{Symbol, Function}(
  :test => nlp -> lbfgs(nlp; mem = 2, atol = 1e-3, verbose = 0),
)
stats = with_logger(NullLogger()) do
  bmark_solvers(nlps, names, other_solvers, atol = 1e-3, colstats = [:name, :nvar, :ncon, :status])
end
keys(stats)
source
JSOSuite.feasible_point — Function
stats = feasible_point(nlp::Union{AbstractNLPModel, JuMP.Model}; kwargs...)
stats = feasible_point(nlp::Union{AbstractNLPModel, JuMP.Model}, solver_name::Symbol; kwargs...)

Compute a feasible point of the optimization problem nlp. The signature is the same as the function minimize.

Output

The value returned is a GenericExecutionStats, see SolverCore.jl, where the status, solution, primal_residual, iter and time are filled-in.

using ADNLPModels, JSOSuite
c(x) = [10 * (x[2] - x[1]^2); x[1] - 1]
b = zeros(2)
nlp = ADNLPModel(x -> 0.0, [-1.2; 1.0], c, b, b)
stats = feasible_point(nlp, verbose = 0)
stats
source
JSOSuite.isnls — Method
isnls(nlp::ADNLPModels.AbstractADNLPModel)
isnls(nlp::MathOptInterface.Nonlinear.Model)
isnls(nlp::JuMP.Model)
isnls(nlp::MathOptNLPModel)

Check if the given model has a nonlinear least squares objective.

The function uses the package ExpressionTreeForge to get the expression tree of the objective function, then try to detect the least squares pattern. There is no guarantee that this function detects it accurately.

source
JSOSuite.minimize — Function
stats = minimize(nlp::Union{AbstractNLPModel, JuMP.Model}; kwargs...)

Compute a local minimum of the optimization problem nlp.

stats = minimize(f::Function, x0::AbstractVector, args...; kwargs...)
stats = minimize(F::Function, x0::AbstractVector, nequ::Integer, args...; kwargs...)

Define an NLPModel using ADNLPModel.

stats = minimize(c, H, c0 = c0, x0 = x0, name = name; kwargs...)
stats = minimize(c, H, lvar, uvar, c0 = c0, x0 = x0, name = name; kwargs...)
stats = minimize(c, H, A, lcon, ucon, c0 = c0, x0 = x0, name = name; kwargs...)
stats = minimize(c, H, lvar, uvar, A, lcon, ucon, c0 = c0, x0 = x0, name = name; kwargs...)

Define a QuadraticModel using QuadraticModel.

The optimizer can be chosen as follows.

stats = minimize(optimizer_name::String, args...; kwargs...)

JuMP.Model are converted in NLPModels via NLPModelsJuMP.jl.

If your optimization problem has a quadratic or linear objective and linear constraints consider using QuadraticModels.jl or LLSModels.jl for the model definition.

Keyword Arguments

All the keyword arguments are passed to the selected solver. Keywords available for all the solvers are given below:

  • atol: absolute tolerance;
  • rtol: relative tolerance;
  • max_time: maximum number of seconds;
  • max_iter: maximum number of iterations;
  • max_eval: maximum number of cons + obj evaluations;
  • callback = (args...) -> nothing: callback called at each iteration;
  • verbose::Int = 0: if > 0, display iteration details every verbose iteration.

The following are specific to nonlinear least squares:

  • Fatol::T = √eps(T): absolute tolerance on the residual;
  • Frtol::T = eps(T): relative tolerance on the residual, the algorithm stops when ‖F(xᵏ)‖ ≤ Fatol + Frtol * ‖F(x⁰)‖.

Further possible options are documented in each solver's documentation.

Callback

The callback is called at each iteration. The expected signature of the callback is callback(nlp, solver, stats), and its output is ignored. Changing any of the input arguments will affect the subsequent iterations. In particular, setting stats.status = :user will stop the algorithm. All relevant information should be available in nlp and solver.

Output

The value returned is a GenericExecutionStats, see SolverCore.jl.

Examples

using JSOSuite
stats = minimize(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], verbose = 0)
stats

The list of available solver can be obtained using JSOSuite.optimizers[!, :name] or see select_optimizers.

using JSOSuite
stats = minimize("TRON", x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0], verbose = 0)
stats

Some optimizers are available after loading only.

using JSOSuite
# We minimize here a quadratic problem with bound-constraints
c = [1.0; 1.0]
H = [-2.0 0.0; 3.0 4.0]
uvar = [1.0; 1.0]
lvar = [0.0; 0.0]
x0 = [0.5; 0.5]
stats = minimize("TRON", c, H, lvar, uvar, x0 = x0, name = "bndqp_QP", verbose = 0)
stats
source
JSOSuite.multi_start — Function
multi_start(nlp::AbstractNLPModel; kwargs...)

This function runs a simple optimization strategy that run local optimizers for several initial guesses.

Arguments

  • nlp::AbstractNLPModel{T, V} represents the model to solve, see NLPModels.jl.

The keyword arguments may include

  • multi_solvers::Bool = false: If true it runs all the available solvers, one solver otherwise;
  • skip_solvers::Vector{String} = String[]: If multi_solvers is true, the solvers in this list are skipped;
  • N::Integer = get_nvar(nlp): number of additional initial guesses considered;
  • max_time::Float64 = 60.0: maximum time limit in seconds;
  • verbose::Integer = 0: if > 0, display iteration details every verbose iteration.
  • solver_verbose::Integer = 0: verbosity of the solver;
  • strategy::Symbol = :random: strategy to compute a next initial guess in [:random].

Other keyword arguments are passed to the solvers.

source
JSOSuite.select_optimizers — Method
select_optimizers(nlp::Union{AbstractNLPModel, JuMP.Model}, verbose = 1, highest_derivative_available::Integer = 2)

Narrow the list of optimizers to solve nlp problem using highest_derivative_available.

This function checks whether the model has:

  • linear or nonlinear constraints;
  • unconstrained, bound constraints, equality constraints, inequality constraints;
  • nonlinear or quadratic objective.

A linear or quadratic objective is detected if the type of nlp is a QuadraticModel or an LLSModel. The selection between a general optimization problem and a nonlinear least squares is done in minimize.

If no optimizers were selected, consider setting verbose to true to see what went wrong.

Output

  • selected_optimizers::DataFrame: A subset of optimizers adapted to the problem nlp.

See also minimize.

Examples

using ADNLPModels, JSOSuite
nlp = ADNLPModel(x -> 100 * (x[2] - x[1]^2)^2 + (x[1] - 1)^2, [-1.2; 1.0])
selected_optimizers = JSOSuite.select_optimizers(nlp)
print(selected_optimizers[!, :name])
using ADNLPModels, JSOSuite
nlp = ADNLSModel(x -> [10 * (x[2] - x[1]^2), (x[1] - 1)], [-1.2; 1.0], 2)
selected_optimizers = JSOSuite.select_optimizers(nlp)
print(selected_optimizers[!, :name])
source
SolverCore.solve! — Method
solve!(solver::AbstractOptimizationSolver, model::Union{AbstractNLPModel, JuMP.Model}; kwargs...)
solve!(solver::AbstractOptimizationSolver, model::Union{AbstractNLPModel, JuMP.Model}, stats; kwargs...)

JSOSuite extension of SolverCore.solve!. The first argument should be of type SolverCore.AbstractOptimizationSolver, see for instance JSOSuite.optimizers[!, :name_solver].

source