79 libmesh_assert_equal_to(m_eq, 0);
88 libmesh_assert_greater(n, 0);
100 opt = nlopt_create(
_alg, n);
107 res = nlopt_set_lower_bounds(opt, &xmin[0]);
108 libmesh_assert_equal_to(res, NLOPT_SUCCESS);
110 res = nlopt_set_upper_bounds(opt, &xmax[0]);
111 libmesh_assert_equal_to(res, NLOPT_SUCCESS);
117 libmesh_assert_equal_to(res, NLOPT_SUCCESS);
120 res = nlopt_add_inequality_mconstraint(opt,
125 libmesh_assert_equal_to(res, NLOPT_SUCCESS);
131 res = nlopt_optimize(opt, &xval[0], &obj);
132 libmesh_assert_equal_to(res, NLOPT_SUCCESS);
156 dfdx (n*n_constr, 0.);
159 eval_grads(n_constr,
false);
171 f0val, grad!=
nullptr, df0dx,
172 fvals, eval_grads, dfdx);
175 for (
unsigned int i=0; i<n; i++) grad[i] = df0dx[i];
195 libmesh_assert_equal_to(m, n_constr);
201 dfdx (n*n_constr, 0.);
204 eval_grads(n_constr, gradient!=
nullptr);
211 fvals, eval_grads, dfdx);
225 for (
unsigned int i=0; i<m; i++)
226 for (
unsigned int j=0; j<n; j++)
227 gradient[i*n+j] = dfdx[j*m+i];
void sanitize_parallel()
make sure that the analysis is setup consistently across all parallel processes
Real objective_evaluation(unsigned n, const double *x, double *grad)
Computes and.
NLOptOptimizationInterface(nlopt_algorithm alg)
unsigned int n_ineq() const
virtual void _evaluate_wrapper(const std::vector< Real > &dvars, Real &obj, bool eval_obj_grad, std::vector< Real > &obj_grad, std::vector< Real > &fvals, std::vector< bool > &eval_grads, std::vector< Real > &grads)
This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is ...
Provides the basic interface API for classes the provide implement optimization problems.
unsigned int n_vars() const
virtual void _output_wrapper(unsigned int iter, const std::vector< Real > &x, Real obj, const std::vector< Real > &fval, bool if_write_to_optim_file)
This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is ...
double _mast_nlopt_objective_function(unsigned n, const double *x, double *grad, void *f_data)
MAST::FunctionEvaluation * _feval
virtual void _init_dvar_wrapper(std::vector< Real > &x, std::vector< Real > &xmin, std::vector< Real > &xmax)
This serves as a wrapper around init_dvar() and makes sure that the derived class's implementation pr...
unsigned int n_eq() const
unsigned int n_iters_relative_change() const
void inequality_constraint_evaluation(unsigned m, double *result, unsigned n, const double *x, double *gradient)
Computes the m inequality constraints and.
void _mast_nlopt_ineq_constr_mfunc(unsigned m, double *result, unsigned n, const double *x, double *gradient, void *func_data)
nlopt_algorithm _alg
NLOpt algorithm to use.