21 #ifndef __mast__function_evaluation_h__ 22 #define __mast__function_evaluation_h__ 37 #include "libmesh/parallel_object.h" 43 class OptimizationInterface;
46 public libMesh::ParallelObject {
51 libMesh::ParallelObject (comm_in),
74 unsigned int n_eq()
const {
99 virtual void init_dvar(std::vector<Real>& x,
100 std::vector<Real>& xmin,
101 std::vector<Real>& xmax) = 0;
107 virtual void evaluate(
const std::vector<Real>& dvars,
110 std::vector<Real>& obj_grad,
111 std::vector<Real>& fvals,
112 std::vector<bool>& eval_grads,
113 std::vector<Real>& grads) = 0;
131 _output->open(nm.c_str(), std::ofstream::out);
139 virtual void output(
unsigned int iter,
140 const std::vector<Real>& x,
142 const std::vector<Real>& fval,
143 bool if_write_to_optim_file);
155 const unsigned int iter,
156 std::vector<Real> &x);
169 const unsigned int iter1,
170 const unsigned int iter2,
174 #if MAST_ENABLE_SNOPT == 1 175 typedef void (*funobj) (
int* mode,
183 typedef void (*funcon) (
int* mode,
198 get_objective_evaluation_function() {
202 libmesh_assert(
false);
212 get_constraint_evaluation_function() {
216 libmesh_assert(
false);
233 std::vector<Real>& xmin,
234 std::vector<Real>& xmax);
246 std::vector<Real>& obj_grad,
247 std::vector<Real>& fvals,
248 std::vector<bool>& eval_grads,
249 std::vector<Real>& grads);
257 const std::vector<Real>& x,
259 const std::vector<Real>& fval,
260 bool if_write_to_optim_file);
286 #endif // __mast__function_evaluation_h__
virtual void output(unsigned int iter, const std::vector< Real > &x, Real obj, const std::vector< Real > &fval, bool if_write_to_optim_file)
outputs the the current iterate to libMesh::out, and to the output file if it was set for this rank...
unsigned int n_eq() const
virtual void parametric_line_study(const std::string &nm, const unsigned int iter1, const unsigned int iter2, unsigned int divs)
computes a parametric evaluation along a line from iter1 to iter2 in file nm with divs runs between t...
void sanitize_parallel()
make sure that the analysis is setup consistently across all parallel processes
virtual void init_dvar(std::vector< Real > &x, std::vector< Real > &xmin, std::vector< Real > &xmax)=0
unsigned int max_iters() const
unsigned int n_vars() const
FunctionEvaluation(const libMesh::Parallel::Communicator &comm_in)
MAST::OptimizationInterface * _optimization_interface
unsigned int n_ineq() const
virtual void evaluate(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)=0
grads(k): Derivative of f_i(x) with respect to x_j, where k = (j-1)*M + i.
virtual ~FunctionEvaluation()
void set_output_file(const std::string &nm)
sets the output file and the function evaluation will write the optimization iterates to this file...
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 ...
void attach_optimization_interface(MAST::OptimizationInterface &opt)
unsigned int _n_rel_change_iters
Provides the basic interface API for classes the provide implement optimization problems.
void initialize_dv_from_output_file(const std::string &nm, const unsigned int iter, std::vector< Real > &x)
This reads and initializes the DV vector from a previous optimization history output file...
unsigned int n_iters_relative_change() 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 ...
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...
virtual bool verify_gradients(const std::vector< Real > &dvars)
verifies the gradients at the specified design point