32 const std::vector<Time>& rateTimes,
33 const std::vector<Time>& evolutionTimes,
34 const std::vector<std::pair<Size,Size> >& relevanceRates)
35 : numberOfRates_(rateTimes.empty() ? 0 : rateTimes.size()-1),
36 rateTimes_(rateTimes),
37 evolutionTimes_(evolutionTimes.empty() && !rateTimes.empty() ?
38 std::vector<
Time>(rateTimes.begin(), rateTimes.end()-1) :
40 relevanceRates_(relevanceRates),
41 rateTaus_(numberOfRates_),
43 firstAliveRate_(evolutionTimes_.size())
53 ") is past the last fixing time (" <<
61 "relevanceRates / evolutionTimes mismatch");
69 Time currentEvolutionTime = 0.0;
112 const std::vector<Size>& numeraires)
114 const std::vector<Time>& evolutionTimes = evolution.
evolutionTimes();
115 Size n = evolutionTimes.size();
117 "Size mismatch between numeraires (" << numeraires.size()
118 <<
") and evolution times (" <<
n <<
")");
120 const std::vector<Time>& rateTimes = evolution.
rateTimes();
121 for (
Size i=0; i<
n-1; i++)
122 QL_REQUIRE(rateTimes[numeraires[i]] >= evolutionTimes[i],
124 evolutionTimes[i] <<
": the numeraire (" << numeraires[i] <<
125 "), corresponding to rate time " <<
126 rateTimes[numeraires[i]] <<
", is expired");
130 const std::vector<Size>& numeraires) {
131 const std::vector<Time>& rateTimes = evolution.
rateTimes();
132 return *std::min_element(numeraires.begin(), numeraires.end()) ==
137 const std::vector<Size>& numeraires,
140 const std::vector<Time>& rateTimes = evolution.
rateTimes();
141 Size maxNumeraire=rateTimes.size()-1;
143 "offset (" << offset <<
144 ") is greater than the max allowed value for numeraire ("
145 << maxNumeraire <<
")");
146 const std::vector<Time>& evolutionTimes = evolution.
evolutionTimes();
147 for (
Size i=0, j=0; i<evolutionTimes.size(); ++i) {
148 while (rateTimes[j] < evolutionTimes[i])
150 res = (numeraires[i] == std::min(j+offset, maxNumeraire)) && res;
156 const std::vector<Size>& numeraires) {
168 const std::vector<Time>& rateTimes = ev.
rateTimes();
169 Size maxNumeraire = rateTimes.size()-1;
171 "offset (" << offset <<
172 ") is greater than the max allowed value for numeraire ("
173 << maxNumeraire <<
")");
176 Size n = evolutionTimes.size();
177 std::vector<Size> numeraires(
n);
178 for (
Size i=0, j=0; i<
n; ++i) {
179 while (rateTimes[j] < evolutionTimes[i])
181 numeraires[i] = std::min(j+offset, maxNumeraire);
Market-model evolution description.
std::vector< std::pair< Size, Size > > relevanceRates_
std::vector< Size > firstAliveRate_
Size numberOfRates() const
const std::vector< std::pair< Size, Size > > & relevanceRates() const
const std::vector< Time > & rateTimes() const
std::vector< Time > rateTimes_
const std::vector< Time > & rateTaus() const
const std::vector< Time > & evolutionTimes() const
Size numberOfSteps() const
const std::vector< Size > & firstAliveRate() const
std::vector< Time > rateTaus_
EvolutionDescription()=default
std::vector< Time > evolutionTimes_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
detail::ordinal_holder ordinal(Size)
outputs naturals as 1st, 2nd, 3rd...
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
matrix used in linear algebra.
bool isInMoneyMarketMeasure(const EvolutionDescription &evolution, const std::vector< Size > &numeraires)
std::vector< Size > terminalMeasure(const EvolutionDescription &evolution)
Terminal measure: the last bond is used as numeraire.
void checkCompatibility(const EvolutionDescription &evolution, const std::vector< Size > &numeraires)
std::vector< Size > moneyMarketPlusMeasure(const EvolutionDescription &ev, Size offset)
void checkIncreasingTimesAndCalculateTaus(const std::vector< Time > ×, std::vector< Time > &taus)
bool isInTerminalMeasure(const EvolutionDescription &evolution, const std::vector< Size > &numeraires)
void checkIncreasingTimes(const std::vector< Time > ×)
check for strictly increasing times, first time greater than zero
std::vector< Size > moneyMarketMeasure(const EvolutionDescription &evol)
bool isInMoneyMarketPlusMeasure(const EvolutionDescription &evolution, const std::vector< Size > &numeraires, Size offset)