source: observatorio/simulacion/SimEscenariosEconomicos/productionNetwork.H @ 18610a4

simulacion
Last change on this file since 18610a4 was 78c6ae6, checked in by Alejandro <amujica@…>, 10 years ago

pendiente de correccion de conversion de numeros a cadenas

  • Property mode set to 100644
File size: 4.2 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    ProductionNetwork()
160        : BaseGraph(), companies(), plants() {
161
162        // Empty
163    }
164
165    ProductionNetwork(const ProductionNetwork & network)
166        : BaseGraph(network), companies(network.companies),
167          plants(network.plants) {
168
169        // Empty
170    }
171
172    Company * searchOrInsert(const Company & company) {
173
174        Company * ptr_company = companies.search(company);
175
176        if (ptr_company == NULL)
177            ptr_company = companies.insert(company);
178
179        return ptr_company;
180    }
181
182    Plant * searchOrInsert(const Plant & plant) {
183
184        Plant * ptr_plant = plants.search(plant);
185
186        if (ptr_plant == NULL)
187            ptr_plant = plants.insert(plant);
188
189        return ptr_plant;
190    }
191
192    Node * insertNode(std::shared_ptr <Good> & good) {
193
194        Node * p = BaseGraph::insert_node(good);
195
196        return p;
197    }
198};
199
200
201# endif // PRODUCTION_NETWORK_H
202
Note: See TracBrowser for help on using the repository browser.