QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
lognormalfwdrateeulerconstrained.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 Ferdinando Ametrano
5 Copyright (C) 2006 Mark Joshi
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21
22#ifndef quantlib_forward_rate_euler_constrained_evolver_hpp
23#define quantlib_forward_rate_euler_constrained_evolver_hpp
24
25#include <ql/models/marketmodels/constrainedevolver.hpp>
26#include <ql/models/marketmodels/curvestates/lmmcurvestate.hpp>
27#include <ql/models/marketmodels/driftcomputation/lmmdriftcalculator.hpp>
28#include <valarray>
29
30namespace QuantLib {
31
32 class MarketModel;
33 class BrownianGenerator;
34 class BrownianGeneratorFactory;
35
38 {
39 public:
40 LogNormalFwdRateEulerConstrained(const ext::shared_ptr<MarketModel>&,
42 const std::vector<Size>& numeraires,
43 Size initialStep = 0);
45
46 void setConstraintType(const std::vector<Size>& startIndexOfSwapRate,
47 const std::vector<Size>& endIndexOfSwapRate) override;
48 void setThisConstraint(const std::vector<Rate>& rateConstraints,
49 const std::valarray<bool>& isConstraintActive) override;
51
53 const std::vector<Size>& numeraires() const override;
54 Real startNewPath() override;
55 Real advanceStep() override;
56 Size currentStep() const override;
57 const CurveState& currentState() const override;
58 void setInitialState(const CurveState&) override;
60 private:
61 void setForwards(const std::vector<Real>& forwards);
62 // inputs
63 ext::shared_ptr<MarketModel> marketModel_;
64 std::vector<Size> numeraires_;
66 ext::shared_ptr<BrownianGenerator> generator_;
67
68 std::vector<Size> startIndexOfSwapRate_;
69 std::vector<Size> endIndexOfSwapRate_;
70
71 //often changing inputs
72 std::vector<Rate> rateConstraints_;
73 std::valarray<bool> isConstraintActive_;
74
75 // fixed variables
76 std::vector<std::vector<Real> > fixedDrifts_;
77 std::vector<std::vector<Real> > variances_;
78
79 // working variables
80 std::vector<std::vector<Real> > covariances_; // covariance of constrained rate with other rates on same step
81 // step first index
86 std::vector<Real> drifts1_, initialDrifts_;
87 std::vector<Real> brownians_, correlatedBrownians_;
88 std::vector<Size> alive_;
89 // helper classes
90 std::vector<LMMDriftCalculator> calculators_;
91 };
92
93}
94
95#endif
Constrained market-model evolver.
Curve state for market-model simulations
Definition: curvestate.hpp:41
Curve state for Libor market models
void setForwards(const std::vector< Real > &forwards)
void setConstraintType(const std::vector< Size > &startIndexOfSwapRate, const std::vector< Size > &endIndexOfSwapRate) override
call once
void setThisConstraint(const std::vector< Rate > &rateConstraints, const std::valarray< bool > &isConstraintActive) override
call before each path
const std::vector< Size > & numeraires() const override
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35