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

Trigger.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 
00024 #ifndef martingale_trigger_h    
00025 #define martingale_trigger_h
00026 
00027 #include "TypedefsMacros.h"
00028 #include "Optimizer.h"        // base class BFGS
00029 
00030 
00031 MTGL_BEGIN_NAMESPACE(Martingale)
00032 
00033 
00034 // dependencies
00035 class LiborMarketModel;
00036 class BermudanSwaption;
00037 
00038 
00039 
00040 
00049 /**********************************************************************************
00050  *
00051  *                                     TRIGGER
00052  *
00053  *********************************************************************************/ 
00054  
00061 class Trigger {
00062         
00063 public:
00064         
00066 virtual bool isTriggered(int t, int s) = 0;
00067         
00073 virtual int nextTriggered(int t) = 0;
00074         
00075 virtual ~Trigger(){ }
00076         
00077 
00078 }; // end Trigger
00079 
00080 
00081 
00082 /*******************************************************************************
00083  *
00084  *                     PjTrigger
00085  *
00086  ******************************************************************************/
00087 
00088 
00092 class PjTrigger : public Trigger {
00093         
00094     
00095     LiborMarketModel* LMM;
00096     BermudanSwaption* bswpn;
00097    
00098     double kappa;       // swaption strike
00099    
00100     int nPath,          // number of training paths
00101         p,              // swaption exercise begins T_p
00102         q;              // swap ends T_q 
00103    
00104     bool verbose;       // messages during optimization
00105    
00106     Array1D<RealArray2D*> path; 
00107         // the components 0,1,2,3 of path_i=*path[i] are as follows:   
00108     // path_i[t][0].... Libor X(t,t) 
00109     // path_i[t][1].... swaprate S_{t+1,n}(t) 
00110     // path_i[t][2].... forward swap payoff from immediate exercise (>=0)
00111     // path_i[t][3].... time s>=t of optimal exercise starting at time t
00112     // all computed from Libor sample path i for p<=t<q
00113    
00114     RealArray1D p1,p2,p3;  // the coefficients p_j(t) in Jaeckel's trigger
00115                                // at each exercise time t.
00116     RealArray1D S;         // S[t]=S_{t+1,n}(0), swaprate
00117         
00118 public:
00119         
00120 // ACCESSORS
00121 
00123 int getPaths(){ return nPath; }
00125 int get_q(){ return q; }
00127 RealArray2D& getTrainingPath(int i){ return *(path[i]); }
00128 
00129         
00130 // CONSTRUCTOR
00131 
00136 PjTrigger
00137 (LiborMarketModel* lmm, BermudanSwaption* swpn, bool vbose);
00138 
00139 ~PjTrigger();
00140 
00141 
00142            
00143 // THE TRIGGER CONDITION
00144 
00150 bool isTriggered(int t, int s);
00151 
00152 
00155 int nextTriggered(int t);
00156 
00157 
00162 bool exercise(int i, int t, const RealArray1D& x);
00163 
00169 Real objectiveFunction(int t, const RealArray1D& v);
00170           
00171  
00172 private:
00173 
00177 void fillTrainingPaths();
00178            
00181 void computeCoefficients();
00182  
00183 
00184 // PARAMETER OPTIMIZATION AT EACH EXERCISE TIME t  
00185 
00186 class LocalBFGS : public BFGS {
00187            
00188         int t;                // time t at which the parameters are optimized
00189         PjTrigger* trg;       // the trigger which contains the optimizer
00190         
00191 public:
00192        
00193        
00206     LocalBFGS
00207     (PjTrigger* pj_trg, int s, const RealArray1D x, int nVals, 
00208      Real stepmax, const RealArray1D h, bool verbose);
00209        
00210     // the function we want to optimize
00211         // forward payoff fom exercise for s>=t under parameters v
00212     Real f(const RealArray1D& v);
00213 
00214 }; // end LocalBFGS
00215 
00216 
00217 class LocalSobolSearch : public SobolSearch {
00218            
00219         int t;                // time t at which the parameters are optimized
00220         PjTrigger* trg;       // the trigger which contains the optimizer
00221         
00222 public:
00223        
00224        
00236     LocalSobolSearch
00237     (PjTrigger* pj_trg, int s, const RealArray1D x, int nVals, 
00238      const RealArray1D delta, bool verbose);
00239        
00240     // the function we want to optimize
00241         // forward payoff fom exercise for s>=t under parameters v
00242     Real f(const RealArray1D& v);
00243 
00244 }; // end LocalSobolSearch
00245  
00246  
00247 };  // end PjTrigger
00248 
00249         
00250 
00251         
00252 MTGL_END_NAMESPACE(Martingale)
00253 
00254 #endif
00255  

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