# QuantLib_FittedBondDiscountCurve_FittingMethod

FittedBondDiscountCurve::FittingMethod — Base fitting method used to construct a fitted bond discount curve.

## Synopsis

`#include <ql/termstructures/yield/fittedbonddiscountcurve.hpp>`

Inherited by **CubicBSplinesFitting**, **ExponentialSplinesFitting**, **NelsonSiegelFitting**, **SimplePolynomialFitting**, **SpreadFittingMethod**, and **SvenssonFitting**.

### Public Member Functions

virtualSize size() const =0

total number of coefficients to fit/solve forArray solution() const

output array of results of optimization problemInteger numberOfIterations() const

final number of iterations used in the optimization problemReal minimumCostValue() const

final value of cost function after optimization

virtual std::auto_ptr<FittingMethod>clone() const =0

clone of the current object

boolconstrainAtZero() const

return whether there is a constraint at zeroArray weights() const

return weights being used

boost::shared_ptr<OptimizationMethod>optimizationMethod() const

return optimization method being usedDiscountFactor discount(constArray&x,Timet) const

open discountFunction to public

### Protected Member Functions

FittingMethod(boolconstrainAtZero=true, constArray&weights=Array(), boost::shared_ptr<OptimizationMethod>optimizationMethod=boost::shared_ptr<OptimizationMethod>())

constructor

virtual voidinit()

rerun every time instruments/referenceDate changes

virtualDiscountFactor discountFunction(constArray&x,Timet) const =0

discount function called byFittedBondDiscountCurve

### Protected Attributes

boolconstrainAtZero_

constrains discount function to unity at $ T=0 $, if trueFittedBondDiscountCurve*curve_

internal reference to theFittedBondDiscountCurveinstanceArray solution_

solution array found from optimization, set in calculate()Array guessSolution_

optional guess solution to be passed into constructor.

boost::shared_ptr< FittingCost >costFunction_

base class sets this cost function used in the optimization routine

### Friends

classFittedBondDiscountCurve

## Detailed Description

Base fitting method used to construct a fitted bond discount curve.

This base class provides the specific methodology/strategy used to construct a **FittedBondDiscountCurve**. Derived classes need only define the virtual function **discountFunction()** based on the particular fitting method to be implemented, as well as **size()**, the number of variables to be solved for/optimized. The generic fitting methodology implemented here can be termed nonlinear, in contrast to (typically faster, computationally) linear fitting method.

Optional parameters for **FittingMethod** include an **Array** of weights, which will be used as weights to each bond. If not given or empty, then the bonds will be weighted by inverse duration

**Warning**

some parameters to the **Simplex** optimization method may need to be tweaked internally to the class, depending on the fitting method used, in order to get proper/reasonable/faster convergence.

## Member Data Documentation

### Array guessSolution_ [protected]

optional guess solution to be passed into constructor. The idea is to use a previous solution as a guess solution to the discount curve, in an attempt to speed up calculations.

## Author

Generated automatically by Doxygen for QuantLib from the source code.

## Referenced By

constrainAtZero(3), constrainAtZero_(3), costFunction_(3), curve_(3), discountFunction(3), guessSolution_(3), init(3), minimumCostValue(3), numberOfIterations(3), optimizationMethod(3), solution(3), solution_(3) and weights(3) are aliases of QuantLib_FittedBondDiscountCurve_FittingMethod(3).