Subsections

 
3.8 OEFunc1

class OEOpt::OEFunc1 : public OEOpt::OEFunc0

The OEFunc0 base class defines the interface for stateful functions (functors) which take a set of variables and compute a function value and gradients. Classes derived from OEFunc1 are intended for use with optimizers which require gradients.

3.8.1 operator()

virtual double operator()(const double *var)
virtual double operator()(const double *var, double *grad)

These pure virtual methods define the interface for function evaluation. An array of variables is passed as the first argument, and a function value is returned. In addition, the second method computes gradients given a set of variables. There should be a one to one correspondence between the elements of the variable and gradient arrays (i.e. the first gradient element corresponds to the first variable element). Methods that override the gradient calculation operator must not initialize the gradient array, but rather assume the array has already been initialized. By convention, classes derived from OEOpt::OEOptimizer1 must initialize gradient arrays before calling a function evaluation.

3.8.2 GetFComponents

virtual OESystem::OEIterBase<OEFComponent>
                                 *GetFComponents(const double *var)

This pure virtual method defines the interface for retrieving information about function names and associated function values given a set of variables. The method takes an array of variables, and returns an iterator over the names and component energies (Section 3.4) calculated for the variables.

3.8.3 NumVar

virtual unsigned int NumVar() const

This pure virtual method defines the interface for returning the number of function variables for which an OEFunc1 derived class instance has been initialized.