The nlopt Reference Manual

This is the nlopt Reference Manual, version 0.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:25:54 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 nlopt

Common Lisp interface to Non-linear optimization library NLopt

Author

Bibek Panthi <>

License

MIT

Version

0.0.1

Dependencies
  • cffi (system).
  • trivial-garbage (system).
Source

nlopt.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 nlopt/nlopt.asd

Source

nlopt.asd.

Parent Component

nlopt (system).

ASDF Systems

nlopt.


3.1.2 nlopt/package.lisp

Source

nlopt.asd.

Parent Component

nlopt (system).

Packages

3.1.3 nlopt/cffi.lisp

Dependency

package.lisp (file).

Source

nlopt.asd.

Parent Component

nlopt (system).

Public Interface

3.1.4 nlopt/utils.lisp

Dependency

cffi.lisp (file).

Source

nlopt.asd.

Parent Component

nlopt (system).

Internals

3.1.5 nlopt/nlopt.lisp

Dependency

utils.lisp (file).

Source

nlopt.asd.

Parent Component

nlopt (system).

Public Interface
Internals

3.1.6 nlopt/nloptimize.lisp

Dependency

nlopt.lisp (file).

Source

nlopt.asd.

Parent Component

nlopt (system).

Public Interface

nloptimize (macro).

Internals

4 Packages

Packages are listed by definition order.


4.1 nlopt.cffi

Source

package.lisp.

Use List

common-lisp.

Public Interface

4.2 nlopt

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: nloptimize ((vars &key algorithm initial) &body body)

Quick and easy way to solve an optimization problem
‘vars’ is list of symbols for variables/parameter names
‘algorithm’ is the algorithm used for solving. It must be a non-gradient algorithm :nlopt_ln_* or :nlopt_gn_* ‘initial’ is the initial values used for parameters
‘body’ can contain normal lisp code however the ‘body’ is parsed for following covenience forms (:minimize expr) (:maximize expr) ;; sets the objective function
(:satisfy expr1 expr2 ...) ;; adds constraints
each constraint can be of the form
(+|- ...) ;; an equality constraint expr = 0
(<|<=|>|>= ...) ;; an inequality constraint or bounds on the parameter
inside the body ‘*nlopt-instance*’ can be used to refer to current nlopt instance

Package

nlopt.

Source

nloptimize.lisp.


5.1.2 Ordinary functions

Function: add-equality-constraint (nlopt function &optional tol)

Add an equality constaint c(x) = 0
c(pointer to doubles x, pointer to gradient or NULL, nlopt) tolerance ‘tol’ is used to check -tol <= c(x) <= tol

Package

nlopt.

Source

nlopt.lisp.

Function: add-inequality-constraint (nlopt function &optional tol)

Add an inequality constaint c(x) <= 0
c(pointer to doubles x, pointer to gradient or NULL, nlopt) tolerance ‘tol’ is used to check c(x) <= tol

Package

nlopt.

Source

nlopt.lisp.

Function: add_equality_constraint (opt h h_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: add_equality_mconstraint (opt m h h_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: add_inequality_constraint (opt fc fc_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: add_inequality_mconstraint (opt m fc fc_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: add_precond_equality_constraint (opt h pre h_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: add_precond_inequality_constraint (opt fc pre fc_data tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: algorithm (nlopt)

Get algorithm used; Returns a keyword

Package

nlopt.

Source

nlopt.lisp.

Function: algorithm-name (algorithm)

Human readable name of ‘algorithm’

Package

nlopt.

Source

nlopt.lisp.

Function: algorithm_name (a)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: algorithms ()

List of algorithms available

Package

nlopt.

Source

nlopt.lisp.

Function: copy (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: copy (nlopt)

Make a copy of ‘nlopt’ problem
If you have subclassed the ‘nlopt’ object define a ‘copy-object’ method on your subclass that copies all slots (including those of ‘nlopt’)

Package

nlopt.

Source

nlopt.lisp.

Function: create (algorithm n)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: create (algorithm dimension)

Create an Non-linear optimization object object
‘algorithm’ is one of the ‘(algorithms)’
‘dimension’ is number of parameters in the optimization problem

Package

nlopt.

Source

nlopt.lisp.

Function: destroy (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: force-stop (nlopt)

In certain cases, the caller may wish to force the optimization to halt, for some reason unknown to NLopt. For example, if the user presses Ctrl-C, or there is an error of some sort in the objective function. In this case, it is possible to tell NLopt to halt the optimization gracefully, returning the best point found so far, by calling the this function from within your objective or constraint functions

Package

nlopt.

Source

nlopt.lisp.

Function: force-stop-value (nlopt)

Returns ‘value’ set using ‘(setf (force-stop-value nlopt) value)’

Package

nlopt.

Source

nlopt.lisp.

Function: (setf force-stop-value) (nlopt)

Set a reason (integer value) for force stopping that can be later retrieved using ‘force-stop-value’

Package

nlopt.

Source

nlopt.lisp.

Function: force_stop (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: (setf ftol-abs) (nlopt)

Set relative tolerance on function value: stop when an optimization step (or an estimate of the optimum) changes the objective function value by less than ‘tol’ multiplied by the absolute value of the function value.

Criterion is disabled if ‘tol’ is non-positive

Package

nlopt.

Source

nlopt.lisp.

Function: ftol-rel (nlopt)

Get relative tolerance in changes in objective function value

Package

nlopt.

Source

nlopt.lisp.

Function: (setf ftol-rel) (nlopt)

Set relative tolerance on function value: stop when an optimization step
(or an estimate of the optimum) changes the objective function value by
less than ‘tol’ multiplied by the absolute value of the function value.
(If there is any chance that your optimum function value is close to zero, you might want to set an absolute tolerance with (setf (ftol-abs nlopt)) as well.)

Criterion is disabled if ‘tol’ is non-positive.

Package

nlopt.

Source

nlopt.lisp.

Function: get_algorithm (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_dimension (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_force_stop (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_ftol_abs (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_ftol_rel (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_initial_step (opt x dx)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_local_search_algorithm (deriv nonderiv maxeval)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_lower_bounds (opt lb)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_maxeval (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_maxtime (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_numevals (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_population (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_stopval (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_upper_bounds (opt ub)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_vector_storage (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_x_weights (opt w)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_xtol_abs (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: get_xtol_rel (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: initial-step (nlopt x)

Get the initial step size
Here, x is the same as the initial guess that you plan to pass to ‘optimize-nlopt’ if you have not set the initial step and NLopt is using its heuristics, its heuristic step size may depend on the initial x, which is why you must pass it here.

Package

nlopt.

Source

nlopt.lisp.

Function: (setf initial-step) (nlopt)

‘dx’ is a number, list or array of doubles of length n (the dimension of the problem) containing the (nonzero) initial step size for each component of the optimization parameters x. If you pass nil for dx, then NLopt will use its heuristics to determine the initial step size.

For derivative-free local-optimization algorithms, the optimizer must somehow decide on some initial step size to perturb x by when it begins the optimization. This step size should be big enough that the value of the objective changes significantly, but not too big if you want to find the local optimum nearest to x. By default, NLopt chooses this initial step size heuristically from the bounds, tolerances, and other information, but this may not always be the best choice.

Package

nlopt.

Source

nlopt.lisp.

Function: lower-bound (nlopt i)
Package

nlopt.

Source

nlopt.lisp.

Function: (setf lower-bound) (nlopt i)
Package

nlopt.

Source

nlopt.lisp.

Function: lower-bounds (nlopt)

Get lower bounds for parameters

Package

nlopt.

Source

nlopt.lisp.

Function: (setf lower-bounds) (nlopt)

Set lower bounds for parameters
bounds can be a number, list or array of doubles

Package

nlopt.

Source

nlopt.lisp.

Function: maxeval (nlopt)

Get maximum number of function evaluations

Package

nlopt.

Source

nlopt.lisp.

Function: (setf maxeval) (nlopt)

Stop when the number of function evaluations exceeds ‘maxeval’
This is not a strict maximum: the number of function evaluations may exceed ‘maxeval’ slightly, depending upon the algorithm.
‘maxeval’ is an integer
Criterion is disabled if ‘maxeval’ is non-positive

Package

nlopt.

Source

nlopt.lisp.

Function: maxtime (nlopt)

Get maximum optimization time allowed (in seconds)

Package

nlopt.

Source

nlopt.lisp.

Function: (setf maxtime) (nlopt)

Stop when the optimization time (in seconds) exceeds maxtime.
This is not a strict maximum: the time may exceed maxtime slightly, depending upon the algorithm and on how slow your function evaluation is. ‘time’ is a double-float
Criterion is disabled if maxtime is non-positive.

Package

nlopt.

Source

nlopt.lisp.

Function: minimize (algorithm n f f_data lb ub x minf minf_max ftol_rel ftol_abs xtol_rel xtol_abs maxeval maxtime)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: minimize_constrained (algorithm n f f_data m fc fc_data fc_datum_size lb ub x minf minf_max ftol_rel ftol_abs xtol_rel xtol_abs maxeval maxtime)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: minimize_econstrained (algorithm n f f_data m fc fc_data fc_datum_size p h h_data h_datum_size lb ub x minf minf_max ftol_rel ftol_abs xtol_rel xtol_abs htol_rel htol_abs maxeval maxtime)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: munge_data (opt munge data)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: nlopt_get_stochastic_population ()
Package

nlopt.cffi.

Source

cffi.lisp.

Function: nlopt_set_stochastic_population (pop)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: numevals (nlopt)

Number of function evaluations used to solve the opt problem

Package

nlopt.

Source

nlopt.lisp.

Function: optimize-nlopt (nlopt &optional x)

Optimize the NonLinear Optimization problem ‘nlopt’ with initial parameters x ‘x’ may be nil, a number, an list or a array of doubles

Package

nlopt.

Source

nlopt.lisp.

Function: optimize_nlp (opt x opt_f)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: remove_equality_constraints (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: remove_inequality_constraints (opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: result-description (result)

Gives description for halting (forcefully or sucessfully) of the optimization problem (result-description (nth-value 2 (optimize-nlopt nlopt)))

Package

nlopt.

Source

nlopt.lisp.

Function: result_from_string (name)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: result_to_string (a)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set-local-optimizer (nlopt local-nlopt)

Some of the algorithms, especially MLSL and AUGLAG, use a different optimization algorithm as a subroutine, typically for local optimization. You can change the local search algorithm and its tolerances by calling:

(setf (local-optimizer nlopt) local-nlo

Here, ‘local-nlopt’ is another nlopt object whose parameters are used to determine the local search algorithm, its stopping criteria, and other algorithm parameters. (However, the objective function, bounds, and nonlinear-constraint parameters of local_opt are ignored.) The dimension ‘n’ of ‘local-nlopt’ must match that of ‘nlopt’.

This function makes a copy of the ‘local-nlopt’ object, so local-optimizer must be assigned to ‘nlopt’ after all criterias are set.

Package

nlopt.

Source

nlopt.lisp.

Function: set-max-objective (nlopt function)

Set maximazation objective function where function(pointer to doubles x, pointer to doubles grad or NULL, nlopt)
returns a double-float

Package

nlopt.

Source

nlopt.lisp.

Function: set-min-objective (nlopt function)

Set minimization objective function where function(pointer to doubles x, pointer to doubles grad or NULL, nlopt)
returns a double-float

Package

nlopt.

Source

nlopt.lisp.

Function: set-population (nlopt size)

Several of the stochastic search algorithms (e.g., CRS, MLSL, and ISRES) start by generating some initial ‘population’ of random points x. By default, this initial population size is chosen heuristically in some algorithm-specific way, but the initial population can by changed by this function. A ‘size’ of zero implies that the heuristic default will be used.

Package

nlopt.

Source

nlopt.lisp.

Function: set-precond-max-objective (nlopt function preconditioner)

See documentation for ‘(set-precond-min-objective)’

Package

nlopt.

Source

nlopt.lisp.

Function: set-precond-min-objective (nlopt function preconditioner)

If you know the Hessian (second-derivative) matrix of your objective function, i.e. the matrix H with Hij=∂2f/∂x_i∂x_j

for an objective f, then in principle this could be used to accelerate local optimization. In fact, even a reasonable approximation for H could be useful if it captures information about the largest eigenvalues of H and the corresponding eigenvectors. Such an approximate Hessian is often called a preconditioner in the context of iterative solvers, so we adopt that terminology here.

Currently, support for preconditioners in NLopt is somewhat experimental, and is only used in the NLOPT_LD_CCSAQ algorithm.

The preconditioner is a function

pre(pointer to doubles x,
pointer to doubles v,
nlopt)

This function should take a vector v and should compute vpre = H(x) v where H is an approximate second derivative at x. The CCSAQ algorithm requires that your matrix H be positive semidefinite, i.e. that it be real-symmetric with nonnegative eigenvalues.

Package

nlopt.

Source

nlopt.lisp.

Function: set_default_initial_step (opt x)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_force_stop (opt val)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_ftol_abs (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_ftol_rel (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_initial_step (opt dx)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_initial_step1 (opt dx)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_local_optimizer (opt local_opt)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_local_search_algorithm (deriv nonderiv maxeval)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_lower_bound (opt i lb)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_lower_bounds (opt lb)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_lower_bounds1 (opt lb)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_max_objective (opt f f_data)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_maxeval (opt maxeval)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_maxtime (opt maxtime)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_min_objective (opt f f_data)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_munge (opt munge_on_destroy munge_on_copy)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_population (opt pop)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_precond_max_objective (opt f pre f_data)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_precond_min_objective (opt f pre f_data)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_stopval (opt stopval)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_upper_bound (opt i lb)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_upper_bounds (opt ub)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_upper_bounds1 (opt ub)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_vector_storage (opt dim)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_x_weights (opt w)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_x_weights1 (opt w)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_xtol_abs (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_xtol_abs1 (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: set_xtol_rel (opt tol)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: srand (seed)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: srand (seed)

For stochastic optimization algorithms, we use pseudorandom numbers generated by the Mersenne Twister algorithm, based on code from Makoto Matsumoto. By default, the seed for the random numbers is generated from the system time, so that you will get a different sequence of pseudorandom numbers each time you run your program. If you want to use a ‘deterministic’ sequence of pseudorandom numbers, i.e. the same sequence from run to run, you can set the seed

Package

nlopt.

Source

nlopt.lisp.

Function: srand-time ()

Reset the seed based on the system time
(It is called automatically, but call this if you have set a deterministic seed using ‘srand’ and want to re-randomize the seed)

Package

nlopt.

Source

nlopt.lisp.

Function: srand_time ()
Package

nlopt.cffi.

Source

cffi.lisp.

Function: stopval (nlopt)

Get the current stopping value for objective function

Package

nlopt.

Source

nlopt.lisp.

Function: (setf stopval) (nlopt)

Stop when an objective value of at least stopval is found: stop minimizing when an objective value <= stopval is found, or stop maximizing a value >= stopval is found.

Package

nlopt.

Source

nlopt.lisp.

Function: upper-bound (nlopt i)
Package

nlopt.

Source

nlopt.lisp.

Function: (setf upper-bound) (nlopt i)
Package

nlopt.

Source

nlopt.lisp.

Function: upper-bounds (nlopt)

Get upper bounds for parameters

Package

nlopt.

Source

nlopt.lisp.

Function: (setf upper-bounds) (nlopt)

Set upper bounds for parameters
bounds can be a number, list or array of doubles

Package

nlopt.

Source

nlopt.lisp.

Function: vector-storage (nlopt)

Get the size/number of previous optimization gradients storage used in limited-memory ‘quasi-Newton’ alogrithms

Package

nlopt.

Source

nlopt.lisp.

Function: (setf vector-storage) (nlopt)

Some of the NLopt algorithms are limited-memory ‘quasi-Newton’ algorithms, which ‘remember’ the gradients from a finite number M of the previous optimization steps in order to construct an approximate 2nd derivative matrix. The bigger M is, the more storage the algorithms require, but on the other hand they may converge faster for larger M. By default, NLopt chooses a heuristic value of M.

Passing M=0 (the default) tells NLopt to use a heuristic value. By default, NLopt currently sets M to 10 or at most 10 MiB worth of vectors, whichever is larger.

Package

nlopt.

Source

nlopt.lisp.

Function: version (major minor bugfix)
Package

nlopt.cffi.

Source

cffi.lisp.

Function: version ()

Get underlying NLopt c library versions (major, minor, bugfix)

Package

nlopt.

Source

nlopt.lisp.

Function: x-weights (nlopt)

Get the weights ‘w_i’ set for relative tolerance in updates of parameters ‘x’

Package

nlopt.

Source

nlopt.lisp.

Function: (setf x-weights) (nlopt)

Set weights ‘w_i’ for relalative tolerance in updates of parameters ‘x’ weights can be a single number, list, or array of doubles

Package

nlopt.

Source

nlopt.lisp.

Function: xtol-abs (nlopt)

Get the stopping tolerances set for updates in parameters ‘x’

Package

nlopt.

Source

nlopt.lisp.

Function: (setf xtol-abs) (nlopt)

Set absolute tolerances on optimization parameters. Stop when an optimization step (or an estimate of the optimum) changes every parameter x[i] by less than tol[i]. Note that since nlopt creates a copy of tolerances array subsequent changes to
the caller’s tolerances have no effect on opt.
‘tolerances’ can be a number, an list or array of doubles of size n = (dimension nlopt) Criterion is disabled if ‘tolerances’ is non-positive.

Package

nlopt.

Source

nlopt.lisp.

Function: xtol-rel (nlopt)

Get relative tolerance in parameters ‘x’

Package

nlopt.

Source

nlopt.lisp.

Function: (setf xtol-rel) (nlopt)

Set relative tolerance on optimization parameters: stop when an optimization step
(or an estimate of the optimum) causes a relative change the parameters ‘x’ by less than ‘tol’, i.e. ∥Δx∥_w <tol * ∥x∥_w as measured by a weighted L₁ norm ∥x∥w=∑_i w_i * |x_i|,
where the weights w_i default to 1. (If there is any chance that the optimal ∥x∥ is close to zero, you might want to set an absolute tolerance with ‘set-xtol-abs’ as well.)

Criterion is disabled if ‘tol’ is non-positive.

Package

nlopt.

Source

nlopt.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *nlopt-instance*

This variable is bound to the nlopt instance being called

Package

nlopt.

Source

nlopt.lisp.


5.2.2 Macros

Macro: dreffing@ (x &body body)

replace occurance of @n with (dref x n) in body Usefull for avoiding

Package

nlopt.

Source

utils.lisp.

Macro: ensure-success (&body body)
Package

nlopt.

Source

utils.lisp.

Macro: with-vector-ptr-to (vector &body body)
Package

nlopt.

Source

utils.lisp.


5.2.3 Ordinary functions

Function: %dreffing@ (var expr)
Package

nlopt.

Source

utils.lisp.

Function: %with-nlopt-constraints (vars exp)
Package

nlopt.

Source

nloptimize.lisp.

Function: %with-nlopt-inequality-constraint (vars exp)

constaints of type (< (- (* 2 x) 5) (* 2 y) z 10) input ‘exp’ should not contain inequality sign

Package

nlopt.

Source

nloptimize.lisp.

Function: %with-nlopt-lambda (vars expression)
Package

nlopt.

Source

nloptimize.lisp.

Function: %with-nlopt-optimize (vars type functions)

Return code for optimizing (first functions)

Package

nlopt.

Source

nloptimize.lisp.

Function: %with-nlopt-satisfy (vars body)
Package

nlopt.

Source

nloptimize.lisp.

Function: %with-nlopt-walker (vars body)

Walk the body and replace :minimize, :maximize and :satisfy with proper code

Package

nlopt.

Source

nloptimize.lisp.

Function: add-equality-mconstraint (nlopt m function tol)

Add multiple equality constraints c_i(x) = 0; i=1,2,..m
‘function’ = ‘c’ should return list of ‘m’ doubles
c(pointer to doubles x,
pointer to gradient(jacobian) ‘∂c_i(x)/∂x_j’ or NULL, (m rows, n columns)
nlopt)
‘tol’ is tolerances as in single constaints, it can be a number, nil, list of tolerance or array of double-floats

In some applications with multiple constraints, it is more convenient to define a single function
that returns the values (and gradients) of all constraints at once. For example, different constraint functions might share computations in some way. Or, if you have a large number of constraints, you may
wish to compute them in parallel.

Package

nlopt.

Source

nlopt.lisp.

Function: add-new-callback (nlopt function)

Adds a callback to nlopt object and returns an struct to identify that callback

Package

nlopt.

Source

nlopt.lisp.

Function: default-initial-x (nlopt)
Package

nlopt.

Source

nlopt.lisp.

Function: doubles (list)

Create an array of double floats from given ‘list’ of double floats

Package

nlopt.

Source

utils.lisp.

Function: doubles* (list)

Create an array of double floats from given ‘list’ (coerces numbers to double-float)

Package

nlopt.

Source

utils.lisp.

Function: doubles-array (size initial-element)

Create oan array of double floats of ‘size’ with ‘initial-element’

Package

nlopt.

Source

utils.lisp.

Function: doubles-array* (size initial-element)

Create oan array of double floats of ‘size’ with ‘initial-element’ (coerces ‘initial-element’ to double-float)

Package

nlopt.

Source

utils.lisp.

Function: dref (ptr index)

Return element of foreign double float array (‘ptr’) at ‘index’ position

Package

nlopt.

Source

utils.lisp.

Function: (setf dref) (ptr index)

Set element of foreign double float array ‘ptr’ at ‘index’ to value ‘val’

Package

nlopt.

Source

utils.lisp.

Function: filter-visible-vars (vars body &optional sofar)

Returns list of ‘vars’ that are seen in ‘body’ results found are stored in ‘sofar’

Package

nlopt.

Source

nloptimize.lisp.

Function: foreign-darray-to-lisp (ptr)
Package

nlopt.

Source

utils.lisp.

Function: no-visible-vars? (vars exp)
Package

nlopt.

Source

nloptimize.lisp.

Function: remove-equality-constraints (nlopt)

Remove all equality constraints

Package

nlopt.

Source

nlopt.lisp.

Function: remove-inequality-constraints (nlopt)

Remove all inequality constraints

Package

nlopt.

Source

nlopt.lisp.

Function: setf-doubles (ptr &rest data)

Set elements of a foreign array of doubles

Package

nlopt.

Source

utils.lisp.

Function: setf-doubles2 (ptr data)

Set elements of a foreign array of doubles

Package

nlopt.

Source

utils.lisp.


5.2.4 Generic functions

Generic Function: add-inequality-mconstraint (nlopt m function tol)
Package

nlopt.

Methods
Method: add-inequality-mconstraint (nlopt m function tol)

Add multiple inequality constraints c_i(x) = 0; i=1,2,..m
‘function’ = ‘c’ should return list of ‘m’ doubles
c(m,
pointer to doubles x,
pointer to gradient(jacobian) ‘∂c_i(x)/∂x_j’, (m rows, n columns)
nlopt)
‘tol’ is tolerances as in single constaints, it can be a number, nil, list of tolerance or array of double-floats

In some applications with multiple constraints, it is more convenient to define a single function
that returns the values (and gradients) of all constraints at once. For example, different constraint functions might share computations in some way. Or, if you have a large number of constraints, you may
wish to compute them in parallel.

Source

nlopt.lisp.

Generic Reader: callbacks (object)
Generic Writer: (setf callbacks) (object)
Package

nlopt.

Methods
Reader Method: callbacks ((nlopt nlopt))
Writer Method: (setf callbacks) ((nlopt nlopt))

Callbacks for different constraints

Source

nlopt.lisp.

Target Slot

callbacks.

Generic Function: copy-object (obj)
Package

nlopt.

Methods
Method: copy-object ((obj nlopt))

Make of copy of nlopt object in lisp side only
You might want to use ‘copy’ to make actual copy of object in lisp and c side

Source

nlopt.lisp.

Generic Reader: dimension (object)
Package

nlopt.

Methods
Reader Method: dimension ((nlopt nlopt))

Number of variables

Source

nlopt.lisp.

Target Slot

dimension.

Generic Reader: identifiers (object)
Generic Writer: (setf identifiers) (object)
Package

nlopt.

Methods
Reader Method: identifiers ((nlopt nlopt))
Writer Method: (setf identifiers) ((nlopt nlopt))

Actually the nlopt c library is passed a single callback which
selects which lisp callback to use. The identifer foreign struct is used to select/identify callbacks

Source

nlopt.lisp.

Target Slot

identifiers.

Generic Reader: objective (object)
Package

nlopt.

Methods
Reader Method: objective ((nlopt nlopt))

Objective function

Source

nlopt.lisp.

Target Slot

objective.

Generic Reader: preconditioner (object)
Package

nlopt.

Methods
Reader Method: preconditioner ((nlopt nlopt))

Preconditioner used with ‘CCSAQ’ algorithm

Source

nlopt.lisp.

Target Slot

preconditioner.

Generic Reader: ptr (object)
Generic Writer: (setf ptr) (object)
Package

nlopt.

Methods
Reader Method: ptr ((nlopt nlopt))
Writer Method: (setf ptr) ((nlopt nlopt))

Pointer to nlopt object

Source

nlopt.lisp.

Target Slot

ptr.


5.2.5 Classes

Class: callback-identifier-tclass
Package

nlopt.

Source

nlopt.lisp.

Direct superclasses
  • foreign-struct-type.
  • translatable-foreign-type.
Class: nlopt
Package

nlopt.

Source

nlopt.lisp.

Direct methods
Direct slots
Slot: ptr

Pointer to nlopt object

Initargs

:ptr

Readers

ptr.

Writers

(setf ptr).

Slot: dimension

Number of variables

Type

integer

Initform

0

Initargs

:dimension

Readers

dimension.

Writers

This slot is read-only.

Slot: objective

Objective function

Readers

objective.

Writers

This slot is read-only.

Slot: callbacks

Callbacks for different constraints

Readers

callbacks.

Writers

(setf callbacks).

Slot: preconditioner

Preconditioner used with ‘CCSAQ’ algorithm

Readers

preconditioner.

Writers

This slot is read-only.

Slot: identifiers

Actually the nlopt c library is passed a single callback which
selects which lisp callback to use. The identifer foreign struct is used to select/identify callbacks

Readers

identifiers.

Writers

(setf identifiers).


5.2.6 Types

Type: doubles ()

Array of double floats

Package

nlopt.

Source

utils.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   %   (  
A   C   D   E   F   G   I   L   M   N   O   P   R   S   U   V   W   X  
Index Entry  Section

%
%dreffing@: Private ordinary functions
%with-nlopt-constraints: Private ordinary functions
%with-nlopt-inequality-constraint: Private ordinary functions
%with-nlopt-lambda: Private ordinary functions
%with-nlopt-optimize: Private ordinary functions
%with-nlopt-satisfy: Private ordinary functions
%with-nlopt-walker: Private ordinary functions

(
(setf callbacks): Private generic functions
(setf callbacks): Private generic functions
(setf dref): Private ordinary functions
(setf force-stop-value): Public ordinary functions
(setf ftol-abs): Public ordinary functions
(setf ftol-rel): Public ordinary functions
(setf identifiers): Private generic functions
(setf identifiers): Private generic functions
(setf initial-step): Public ordinary functions
(setf lower-bound): Public ordinary functions
(setf lower-bounds): Public ordinary functions
(setf maxeval): Public ordinary functions
(setf maxtime): Public ordinary functions
(setf ptr): Private generic functions
(setf ptr): Private generic functions
(setf stopval): Public ordinary functions
(setf upper-bound): Public ordinary functions
(setf upper-bounds): Public ordinary functions
(setf vector-storage): Public ordinary functions
(setf x-weights): Public ordinary functions
(setf xtol-abs): Public ordinary functions
(setf xtol-rel): Public ordinary functions

A
add-equality-constraint: Public ordinary functions
add-equality-mconstraint: Private ordinary functions
add-inequality-constraint: Public ordinary functions
add-inequality-mconstraint: Private generic functions
add-inequality-mconstraint: Private generic functions
add-new-callback: Private ordinary functions
add_equality_constraint: Public ordinary functions
add_equality_mconstraint: Public ordinary functions
add_inequality_constraint: Public ordinary functions
add_inequality_mconstraint: Public ordinary functions
add_precond_equality_constraint: Public ordinary functions
add_precond_inequality_constraint: Public ordinary functions
algorithm: Public ordinary functions
algorithm-name: Public ordinary functions
algorithms: Public ordinary functions
algorithm_name: Public ordinary functions

C
callbacks: Private generic functions
callbacks: Private generic functions
copy: Public ordinary functions
copy: Public ordinary functions
copy-object: Private generic functions
copy-object: Private generic functions
create: Public ordinary functions
create: Public ordinary functions

D
default-initial-x: Private ordinary functions
destroy: Public ordinary functions
dimension: Private generic functions
dimension: Private generic functions
doubles: Private ordinary functions
doubles*: Private ordinary functions
doubles-array: Private ordinary functions
doubles-array*: Private ordinary functions
dref: Private ordinary functions
dreffing@: Private macros

E
ensure-success: Private macros

F
filter-visible-vars: Private ordinary functions
force-stop: Public ordinary functions
force-stop-value: Public ordinary functions
force_stop: Public ordinary functions
foreign-darray-to-lisp: Private ordinary functions
ftol-rel: Public ordinary functions
Function, %dreffing@: Private ordinary functions
Function, %with-nlopt-constraints: Private ordinary functions
Function, %with-nlopt-inequality-constraint: Private ordinary functions
Function, %with-nlopt-lambda: Private ordinary functions
Function, %with-nlopt-optimize: Private ordinary functions
Function, %with-nlopt-satisfy: Private ordinary functions
Function, %with-nlopt-walker: Private ordinary functions
Function, (setf dref): Private ordinary functions
Function, (setf force-stop-value): Public ordinary functions
Function, (setf ftol-abs): Public ordinary functions
Function, (setf ftol-rel): Public ordinary functions
Function, (setf initial-step): Public ordinary functions
Function, (setf lower-bound): Public ordinary functions
Function, (setf lower-bounds): Public ordinary functions
Function, (setf maxeval): Public ordinary functions
Function, (setf maxtime): Public ordinary functions
Function, (setf stopval): Public ordinary functions
Function, (setf upper-bound): Public ordinary functions
Function, (setf upper-bounds): Public ordinary functions
Function, (setf vector-storage): Public ordinary functions
Function, (setf x-weights): Public ordinary functions
Function, (setf xtol-abs): Public ordinary functions
Function, (setf xtol-rel): Public ordinary functions
Function, add-equality-constraint: Public ordinary functions
Function, add-equality-mconstraint: Private ordinary functions
Function, add-inequality-constraint: Public ordinary functions
Function, add-new-callback: Private ordinary functions
Function, add_equality_constraint: Public ordinary functions
Function, add_equality_mconstraint: Public ordinary functions
Function, add_inequality_constraint: Public ordinary functions
Function, add_inequality_mconstraint: Public ordinary functions
Function, add_precond_equality_constraint: Public ordinary functions
Function, add_precond_inequality_constraint: Public ordinary functions
Function, algorithm: Public ordinary functions
Function, algorithm-name: Public ordinary functions
Function, algorithms: Public ordinary functions
Function, algorithm_name: Public ordinary functions
Function, copy: Public ordinary functions
Function, copy: Public ordinary functions
Function, create: Public ordinary functions
Function, create: Public ordinary functions
Function, default-initial-x: Private ordinary functions
Function, destroy: Public ordinary functions
Function, doubles: Private ordinary functions
Function, doubles*: Private ordinary functions
Function, doubles-array: Private ordinary functions
Function, doubles-array*: Private ordinary functions
Function, dref: Private ordinary functions
Function, filter-visible-vars: Private ordinary functions
Function, force-stop: Public ordinary functions
Function, force-stop-value: Public ordinary functions
Function, force_stop: Public ordinary functions
Function, foreign-darray-to-lisp: Private ordinary functions
Function, ftol-rel: Public ordinary functions
Function, get_algorithm: Public ordinary functions
Function, get_dimension: Public ordinary functions
Function, get_force_stop: Public ordinary functions
Function, get_ftol_abs: Public ordinary functions
Function, get_ftol_rel: Public ordinary functions
Function, get_initial_step: Public ordinary functions
Function, get_local_search_algorithm: Public ordinary functions
Function, get_lower_bounds: Public ordinary functions
Function, get_maxeval: Public ordinary functions
Function, get_maxtime: Public ordinary functions
Function, get_numevals: Public ordinary functions
Function, get_population: Public ordinary functions
Function, get_stopval: Public ordinary functions
Function, get_upper_bounds: Public ordinary functions
Function, get_vector_storage: Public ordinary functions
Function, get_xtol_abs: Public ordinary functions
Function, get_xtol_rel: Public ordinary functions
Function, get_x_weights: Public ordinary functions
Function, initial-step: Public ordinary functions
Function, lower-bound: Public ordinary functions
Function, lower-bounds: Public ordinary functions
Function, maxeval: Public ordinary functions
Function, maxtime: Public ordinary functions
Function, minimize: Public ordinary functions
Function, minimize_constrained: Public ordinary functions
Function, minimize_econstrained: Public ordinary functions
Function, munge_data: Public ordinary functions
Function, nlopt_get_stochastic_population: Public ordinary functions
Function, nlopt_set_stochastic_population: Public ordinary functions
Function, no-visible-vars?: Private ordinary functions
Function, numevals: Public ordinary functions
Function, optimize-nlopt: Public ordinary functions
Function, optimize_nlp: Public ordinary functions
Function, remove-equality-constraints: Private ordinary functions
Function, remove-inequality-constraints: Private ordinary functions
Function, remove_equality_constraints: Public ordinary functions
Function, remove_inequality_constraints: Public ordinary functions
Function, result-description: Public ordinary functions
Function, result_from_string: Public ordinary functions
Function, result_to_string: Public ordinary functions
Function, set-local-optimizer: Public ordinary functions
Function, set-max-objective: Public ordinary functions
Function, set-min-objective: Public ordinary functions
Function, set-population: Public ordinary functions
Function, set-precond-max-objective: Public ordinary functions
Function, set-precond-min-objective: Public ordinary functions
Function, setf-doubles: Private ordinary functions
Function, setf-doubles2: Private ordinary functions
Function, set_default_initial_step: Public ordinary functions
Function, set_force_stop: Public ordinary functions
Function, set_ftol_abs: Public ordinary functions
Function, set_ftol_rel: Public ordinary functions
Function, set_initial_step: Public ordinary functions
Function, set_initial_step1: Public ordinary functions
Function, set_local_optimizer: Public ordinary functions
Function, set_local_search_algorithm: Public ordinary functions
Function, set_lower_bound: Public ordinary functions
Function, set_lower_bounds: Public ordinary functions
Function, set_lower_bounds1: Public ordinary functions
Function, set_maxeval: Public ordinary functions
Function, set_maxtime: Public ordinary functions
Function, set_max_objective: Public ordinary functions
Function, set_min_objective: Public ordinary functions
Function, set_munge: Public ordinary functions
Function, set_population: Public ordinary functions
Function, set_precond_max_objective: Public ordinary functions
Function, set_precond_min_objective: Public ordinary functions
Function, set_stopval: Public ordinary functions
Function, set_upper_bound: Public ordinary functions
Function, set_upper_bounds: Public ordinary functions
Function, set_upper_bounds1: Public ordinary functions
Function, set_vector_storage: Public ordinary functions
Function, set_xtol_abs: Public ordinary functions
Function, set_xtol_abs1: Public ordinary functions
Function, set_xtol_rel: Public ordinary functions
Function, set_x_weights: Public ordinary functions
Function, set_x_weights1: Public ordinary functions
Function, srand: Public ordinary functions
Function, srand: Public ordinary functions
Function, srand-time: Public ordinary functions
Function, srand_time: Public ordinary functions
Function, stopval: Public ordinary functions
Function, upper-bound: Public ordinary functions
Function, upper-bounds: Public ordinary functions
Function, vector-storage: Public ordinary functions
Function, version: Public ordinary functions
Function, version: Public ordinary functions
Function, x-weights: Public ordinary functions
Function, xtol-abs: Public ordinary functions
Function, xtol-rel: Public ordinary functions

G
Generic Function, (setf callbacks): Private generic functions
Generic Function, (setf identifiers): Private generic functions
Generic Function, (setf ptr): Private generic functions
Generic Function, add-inequality-mconstraint: Private generic functions
Generic Function, callbacks: Private generic functions
Generic Function, copy-object: Private generic functions
Generic Function, dimension: Private generic functions
Generic Function, identifiers: Private generic functions
Generic Function, objective: Private generic functions
Generic Function, preconditioner: Private generic functions
Generic Function, ptr: Private generic functions
get_algorithm: Public ordinary functions
get_dimension: Public ordinary functions
get_force_stop: Public ordinary functions
get_ftol_abs: Public ordinary functions
get_ftol_rel: Public ordinary functions
get_initial_step: Public ordinary functions
get_local_search_algorithm: Public ordinary functions
get_lower_bounds: Public ordinary functions
get_maxeval: Public ordinary functions
get_maxtime: Public ordinary functions
get_numevals: Public ordinary functions
get_population: Public ordinary functions
get_stopval: Public ordinary functions
get_upper_bounds: Public ordinary functions
get_vector_storage: Public ordinary functions
get_xtol_abs: Public ordinary functions
get_xtol_rel: Public ordinary functions
get_x_weights: Public ordinary functions

I
identifiers: Private generic functions
identifiers: Private generic functions
initial-step: Public ordinary functions

L
lower-bound: Public ordinary functions
lower-bounds: Public ordinary functions

M
Macro, dreffing@: Private macros
Macro, ensure-success: Private macros
Macro, nloptimize: Public macros
Macro, with-vector-ptr-to: Private macros
maxeval: Public ordinary functions
maxtime: Public ordinary functions
Method, (setf callbacks): Private generic functions
Method, (setf identifiers): Private generic functions
Method, (setf ptr): Private generic functions
Method, add-inequality-mconstraint: Private generic functions
Method, callbacks: Private generic functions
Method, copy-object: Private generic functions
Method, dimension: Private generic functions
Method, identifiers: Private generic functions
Method, objective: Private generic functions
Method, preconditioner: Private generic functions
Method, ptr: Private generic functions
minimize: Public ordinary functions
minimize_constrained: Public ordinary functions
minimize_econstrained: Public ordinary functions
munge_data: Public ordinary functions

N
nloptimize: Public macros
nlopt_get_stochastic_population: Public ordinary functions
nlopt_set_stochastic_population: Public ordinary functions
no-visible-vars?: Private ordinary functions
numevals: Public ordinary functions

O
objective: Private generic functions
objective: Private generic functions
optimize-nlopt: Public ordinary functions
optimize_nlp: Public ordinary functions

P
preconditioner: Private generic functions
preconditioner: Private generic functions
ptr: Private generic functions
ptr: Private generic functions

R
remove-equality-constraints: Private ordinary functions
remove-inequality-constraints: Private ordinary functions
remove_equality_constraints: Public ordinary functions
remove_inequality_constraints: Public ordinary functions
result-description: Public ordinary functions
result_from_string: Public ordinary functions
result_to_string: Public ordinary functions

S
set-local-optimizer: Public ordinary functions
set-max-objective: Public ordinary functions
set-min-objective: Public ordinary functions
set-population: Public ordinary functions
set-precond-max-objective: Public ordinary functions
set-precond-min-objective: Public ordinary functions
setf-doubles: Private ordinary functions
setf-doubles2: Private ordinary functions
set_default_initial_step: Public ordinary functions
set_force_stop: Public ordinary functions
set_ftol_abs: Public ordinary functions
set_ftol_rel: Public ordinary functions
set_initial_step: Public ordinary functions
set_initial_step1: Public ordinary functions
set_local_optimizer: Public ordinary functions
set_local_search_algorithm: Public ordinary functions
set_lower_bound: Public ordinary functions
set_lower_bounds: Public ordinary functions
set_lower_bounds1: Public ordinary functions
set_maxeval: Public ordinary functions
set_maxtime: Public ordinary functions
set_max_objective: Public ordinary functions
set_min_objective: Public ordinary functions
set_munge: Public ordinary functions
set_population: Public ordinary functions
set_precond_max_objective: Public ordinary functions
set_precond_min_objective: Public ordinary functions
set_stopval: Public ordinary functions
set_upper_bound: Public ordinary functions
set_upper_bounds: Public ordinary functions
set_upper_bounds1: Public ordinary functions
set_vector_storage: Public ordinary functions
set_xtol_abs: Public ordinary functions
set_xtol_abs1: Public ordinary functions
set_xtol_rel: Public ordinary functions
set_x_weights: Public ordinary functions
set_x_weights1: Public ordinary functions
srand: Public ordinary functions
srand: Public ordinary functions
srand-time: Public ordinary functions
srand_time: Public ordinary functions
stopval: Public ordinary functions

U
upper-bound: Public ordinary functions
upper-bounds: Public ordinary functions

V
vector-storage: Public ordinary functions
version: Public ordinary functions
version: Public ordinary functions

W
with-vector-ptr-to: Private macros

X
x-weights: Public ordinary functions
xtol-abs: Public ordinary functions
xtol-rel: Public ordinary functions