source: observatorio/simulacion/SimEscenariosEconomicos/common.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: 8.3 KB
Line 
1
2/*
3  Copyright (C) 2012
4  Alejandro Mujica (amujica@cenditel.gob.ve)
5  Erwin Paredes (eparedes@cenditel.gob.ve)
6  José Ruiz (jruiz@cenditel.gob.ve)
7  Rodolfo Rangel (rrangel@cenditel.gob.ve)
8  Julie Vera (jvera@cenditel.gob.ve)
9 
10  CENDITEL Fundación Centro Nacional de Desarrollo e Investigación en
11  Tecnologías Libres
12 
13  Este programa es software libre; Usted puede usarlo bajo los términos de la
14  licencia de software GPL versión 2.0 de la Free Software Foundation.
15 
16  Este programa se distribuye con la esperanza de que sea útil, pero SIN
17  NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o
18  ADECUACIÓN A UN PROPÓSITO PARTICULAR.
19  Consulte la licencia GPL para más detalles. Usted debe recibir una copia
20  de la GPL junto con este programa; si no, escriba a la Free Software
21  Foundation Inc. 51 Franklin Street,5 Piso, Boston, MA 02110-1301, USA.
22*/
23
24/*
25  Autor:             Alejandro J. Mujica
26  Fecha de creación: 22/07/2013
27  Este archivo contiene definiciones de constantes, funciones y algunos tipos de
28  datos utilitarios.
29*/
30
31# ifndef COMMON_H
32# define COMMON_H
33
34// Biblioteca estándar de C
35# include <cstdlib>
36# include <cmath>
37# include <cstdarg>
38# include <cassert>
39
40// Biblioteca estándar de C++
41# include <iostream>
42# include <string>
43# include <sstream>
44# include <stdexcept>
45
46// Biblioteca libxml++
47# include <libxml++/libxml++.h>
48# include <libxml++/parsers/textreader.h>
49# include <libxml++/nodes/node.h>
50# include <libxml++/document.h>
51# include <libxml++/parsers/domparser.h>
52# include <libxml++/keepblanks.h>
53
54// Cabeceras propias
55# include <types.H>
56# include <productionNetwork.H>
57
58/** Constantes de nombres de tablas y atributos de la base de datos.
59 *
60 *  Contiene todos los nombres de tablas y campos almacenados en constantes
61 *  estáticas con el fin de evitar errores en los nombres al efectuar una
62 *  consulta. Al éstos estar en constantes, si se escribe mal daría error de
63 *  compilación y en el caso de uso de IDE's existe la opción de
64 *  autocompletación.
65 *
66 * @author Alejandro J. Mujica
67 */
68struct DB {
69
70    // Nombres de tablas
71    static const std::string PRODUCT_TABLE_NAME;
72
73    static const std::string INPUT_TABLE_NAME;
74
75    static const std::string PLANT_TABLE_NAME;
76
77    static const std::string COMPANY_TABLE_NAME;
78
79    static const std::string COMPANY_ACTIVITY_CIIU_TABLE_NAME;
80
81    static const std::string PRODUCT_INPUT_TABLE_NAME;
82
83    static const std::string MEASUREMENT_UNIT_TABLE_NAME;
84
85    static const std::string INPUT_SUPPLIER_TABLE_NAME;
86
87    static const std::string SUPPLIER_TABLE_NAME;
88
89    static const std::string PRODUCTION_QUANTITIES_TABLE_NAME;
90
91    static const std::string ACQ_PRICE_TABLE_NAME;
92
93    static const std::string COUNTRY_TABLE_NAME;
94
95    static const std::string PARISH_TABLE_NAME;
96
97    static const std::string TOWN_TABLE_NAME;
98
99    static const std::string STATE_TABLE_NAME;
100
101    static const std::string COMPANY_OCCUPANCY_TABLE_NAME;
102
103    // Nombres de campos
104    static const std::string ID;
105
106    static const std::string NAME;
107
108    static const std::string COMPANY_NAME;
109
110    static const std::string TECHNICAL_SPECIFICATION;
111
112    static const std::string TARIFF_CODE;
113
114    static const std::string MEASUREMENT_UNIT_ID;
115
116    static const std::string TRADEMARK;
117
118    static const std::string PLANT_ID;
119
120    static const std::string CODE;
121
122    static const std::string PARISH_CODE;
123
124    static const std::string TOWN_CODE;
125
126    static const std::string STATE_CODE;
127
128    static const std::string COMPANY_RIF;
129
130    static const std::string UE_RIF;
131
132    static const std::string RIF;
133
134    static const std::string NATIONALITY;
135
136    static const std::string ACQ_PRICE;
137
138    static const std::string NAC_ACQ_PRICE;
139
140    static const std::string CIIU_ID;
141
142    static const std::string ACTIVE;
143
144    static const std::string MAIN;
145
146    static const std::string INPUT_ID;
147
148    static const std::string PRODUCT_ID;
149
150    static const std::string SUPPLIER_ID;
151
152    static const std::string PRODUCED_QUANTITY;
153
154    static const std::string PRICE;
155
156    static const std::string BOUGHT_QUANTITY;
157
158    static const std::string QUANTITY;
159
160    static const std::string ORIG_COUNTRY_ID;
161
162    static const std::string PROC_COUNTRY_ID;
163
164    static const std::string YEAR_R;
165
166    static const std::string YEAR;
167
168    static const std::string USED_CAPACITY;
169
170    static const std::string INSERTION_DATE;
171
172    static const std::string OPERATING;
173};
174
175/** Paleta de colores
176 *
177 * Contiene un conjunto de colores seleccionados arbitrariamente para la
178 * generación de archivos dot con el fin de elegir colores aleatorios para los
179 * arcos.
180 *
181 * @author Alejandro J. Mujica
182 */
183struct DotColor {
184
185    static const size_t NUM_COLORS = 15;
186
187    static const std::string COLORS[NUM_COLORS];
188
189    /** Retorna el color en la posición i de la paleta
190     *
191     * @param[in] i posición del color.
192     * @return cadena identificadora del color para dot.
193     */
194    const std::string & operator () (const size_t & i);
195};
196
197# define GOOD_ATTRS                                                            \
198    std::string name;                                                          \
199    std::string technicalSpecifications;                                       \
200    std::string tariffCode;                                                    \
201    std::string measurementUnit;                                               \
202    std::string trademark;                                                     \
203    real quantity;                                                           \
204    real totalQuantity;                                                      \
205    real unitarianPrice;
206
207# define INIT_GOOD_ATTRS                                                       \
208    name("NULL"), technicalSpecifications("NULL"), tariffCode("NULL"),         \
209    measurementUnit("NULL"), trademark("NULL"), quantity(0), totalQuantity(0), \
210    unitarianPrice(0)
211
212# define COMPANY_ATTRS                                                         \
213    std::string companyName;                                                   \
214    std::string companyRif;                                                    \
215    std::string nationality;                                                   \
216    std::string origCountry;                                                   \
217    std::string procCountry;
218
219# define INIT_COMPANY_ATTRS                                                    \
220    companyName("NULL"), companyRif("NULL"), nationality("NULL"),              \
221    origCountry("NULL"), procCountry("NULL")
222 
223/** Información completa de un producto.
224 *
225 * Esta estructura agrupa todos los atributos de información correspondientes
226 * a un producto. Se usa para extraer de la base de datos.
227 *
228 * @author Alejandro J. Mujica
229 */
230struct ProductInfo {
231
232    // Datos de planta
233    long plantId;
234
235    std::string plantName;
236
237    real usedCapacity;
238
239    // Datos de la unidad económica
240    COMPANY_ATTRS
241
242    long productId;
243
244    //Datos comunes del bien
245    GOOD_ATTRS
246
247    ProductInfo();
248};
249
250/** Información completa de un insumo.
251 *
252 * Esta estructura agrupa todos los atributos de información correspondientes
253 * a un insumo. Se usa para extraer de la base de datos.
254 *
255 * @author Alejandro J. Mujica
256 */
257struct InputInfo {
258
259    COMPANY_ATTRS
260
261    long id;
262
263    GOOD_ATTRS
264
265    InputInfo();
266};
267
268/** Información de alteración.
269 *
270 * Esta estructura agrupa los atributos requeridos para la alteración de una red
271 * mediante la ejecución de la simulación.
272 *
273 * @author Alejandro J. Mujica
274 */
275struct AlterInfo {
276
277    long numNode;
278
279    real value;
280
281    AlterInfo();
282};
283
284/** Información de ubicación de una planta para los indicadores.
285 *
286 * @author Alejandro J. Mujica
287 */
288struct PlantLocation {
289
290    std::string parish;
291
292    std::string town;
293
294    std::string state;
295
296    PlantLocation();
297};
298
299/// Pasa la información de un insumo a un producto.
300ProductInfo inputToProduct(const InputInfo &);
301
302/// Convierte un número en cadena numérica con formato de números en español.
303std::string numtostr(const real & num, const int & numDec = 3,
304                     const char & thousandSep = '.', const char & decSep = ',');
305
306/// Sustituye los caracteres < y > por los equivalentes a html.
307void modStr(std::string & str);
308
309template <typename T>
310std::string toStr(const T & number) {
311
312    std::stringstream sstr;
313
314    sstr.precision(PRECISION);
315
316    sstr << number;
317
318    return sstr.str();
319}
320
321std::string currentTime();
322
323# endif // COMMON_H
324
Note: See TracBrowser for help on using the repository browser.