NC::Fitter::Penalizer Class Reference

#include <NCFitter.h>

Inheritance diagram for NC::Fitter::Penalizer:

List of all members.

Public Member Functions

 Penalizer (ICallableND *g, std::vector< NCParameter > ps)
virtual double EvalAtEx (const CoordNDim &r, CoordNDim *ret) const
 Find the value of the function and return additional information.

Protected Attributes

std::vector< NCParameterfParams

Detailed Description

Definition at line 71 of file NCFitter.h.

Constructor & Destructor Documentation

NC::Fitter::Penalizer::Penalizer ( ICallableND g,
std::vector< NCParameter ps 
) [inline]

Definition at line 74 of file NCFitter.h.

00075       : fFunc(g), fParams(ps){}

Member Function Documentation

double NC::Fitter::Penalizer::EvalAtEx ( const CoordNDim r,
CoordNDim ret 
) const [virtual]

Find the value of the function and return additional information.

r Coordinate at which to evaluate the function
[out] ret Return additional information. By convention, the true underlying coordinates evaluated.
Value of the function at the point r

Implementations must be prepared for ret to be null

Rename to just EvalAt

Implements NC::Fitter::ICallableND.

Definition at line 82 of file NCFitter.cxx.

References NC::Fitter::ICallableND::EvalAtEx(), fFunc, fParams, n, and SQR.

00083   {
00084     CoordNDim reval = r;
00086     // If the point is outside the physical region - move it to the boundary
00087     for(unsigned int n = 0; n < fParams.size(); ++n){
00088       if(r[n] < fParams[n].Min()) reval[n] = fParams[n].Min();
00089       if(r[n] > fParams[n].Max()) reval[n] = fParams[n].Max();
00090     }
00092     double ret = fFunc->EvalAtEx(reval, retCoord);
00094     // If we had to move the point then apply a quadratic penalty term.
00095     // The factor of 1000 is fairly arbitrary.
00096     const double amplitude = 1e3;
00097     for(unsigned int n = 0; n < fParams.size(); ++n){
00098       const double wsqr = SQR(fParams[n].Min()-fParams[n].Max());
00099       assert(wsqr);
00100       if(r[n] < fParams[n].Min())
00101         ret += amplitude*SQR(fParams[n].Min()-r[n])/wsqr;
00102       if(r[n] > fParams[n].Max())
00103         ret += amplitude*SQR(r[n]-fParams[n].Max())/wsqr;
00104     }
00106     return ret;
00107   }

Member Data Documentation

Definition at line 78 of file NCFitter.h.

Referenced by EvalAtEx().

std::vector<NCParameter> NC::Fitter::Penalizer::fParams [protected]

Definition at line 79 of file NCFitter.h.

Referenced by EvalAtEx().

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

Generated on 16 Apr 2018 for loon by  doxygen 1.6.1