Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

StochasticGenerator.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 #ifndef martingale_stochasticgenerator_h
00024 #define martingale_stochasticgenerator_h
00025 
00026 #include "TypedefsMacros.h"
00027 #include "Utils.h"
00028 #include "Random.h"
00029 #include "Matrix.h"          // problem with typedefs in forward declarations
00030 
00031 
00032 MTGL_BEGIN_NAMESPACE(Martingale) 
00033 
00034 
00035 
00036 
00037 // depedencies
00038 class LowDiscrepancySequence;
00039 //class RealVector;
00040 //class UTRRealMatrix;
00041 //class RealMatrix;
00042 //class RealArray2D;
00043 class std::ostream;
00044 
00045 
00046 
00047 
00073 /*********************************************************************************
00074  *
00075  *         Stochastic Generator (Driver)       
00076  *
00077  *********************************************************************************/
00078 
00089 class StochasticGenerator {
00090         
00091 protected:
00092         
00093         int n;  // dimension of the process, 
00094                 // size of the vector needed to drive one time step
00095         
00096 public:
00097         
00101         StochasticGenerator(int m=1) : n(m) {  }
00102         
00103 // ADAPTERS
00104 // cannot be declared const because the Sobol driver has to reset the Sobol sequence.
00105         
00110         virtual void newWienerIncrements(int t, int T, RealVector& Z)  {  }
00111         
00116         virtual void newWienerIncrements(int t, int T, Real* Z)  {  }
00117     
00122     virtual void newWienerIncrements(int t, int T, UTRRealMatrix& Z)   {  }
00123         
00128     virtual void newWienerIncrements(int t, int T, RealMatrix& Z)  {  }
00129         
00134     virtual void newWienerIncrements(int t, int T, RealArray2D& Z)  {  }
00135         
00140         virtual void newWienerIncrements(int t, int T, Real** Z)   {  }
00141         
00145         virtual void restart()  {  }
00146         
00150    virtual std::ostream& printSelf(std::ostream& os) const;
00151         
00152 }; // end StochasticGenerator
00153 
00154 
00155 
00156 
00157 /*********************************************************************************
00158  *
00159  *         Libor Drivers   
00160  *
00161  *********************************************************************************/
00162 
00163 
00166 class MonteCarloLiborDriver : public StochasticGenerator {
00167         
00168 public:
00169         
00170         MonteCarloLiborDriver(int n) : StochasticGenerator(n) {  }
00171         
00176     void newWienerIncrements(int t, int T, UTRRealMatrix& Z);
00177         
00180    std::ostream& printSelf(std::ostream& os) const;
00181 
00182 
00183 }; // end MonteCarloLiborDriver
00184 
00185 
00186 
00189 class SobolLiborDriver : public StochasticGenerator {
00190         
00191         LowDiscrepancySequence* lds;
00192         
00193 public:
00194         
00195         SobolLiborDriver(int n) : StochasticGenerator(n), lds(0) {  }
00196         
00201     void newWienerIncrements(int t, int T, UTRRealMatrix& Z);
00202         
00203         void restart();
00204         
00207         std::ostream& printSelf(std::ostream& os) const;
00208 
00209 
00210 }; // end SobolLiborDriver
00211 
00212 
00213 
00214 /*********************************************************************************
00215  *
00216  *         VectorProcess Drivers       
00217  *
00218  *********************************************************************************/
00219 
00220 
00223 class MonteCarloVectorDriver : public StochasticGenerator {
00224         
00225 public:
00226         
00227         MonteCarloVectorDriver(int n) : StochasticGenerator(n) {  }
00228         
00233     void newWienerIncrements(int t, int s, Real** Z);
00234         
00239         void newWienerIncrements(int t, int s, RealMatrix& Z);
00240         
00243         std::ostream& printSelf(std::ostream& os) const;
00244         
00245 
00246 }; // end MonteCarloVectorDriver
00247 
00248 
00249 
00252 class SobolVectorDriver : public StochasticGenerator {
00253         
00254         int T;     // number of time steps to horizon
00255         LowDiscrepancySequence* lds;
00256         
00257 public:
00258         
00262         SobolVectorDriver(int n, int T_oo) : StochasticGenerator(n), 
00263         T(T_oo), lds(0) {  }
00264         
00269     void newWienerIncrements(int t, int s, Real** Z);
00270         
00271     
00276         void newWienerIncrements(int t, int s, RealMatrix& Z);
00277         
00278         void restart();
00279         
00282         std::ostream& printSelf(std::ostream& os) const;
00283 
00284 }; // end SobolVectorDriver
00285 
00286 
00287 
00288 /*********************************************************************************
00289  *
00290  *         ScalarProcess Drivers    
00291  *
00292  *********************************************************************************/
00293 
00294 
00297 class MonteCarloScalarDriver : public StochasticGenerator {
00298         
00299 public:
00300         
00301         MonteCarloScalarDriver() : StochasticGenerator() {  }
00302         
00306     void newWienerIncrements(int t, int s, Real* Z);
00307         
00310         std::ostream& printSelf(std::ostream& os) const;
00311 
00312 }; // end MonteCarloScalarDriver
00313 
00314 
00315 
00318 class SobolScalarDriver : public StochasticGenerator {
00319         
00320         int T;   // number of time steps to horizon
00321         LowDiscrepancySequence* lds;
00322         
00323 public:
00324         
00326         SobolScalarDriver(int T_oo) : StochasticGenerator(), T(T_oo), lds(0) {  }
00327         
00331     void newWienerIncrements(int t, int s, Real* Z);
00332         
00333         void restart();
00334         
00337         std::ostream& printSelf(std::ostream& os) const;
00338 
00339 }; // end SobolScalarDriver
00340 
00341 
00342 
00343 
00344 
00345 
00346 MTGL_END_NAMESPACE(Martingale) 
00347 
00348 
00349 #endif
00350 

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3