Commits

Chris_T  committed 4062c4b

Propose an alternative interface.

  • Participants
  • Parent commits 46ff9cc

Comments (0)

Files changed (1)

File src/nlopt_FC.mli

+open Bigarray
+
+type 'a vec = (float, float64_elt, 'a) Array1.t
+
+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, 'b) t
+(** A value containing the information about the optimization problem. *)
+
+val create : 'a algorithm -> int -> 'b layout -> ('a, 'b) t
+val copy : ('a, 'b) t -> ('a, 'b) t
+
+val dim : ('a, 'b) t -> int
+val algorithm : ('a, 'b) t -> 'a algorithm
+
+val set_min_objective : ('a, 'b) t -> ?pre:('b vec -> 'b vec -> 'b vec -> unit) ->
+                        ('b vec -> 'b 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, 'b) t -> ?pre:('b vec -> 'b vec -> 'b vec -> unit) ->
+                        ('b vec -> 'b vec -> float) -> unit
+(** See {!set_min_objective}. *)
+
+type result =
+  | Roundoff_limited
+  | Success
+  | Stopval_reached
+  | Ftol_reached
+  | Xtol_reached
+  | Maxeval_reached
+  | Maxtime_reached
+
+val optimize : ('a, 'b) t -> 'b 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)
+ *)
+
+(** {2 Bound constraints} *)
+
+val set_lower_bounds : ('a, 'b) t -> 'b vec -> unit
+val get_lower_bounds : ?y: 'b vec -> ('a, 'b) t -> 'b vec
+val set_upper_bounds : ('a, 'b) t -> 'b vec -> unit
+val get_upper_bounds : ?y: 'b vec -> ('a, 'b) t -> 'b vec
+
+(** {2 Nonlinear constraints} *)
+
+val add_inequality_constraint :
+  ([> `Ineq], 'b) t -> ?tol:float -> ('b vec -> 'b vec -> float) -> unit
+val add_equality_constraint :
+  ([> `Eq], 'b) t -> ?tol:float -> ('b vec -> 'b vec -> float) -> unit
+
+val add_inequality_mconstraint :
+  ([> `Ineq], 'b) t -> tol: 'b vec -> ('b vec -> 'b vec -> 'b vec) -> unit
+
+val add_equality_mconstraint :
+  ([> `Eq], 'b) t -> tol: 'b vec -> ('b vec -> 'b vec -> 'b vec) -> unit
+
+(** {2 Stopping criteria} *)
+
+val set_stopval: ('a, 'b) ('a, 'b) t -> float -> unit
+val get_stopval: ('a, 'b) ('a, 'b) t -> float
+
+val set_ftol_rel: ('a, 'b) t -> float -> unit
+val get_ftol_rel: ('a, 'b) t -> float
+
+val set_ftol_abs: ('a, 'b) t -> float -> unit
+val get_ftol_abs: ('a, 'b) t -> float
+
+val set_xtol_rel: ('a, 'b) t -> float -> unit
+val get_xtol_rel: ('a, 'b) t -> float
+
+val set_xtol_abs: ('a, 'b) t -> float array -> unit
+val get_xtol_abs: ('a, 'b) t -> float array
+
+val set_maxeval: ('a, 'b) t -> int -> unit
+val get_maxeval: ('a, 'b) t -> int
+
+val set_maxtime: ('a, 'b) t -> float -> unit
+val get_maxtime: ('a, 'b) 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], 'b) t -> ([> `Local | `Global], 'c) t -> unit
+
+(** {2 Initial step size} *)
+
+val set_initial_step: ('a, 'b) t -> dx: 'b vec -> unit
+val set_initial_step_heuristics: ('a, 'b) t -> unit
+val get_initial_step: ('a, 'b) t -> 'b vec -> 'b vec
+
+(** {2 Stochastic population} *)
+
+val set_population: ('a, 'b) 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, 'b) t -> int -> unit
+val get_vector_storage: ('a, 'b) t -> int
+
+
+(** {2 Version number} *)
+
+val version: unit -> int * int * int
+
+
+;;