source: observatorio/simulacion/SimEscenariosEconomicos/productionNetwork.H

simulacion
Last change on this file was 76e705a, checked in by Alejandro <amujica@…>, 10 years ago

Agregada a los graficos la leyenda con los parametros bajo los cuales son generados

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2  Copyright (C) 2012
3  Alejandro Mujica (amujica@cenditel.gob.ve)
4  Erwin Paredes (eparedes@cenditel.gob.ve)
5  José Ruiz (jruiz@cenditel.gob.ve)
6  Rodolfo Rangel (rrangel@cenditel.gob.ve)
7  Julie Vera (jvera@cenditel.gob.ve)
8 
9  CENDITEL Fundación Centro Nacional de Desarrollo e Investigación en
10  Tecnologías Libres
11 
12  Este programa es software libre; Usted puede usarlo bajo los términos de la
13  licencia de software GPL versión 2.0 de la Free Software Foundation.
14 
15  Este programa se distribuye con la esperanza de que sea útil, pero SIN
16  NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o
17  ADECUACIÓN A UN PROPÓSITO PARTICULAR.
18  Consulte la licencia GPL para más detalles. Usted debe recibir una copia
19  de la GPL junto con este programa; si no, escriba a la Free Software
20  Foundation Inc. 51 Franklin Street,5 Piso, Boston, MA 02110-1301, USA.
21*/
22
23/*
24  Autor:             Alejandro J. Mujica
25  Fecha de creación: 10/09/2013
26  Este archivo contiene la implementación de la clase ProductionNetwork.
27*/
28
29# ifndef PRODUCTION_NETWORK_H
30# define PRODUCTION_NETWORK_H
31
32# include <types.H>
33
34# include <tpl_graph_indexes.H>
35
36# include <product.H>
37# include <input.H>
38
39enum NodeType {
40
41    ROOT,
42
43    UPSTREAM,
44
45    DOWNSTREAM,
46
47    SUGGESTED,
48
49    IMPORT,
50
51    NUM_NODE_TYPES
52};
53
54typedef Graph_Node <std::shared_ptr<Good>> BaseNode;
55
56struct ProductionNode : public BaseNode {
57
58    long id;
59
60    ::NodeType type;
61
62    Tree <long> levels;
63
64    bool isInQueue;
65
66    real newValue1;
67
68    real newValue2;
69
70    real newValue3;
71
72    ProductionNode()
73        : BaseNode(), id(-1),  type(ROOT), levels(), isInQueue(false),
74          newValue1(0.0), newValue2(0.0) {
75
76        // Empty
77    }
78
79    ProductionNode(const std::shared_ptr<Good> & good)
80        : BaseNode(good), id(-1), type(ROOT), levels(), isInQueue(false),
81          newValue1(0.0), newValue2(0.0) {
82
83        // Empty
84    }
85
86    ProductionNode(ProductionNode * node)
87        : BaseNode(node), id(node->id), type(node->type), levels(node->levels),
88          isInQueue(false), newValue1(0.0), newValue2(0.0) {
89
90      // Empty
91    }
92};
93
94struct ArcInfo {
95
96    long inputId;
97
98    std::string measurementUnit;
99
100    real quantity;
101
102    real totalQuantity;
103
104    real usedQuantity;
105
106    real reqQuantity; // Coeficiente técnico
107
108    real price; // Precio unitario
109
110    bool isMin;
111
112    real newValue1;
113
114    real newValue2;
115
116    real newValue3;
117
118    ArcInfo()
119        : inputId(-1), measurementUnit(), quantity(0.0), totalQuantity(0.0),
120          usedQuantity(0.0), reqQuantity(0.0), price(0.0), isMin(false),
121          newValue1(0.0), newValue2(0.0), newValue3(0.0) {
122
123        // Empty
124    }
125};
126
127typedef Graph_Arc <ArcInfo> ProductionArc;
128
129typedef List_Graph <ProductionNode, ProductionArc> BaseGraph;
130
131struct CmpCompany {
132
133    bool operator () (const Company & c1, const Company & c2) {
134
135        const std::string & str1 = c1.getNationality() == "E"
136                                   ? c1.getName() : c1.getRif();
137
138        const std::string & str2 = c2.getNationality() == "E"
139                                   ? c2.getName() : c2.getRif();
140
141        return str1 < str2;
142    }
143};
144
145struct CmpPlant {
146
147    bool operator () (const Plant & p1, const Plant & p2) {
148        return p1.getId() < p2.getId();
149    }
150};
151
152class ProductionNetwork : public BaseGraph {
153
154    Tree <Company, CmpCompany> companies;
155
156    Tree <Plant, CmpPlant> plants;
157
158public:
159    std::string year;
160
161    size_t maxLevelUpstream;
162
163    size_t maxLevelDownstream;
164
165    ProductionNetwork()
166        : BaseGraph(), companies(), plants() {
167
168        // Empty
169    }
170
171    ProductionNetwork(const ProductionNetwork & network)
172        : BaseGraph(network), companies(network.companies),
173          plants(network.plants) {
174
175        // Empty
176    }
177
178    Company * searchOrInsert(const Company & company) {
179
180        Company * ptr_company = companies.search(company);
181
182        if (ptr_company == NULL)
183            ptr_company = companies.insert(company);
184
185        return ptr_company;
186    }
187
188    Plant * searchOrInsert(const Plant & plant) {
189
190        Plant * ptr_plant = plants.search(plant);
191
192        if (ptr_plant == NULL)
193            ptr_plant = plants.insert(plant);
194
195        return ptr_plant;
196    }
197
198    Node * insertNode(std::shared_ptr <Good> & good) {
199
200        Node * p = BaseGraph::insert_node(good);
201
202        return p;
203    }
204};
205
206
207# endif // PRODUCTION_NETWORK_H
208
Note: See TracBrowser for help on using the repository browser.