close Warning: Can't synchronize with repository "(default)" (/var/svn/mms does not appear to be a Subversion repository.). Look in the Trac log for more information.

Ticket #690: test_forDespuesFinEst.tol

File test_forDespuesFinEst.tol, 5.6 KB (added by jgallardo, 14 years ago)
Line 
1//////////////////////////////////////////////////////////////////////////////
2// FILE    :
3// PURPOSE :
4//////////////////////////////////////////////////////////////////////////////
5
6MMS::Container::RemoveForecasts(?);
7MMS::Container::RemoveEstimations(?);
8MMS::Container::RemoveModels(?);
9MMS::Container::RemoveDataSets(?);
10
11
12Date DesdeEst = y2001m01d01;
13Date HastaEst = y2002m01d01;
14
15Date DesdeFor = Succ(HastaEst, Diario, 10);
16Date HastaFor = Succ(HastaEst, Diario, 20);
17
18
19Date Hasta = Max(HastaEst, HastaFor); // Para los inputs
20
21//////////////////////////////////////////////////////////////////////////////
22Serie CreateOutput(Real isMult, Date desde, Date hasta){
23//////////////////////////////////////////////////////////////////////////////
24  Serie media = {
25    Set avrWD = If(isMult,
26      [[1.1,  1.12, 1.15, 1.2, 1.3, 1.35, 1.5]],
27      [[1000, 1100, 1300, 1600, 2100, 2600, 3000]]
28    );
29
30 
31    Set byWD = For(1, Card(avrWD), Serie(Real k_wd){
32      avrWD[k_wd] * CalInd(WD(k_wd))
33    });
34 
35    SetSum(byWD)
36  };
37 
38  Polyn ari = (1-B^7)*(1-0.4*B);
39  Polyn ma  = (1-0.8*B^7);
40 
41 
42  Serie residuos = If(isMult,
43    SubSer(Gaussian(0, 0.05), desde, hasta),
44    SubSer(Gaussian(0, 100), desde, hasta)
45  );
46
47  Serie noise = DifEq(ma/ari, residuos, media);
48 
49  Serie inputs = {
50    Serie ser01 = If(isMult,
51      0.13*CalInd(In(y2001m03d01, y2001m04d01)),
52      1300*CalInd(In(y2001m03d01, y2001m04d01))
53    );
54
55    Serie ser02 = If(isMult,
56      0.17*Pulse(y2001m07d01),
57      1500*Pulse(y2001m07d01)
58    );
59
60    Serie ser03 = If(isMult,
61      0.15*TendLocNegTimeSet(C, y2001m09d01, y2001m10d01),
62      1400*TendLocNegTimeSet(C, y2001m09d01, y2001m10d01)
63    );
64
65    ser01 + ser02 + ser03
66  };
67 
68  noise + inputs
69};
70//////////////////////////////////////////////////////////////////////////////
71
72
73// Data Set Outputs
74MMS::@DataSet DS_Out = MMS::Container::ReplaceDataSet([[
75  Text _.name = "dsOut";
76  Text _.description = "DataSet de outputs"
77]]);
78
79// Data Set Inputs
80MMS::@DataSet DS_Inp = MMS::Container::ReplaceDataSet([[
81  Text _.name = "dsInp";
82  Text _.description = "DataSet de inputs"
83]]);
84
85
86Real DS_Out::AppendInterval("Diario", DesdeEst, HastaEst);
87Real DS_Inp::AppendInterval("Diario", DesdeEst, HastaEst);
88
89
90Real DS_Out::ReplaceVariable([[
91  Text _.name = "OutputUnico";
92  Text _.description = "output";
93  Text _.expression = "CreateOutput(1, DesdeEst, HastaEst)";
94  Text _.type = "Serie";
95  Real _.isTrivial = 0;
96  Set _.tags = [[ "Output", "Pulse" ]]
97]]);
98
99
100Real DS_Inp::ReplaceVariable([[
101  Text _.name = "CalInd_y2001m03d01";
102  Text _.description = "escalón";
103  Text _.expression
104    = "SubSer(CalInd(In(y2001m03d01, y2001m04d01)), DesdeEst, Hasta)";
105  Text _.type = "Serie";
106  Real _.isTrivial = 0;
107  Set _.tags = [[ "Input", "CalInd" ]]
108]]);
109
110
111Real DS_Inp::ReplaceVariable([[
112  Text _.name = "Pulse_y2001m07d01";
113  Text _.description = "pulso";
114  Text _.expression
115    = "SubSer(Pulse(y2001m07d01), DesdeEst, Hasta)";
116  Text _.type = "Serie";
117  Real _.isTrivial = 0;
118  Set _.tags = [[ "Input", "Pulse" ]]
119]]);
120
121
122Real DS_Inp::ReplaceVariable([[
123  Text _.name = "Trend_y2001m09d01";
124  Text _.description = "tendencia";
125  Text _.expression
126    = "SubSer(TendLocNegTimeSet(C, y2001m09d01, y2001m10d01), DesdeEst, Hasta)";
127  Text _.type = "Serie";
128  Real _.isTrivial = 0;
129  Set _.tags = [[ "Input", "Trend" ]]
130]]);
131
132
133MMS::@Model Modelo = MMS::Container::ReplaceModel([[
134  Text _.name = "ModeloUnico";
135  Text _.description = "modelo único";
136  Text _.version = "1.0";
137  Set _.dataSets = SetOfText("dsOut", "dsInp")
138]]);
139
140MMS::@Submodel Submodelo = Modelo::CreateSubmodel([[
141  Text _.name = "SubmodeloUnico";
142  NameBlock _.output = [[
143    Text _.name = "OutputUnico";
144    Text _.variableIdentifier = "OutputUnico";
145    MMS::@Transformation _.transformation
146      = MMS::@Transformation.BoxCox::Default(0,0)
147  ]];
148  Date _.begin = DesdeEst;
149  Date _.end   = HastaEst;
150  NameBlock _.noise = [[
151  Text _.type = "ARIMA";
152  Text _.arimaLabel = "P1_7DIF0_1AR1_0MA0_7";
153  Real _.sigma = 1
154  ]]
155]]);
156
157NameBlock Submodelo::CreateExpTerm_TransferFunction([[
158  Text _.name = "Pulse_y2001m07d01";
159  NameBlock _.input = [[
160    Text _.name = "Pulse_y2001m07d01";
161    Text _.variableIdentifier = "Pulse_y2001m07d01"
162  ]];   
163  Polyn _.transferFunction = 1
164]]);
165
166NameBlock Submodelo::CreateExpTerm_TransferFunction([[
167  Text _.name = "CalInd_y2001m03d01";
168  NameBlock _.input = [[
169    Text _.name = "CalInd_y2001m03d01";
170    Text _.variableIdentifier = "CalInd_y2001m03d01"
171  ]];   
172  Polyn _.transferFunction = 1
173]]);
174
175
176NameBlock Submodelo::CreateExpTerm_TransferFunction([[
177  Text _.name = "Trend_y2001m09d01";
178  NameBlock _.input = [[
179    Text _.name = "Trend_y2001m09d01";
180    Text _.variableIdentifier = "Trend_y2001m09d01"
181  ]];   
182  Polyn _.transferFunction = 1
183]]);
184
185
186MMS::@Estimation Estimacion = MMS::Container::ReplaceEstimation([[
187  Text _.name = "EstimacionUnica";
188  MMS::@Model _.model = Modelo;
189
190  MMS::@SettingsMultiMLE _.settings = [[
191    Real _.showTraces =  False
192  ]]
193]]);
194
195
196Real Estimacion::Execute(?);
197
198Set Parametros = Estimacion::GetParameters(?);
199
200
201MMS::@Forecast Prevision = MMS::Container::ReplaceForecast([[
202  Text _.name = "Forecast_caso00";
203  MMS::@SettingsForecast _.settings = [[
204    Text _.mode = "Point";
205    Real _.showTraces = False
206  ]];
207  MMS::@Model _.model = Modelo; // Estimacion::GetModel(?);
208  Set _.parameters = Parametros;
209  // MMS::@Model _.estimation = Estimacion;
210  Set _.fIntervals = {Set [[
211     Set [["*", DesdeFor, HastaFor]]
212  ]] }
213]]);
214
215
216Real Prevision::Execute(?);
217
218
219
220