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

Ticket #877: nucleos.tarifa.tol

File nucleos.tarifa.tol, 6.4 KB (added by Jorge, 15 years ago)
Line 
1/* -*- mode: c++ -*- */
2
3Set Include( "nucleos.data.tol" );
4Set Include( "nucleos.models.tol" );
5
6NameBlock bsr.config = BysMcmc::@Config::Default( 0 );
7
8//Text variable = "DUR_VOZ_TOT_NUCLEO";
9//Text variable = "L3G_BIG_SCREEN";
10Text variable = "V3G_TOT_NUCLEO";
11//Text variable = "L3G_TOT_NUCLEO";
12
13
14Set data_args =
15[[
16
17  NameBlock DUR_VOZ_TOT_NUCLEO =
18  [[
19    NameBlock estim_args = [[
20      Real lower_vol3g = -1;
21      Real lower_duracion_voz = 500 * 60;
22      Real lower_cob_ba = -1;
23      Real lower_cob_3g = -1;
24      Real lower_cob_2g = -1;
25      Real is_estim = 1;
26      //Text select_category = "CCAA";
27      //Set select_regions = [[ "05" ]];
28      Real rebuild = 1
29    ]];
30    Code build_data_estim = FindCode( "Set", "BuildDataNucleos" );
31    Set mdl_info =
32     [[ "Nucleos.DurVoz",
33         FindCode( "NameBlock", "BuildModelNucleosDuracionVOZ" ) ]];
34    NameBlock fore_args = [[
35      Real lower_vol3g = -1;
36      Real lower_duracion_voz = -1;
37      Real lower_cob_ba = -1;
38      Real lower_cob_3g =  1;
39      //Real lower_cob_2g =  1;
40      Real is_estim = 0;
41      //Text select_category = "CCAA";
42      //Set select_regions = [[ "05" ]];
43      Real rebuild = 1
44    ]];
45    Code build_data_fore = FindCode( "Set", "BuildDataNucleos" )
46  ]];
47
48  NameBlock V3G_TOT_NUCLEO =
49  [[
50    NameBlock estim_args = [[
51      Real lower_vol3g = 5*1024*1024;
52      Real lower_duracion_voz = -1;
53      Real lower_cob_ba = -1;
54      Real lower_cob_3g = 0.2;
55      //Text select_category = "CCAA";
56      //Set select_regions = [[ "05" ]];
57      Real is_estim = 1;
58      Real rebuild = 1
59    ]];
60    Code build_data_estim = FindCode( "Set", "BuildDataNucleos" );
61    Set mdl_info =
62     [[ "Nucleos.V3G",
63         FindCode( "NameBlock", "BuildModelNucleosV3G" ) ]];
64    NameBlock fore_args = [[
65      Real lower_vol3g = -1;
66      Real lower_duracion_voz = -1;
67      Real lower_cob_ba = -1;
68      Real lower_cob_3g = 1;
69      //Text select_category = "CCAA";
70      //Set select_regions = [[ "05" ]]; // [[ "16", "17" ]];
71      Real is_estim = 0;
72      Real rebuild = 1
73    ]];
74    Code build_data_fore = FindCode( "Set", "BuildDataNucleos" )
75  ]];
76
77  NameBlock L3G_TOT_NUCLEO =
78  [[
79    NameBlock estim_args = [[
80      Real lower_vol3g = 5*1024*1024;
81      Real lower_duracion_voz = -1;
82      Real lower_cob_ba = -1;
83      Real lower_cob_3g = 0.2;
84      Real is_estim = 1;
85      Real rebuild = 1
86    ]];
87    Code build_data_estim = FindCode( "Set", "BuildDataNucleos" );
88    Set mdl_info =
89     [[ "Nucleos.L3G",
90         FindCode( "NameBlock", "BuildModelNucleosL3G" ) ]];
91    NameBlock fore_args = [[
92      Real lower_vol3g = -1;
93      Real lower_duracion_voz = -1;
94      Real lower_cob_ba = -1;
95      Real lower_cob_3g = 0.2;
96      Real is_estim = 0;
97      Real rebuild = 1
98    ]];
99    Code build_data_fore = FindCode( "Set", "BuildDataNucleos" )
100  ]];
101
102  NameBlock L3G_BIG_SCREEN =
103  [[
104    NameBlock estim_args =
105    [[
106      Text tarifa = "Big Screen";
107      Real lower_vol3g = 5*1024*1024;
108      Real lower_duracion_voz = -1;
109      Real lower_cob_ba = -1;
110      Real lower_cob_3g = 0.2;
111      //Text select_category = "CCAA";
112      //Set select_regions = [[ "05" ]];
113      Text file.suffix = ".estim";
114      Real rebuild = 1
115    ]];
116    Code build_data_estim = FindCode( "Set", "BuildDataNucleosEstimTarifa" );
117    Set mdl_info =
118     [[ "Nucleos.Big_Screen.LinDat3G",
119        FindCode( "NameBlock", "BuildModelNucleosLineasDatos3GTarifa" ) ]];
120    NameBlock fore_args =
121    [[
122      Real lower_vol3g = -1;
123      Real lower_duracion_voz = -1;
124      Real lower_cob_ba = -1;
125      Real lower_cob_3g = 1;
126      //Text select_category = "CCAA";
127      //Set select_regions = [[ "05" ]];
128      Text file.suffix = ".Big_Screen.forecast";
129      Real rebuild = 1
130    ]];
131    Code build_data_fore = FindCode( "Set", "BuildDataNucleosForecast" )
132  ]]
133
134]];
135
136/*
137Set data_estim =
138  Set BuildDataNucleosEstimTarifa( estim_args );
139*/
140
141NameBlock variable_info = data_args[ variable ];
142Set data_estim = variable_info::build_data_estim( variable_info::estim_args );
143
144//Real Stop;
145
146Real If( Not( Card( data_estim ) ), {
147    Error( "No hay datos para estimar" );
148    Real Stop
149  } );
150
151//Real Stop;
152
153NameBlock df_estim = data_estim[ 1 ];
154// Real Stop;
155
156Set models = BuildTreeModels( df_estim, [[ variable_info::mdl_info ]] );
157
158Set estim = EstimTreeModels( models, bsr.config, 0 );
159
160Matrix histY = Frequency( (estim[1])::Y, 20 );
161
162Real Stop;
163
164/*
165Set mdl.info =
166  [[
167    [[ "Nucleos." + Replace( estim_args::tarifa, " ", "_" ) + ".LinVoz",
168       FindCode( "NameBlock", "BuildModelNucleosLineasVOZTarifa" ) ]]
169  ]];
170*/
171
172/*
173Set mdl.info =
174  [[
175    [[ "Nucleos." + Replace( estim_args::tarifa, " ", "_" ) + ".DurVoz",
176       FindCode( "NameBlock", "BuildModelNucleosDuracionVOZTarifa" ) ]]
177  ]];
178*/
179
180/*
181Set mdl.info =
182  [[
183    [[ "Nucleos." + Replace( estim_args::tarifa, " ", "_" ) + ".VolDat3G",
184       FindCode( "NameBlock", "BuildModelNucleosV3GTarifa" ) ]]
185  ]];
186*/
187
188/*
189Set mdl.info =
190  [[
191    [[ "Nucleos." + Replace( estim_args::tarifa, " ", "_" ) + ".VolDat3G",
192       FindCode( "NameBlock", "BuildModelNucleosV3GTarifa.ByLines" ) ]]
193  ]];
194*/
195
196/*
197Set mdl.info =
198  [[
199    [[ "Nucleos." + Replace( estim_args::tarifa, " ", "_" ) + ".LinDat3G",
200       FindCode( "NameBlock", "BuildModelNucleosLineasDatos3GTarifa" ) ]]
201  ]];
202*/
203
204/*
205Set models = BuildTreeModels( df_estim, mdl.info );
206
207Set estim = EstimTreeModels( models, bsr.config, 0 );
208
209Real Stop;
210*/
211
212// a partir de aqui es prevision
213
214Set data_pred = variable_info::build_data_fore( variable_info::fore_args );
215
216Real If( Not( Card( data_pred ) ), {
217    Error( "No hay datos para predecir" );
218    Real Stop
219  } );
220
221NameBlock df_pred = data_pred[ 1 ];
222Set forecast = ForecastFromEstim( estim[ 1 ], df_pred );
223Text output_name = (models[ 1 ])::_.output.name;
224Text header = JoinTexts( [[ df_pred::GetObsIdColumnName(?),
225                            Sub( output_name, 5, TextLength( output_name ) ),
226                            output_name ]] <<
227                         forecast::predictors, ";" );
228
229Text file_export = TmpDir + "cnuc_fore_" + variable + ".csv";
230Set BMTFile([[ forecast::ID | forecast::Yhat1 | forecast::Yhat0 | forecast::X ]],
231            file_export,
232            header, CIERTO, ";", "\n" );
233WriteLn( "La prediccion ha sido exportada a " + file_export );
234
235/*
236
237Matrix Y = estim[1]["Y"];
238
239Set stats = SetOfReal(
240Real output.min = MatMin(Y),
241Real output.max = MatMax(Y),
242Real output.var = MatVar(Y)
243);
244
245Matrix stand.res.hist = Frequency( estim[1][1], 100 ) * (1/estim[1]["sigma"]);
246
247
248*/