Interface for classes decorating SmootherCostFunction. More...

#include <CostFunctionDecorator.hpp>

Inheritance diagram for julian::ir::CostFunctionDecorator:
julian::ir::SmootherCostFunction julian::ir::FirstDerivativeCostFunction julian::ir::SecondDerivativeCostFunction

Public Member Functions

 CostFunctionDecorator (SmartPointer< SmootherCostFunction > c)
 Constructor. More...
 
virtual arma::mat giveQmatrix (const InterpolatedCurve &) const
 returns Q matrix, the quadratic term of optimization cost function More...
 
virtual arma::mat giveCvector (const InterpolatedCurve &) const
 returns C vector, the linear term of optimization cost function More...
 
virtual double calculateCost (const InterpolatedCurve &) const
 calculates value of cost function More...
 
virtual std::vector< double > giveSmoothedCurve (const InterpolatedCurve &) const
 returns curve as vector of doubles More...
 
virtual void updateSmoothedCurve (InterpolatedCurve &, const std::vector< double > &) const
 updates the curve as with the vector of doubles More...
 
virtual CostFunctionDecoratorclone () const
 virtual copy constructor More...
 
virtual ~CostFunctionDecorator ()
 destructor More...
 
- Public Member Functions inherited from julian::ir::SmootherCostFunction
 SmootherCostFunction ()
 constructor More...
 
virtual ~SmootherCostFunction ()
 destructor More...
 

Protected Member Functions

arma::mat matrixD (int size, int order) const
 Creates matrix representation of differential operator. More...
 
arma::mat matrixX (const InterpolatedCurve &c, int order) const
 Creates matrix representation of differential operator. More...
 

Private Attributes

SmartPointer< SmootherCostFunctioncost_function_
 Pointer to decorator interface. More...
 

Detailed Description

Interface for classes decorating SmootherCostFunction.

CostFunctionDecorator is a interface for all classes decorating the SmootherCostFunction. CostFunctionSmoother's derived classes are used to define the cost function of optimization problems used in ir::InterpolatedCurve construction.

Class also contains methods to calculate the D matrix and X matrix that implements differential operator.

Constructor & Destructor Documentation

julian::ir::CostFunctionDecorator::CostFunctionDecorator ( SmartPointer< SmootherCostFunction c)
inlineexplicit

Constructor.

virtual julian::ir::CostFunctionDecorator::~CostFunctionDecorator ( )
inlinevirtual

destructor

Member Function Documentation

double julian::ir::CostFunctionDecorator::calculateCost ( const InterpolatedCurve input) const
virtual
CostFunctionDecorator * julian::ir::CostFunctionDecorator::clone ( ) const
virtual
arma::mat julian::ir::CostFunctionDecorator::giveCvector ( const InterpolatedCurve input) const
virtual

returns C vector, the linear term of optimization cost function

Implements julian::ir::SmootherCostFunction.

Reimplemented in julian::ir::FirstDerivativeCostFunction, and julian::ir::SecondDerivativeCostFunction.

arma::mat julian::ir::CostFunctionDecorator::giveQmatrix ( const InterpolatedCurve input) const
virtual

returns Q matrix, the quadratic term of optimization cost function

Implements julian::ir::SmootherCostFunction.

Reimplemented in julian::ir::FirstDerivativeCostFunction, and julian::ir::SecondDerivativeCostFunction.

std::vector< double > julian::ir::CostFunctionDecorator::giveSmoothedCurve ( const InterpolatedCurve input) const
virtual

returns curve as vector of doubles

InterpolatedCurve may be represented by different

Implements julian::ir::SmootherCostFunction.

arma::mat julian::ir::CostFunctionDecorator::matrixD ( int  size,
int  derivative 
) const
protected

Creates matrix representation of differential operator.

Numerical derivative of a function f can be approximated using following formula

\[\frac{df(x)}{dx}|_{x=x_i} \approx \frac{f(x_{i+1}) - f(x_{i})}{x_{i+1}-x_{i}}\]

If $F = [f(x_1), f(x_2), ..., f(x_n)]$ then differencing of function can be presented in matrix form"

\[\frac{dF}{sX} = X^{-1} \times D_{1} \times F\]

where:

\[ D_{1} = \begin{bmatrix} 0 & 0 & 0 & \dots & 0 & 0 \\ -1 & 1 & 0 & \dots & 0 & 0 \\ 0 & -1 & 1 & \dots & 0 & 0 \\ 0 & 0 &-1 & \dots & 0 & 0 \\ \hdotsfor{6} \\ 0 & 0 & 0 & \dots & -1 & 1 \end{bmatrix}\]

  • \[ X = \begin{bmatrix} x_{1} - x_{0} & 0 & 0 & \dots & 0 & 0 \\ 0 & x_{2} - x_{1} & 0 & \dots & 0 & 0 \\ 0 & 0 & x_{3} - x_{2} & \dots & 0 & 0 \\ 0 & 0 & 0 & \dots & 0 & 0 \\ \hdotsfor{6} \\ 0 & 0 & 0 &\dots & 0 & x_{n}-x_{n-1} \end{bmatrix}\]

The second derivative can be calculated by analogy.

This method calculates the D matrix.

Parameters
sizeSize of D matrix
derivativeOrder of derivative
arma::mat julian::ir::CostFunctionDecorator::matrixX ( const InterpolatedCurve c,
int  order 
) const
protected

Creates matrix representation of differential operator.

Numerical derivative of a function f can be approximated using following formula

\[\frac{df(x)}{dx}|_{x=x_i} \approx \frac{f(x_{i+1}) - f(x_{i})}{x_{i+1}-x_{i}}\]

If $F = [f(x_1), f(x_2), ..., f(x_n)]$ then differencing of function can be presented in matrix form:

\[\frac{dF}{dX} = X^{-1} \times D_{1} \times F\]

where:

\[ D_{1} = \begin{bmatrix} 0 & 0 & 0 & \dots & 0 & 0 \\ -1 & 1 & 0 & \dots & 0 & 0 \\ 0 & -1 & 1 & \dots & 0 & 0 \\ 0 & 0 &-1 & \dots & 0 & 0 \\ \hdotsfor{6} \\ 0 & 0 & 0 & \dots & -1 & 1 \end{bmatrix}\]

  • \[ X = \begin{bmatrix} x_{1} - x_{0} & 0 & 0 & \dots & 0 & 0 \\ 0 & x_{2} - x_{1} & 0 & \dots & 0 & 0 \\ 0 & 0 & x_{3} - x_{2} & \dots & 0 & 0 \\ 0 & 0 & 0 & \dots & 0 & 0 \\ \hdotsfor{6} \\ 0 & 0 & 0 &\dots & 0 & x_{n}-x_{n-1} \end{bmatrix}\]

The second derivative can be calculated by analogy.

This method calculates the X matrix.

Parameters
cCurve which derivative we calculates
orderOrder of derivative
void julian::ir::CostFunctionDecorator::updateSmoothedCurve ( InterpolatedCurve c,
const std::vector< double > &  r 
) const
virtual

updates the curve as with the vector of doubles

Implements julian::ir::SmootherCostFunction.

Member Data Documentation

SmartPointer<SmootherCostFunction> julian::ir::CostFunctionDecorator::cost_function_
private

Pointer to decorator interface.


The documentation for this class was generated from the following files:
  • C:/Unix/home/OEM/jULIAN/src/marketData/interestRateCurves/estimators/costFunctions/CostFunctionDecorator.hpp
  • C:/Unix/home/OEM/jULIAN/src/marketData/interestRateCurves/estimators/costFunctions/CostFunctionDecorator.cpp