Docstrings

NonconvexCore.NonconvexCore — Module
NonconvexCore

The modelling and automatic differentiation core of the Nonconvex ecosystem: the optimization model types, objective and constraint functions, the differentiation machinery shared by the solver packages, and the solver capability system. See the Introduction for an overview.

NonconvexCore.ConstraintCapabilities — Type
ConstraintCapabilities(; linear_eq = missing, nonlinear_eq = missing,
                         linear_ineq = missing, nonlinear_ineq = missing,
                         sd = missing, box = missing,
                         continuous = missing, binary = missing,
                         integer = missing, infinite_bounds = missing)

Declares which constraint/variable features an optimizer supports:

  • linear_eq: linear equality constraints,
  • nonlinear_eq: nonlinear equality constraints,
  • linear_ineq: linear inequality constraints,
  • nonlinear_ineq: nonlinear inequality constraints,
  • linear_sd: linear semidefinite constraints,
  • nonlinear_sd: nonlinear semidefinite constraints,
  • box: finite variable bounds,
  • continuous: continuous variables,
  • binary: binary (0/1) variables,
  • integer: integer (non-binary) variables,
  • infinite_bounds: variables with infinite (unbounded) bounds.

Each field is one of true (supported), false (not supported) or missing (unknown/not declared). A solver that returns nothing from solver_capabilities declares nothing at all.

NonconvexCore.CustomGradFunction — Type
CustomGradFunction(f, g)

Wraps the function f so that its gradient (or Jacobian, for vector-valued f) is computed by the user-supplied function g instead of automatic differentiation.

NonconvexCore.CustomHessianFunction — Type
CustomHessianFunction(f, g, h; hvp = false)

Wraps the scalar-valued function f so that its gradient is computed by g and its Hessian by h (or, with hvp = true, by a Hessian-vector product operator).

NonconvexCore.DictModel — Type
DictModel(obj = nothing)

An AbstractModel whose variables are named: each variable has a Symbol or String key and arbitrary structured values, collected in an OrderedDict. The JuMP model conversion is provided by the NonconvexCoreJuMPExt extension when JuMP is loaded.

NonconvexCore.FunctionWrapper — Type
struct FunctionWrapper <: AbstractFunction
    f::Function
    dim::Int
end

A function wrapper type that wraps the function f where the function f is declared to return an output of dimension dim.

NonconvexCore.FunctionWrapper — Method
(f::FunctionWrapper)(args...; kwargs...)

Calls the wrapped function in f with arguments args and keyword arguments kwargs and returns the output.

NonconvexCore.GenericCriteria — Type
GenericCriteria

This is a generic convergence criteria that uses:

  1. The maximum change in the solution, Δx,
  2. The change in the objective value, Δf, and
  3. The change percentage in the objective value, Δf, and
  4. The maximum infeasibility infeas.

to assess convergence. More details are given in assess_convergence!.

NonconvexCore.IpoptCriteria — Type
IpoptCriteria

This convergence criteria uses a scaled version of the Karush-Kuhn-Tucker (KKT) residual and maximum infeasibility to assess convergence. This scaled KKT residual is used in the IPOPT nonlinear programming solver as explained in this paper. More details are given in assess_convergence!.

NonconvexCore.JuMPSymbolicFunction — Type
JuMPSymbolicFunction(expr::MOI.AbstractScalarFunction, vars::Vector{MOI.VariableIndex})

Returns a callable that evaluates expr at a flat vector x (ordered like vars) with value, gradient and Hessian computed by MathOptInterface's Nonlinear sparse reverse-mode evaluator. Reverse-mode differentiation of the callable uses a ChainRules rrule; the gradient and Hessian are also available via jump_symbolic_gradient and jump_symbolic_hessian.

NonconvexCore.LazyJacobian — Type
LazyJacobian(; jvp = nothing, jtvp = nothing, symmetric = false)

Represents a Jacobian by its matrix-free Jacobian-vector (jvp) and vector-Jacobian (jtvp) product operators instead of a matrix. Supports adjoint, transpose and matrix-vector multiplication.

NonconvexCore.Model — Type
struct Model <: AbstractModel
    objective::Objective
    eq_constraints::VectorOfFunctions
    ineq_constraints::VectorOfFunctions
    box_min::AbstractVector
    box_max::AbstractVector
    init::AbstractVector
    integer::AbstractVector
end

The Model structs stores information about the nonlinear optimization problem.

  • objective: the objective function of the problem of type Objective.
  • eq_constraints: the equality constraints of the problem of type VectorOfFunctions. Each function in ineq_constraints can be an instance of IneqConstraint or AbstractFunction. If the function is not an IneqConstraint, its right-hand-side bound is assumed to be 0.
  • ineq_constraints: the inequality constraints of the problem of type VectorOfFunctions. Each function in ineq_constraints can be an instance of IneqConstraint or AbstractFunction. If the function is not an IneqConstraint, its right-hand-side bound is assumed to be 0.
  • sd_constraints: a list of matrix-valued functions which must be positive semidefinite at any feasible solution.
NonconvexCore.Model — Type
Model()
Model(f)

Constructs an empty model or a model with objective function f. The decision variables are assumed to be of type Vector{Any}.

NonconvexCore.Model — Method
Model(::Type{T}, f::Union{Nothing, Function}) where {T}

Constructs an empty model with objective function f and decision variable value type Vector{T}. f can be an instance of Base.Function but must return a number, or it can be an intance of Objective. f can also be nothing in which case, the objective function can be defined later using set_objective!.

NonconvexCore.ScaledKKTCriteria — Type
ScaledKKTCriteria

This convergence criteria uses another scaled version of the Karush-Kuhn-Tucker (KKT) residual and maximum infeasibility to assess convergence. In particular if the objective was scaled by a factor m, the KKT residual will be scaled down by a factor max(m, 1/m). This scaling was found to make the convergence criteria less sensitive to scale compared to using the traditional KKT residual. More details are given in assess_convergence!.

NonconvexCore.Tolerance — Type
Tolerance

A struct specifying the different tolerances used to assess the convergence of the algorithms. The following are the fields of Tolerance:

  • x: the tolerance for Δx in ConvergenceState. x_converged will be true if Δx is less than the x tolerance in Tolerance. This is used to assess convergence when the GenericCriteria is used as the convergence criteria.
  • fabs: the tolerance for Δf in ConvergenceState. f_converged will be true if Δf is less than the fabs tolerance in Tolerance. This is used to assess convergence when the GenericCriteria is used as the convergence criteria.
  • frel: the tolerance for relΔf in ConvergenceState. f_converged will be true if relΔf is less than the frel tolerance in Tolerance. This is used to assess convergence when the GenericCriteria is used as the convergence criteria.
  • kkt: the KKT tolerance. kkt_converged in ConvergenceState will be true if the kkt_residual is less than the KKT tolerance. And ipopt_converged in ConvergenceState will be true if ipopt_residual is less than the KKT tolerance. This is used to assess convergence when the KKTCriteria, the ScaledKKTCriteria or IpoptCriteria criteria is used as the convergence criteria.
  • infeas: the maximum infeasibility tolerance. infeas_converged in ConvergenceState will be true if the maximum infeasibility is less than the infeasibility tolerance. This is used to assess convergence regardless of the convergence criteria used.

For more on convergence criteria, see GenericCriteria, KKTCriteria, ScaledKKTCriteria and IpoptCriteria.

NonconvexCore.TraceFunction — Type
TraceFunction(f; on_call = ..., on_grad = ...)

Wraps f and records a trace of where it is evaluated (on the function call and/or on gradient evaluations), for debugging which part of a model calls a function during optimization.

NonconvexCore.Workspace — Type
Workspace

Abstract Workspace, which is a struct that stores states and information needed for optimization process. Implementation depends on specific algorithm.

NonconvexCore.add_eq_constraint! — Function
add_eq_constraint!(model::AbstractModel, f::EqConstraint)
add_eq_constraint!(model::AbstractModel, fs::Vector{<:EqConstraint})

Adds a new equality constraint f or multiple new equality constraints fs to model.

NonconvexCore.add_ineq_constraint! — Function
add_ineq_constraint!(model::AbstractModel, f::IneqConstraint)
add_ineq_constraint!(model::AbstractModel, fs::Vector{<:IneqConstraint})

Adds a new constraint f or multiple new constraints fs to model.

NonconvexCore.addvar! — Function
addvar!(model::AbstractModel, lb::Number, ub::Number; init = lb, integer = false)

Adds a new variable to model with lower and upper bounds lb and ub, initial value init and integer = true if the variable is integer.

NonconvexCore.checksubproblem! — Method
checksubproblem!(model::VecModel, optimizer; assumed = nothing,
                 hint = "", context = "the model")

Validates the features present in model against solver_capabilities of optimizer. Semantics per present feature:

  • declared true → pass;
  • declared false → ArgumentError naming the solver, the feature and a hint on how to work around it;
  • undeclared (missing or no declaration at all) → ArgumentError requiring the solver to declare the capability via solver_capabilities (strict-by-default: no opt-in).

Keyword arguments:

  • assumed: optional ConstraintCapabilities to use instead of querying the solver (for meta-algorithms that override their sub-solver's declaration),
  • hint: extra text appended to error messages,
  • context: description of the model used in error messages.
NonconvexCore.getmax — Function
getmax(model::AbstractModel)

Returns the variables' upper bounds of model.

NonconvexCore.getmin — Function
getmin(model::AbstractModel)

Returns the variables' lower bounds of model.

NonconvexCore.getobjective — Function
getobjective(model::AbstractModel)

Returns a that when called with input x returns the objective value of model at x.

NonconvexCore.jump_symbolic_gradient — Method
jump_symbolic_gradient(f::JuMPSymbolicFunction, x)

Returns the gradient of the wrapped function at x, computed by the MathOptInterface Nonlinear evaluator.

NonconvexCore.jump_symbolic_hessian — Method
jump_symbolic_hessian(f::JuMPSymbolicFunction, x)

Returns the Hessian of the wrapped function at x, computed by the MathOptInterface Nonlinear evaluator.

NonconvexCore.merge_capabilities — Method
merge_capabilities(base::Union{ConstraintCapabilities,Nothing}; kwargs...)

Returns a new ConstraintCapabilities where fields not overridden by kwargs are taken from base (nothing fields become missing). Useful for meta-algorithms that forward part of their sub-solver's capabilities.

NonconvexCore.optimize — Method
optimize(
    model::AbstractModel,
    optimizer::AbstractOptimizer,
    x0;
    options,
    convcriteria::ConvergenceCriteria = KKTCriteria(),
    callback = NoCallback(),
    kwargs...,
)

Optimizes model using the algorithm optimizer (a solver package's AbstractOptimizer instance, e.g. IpoptAlg() from NonconvexIpopt). x0 is the initial solution, and defaults to getinit when omitted. The keyword arguments are:

  • options: the solver options object of the selected algorithm.
  • convcriteria: an instance of ConvergenceCriteria that specifies the convergence criteria of the algorithm.
  • callback: a function that is called on solution in every iteration of the algorithm. This can be used to store information about the optimization process.

The model is validated against the solver's declared capabilities with checksubproblem! before the optimization starts, and the returned result contains the minimum and minimizer fields (see Optimization result).

NonconvexCore.prepare_gradient — Function
prepare_gradient(f, x, [backend])
prepare_jacobian(f, x, [backend])
prepare_hessian(f, x, [backend])

Explicitly prepares the differentiation backend backend (an ADTypes backend, defaulting to the package-wide backend) for f at the representative point x. The preparation (chunk selection, tape compilation, sparsity detection and coloring, ...) is cached by (f, backend) and used by default by value_gradient, value_jacobian and value_hessian afterwards.

NonconvexCore.prepare_gradient — Function
prepare_gradient(f, x, [backend])

Explicitly prepares the gradient backend of f; cached and used by default.

NonconvexCore.prepare_hessian — Function
prepare_hessian(f, x, [backend])

Explicitly prepares the Hessian backend of f; cached and used by default.

NonconvexCore.prepare_jacobian — Function
prepare_jacobian(f, x, [backend])

Explicitly prepares the Jacobian backend of f; cached and used by default.

NonconvexCore.prepare_model — Function
prepare_model(model, [x], [backend]; gradient = true, hessian = true, jacobian = true)

Explicitly prepares the differentiation backend for the selected pieces of model at the initial point, and returns the prepared vectorized model:

  • gradient: the objective gradient,
  • hessian: the objective Hessian (not always required, e.g. for first-order solvers),
  • jacobian: the Jacobians of all the constraints.

The preparations are cached per function and backend and are used by default by the value-and-derivative and sparse derivative functions on the returned model.

NonconvexCore.prepare_sparse_hessian — Function
prepare_sparse_hessian(f, x, [backend])

Explicitly prepares the sparse Hessian pipeline of f; cached and used by default by sparse_hessian.

NonconvexCore.prepare_sparse_jacobian — Function
prepare_sparse_jacobian(f, x, [backend])
prepare_sparse_hessian(f, x, [backend])

Explicitly prepares the sparse derivative pipeline (sparsity detection with SparseConnectivityTracer, coloring with SparseMatrixColorings and the colored DifferentiationInterface evaluation) for f at the representative point x. The preparation is cached by (f, backend) and used by default by sparse_jacobian and sparse_hessian.

NonconvexCore.prepare_sparse_jacobian — Function
prepare_sparse_jacobian(f, x, [backend])

Explicitly prepares the sparse Jacobian pipeline of f; cached and used by default by sparse_jacobian.

NonconvexCore.set_ad_backend! — Method
set_ad_backend!(backend::ADTypes.AbstractADType)

Sets the package-wide default automatic differentiation backend used by value_gradient, value_jacobian, sparse_jacobian and the solver-facing derivative evaluators. The package providing the backend (e.g. Enzyme.jl for AutoEnzyme()) must be loaded by the caller.

NonconvexCore.setinteger! — Function
setinteger!(model::AbstractModel, i, integer)

Constrains the ith variable of model to be integer (or relaxes the constraint) when integer is true (false).

NonconvexCore.setmax! — Function
setmax!(model::AbstractModel, max::Union{Number, AbstractVector})
setmax!(model::AbstractModel, i::Integer, max::Number)

Sets the variables' upper bound in model to max. Or if i is given, it sets the upper bound of the i^th variable in model to max.

NonconvexCore.setmin! — Function
setmin!(model::AbstractModel, min::Union{Number, AbstractVector})
setmin!(model::AbstractModel, i::Integer, min::Number)

Sets the variables' lower bounds in model to min. Or if i is given, it sets the lower bound of the i^th variable in model to min.

NonconvexCore.solver_capabilities — Method
solver_capabilities(::AbstractOptimizer)

Returns the ConstraintCapabilities of the optimizer, or nothing when the solver does not declare capabilities. Every optimizer that can receive constrained models must specialize this method: optimize validates the model against the declaration via checksubproblem! and errors when capabilities are undeclared or unsupported.

NonconvexCore.symbolify — Function
symbolify(f, x...; flatteny = true, kwargs...)

Returns a version of f whose value, gradient and Hessian are computed symbolically with Symbolics. The Symbolics-specific implementation lives in the NonconvexCoreSymbolicsExt package extension (Symbolics is an optional dependency of NonconvexCore).

NonconvexCore.Objective — Type
struct Objective <: AbstractFunction
    f
    multiple
    flags::Set{Symbol}
end

The objective function to be optimized. The objective is always assumed to be of dimension 1. multiple is of type Ref{<:Number}. When an instance of Objective is called, its output will be scaled by a multiplier multiple[]. This is 1 by default.

NonconvexCore.IneqConstraint — Type
struct IneqConstraint <: AbstractConstraint
    f::Function
    rhs
    dim::Int
    flags::Set{Symbol}
end

A struct for an inequality constraint of the form f(x) .- rhs .<= 0. The dimension of the constraint is dim. Calling the struct will return f(x) .- rhs.

NonconvexCore.EqConstraint — Type
struct EqConstraint <: AbstractConstraint
    f::Function
    rhs
    dim::Int
    flags::Set{Symbol}
end

A struct for an equality constraint of the form f(x) .- rhs .== 0. The dimension of the constraint is dim. Calling the struct will return f(x) .- rhs.

NonconvexCore.VectorOfFunctions — Type
struct VectorOfFunctions <: AbstractFunction
    fs
end

A struct for a collection of instances of AbstractFunction. The dimension of this function is the sum of the dimensions of the individual functions and the outputs are concatenated in a vector.

NonconvexCore.getdim — Function
getdim(f::AbstractFunction)

Returns the dimension of the function f, i.e. the number of outputs.

NonconvexCore.value_gradient — Function
value_gradient(f, x, [backend])

Returns the value and gradient of the scalar-valued function f at x.

NonconvexCore.value_jacobian — Function
value_jacobian(f, x, [backend])

Returns the value and Jacobian of the function (or VectorOfFunctions collection) f at x.

NonconvexCore.sparse_jacobian — Function
sparse_jacobian(f, x, [backend::ADTypes.AbstractADType])

Returns the structurally sparse Jacobian of f at x as a SparseMatrixCSC. The sparsity pattern is detected with SparseConnectivityTracer, colored with SparseMatrixColorings and the entries are computed with the automatic differentiation backend backend (defaults to the package-wide backend, see get_ad_backend). If the sparse pipeline fails for f, the values are assembled from per-function derivatives at the detected pattern positions. Failures (for example, sparsity detection on functions whose internals branch on values) raise errors rather than degrading silently.

NonconvexCore.sparse_hessian — Function
sparse_hessian(f, x, [backend::ADTypes.AbstractADType])

Returns the structurally sparse Hessian of the scalar-valued function f at x as a SparseMatrixCSC. The sparsity pattern is detected with SparseConnectivityTracer, colored with SparseMatrixColorings and the entries are computed by forward-mode differentiation of the gradient computed with backend (defaults to the package-wide backend, see get_ad_backend). Failures raise errors rather than degrading silently.

NonconvexCore.second_order_backend — Function
second_order_backend(backend::ADTypes.AbstractADType)

Returns the backend used to compose second derivatives from backend for sparse_hessian. The default is forward-mode differentiation over the gradient computed with backend (DI.SecondOrder(AutoForwardDiff(), backend)). This function can be specialized for specific backends, e.g. to use a forward-over-reverse composition with the same engine.

NonconvexCore.getineqconstraints — Function
getineqconstraints(model::AbstractModel)

Returns a that when called with input x returns the constraint violation values of all the inequality constraints of model at x.

NonconvexCore.geteqconstraints — Function
geteqconstraints(model::AbstractModel)

Returns a that when called with input x returns the constraint violation values of all the equality constraints of model at x.

NonconvexCore.getobjectiveconstraints — Function
getobjectiveconstraints(model::AbstractModel)

Returns an instance of AbstractFunction that when called with input x returns the objective and constraint values of model at x in a single vector.

NonconvexCore.ConvergenceState — Type
ConvergenceState

A struct that summarizes the convergence state of a solution. The fields in this struct are:

  • Δx: the infinity norm of the change in the solution x.
  • Δf: the change in the objective value f.
  • relΔf: the ratio of change in the objective value f.
  • kkt_residual: the Karush-Kuhn-Tucker (KKT) residual of the solution. If ScaledKKTCriteria is used instead of KKTCriteria, the kkt_residual will be divided by a factor.
  • ipopt_residual: the modified KKT residual used in the IPOPT solver.
  • infeas: maximum infeasibility amount. This is 0 if the solution is feasible.
  • x_converged: true if Δx is less than the x tolerance in Tolerance.
  • fabs_converged: true if Δf is less than the f tolerance in Tolerance.
  • frel_converged: true if relΔf is less than the f tolerance in Tolerance.
  • kkt_converged: true if the kkt_residual is less than the KKT tolerance in Tolerance.
  • ipopt_converged: true if the ipopt_residual is less than the KKT tolerance in Tolerance.
  • infeas_converged: true if infeas is less than the infeasibility tolerance in Tolerance.
  • f_increased: true if the objective value of the current solution is higher than that of the previous solution.
  • converged: true if the solution satisfies the convergence criteria of choice. See ConvergenceCriteria for more on the different convergence criteria available.
NonconvexCore.assess_convergence! — Function
assess_convergence!(workspace::Workspace)

Updates the workspace by evaluating the convergence criteria against the model at the current solution.

NonconvexCore.JuMPEvaluator — Type
JuMPEvaluator

A single MathOptInterface Nonlinear evaluator over an entire JuMP model converted into a NonconvexCore model. The objective and every constraint are expressions of one MOI.Nonlinear.Model, so shared subexpressions are evaluated once per pass, and the whole Jacobian and Lagrangian Hessian come from single evaluator calls.

The constraints are keyed by their ConstraintIndex, because neither the JuMP constraint iteration order nor the evaluator row order is meaningful; the evaluator's own row order is recovered from ordered_constraints. Converted rows are exposed inequality-first (sorted by constraint index), then equalities (also sorted by constraint index). Inequality row k has value sign * f_k(x) + shift (Nonconvex convention: feasible when <= 0); equality row k has value f_k(x) + shift (feasible when 0). The objective is objective_sign * f_obj(x).

NonconvexCore.JuMPModelObjective — Type
JuMPModelObjective(m::JuMPEvaluator, ks)

The objective of a JuMP-converted model: evaluates the converted objective expression on the model's variable container through the shared JuMPEvaluator.

NonconvexCore.JuMPModelIneq — Type
JuMPModelIneq(m::JuMPEvaluator, ks)

The inequality constraints of a JuMP-converted model: a single vector-valued function evaluating every converted inequality row (in the converted row order) through the shared JuMPEvaluator.

NonconvexCore.JuMPModelEq — Type
JuMPModelEq(m::JuMPEvaluator, ks)

The equality constraints of a JuMP-converted model: a single vector-valued function evaluating every converted equality row through the shared JuMPEvaluator.

NonconvexCore.jump_objective_gradient — Function
jump_objective_gradient(m::JuMPEvaluator, x)

Returns the gradient of the converted objective at x, computed by the MathOptInterface Nonlinear evaluator.

NonconvexCore.jump_jacobian — Function
jump_jacobian(m::JuMPEvaluator, x)

Returns the constraint Jacobian of the converted model at x as a sparse matrix, computed by the MathOptInterface Nonlinear evaluator.

NonconvexCore.jump_jacobian_structure — Function
jump_jacobian_structure(m::JuMPEvaluator)

Returns (rows, columns) of the converted model's constraint Jacobian, with rows ordered inequality-first like the constraint values.

NonconvexCore.jump_hessian_structure — Function
jump_hessian_structure(m::JuMPEvaluator)

Returns (rows, columns) of the converted model's Lagrangian Hessian in lower-triangular form.

NonconvexCore.@params — Macro
@params struct_def

A macro that changes all fields' types to type parameters while respecting the type bounds specificied by the user. For example:

@params struct MyType{T}
    f1::T
    f2::AbstractVector{T}
    f3::AbstractVector{<:Real}
    f4
end

will define:

struct MyType{T, T1 <: T, T2 <: AbstractVector{T}, T3 <: AbstractVector{<:Real}, T4}
    f1::T1
    f2::T2
    f3::T3
    f4::T4
end

The default non-parameteric constructor, e.g. MyType(f1, f2, f3, f4), will always work if all the type parameters used in the type header are used in the field types. Using a type parameter in the type header that is not used in the field types such as:

struct MyType{T}
    f1
    f2
end

is not recommended.

NonconvexCore.get_variable_info — Function
get_variable_info(model::JuMP.Model)

Returns the lower bounds, upper bounds, initial points and integer flags of the variables of a JuMP model as OrderedDicts, in the structure NonconvexCore models use.

NonconvexCore._nonlinear_constraints — Function
_nonlinear_constraints(model::JuMP.Model)

Returns the model's nonlinear (and quadratic and affine, when a nonlinear expression is present) constraints as (expr, set) pairs with the expressions converted to MathOptInterface scalar functions.

NonconvexCore.get_jump_problem — Function
get_jump_problem(model::VecModel, x0 = getinit(model); optimizer, first_order, backend, kwargs...)

Builds a JuMP model wrapping a NonconvexCore model through a custom MOI.AbstractNLPEvaluator, for solvers that interface through JuMP.

NonconvexCore.Solution — Type
Solution

A struct that stores all the information about a solution. The following are the fields of Solution:

  • x: the current primal solution
  • prevx: the previous primal solution
  • λ: the current dual solution
  • f: the objective value of x
  • prevf: the obejctive value of prevx
  • ∇f: the gradient of the objective at x
  • g: the constraint function value at x
  • ∇g: the Jacobian of the constraint functions at x
  • convstate: the convergence state of the solution
NonconvexCore.GenericResult — Type
GenericResult

A summary result struct returned by optimize, including following fields:

  • optimizer: the optimization algorithm used
  • initial_x: the initial primal solution
  • minimizer: the best solution found
  • minimum: the optimal value
  • iter: number of inner iterations run
  • maxiter_reached: true if the algorithm stopped due to reaching the maximum number of iterations
  • tol: an instance of Tolerance that specifies the convergence tolerances
  • convstate: an instance of ConvergenceCriteria that summarizes the convergence state of the best solution found
  • fcalls: the number of times the objective and constraint functions were called during the optimization
NonconvexCore.PlottingCallback — Type

PlottingCallback

A callback function that plots a number of convergence metrics using ConvergencePlots.jl. The following are the fields of the struct:

  • plot: an instance of ConvergencePlots.ConvergencePlot.
  • n: the number of history points to keep track of.
  • iter: the number of times the callback was called.
NonconvexCore.LazyPlottingCallback — Type
LazyPlottingCallback

A callback function that plots a number of convergence metrics using ConvergencePlots.jl only when show is called. The following are the fields of the struct:

  • plot: an instance of ConvergencePlots.ConvergencePlot.
  • n: the number of history points to keep track of.
  • iter: the number of times the callback was called.
NonconvexCore.PreparedFunction — Type
diffy(f, x, [backend])

Returns a callable that evaluates f and whose derivatives are computed by the differentiation backend backend (an ADTypes backend, defaulting to the package-wide backend), prepared eagerly at the representative point x. The returned function can be used in place of f in objectives and constraints; any ChainRules-compatible outer differentiation uses the prepared backend.

NonconvexCore.FlattenedFunction — Type
FlattenedFunction

A callable that evaluates the wrapped function f on the structure rebuilt by unflattenx from a flat vector, and flattens the output. The raw function and the input unflattening are exposed via getrawfunction and getinputunflatten so that solvers can evaluate all model functions against a single reconstructed structure per point.

NonconvexCore.DEFAULT_AD_BACKEND — Constant
DEFAULT_AD_BACKEND

The automatic differentiation backend used by default wherever NonconvexCore computes derivatives, e.g. in value_gradient, value_jacobian, sparse_jacobian and the solver-facing derivative evaluators. It is initially ADTypes.AutoZygote(), whose ChainRules-based design supports arbitrary argument types (dictionaries, structs, arrays) through the model-flattening machinery. Change it with set_ad_backend!, or pass a backend explicitly to the functions above.

NonconvexCore.check_finite_start! — Method
check_finite_start!(model, args)

Throws a descriptive error when the objective or any constraint returns a non-finite value at the initial point. args carries the initial point when optimize was called with one; the model's init is used otherwise.

Base.length — Method
length(f::AbstractFunction)

Returns the number of outputs of f.

NonconvexCore.getinputunflatten — Method
getinputunflatten(f)

Returns the callable that rebuilds the user-facing input structure of the function f from a flat vector.

NonconvexCore.getrawfunction — Method
getrawfunction(f)

Returns the raw function wrapped by f, callable on the structure returned by getinputunflatten. For a FlattenedFunction this is the function as defined by the user before flattening.

NonconvexCore.set_objective — Method
set_objective!(m::AbstractModel, f::Function)

Sets the objective of the moodel m to the function f. f must return a scalar.

NonconvexCore.correctsolution! — Method
correctsolution!(solution, model, options)

Default no-op fallback: solvers may specialize this to undo any scaling applied to the model during the optimization, e.g. to correct solution.f by the objective multiple before reporting the result.

NonconvexCore.jump_symbolic_hessian_sparsity — Function
jump_symbolic_hessian_sparsity(f::JuMPSymbolicFunction, n)

Returns the sparse Hessian structure (row, column) of the wrapped expression with respect to a vector of length n.

NonconvexCore.tovecmodel — Method
tovecmodel(m::DictModel, x0::AbstractVector)

A DictModel stores variables keyed by name, so an initial solution must be a dict-like structure with the variable names as keys. This method throws a descriptive error instead of failing deep inside the flattening machinery.

NonconvexCore.geteqconstraint — Function
geteqconstraint(model::AbstractModel, i::Integer)

Returns a that when called with input x returns the constraint violation value of the i^th equality constraint of model at x.

NonconvexCore.getineqconstraint — Function
getineqconstraint(model::AbstractModel, i::Integer)

Returns a that when called with input x returns the constraint violation value of the i^th inequality constraint of model at x.

NonconvexCore.setbox! — Function
setbox!(model::AbstractModel, min::Union{Number, AbstractVector}, max::Union{Number, AbstractVector})
setbox!(model::AbstractModel, i::Integer, min::Number, max::Number)

Sets the variables' lower and upper bounds in model to min and max respectively. Or if i is given, it sets the lower and upper bounds of the i^th variable in model to min and max respectively.

NonconvexCore.sparse_gradient — Function
sparse_gradient(f, x, [backend::ADTypes.AbstractADType])

Returns the gradient of the scalar-valued function f at x computed with the automatic differentiation backend backend (defaults to the package-wide backend, see get_ad_backend).

NonconvexCore.jump_constraint_linearity — Function
jump_constraint_linearity(m::JuMPEvaluator)

Returns (ineq_linear, eq_linear): per-row Bools recording whether each converted inequality and equality row is a linear expression.