MAST
MAST::FunctionEvaluation Class Referenceabstract

#include <function_evaluation.h>

Inheritance diagram for MAST::FunctionEvaluation:
Collaboration diagram for MAST::FunctionEvaluation:

Public Member Functions

 FunctionEvaluation (const libMesh::Parallel::Communicator &comm_in)
 
virtual ~FunctionEvaluation ()
 
void attach_optimization_interface (MAST::OptimizationInterface &opt)
 
unsigned int n_vars () const
 
unsigned int n_eq () const
 
unsigned int n_ineq () const
 
unsigned int max_iters () const
 
unsigned int n_iters_relative_change () const
 
Real tolerance () const
 
virtual void init_dvar (std::vector< Real > &x, std::vector< Real > &xmin, std::vector< Real > &xmax)=0
 
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. More...
 
void set_output_file (const std::string &nm)
 sets the output file and the function evaluation will write the optimization iterates to this file. More...
 
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. More...
 
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. More...
 
virtual bool verify_gradients (const std::vector< Real > &dvars)
 verifies the gradients at the specified design point More...
 
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 the two. More...
 
void sanitize_parallel ()
 make sure that the analysis is setup consistently across all parallel processes More...
 
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 provides the same initialization to the design variable vector on all processors. More...
 
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 given the same design variable vector and returns the same values for specific parameters on all processors. More...
 
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 given the same design variable vector on all processors. More...
 

Protected Attributes

unsigned int _n_vars
 
unsigned int _n_eq
 
unsigned int _n_ineq
 
unsigned int _max_iters
 
unsigned int _n_rel_change_iters
 
Real _tol
 
std::ofstream * _output
 
MAST::OptimizationInterface_optimization_interface
 

Detailed Description

Definition at line 45 of file function_evaluation.h.

Constructor & Destructor Documentation

MAST::FunctionEvaluation::FunctionEvaluation ( const libMesh::Parallel::Communicator &  comm_in)
inline

Definition at line 50 of file function_evaluation.h.

virtual MAST::FunctionEvaluation::~FunctionEvaluation ( )
inlinevirtual

Definition at line 62 of file function_evaluation.h.

Here is the call graph for this function:

Member Function Documentation

void MAST::FunctionEvaluation::_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 
)
virtual

This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is given the same design variable vector and returns the same values for specific parameters on all processors.

Definition at line 474 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void MAST::FunctionEvaluation::_init_dvar_wrapper ( std::vector< Real > &  x,
std::vector< Real > &  xmin,
std::vector< Real > &  xmax 
)
virtual

This serves as a wrapper around init_dvar() and makes sure that the derived class's implementation provides the same initialization to the design variable vector on all processors.

Definition at line 460 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void MAST::FunctionEvaluation::_output_wrapper ( unsigned int  iter,
const std::vector< Real > &  x,
Real  obj,
const std::vector< Real > &  fval,
bool  if_write_to_optim_file 
)
virtual

This serves as a wrapper around evaluate() and makes sure that the derived class's implementation is given the same design variable vector on all processors.

Definition at line 506 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void MAST::FunctionEvaluation::attach_optimization_interface ( MAST::OptimizationInterface opt)

Definition at line 33 of file function_evaluation.cpp.

Here is the caller graph for this function:

virtual void MAST::FunctionEvaluation::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 
)
pure virtual

grads(k): Derivative of f_i(x) with respect to x_j, where k = (j-1)*M + i.

Here is the caller graph for this function:

virtual void MAST::FunctionEvaluation::init_dvar ( std::vector< Real > &  x,
std::vector< Real > &  xmin,
std::vector< Real > &  xmax 
)
pure virtual

Here is the caller graph for this function:

void MAST::FunctionEvaluation::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.

This will verify that the optimization setup (number of DVs, constraints, etc.) are the same as the initialized data for this object and then read the dv values from iter iteration into x.

Definition at line 167 of file function_evaluation.cpp.

Here is the caller graph for this function:

unsigned int MAST::FunctionEvaluation::max_iters ( ) const
inline

Definition at line 83 of file function_evaluation.h.

Here is the caller graph for this function:

unsigned int MAST::FunctionEvaluation::n_eq ( ) const
inline

Definition at line 73 of file function_evaluation.h.

Here is the caller graph for this function:

unsigned int MAST::FunctionEvaluation::n_ineq ( ) const
inline

Definition at line 78 of file function_evaluation.h.

Here is the caller graph for this function:

unsigned int MAST::FunctionEvaluation::n_iters_relative_change ( ) const
inline

Definition at line 88 of file function_evaluation.h.

Here is the caller graph for this function:

unsigned int MAST::FunctionEvaluation::n_vars ( ) const
inline

Definition at line 68 of file function_evaluation.h.

Here is the caller graph for this function:

void MAST::FunctionEvaluation::output ( unsigned int  iter,
const std::vector< Real > &  x,
Real  obj,
const std::vector< Real > &  fval,
bool  if_write_to_optim_file 
)
virtual

outputs the the current iterate to libMesh::out, and to the output file if it was set for this rank.

Definition at line 42 of file function_evaluation.cpp.

Here is the caller graph for this function:

void MAST::FunctionEvaluation::parametric_line_study ( const std::string &  nm,
const unsigned int  iter1,
const unsigned int  iter2,
unsigned int  divs 
)
virtual

computes a parametric evaluation along a line from iter1 to iter2 in file nm with divs runs between the two.

Definition at line 410 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void MAST::FunctionEvaluation::sanitize_parallel ( )

make sure that the analysis is setup consistently across all parallel processes

Definition at line 442 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void MAST::FunctionEvaluation::set_output_file ( const std::string &  nm)
inline

sets the output file and the function evaluation will write the optimization iterates to this file.

If this is not called no file will be created. The user may choose to set different file names on different ranks on the communicator, or set the output only on one of the ranks. Specifying the same filename on multiple ranks will lead to undefined behavior since all ranks will try to write to the same file.

Definition at line 124 of file function_evaluation.h.

Here is the call graph for this function:

Real MAST::FunctionEvaluation::tolerance ( ) const
inline

Definition at line 93 of file function_evaluation.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MAST::FunctionEvaluation::verify_gradients ( const std::vector< Real > &  dvars)
virtual

verifies the gradients at the specified design point

Definition at line 244 of file function_evaluation.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

unsigned int MAST::FunctionEvaluation::_max_iters
protected

Definition at line 269 of file function_evaluation.h.

unsigned int MAST::FunctionEvaluation::_n_eq
protected

Definition at line 265 of file function_evaluation.h.

unsigned int MAST::FunctionEvaluation::_n_ineq
protected

Definition at line 267 of file function_evaluation.h.

unsigned int MAST::FunctionEvaluation::_n_rel_change_iters
protected

Definition at line 271 of file function_evaluation.h.

unsigned int MAST::FunctionEvaluation::_n_vars
protected

Definition at line 263 of file function_evaluation.h.

MAST::OptimizationInterface* MAST::FunctionEvaluation::_optimization_interface
protected

Definition at line 277 of file function_evaluation.h.

std::ofstream* MAST::FunctionEvaluation::_output
protected

Definition at line 275 of file function_evaluation.h.

Real MAST::FunctionEvaluation::_tol
protected

Definition at line 273 of file function_evaluation.h.


The documentation for this class was generated from the following files: