1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2007 Giorgio Facchinetti
5  Copyright (C) 2007 Chiara Fornarola
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 #ifndef quantlib_forward_rate_normal_pc_evolver_hpp
22 #define quantlib_forward_rate_normal_pc_evolver_hpp
23 
24 #include <ql/models/marketmodels/evolver.hpp>
25 #include <ql/models/marketmodels/curvestates/lmmcurvestate.hpp>
26 #include <ql/models/marketmodels/driftcomputation/lmmnormaldriftcalculator.hpp>
27 
28 namespace QuantLib {
29 
30     class MarketModel;
31     class BrownianGenerator;
32     class BrownianGeneratorFactory;
33 
34     //! Predictor-Corrector
35     class NormalFwdRatePc : public MarketModelEvolver {
36       public:
37         NormalFwdRatePc(const ext::shared_ptr<MarketModel>&,
38                         const BrownianGeneratorFactory&,
39                         const std::vector<Size>& numeraires,
40                         Size initialStep = 0);
41         //! \name MarketModel interface
42         //@{
43         const std::vector<Size>& numeraires() const;
44         Real startNewPath();
45         Real advanceStep();
46         Size currentStep() const;
47         const CurveState& currentState() const;
48         void setInitialState(const CurveState&);
49         //@}
50       private:
51         void setForwards(const std::vector<Real>& forwards);
52         // inputs
53         ext::shared_ptr<MarketModel> marketModel_;
54         std::vector<Size> numeraires_;
55         Size initialStep_;
56         ext::shared_ptr<BrownianGenerator> generator_;
57          // working variables
58         Size numberOfRates_, numberOfFactors_;
59         LMMCurveState curveState_;
60         Size currentStep_;
61         std::vector<Rate> forwards_, initialForwards_;
62         std::vector<Real> drifts1_, drifts2_, initialDrifts_;
63         std::vector<Real> brownians_, correlatedBrownians_;
64         std::vector<Size> alive_;
65         // helper classes
66         std::vector<LMMNormalDriftCalculator> calculators_;
67     };
68 
69 }
70 
71 #endif
72