Source

nlopt-ocaml / src / nlopt_FC.mli

Full commit

type vec = $VECTOR

type 'a algorithm
(** Represent an algorithm, the parameter giving some properties of
    the algorithm. *)

(* http://ab-initio.mit.edu/wiki/index.php/NLopt_Algorithms *)
val direct : [`Global ] algorithm
val direct_l : [`Global | `Ineq] algorithm
val direct_l_rand : [`Global] algorithm
val direct_noscal : [`Global] algorithm
val direct_l_noscal : [`Global] algorithm
val direct_l_rand_noscal : [`Global] algorithm
val orig_direct : [`Global | `Ineq] algorithm
val orig_direct_l : [`Global] algorithm
val stogo : [`Global | `Grad] algorithm
val stogo_rand : [`Global | `Grad] algorithm
val lbfgs_nocedal : [`Local | `Grad] algorithm
val lbfgs : [`Local | `Grad] algorithm
val praxis : [`Local] algorithm
val var1 : [`Local | `Grad] algorithm
val var2 : [`Local | `Grad] algorithm
val tnewton : [`Local | `Grad] algorithm
val tnewton_restart : [`Local | `Grad] algorithm
val tnewton_precond : [`Local | `Grad] algorithm
val tnewton_precond_restart : [`Local | `Grad] algorithm
val crs2_lm : [`Global] algorithm
val mlsl : [`Global] algorithm
val mlsl : [`Global | `Grad] algorithm
val mlsl_lds : [`Global] algorithm
val mlsl_lds : [`Global | `Grad] algorithm
val mma  : [`Local | `Grad | `Ineq] algorithm
val cobyla : [`Local | `Ineq | `Eq] algorithm
val newuoa : [`Local] algorithm
val newuoa_bound : [`Local] algorithm
val neldermead : [`Local] algorithm
val sbplx : [`Local] algorithm
val auglag : [`Local] algorithm
val auglag : [`Local | `Grad] algorithm
val auglag_EQ : [`Local] algorithm
val auglag_EQ : [`Local | `Grad] algorithm
val bobyqa : [`Local] algorithm
val isres : [`Global | `Ineq | `Eq] algorithm
val auglag : [`Subsidiary | `Ineq | `Eq] algorithm
val auglag_eq : [`Subsidiary | `Ineq | `Eq] algorithm
val mlsl : [`Subsidiary | `Global] algorithm
val mlsl_lds : [`Subsidiary | `Global] algorithm
val slsqp : [`Local | `Grad | `Ineq | `Eq] algorithm

type 'a t
(** A value containing the information about the optimization problem. *)

val create : 'a algorithm -> int -> 'a t
val copy : 'a t -> 'a t

val dim : 'a t -> int
val algorithm : 'a t -> 'a algorithm

val set_min_objective : 'a t -> ?pre:(vec -> vec -> vec -> unit) ->
                        (vec -> vec -> float) -> unit
(** [set_min_objective opt f]

    @param pre use a preconditionner with approximate Hessians.  The
    function [pre x v vpre] should store in [vpre] the vector
    H([x]) [v] where H is an approximate second derivative at [x].
    This is currently only supported by {!ccsaq} which requires that H
    is positive semidefinite.  *)

val set_max_objective : 'a t -> ?pre:(vec -> vec -> vec -> unit) ->
                        (vec -> vec -> float) -> unit
(** See {!set_min_objective}. *)

type result =
  | Success
  | Stopval_reached
  | Ftol_reached
  | Xtol_reached
  | Maxeval_reached
  | Maxtime_reached

exception Roundoff_limited
(** This exception is raised when the algorithm is halted because
    roundoff errors limited progress.  (In this case, the optimization
    still typically returns a useful result.)  *)

val optimize : 'a t -> vec -> result * float
(** [optimize opt x] performs the optimization using [x] as an initial
    guess (it must be of size {!dim opt}).  On return, [x] is updated
    with the optimized values of the parameters and the second
    component of the returned value is the corresponding value of the
    objective function.

    @raise Invalid_argument
    @raise Out_of_memory
    @raise Failure (not sure about reusing that one)
    @raise Roundoff_limited
 *)

(** {2 Bound constraints} *)

val set_lower_bounds : 'a t -> vec -> unit
val get_lower_bounds : ?y: vec -> 'a t -> vec
val set_upper_bounds : 'a t -> vec -> unit
val get_upper_bounds : ?y: vec -> 'a t -> vec

(** {2 Nonlinear constraints} *)

val add_inequality_constraint :
  [> `Ineq] t -> ?tol:float -> (vec -> vec -> float) -> unit
val add_equality_constraint :
  [> `Eq] t -> ?tol:float -> (vec -> vec -> float) -> unit

val add_inequality_mconstraint :
  [> `Ineq] t -> tol: vec -> (vec -> vec -> vec) -> unit

val add_equality_mconstraint :
  [> `Eq] t -> tol: vec -> (vec -> vec -> vec) -> unit

(** {2 Stopping criteria} *)

val set_stopval: 'a t -> float -> unit
val get_stopval: 'a t -> float

val set_ftol_rel: 'a t -> float -> unit
val get_ftol_rel: 'a t -> float

val set_ftol_abs: 'a t -> float -> unit
val get_ftol_abs: 'a t -> float

val set_xtol_rel: 'a t -> float -> unit
val get_xtol_rel: 'a t -> float

val set_xtol_abs: 'a t -> vec -> unit
val get_xtol_abs: 'a t -> vec

val set_maxeval: 'a t -> int -> unit
val get_maxeval: 'a t -> int

val set_maxtime: 'a t -> float -> unit
val get_maxtime: 'a t -> float

val force_stop: t -> unit
(* This should not be exported.  Use it to deal with exceptions raised
   by objective or constrain functions. *)

(** {2 Local/subsidiary optimization algorithm} *)

val set_local_optimizer : [> `Subsidiary] t -> [> `Local | `Global] t -> unit

(** {2 Initial step size} *)

val set_initial_step: 'a t -> dx: vec -> unit
val set_initial_step_heuristics: 'a t -> unit
val get_initial_step: 'a t -> vec -> vec

(** {2 Stochastic population} *)

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

(** {2 Pseudorandom numbers} *)

val srand : int -> unit
val srand_time : unit -> unit

(** {2 Vector storage for limited-memory quasi-Newton algorithms} *)

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


(** {2 Version number} *)

val version: unit -> int * int * int


;;