Module NloptSource

OCaml interface to the NLopt optimization library

Sourcetype 'a algorithm

Represent an algorithm, the parameter giving some properties of the algorithm.

Sourceval direct : [ `Global ] algorithm
Sourceval direct_l : [ `Global | `Ineq ] algorithm
Sourceval direct_l_rand : [ `Global ] algorithm
Sourceval direct_noscal : [ `Global ] algorithm
Sourceval direct_l_noscal : [ `Global ] algorithm
Sourceval direct_l_rand_noscal : [ `Global ] algorithm
Sourceval orig_direct : [ `Global | `Ineq ] algorithm
Sourceval orig_direct_l : [ `Global ] algorithm
Sourceval stogo : [ `Global | `Grad ] algorithm
Sourceval stogo_rand : [ `Global | `Grad ] algorithm
Sourceval lbfgs_nocedal : [ `Local | `Grad ] algorithm
Sourceval lbfgs : [ `Local | `Grad ] algorithm
Sourceval praxis : [ `Local ] algorithm
Sourceval var1 : [ `Local | `Grad ] algorithm
Sourceval var2 : [ `Local | `Grad ] algorithm
Sourceval tnewton : [ `Local | `Grad ] algorithm
Sourceval tnewton_restart : [ `Local | `Grad ] algorithm
Sourceval tnewton_precond : [ `Local | `Grad ] algorithm
Sourceval tnewton_precond_restart : [ `Local | `Grad ] algorithm
Sourceval crs2_lm : [ `Global ] algorithm
Sourceval mma : [ `Local | `Grad | `Ineq ] algorithm
Sourceval cobyla : [ `Local | `Ineq | `Eq ] algorithm
Sourceval newuoa : [ `Local ] algorithm
Sourceval newuoa_bound : [ `Local ] algorithm
Sourceval neldermead : [ `Local ] algorithm
Sourceval sbplx : [ `Local ] algorithm
Sourceval bobyqa : [ `Local ] algorithm
Sourceval isres : [ `Global | `Ineq | `Eq ] algorithm
Sourceval auglag : [ `Subsidiary | `Ineq | `Eq ] algorithm
Sourceval auglag_eq : [ `Subsidiary | `Ineq | `Eq ] algorithm
Sourceval mlsl : [ `Subsidiary | `Global ] algorithm
Sourceval mlsl_lds : [ `Subsidiary | `Global ] algorithm
Sourceval slsqp : [ `Local | `Grad | `Ineq | `Eq ] algorithm
Sourcetype 'a t

A value containing the information about the optimization problem.

Sourceexception Roundoff_limited
Sourceexception Forced_stop
Sourceval create : 'a algorithm -> int -> 'a t
Sourceval set_min_objective : 'a t -> (float array -> float array option -> float) -> unit
Sourceval set_max_objective : 'a t -> (float array -> float array option -> float) -> unit
Sourceval optimize : 'a t -> float array -> [> `Success | `Stopval_reached | `Stopval_reached | `Ftol_reached | `Xtol_reached | `Maxeval_reached | `Maxtime_reached ] * float array * float

optimize opt x performs the optimization using x as an initial guess (it must be of size get_dimension opt). Returns a triple (result, xopt, fopt) where xopt is the optimzed value and fopt is the function value at that optimum.

  • raises Invalid_argument

    x does not match the dimension of opt or NLopt returned NLOPT_INVALID_ARGS

  • raises Failure

    NLopt returned NLOPT_FAILURE

Sourceval get_dimension : 'a t -> int

Bound constraints

Sourceval set_lower_bounds : 'a t -> float array -> unit
Sourceval get_lower_bounds : 'a t -> float array
Sourceval set_upper_bounds : 'a t -> float array -> unit
Sourceval get_upper_bounds : 'a t -> float array

Nonlinear constraints

Sourceval add_inequality_constraint : [> `Ineq ] t -> (float array -> float array option -> float) -> float -> unit
Sourceval add_equality_constraint : [> `Eq ] t -> (float array -> float array option -> float) -> float -> unit

Stopping criteria

Sourceval set_stopval : 'a t -> float -> unit
Sourceval get_stopval : 'a t -> float
Sourceval set_ftol_rel : 'a t -> float -> unit
Sourceval get_ftol_rel : 'a t -> float
Sourceval set_ftol_abs : 'a t -> float -> unit
Sourceval get_ftol_abs : 'a t -> float
Sourceval set_xtol_rel : 'a t -> float -> unit
Sourceval get_xtol_rel : 'a t -> float
Sourceval set_xtol_abs : 'a t -> float array -> unit
Sourceval get_xtol_abs : 'a t -> float array
Sourceval set_maxeval : 'a t -> int -> unit
Sourceval get_maxeval : 'a t -> int
Sourceval set_maxtime : 'a t -> float -> unit
Sourceval get_maxtime : 'a t -> float

Force stop

Sourceval force_stop : 'a t -> unit

Local/subsidiary optimization algorithm

Sourceval set_local_optimizer : [> `Subsidiary ] t -> 'a t -> unit

Initial step size

Sourceval set_initial_step : 'a t -> float array -> unit
Sourceval get_initial_step : 'a t -> float array -> float array

Stochastic population

Sourceval set_population : 'a t -> int -> unit

Vector storage for limited-memory quasi-Newton algorithms

Sourceval set_vector_storage : 'a t -> int -> unit
Sourceval get_vector_storage : 'a t -> int

Utility functions

Sourceval version : unit -> int * int * int
Sourceval string_of_result : [< `Success | `Stopval_reached | `Stopval_reached | `Ftol_reached | `Xtol_reached | `Maxeval_reached | `Maxtime_reached ] -> string