Opt

Defines an object to interact with nlopt C API.

Equivalent in C API: nlopt_opt

struct Opt {}

Constructors

this
this(Algorithm algorithm, uint n)

Initializes Opt.

Destructor

~this
~this()

Standard destructor.

Members

Functions

addEqualityConstraint
void addEqualityConstraint(T fc, U fc_data, double tol)
void addEqualityConstraint(T fc)

Add equality constraint

addEqualityMConstraint
void addEqualityMConstraint(uint m, T fc, U fc_data, V tol)
void addEqualityMConstraint(uint m, T fc, U fc_data)
void addEqualityMConstraint(uint m, T fc)

Add multiple equality constraints

addInequalityConstraint
void addInequalityConstraint(T fc, U fc_data, double tol)

Add inequality constraint

addInequalityConstraint
void addInequalityConstraint(T fc)
Undocumented in source. Be warned that the author may not have intended to support it.
addInequalityMConstraint
void addInequalityMConstraint(uint m, T fc, U fc_data, V tol)
void addInequalityMConstraint(uint m, T fc, U fc_data)
void addInequalityMConstraint(uint m, T fc)

Add multiple inequality constraints

addPrecondEqualityConstraint
void addPrecondEqualityConstraint(T fc, U pre, V fc_data, double tol)

Add pre-conditioned equality constraint

addPrecondEqualityConstraint
void addPrecondEqualityConstraint(T fc, U pre)
Undocumented in source. Be warned that the author may not have intended to support it.
addPrecondInequalityConstraint
void addPrecondInequalityConstraint(T fc, U pre, V fc_data, double tol)

Add pre-conditioned inequality constraint.

addPrecondInequalityConstraint
void addPrecondInequalityConstraint(T fc, U pre)
Undocumented in source.
copy
auto copy()

Copies an instance of Opt to new instance.

create
void create(Algorithm algorithm, uint n)

Calls nlopt_create and sets its result to _opt.

forceStop
void forceStop()

Force optimization to stop. Refer to http://ab-initio.mit.edu/wiki/index.php/NLopt_Reference#Forced_termination

getAlgorithm
auto getAlgorithm()

Get Algorithm

getAlgorithmRaw
auto getAlgorithmRaw()

Get Raw Algorithm

getDimension
auto getDimension()

Get dimension

getFTolAbs
auto getFTolAbs()

Gets the absolute tolerance for objective function f(x).

getFTolRel
auto getFTolRel()

Gets the relative tolerance for objective function f(x).

getForceStop
auto getForceStop()

Refer to http://ab-initio.mit.edu/wiki/index.php/NLopt_Reference#Forced_termination

getInitialStep
void getInitialStep(T x, U dx)
void getInitialStep(double x, double dx)

Gets initial step for derivative-free local optimization algorithms.

getLowerBounds
void getLowerBounds(T lb)
void getLowerBounds(double lb)

Get lower bounds

getMaxeval
auto getMaxeval()

Gets the maximum number of evaluations.

getMaxtime
auto getMaxtime()

Gets the maximum amount of time spent on optimization.

getOptRaw
nlopt_opt getOptRaw()

Gets raw opt object

getPopulation
auto getPopulation()

Get population in stochastic search algorithms.

getResult
auto getResult()

Gets the result value.

getResultRaw
auto getResultRaw()

Gets the raw result value.

getStopval
auto getStopval()

Gets the Stopval.

getUpperBounds
void getUpperBounds(T ub)
void getUpperBounds(double ub)

Get upper bounds

getVectorStorage
auto getVectorStorage()

Get vector storage.

getXTolAbs
void getXTolAbs(T tol)

Gets the absolute tolerance for x.

getXTolRel
auto getXTolRel()

Gets the relative tolerance for x.

optimize
void optimize(T x, double minf)

Optimize

processResult
void processResult(nlopt_result result)

Processes a member of nlopt_result.

removeEqualityConstraints
void removeEqualityConstraints()

Remove equality constraints

removeInequalityConstraints
void removeInequalityConstraints()

Remove inequality constraints

setDefaultInitialStep
void setDefaultInitialStep(T dx)
void setDefaultInitialStep(double dx)

Sets default initial step for derivative-free local optimization algorithms.

setFTolAbs
void setFTolAbs(double tol)

Sets the absolute tolerance for objective function f(x).

setFTolRel
void setFTolRel(double tol)

Sets the relative tolerance for objective function f(x).

setForceStop
void setForceStop(int val)

Force optimization to stop with more information. Refer to http://ab-initio.mit.edu/wiki/index.php/NLopt_Reference#Forced_termination

setInitialStep
void setInitialStep(T dx)
void setInitialStep(double dx)

Sets initial step for derivative-free local optimization algorithms.

setLocalOptimizer
void setLocalOptimizer(nlopt_opt local_opt)
void setLocalOptimizer(Opt local_opt)

From NLopt Reference: "Some of the algorithms, especially MLSL and AUGLAG, use a different optimization algorithm as a subroutine, typically for local optimization."

setLowerBounds
void setLowerBounds(T lb)
void setLowerBounds(double lb)

Set lower bounds

setMaxObjective
void setMaxObjective(T f, U f_data)

Set Maximum Objective

setMaxeval
void setMaxeval(int maxeval)

Sets the maximum number of evaluations.

setMaxtime
void setMaxtime(double maxtime)

Sets the maximum amount of time spent on optimization.

setMinObjective
void setMinObjective(T f, U f_data)

Set Minimum Objective

setPopulation
void setPopulation(uint pop)

For use in stochastic search algorithms, size of initial population of random points. Default is that it is chosen heuristically by algorithm.

setPrecondMaxObjective
void setPrecondMaxObjective(T f, U pre, V f_data)

Set Maximum Objective with Pre-conditioned Hessian

setPrecondMinObjective
void setPrecondMinObjective(T f, U pre, V f_data)

Set Minimum Objective with Pre-conditioned Hessian

setStopval
void setStopval(double stopval)

Sets the Stopval.

setUpperBounds
void setUpperBounds(T ub)
void setUpperBounds(double ub)

Set upper bounds

setVectorStorage
void setVectorStorage(uint M)

For use with limited-memory algorithms that remember gradients from previous iterations.

setXTolAbs
void setXTolAbs(T tol)
void setXTolAbs(double tol)

Sets the absolute tolerance for x.

setXTolRel
void setXTolRel(double tol)

Sets the relative tolerance for x.

srand
void srand(uint seed)

Sets the seed for stochastic optimization.

srandTime
void srandTime()

Re-sets the seed for stochastic optimization back to system time.

Examples

TODO

Meta