nloptOptimizeTest

Undocumented in source. Be warned that the author may not have intended to support it.
version(unittest)
void
nloptOptimizeTest
(
T
U
)
(
T x
,
U lb
)

Examples

import core.stdc.math : HUGE_VAL;
import std.math : approxEqual;

auto opt = Opt(Algorithm.ldMMA, 2);

double[] lb = [-HUGE_VAL, 0];
double[] x = [1.234, 5.678];
double minf;
my_constraint_data[2] c_data = [{2.0, 0.0}, {-1.0, 1.0}];

opt.setLowerBounds(lb);

opt.setMinObjective(&myFuncC);

opt.addInequalityConstraint(&myConstraintC, c_data[0]);
opt.addInequalityConstraint(&myConstraintC, c_data[1]);

opt.optimize(x, minf);

assert(opt.getResult() > 0);
assert(approxEqual(x[0], 0.333333));
assert(approxEqual(x[1], 0.296296));
assert(approxEqual(minf, 0.5443310476));

Meta