Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ModelParameter Class Reference

#include <ored/model/modelparameter.hpp>

+ Inheritance diagram for ModelParameter:
+ Collaboration diagram for ModelParameter:

Public Member Functions

 ModelParameter ()
 Default constructor. More...
 
 ModelParameter (bool calibrate, ParamType type, std::vector< QuantLib::Time > times, std::vector< QuantLib::Real > values)
 Detailed constructor. More...
 
Inspectors
bool calibrate () const
 
ParamType type () const
 
const std::vector< QuantLib::Time > & times () const
 
const std::vector< QuantLib::Real > & values () const
 
Setters / Modifiers
void setTimes (std::vector< Real > times)
 
void setValues (std::vector< Real > values)
 
void mult (const Real f)
 
void setCalibrate (const bool b)
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Serialisation

bool calibrate_
 
ParamType type_
 
std::vector< QuantLib::Time > times_
 
std::vector< QuantLib::Real > values_
 
void fromXML (XMLNode *node) override
 
void append (XMLDocument &doc, XMLNode *node) const
 Method used by toXML in derived classes to add the members here to a node. More...
 
virtual void check () const
 Perform some checks on the parameters. More...
 

Detailed Description

Abstract base class for holding model parameter data.

Definition at line 38 of file modelparameter.hpp.

Constructor & Destructor Documentation

◆ ModelParameter() [1/2]

Default constructor.

Definition at line 29 of file modelparameter.cpp.

◆ ModelParameter() [2/2]

ModelParameter ( bool  calibrate,
ParamType  type,
std::vector< QuantLib::Time >  times,
std::vector< QuantLib::Real >  values 
)

Detailed constructor.

Member Function Documentation

◆ calibrate()

bool calibrate ( ) const

Definition at line 37 of file modelparameter.cpp.

37 {
38 return calibrate_;
39}
+ Here is the caller graph for this function:

◆ type()

ParamType type ( ) const

Definition at line 41 of file modelparameter.cpp.

41 {
42 return type_;
43}
+ Here is the caller graph for this function:

◆ times()

const vector< Time > & times ( ) const

Definition at line 45 of file modelparameter.cpp.

45 {
46 return times_;
47}
std::vector< QuantLib::Time > times_
+ Here is the caller graph for this function:

◆ values()

const vector< Real > & values ( ) const

Definition at line 49 of file modelparameter.cpp.

49 {
50 return values_;
51}
std::vector< QuantLib::Real > values_
+ Here is the caller graph for this function:

◆ setTimes()

void setTimes ( std::vector< Real >  times)

Definition at line 53 of file modelparameter.cpp.

53{ times_ = std::move(times); }
const std::vector< QuantLib::Time > & times() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValues()

void setValues ( std::vector< Real >  values)

Definition at line 55 of file modelparameter.cpp.

55{ values_ = std::move(values); }
const std::vector< QuantLib::Real > & values() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mult()

void mult ( const Real  f)

Definition at line 57 of file modelparameter.cpp.

57 {
58 std::transform(values_.begin(), values_.end(), values_.begin(), [&f](const Real v) { return f * v; });
59}
+ Here is the caller graph for this function:

◆ setCalibrate()

void setCalibrate ( const bool  b)

Definition at line 61 of file modelparameter.cpp.

61{ calibrate_ = b; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Reimplemented in VolatilityParameter, and ReversionParameter.

Definition at line 63 of file modelparameter.cpp.

63 {
64 calibrate_ = XMLUtils::getChildValueAsBool(node, "Calibrate", true);
65 type_ = parseParamType(XMLUtils::getChildValue(node, "ParamType", true));
66 values_ = XMLUtils::getChildrenValuesAsDoublesCompact(node, "InitialValue", true);
69 }
70 check();
71}
virtual void check() const
Perform some checks on the parameters.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:327
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
Definition: irmodeldata.cpp:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append()

void append ( XMLDocument doc,
XMLNode node 
) const
protected

Method used by toXML in derived classes to add the members here to a node.

Definition at line 73 of file modelparameter.cpp.

73 {
74 XMLUtils::addChild(doc, node, "Calibrate", calibrate_);
75 XMLUtils::addGenericChild(doc, node, "ParamType", type_);
76 XMLUtils::addGenericChildAsList(doc, node, "TimeGrid", times_);
77 XMLUtils::addGenericChildAsList(doc, node, "InitialValue", values_);
78}
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
Definition: xmlutils.hpp:144
static void addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
Definition: xmlutils.hpp:137
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check()

void check ( ) const
protectedvirtual

Perform some checks on the parameters.

Definition at line 80 of file modelparameter.cpp.

80 {
82 QL_REQUIRE(values_.size() == 1, "Parameter type is Constant so expecting a single InitialValue.");
83 QL_REQUIRE(times_.empty(), "Parameter type is Constant so expecting an empty time vector.");
84 } else if (type_ == ParamType::Piecewise) {
85 QL_REQUIRE(values_.size() == times_.size() + 1, "Parameter type is Piecewise so expecting the size of the " <<
86 "InitialValue vector (" << values_.size() << ") to be one greater than size of time vector (" <<
87 times_.size() << ").");
88 }
89}
+ Here is the caller graph for this function:

Member Data Documentation

◆ calibrate_

bool calibrate_
private

Definition at line 77 of file modelparameter.hpp.

◆ type_

ParamType type_
private

Definition at line 78 of file modelparameter.hpp.

◆ times_

std::vector<QuantLib::Time> times_
private

Definition at line 79 of file modelparameter.hpp.

◆ values_

std::vector<QuantLib::Real> values_
private

Definition at line 80 of file modelparameter.hpp.