1 | ////////////////////////////////////////////////////////////////////////////// |
---|
2 | // fusion_forecast.tol |
---|
3 | ////////////////////////////////////////////////////////////////////////////// |
---|
4 | #Require MMS; |
---|
5 | Date EndFore = y2015m12d01; |
---|
6 | NameBlock JointForecasts(Set forecasts) |
---|
7 | { |
---|
8 | // Set forecast = [[ fore1, fore2 ]]; |
---|
9 | NameBlock foreUnion = (forecasts[1])::Duplicate(?); |
---|
10 | Text subclass = foreUnion::GetSubclass(?); |
---|
11 | Text version = foreUnion::GetVersion(?); |
---|
12 | Text name = MMS::Container::ObtainNewObjectName( |
---|
13 | subclass, "ForecastUnion", version |
---|
14 | ); |
---|
15 | Real foreUnion::SetName(name); |
---|
16 | WriteLn("Fusionando dataSet"); |
---|
17 | |
---|
18 | Set dataSets = For(2, Card(forecasts), NameBlock(Real n) |
---|
19 | { |
---|
20 | (forecasts[n])::GetModel(?)::GetDataSet(?) |
---|
21 | }); |
---|
22 | Real foreUnion::GetModel(?)::GetDataSet(?)::JoinDataSets_Ignore(dataSets); |
---|
23 | WriteLn("Fusionando MVariables"); |
---|
24 | |
---|
25 | Set mVariables = BinGroup("<<", For(2, Card(forecasts), Set(Real n) |
---|
26 | { |
---|
27 | (forecasts[n])::GetModel(?)::GetMVariables(?) |
---|
28 | })); |
---|
29 | Set EvalSet(mVariables, Real(NameBlock mVar) |
---|
30 | { |
---|
31 | If( |
---|
32 | foreUnion::GetModel(?)::FindMVariable((mVar::GetName(?))), |
---|
33 | 1, |
---|
34 | { |
---|
35 | Set specification = mVar::GetSpecification(?); |
---|
36 | NameBlock foreUnion::GetModel(?)::CreateMVariable_Spc(specification); |
---|
37 | 1 |
---|
38 | } |
---|
39 | ) |
---|
40 | }); |
---|
41 | |
---|
42 | WriteLn("Fusionando subModels"); |
---|
43 | |
---|
44 | Set subModels = BinGroup("<<", For(2, Card(forecasts), Set(Real n) |
---|
45 | { |
---|
46 | (forecasts[n])::GetModel(?)::GetSubmodels(?) |
---|
47 | })); |
---|
48 | |
---|
49 | Set EvalSet(subModels, Real(NameBlock sbm) |
---|
50 | { |
---|
51 | Set specification = sbm::GetSpecification(?); |
---|
52 | NameBlock foreUnion::GetModel(?)::CreateSubmodel_Spc(specification); |
---|
53 | 1 |
---|
54 | }); |
---|
55 | WriteLn("Fusionando hierarchies"); |
---|
56 | |
---|
57 | Set hierarchies = BinGroup("<<", For(2, Card(forecasts), Set(Real n) |
---|
58 | { |
---|
59 | (forecasts[n])::GetModel(?)::GetHierarchies(?) |
---|
60 | })); |
---|
61 | Set EvalSet(hierarchies, Real(NameBlock hie) |
---|
62 | { |
---|
63 | |
---|
64 | Set specification = hie::GetSpecification(?); |
---|
65 | NameBlock foreUnion::GetModel(?)::CreateHierarchy_Spc(specification); |
---|
66 | 1 |
---|
67 | }); |
---|
68 | WriteLn("Fusionando mCombinations"); |
---|
69 | |
---|
70 | Set mCombinations = BinGroup("<<", For(2, Card(forecasts), Set(Real n) |
---|
71 | { |
---|
72 | (forecasts[n])::GetModel(?)::GetMCombinations(?) |
---|
73 | })); |
---|
74 | Set EvalSet(mCombinations, Real(NameBlock mCom) |
---|
75 | { |
---|
76 | |
---|
77 | Set specification = mCom::GetSpecification(?); |
---|
78 | NameBlock foreUnion::GetModel(?)::CreateMCombination_Spc(specification); |
---|
79 | 1 |
---|
80 | }); |
---|
81 | WriteLn("Fusionando mEquivalences"); |
---|
82 | |
---|
83 | Set mEquivalences = BinGroup("<<", For(2, Card(forecasts), Set(Real n) |
---|
84 | { |
---|
85 | (forecasts[n])::GetModel(?)::GetMEquivalences(?) |
---|
86 | })); |
---|
87 | Set EvalSet(mEquivalences, Real(NameBlock mEqui) |
---|
88 | { |
---|
89 | |
---|
90 | Set specification = mEqui::GetSpecification(?); |
---|
91 | NameBlock foreUnion::GetModel(?)::CreateMEquivalence_Spc(specification); |
---|
92 | 1 |
---|
93 | }); |
---|
94 | WriteLn("Fusionando parametersR"); |
---|
95 | |
---|
96 | Set parametersR = BinGroup("<<", For(1, Card(forecasts), Set(Real n) |
---|
97 | { |
---|
98 | (forecasts[n])::GetParameters(?) |
---|
99 | })); |
---|
100 | Real foreUnion::SetParameters(parametersR); |
---|
101 | foreUnion |
---|
102 | }; |
---|
103 | |
---|
104 | NameBlock JointForecastsWithExecute(Set forecasts) |
---|
105 | { |
---|
106 | // Set forecasts = [[ fore1, fore2 ]]; |
---|
107 | NameBlock object = JointForecasts(forecasts); |
---|
108 | Real object::Execute(?); |
---|
109 | object |
---|
110 | }; |
---|
111 | |
---|
112 | |
---|
113 | //Ejemplo |
---|
114 | |
---|
115 | Text Path = "C:/"; |
---|
116 | Text file1 = "UnionForecast.Emergencia.oza"; |
---|
117 | Text file2 = "UnionForecast.Informativas.oza"; |
---|
118 | Text file3 = "UnionForecast.Intrusion.oza"; |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | NameBlock fore1 = MMS::Container::LoadFile(Path+file1); |
---|
124 | NameBlock fore2 = MMS::Container::LoadFile(Path+file2); |
---|
125 | NameBlock fore3 = MMS::Container::LoadFile(Path+file3); |
---|
126 | |
---|
127 | |
---|
128 | |
---|
129 | |
---|
130 | NameBlock JointForecastsWithExecute([[ fore1, fore2, fore3 ]]); // ]]); // |
---|
131 | |
---|
132 | |
---|