00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef martingale_trigger_h
00025 #define martingale_trigger_h
00026
00027 #include "TypedefsMacros.h"
00028 #include "Optimizer.h"
00029
00030
00031 MTGL_BEGIN_NAMESPACE(Martingale)
00032
00033
00034
00035 class LiborMarketModel;
00036 class BermudanSwaption;
00037
00038
00039
00040
00049
00050
00051
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 };
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00092 class PjTrigger : public Trigger {
00093
00094
00095 LiborMarketModel* LMM;
00096 BermudanSwaption* bswpn;
00097
00098 double kappa;
00099
00100 int nPath,
00101 p,
00102 q;
00103
00104 bool verbose;
00105
00106 Array1D<RealArray2D*> path;
00107
00108
00109
00110
00111
00112
00113
00114 RealArray1D p1,p2,p3;
00115
00116 RealArray1D S;
00117
00118 public:
00119
00120
00121
00123 int getPaths(){ return nPath; }
00125 int get_q(){ return q; }
00127 RealArray2D& getTrainingPath(int i){ return *(path[i]); }
00128
00129
00130
00131
00136 PjTrigger
00137 (LiborMarketModel* lmm, BermudanSwaption* swpn, bool vbose);
00138
00139 ~PjTrigger();
00140
00141
00142
00143
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
00185
00186 class LocalBFGS : public BFGS {
00187
00188 int t;
00189 PjTrigger* trg;
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
00211
00212 Real f(const RealArray1D& v);
00213
00214 };
00215
00216
00217 class LocalSobolSearch : public SobolSearch {
00218
00219 int t;
00220 PjTrigger* trg;
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
00241
00242 Real f(const RealArray1D& v);
00243
00244 };
00245
00246
00247 };
00248
00249
00250
00251
00252 MTGL_END_NAMESPACE(Martingale)
00253
00254 #endif
00255