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

#include <ored/model/calibrationconfiguration.hpp>

+ Inheritance diagram for CalibrationConfiguration:
+ Collaboration diagram for CalibrationConfiguration:

Public Member Functions

 CalibrationConfiguration (QuantLib::Real rmseTolerance=0.0001, QuantLib::Size maxIterations=50)
 Constructor. More...
 
Inspectors
QuantLib::Real rmseTolerance () const
 A final tolerance on the RMSE of the calibration that may be used by various builders. More...
 
QuantLib::Size maxIterations () const
 
does not have a constraint, a

Return constraint for the parameter name.

Currently, only boundary constraints are supported. If the parameter NoConstraint instance is returned.

QuantLib::ext::shared_ptr< QuantLib::Constraint > constraint (const std::string &name) const
 
std::pair< QuantLib::Real, QuantLib::Real > boundaries (const std::string &name) const
 
void add (const std::string &name, QuantLib::Real lowerBound, QuantLib::Real upperBound)
 
- 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

QuantLib::Real rmseTolerance_
 
QuantLib::Size maxIterations_
 
std::map< std::string, std::pair< QuantLib::Real, QuantLib::Real > > constraints_
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 

Detailed Description

Class for holding calibration configuration details.

Definition at line 38 of file calibrationconfiguration.hpp.

Constructor & Destructor Documentation

◆ CalibrationConfiguration()

CalibrationConfiguration ( QuantLib::Real  rmseTolerance = 0.0001,
QuantLib::Size  maxIterations = 50 
)

Constructor.

Definition at line 36 of file calibrationconfiguration.cpp.

QuantLib::Real rmseTolerance() const
A final tolerance on the RMSE of the calibration that may be used by various builders.

Member Function Documentation

◆ rmseTolerance()

Real rmseTolerance ( ) const

A final tolerance on the RMSE of the calibration that may be used by various builders.

Definition at line 39 of file calibrationconfiguration.cpp.

39 {
40 return rmseTolerance_;
41}

◆ maxIterations()

Size maxIterations ( ) const

High level maximum iterations. This may mean different to things to different builders. This is not the maximum number of iterations used by the EndCriteria for optimisation. If this is needed, this should be added in another XML object along with the other EndCriteria elements and included as a CalibrationConfiguration member.

Definition at line 43 of file calibrationconfiguration.cpp.

43 {
44 return maxIterations_;
45}

◆ constraint()

QuantLib::ext::shared_ptr< Constraint > constraint ( const std::string &  name) const

Definition at line 47 of file calibrationconfiguration.cpp.

47 {
48 auto it = constraints_.find(name);
49 if (it != constraints_.end()) {
50 return QuantLib::ext::make_shared<BoundaryConstraint>(it->second.first, it->second.second);
51 } else {
52 return QuantLib::ext::make_shared<NoConstraint>();
53 }
54}
std::map< std::string, std::pair< QuantLib::Real, QuantLib::Real > > constraints_
string name

◆ boundaries()

pair< Real, Real > boundaries ( const std::string &  name) const

Return the boundaries for the parameter name.

If no boundaries have been given for parameter name, a pair with both elements set to Null<Real>() is returned.

Definition at line 56 of file calibrationconfiguration.cpp.

56 {
57 auto it = constraints_.find(name);
58 if (it != constraints_.end()) {
59 return it->second;
60 } else {
61 return make_pair(Null<Real>(), Null<Real>());
62 }
63}

◆ add()

void add ( const std::string &  name,
QuantLib::Real  lowerBound,
QuantLib::Real  upperBound 
)

Add a boundary constraint on the parameter name.

Definition at line 65 of file calibrationconfiguration.cpp.

65 {
66 QL_REQUIRE(lowerBound < upperBound, "CalibrationConfiguration: Lower bound (" << lowerBound <<
67 ") must be less than upper bound (" << upperBound << ").");
68 constraints_[name] = make_pair(lowerBound, upperBound);
69 DLOG("Boundary constraint [" << lowerBound << "," << upperBound << "] added for parameter " << name << ".");
70}
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 72 of file calibrationconfiguration.cpp.

72 {
73
74 XMLUtils::checkNode(node, "CalibrationConfiguration");
75
76 rmseTolerance_ = 0.0001;
77 if (XMLNode* n = XMLUtils::getChildNode(node, "RmseTolerance")) {
79 }
80
81 maxIterations_ = 50;
82 if (XMLNode* n = XMLUtils::getChildNode(node, "MaxIterations")) {
84 }
85
86 XMLNode* constraintsNode = XMLUtils::getChildNode(node, "Constraints");
87 for (XMLNode* cn = XMLUtils::getChildNode(constraintsNode); cn; cn = XMLUtils::getNextSibling(cn)) {
88
89 // Only support boundary constraints for the moment.
90 string constraintName = XMLUtils::getNodeName(cn);
91 if (constraintName != "BoundaryConstraint") {
92 DLOG("CalibrationConfiguration skipping constraint with name " << constraintName << ". Only " <<
93 "BoundaryConstraint is currently supported.");
94 continue;
95 }
96
97 auto name = XMLUtils::getAttribute(cn, "parameter");
98 auto lowerBound = parseReal(XMLUtils::getChildValue(cn, "LowerBound", true));
99 auto upperBound = parseReal(XMLUtils::getChildValue(cn, "UpperBound", true));
100 add(name, lowerBound, upperBound);
101 }
102
103}
void add(const std::string &name, QuantLib::Real lowerBound, QuantLib::Real upperBound)
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 105 of file calibrationconfiguration.cpp.

105 {
106
107 XMLNode* node = doc.allocNode("CalibrationConfiguration");
108
109 XMLUtils::addChild(doc, node, "RmseTolerance", rmseTolerance_);
110 XMLUtils::addChild(doc, node, "MaxIterations", static_cast<int>(maxIterations_));
111
112 XMLNode* constraintsNode = doc.allocNode("Constraints");
113 for (const auto& kv : constraints_) {
114 XMLNode* n = doc.allocNode("BoundaryConstraint");
115 XMLUtils::addChild(doc, n, "LowerBound", kv.second.first);
116 XMLUtils::addChild(doc, n, "UpperBound", kv.second.second);
117 XMLUtils::addAttribute(doc, n, "parameter", kv.first);
118 XMLUtils::appendNode(constraintsNode, n);
119 }
120 XMLUtils::appendNode(node, constraintsNode);
121
122 return node;
123}
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ rmseTolerance_

QuantLib::Real rmseTolerance_
protected

Definition at line 82 of file calibrationconfiguration.hpp.

◆ maxIterations_

QuantLib::Size maxIterations_
protected

Definition at line 83 of file calibrationconfiguration.hpp.

◆ constraints_

std::map<std::string, std::pair<QuantLib::Real, QuantLib::Real> > constraints_
protected

Definition at line 84 of file calibrationconfiguration.hpp.