Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to set latency_factor, bandwidth_factor and weight_S parameters of the network...
[simgrid.git] / src / surf / surfxml_parse.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "xbt/misc.h"
9 #include "xbt/log.h"
10 #include "xbt/str.h"
11 #include "xbt/dict.h"
12 #include "surf/surfxml_parse_private.h"
13 #include "surf/surf_private.h"
14
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf,
16                                 "Logging specific to the SURF parsing module");
17 #undef CLEANUP
18 #include "simgrid_dtd.c"
19
20 /* Initialize the parsing globals */
21 int route_action = 0;
22 xbt_dict_t traces_set_list = NULL;
23 //xbt_dynar_t traces_connect_list = NULL;
24 xbt_dict_t trace_connect_list_host_avail = NULL;
25 xbt_dict_t trace_connect_list_power = NULL;
26 xbt_dict_t trace_connect_list_link_avail = NULL;
27 xbt_dict_t trace_connect_list_bandwidth = NULL;
28 xbt_dict_t trace_connect_list_latency = NULL;
29
30 /* This buffer is used to store the original buffer before substituing it by out own buffer. Usefull for the foreach tag */
31 static xbt_dynar_t surfxml_bufferstack_stack = NULL;
32 int surfxml_bufferstack_size = 2048;
33 static char *old_buff = NULL;
34 static void surf_parse_error(char *msg);
35
36 void surfxml_bufferstack_push(int new)
37 {
38   if (!new)
39     old_buff = surfxml_bufferstack;
40   else {
41     xbt_dynar_push(surfxml_bufferstack_stack, &surfxml_bufferstack);
42     surfxml_bufferstack = xbt_new0(char, surfxml_bufferstack_size);
43   }
44 }
45
46 void surfxml_bufferstack_pop(int new)
47 {
48   if (!new)
49     surfxml_bufferstack = old_buff;
50   else {
51     free(surfxml_bufferstack);
52     xbt_dynar_pop(surfxml_bufferstack_stack, &surfxml_bufferstack);
53   }
54 }
55
56 /* Stores the set name reffered to by the foreach tag */
57 static char *foreach_set_name;
58 static xbt_dynar_t main_STag_surfxml_host_cb_list = NULL;
59 static xbt_dynar_t main_STag_surfxml_link_cb_list = NULL;
60
61 /* make sure these symbols are defined as strong ones in this file so that the linked can resolve them */
62 xbt_dynar_t STag_surfxml_platform_cb_list = NULL;
63 xbt_dynar_t ETag_surfxml_platform_cb_list = NULL;
64 xbt_dynar_t STag_surfxml_host_cb_list = NULL;
65 xbt_dynar_t ETag_surfxml_host_cb_list = NULL;
66 xbt_dynar_t STag_surfxml_router_cb_list = NULL;
67 xbt_dynar_t ETag_surfxml_router_cb_list = NULL;
68 xbt_dynar_t STag_surfxml_link_cb_list = NULL;
69 xbt_dynar_t ETag_surfxml_link_cb_list = NULL;
70 xbt_dynar_t STag_surfxml_route_cb_list = NULL;
71 xbt_dynar_t ETag_surfxml_route_cb_list = NULL;
72 xbt_dynar_t STag_surfxml_link_c_ctn_cb_list = NULL;
73 xbt_dynar_t ETag_surfxml_link_c_ctn_cb_list = NULL;
74 xbt_dynar_t STag_surfxml_process_cb_list = NULL;
75 xbt_dynar_t ETag_surfxml_process_cb_list = NULL;
76 xbt_dynar_t STag_surfxml_argument_cb_list = NULL;
77 xbt_dynar_t ETag_surfxml_argument_cb_list = NULL;
78 xbt_dynar_t STag_surfxml_prop_cb_list = NULL;
79 xbt_dynar_t ETag_surfxml_prop_cb_list = NULL;
80 xbt_dynar_t STag_surfxml_set_cb_list = NULL;
81 xbt_dynar_t ETag_surfxml_set_cb_list = NULL;
82 xbt_dynar_t STag_surfxml_foreach_cb_list = NULL;
83 xbt_dynar_t ETag_surfxml_foreach_cb_list = NULL;
84 xbt_dynar_t STag_surfxml_route_c_multi_cb_list = NULL;
85 xbt_dynar_t ETag_surfxml_route_c_multi_cb_list = NULL;
86 xbt_dynar_t STag_surfxml_cluster_cb_list = NULL;
87 xbt_dynar_t ETag_surfxml_cluster_cb_list = NULL;
88 xbt_dynar_t STag_surfxml_trace_cb_list = NULL;
89 xbt_dynar_t ETag_surfxml_trace_cb_list = NULL;
90 xbt_dynar_t STag_surfxml_trace_c_connect_cb_list = NULL;
91 xbt_dynar_t ETag_surfxml_trace_c_connect_cb_list = NULL;
92 xbt_dynar_t STag_surfxml_random_cb_list = NULL;
93 xbt_dynar_t ETag_surfxml_random_cb_list = NULL;
94
95 /* Stores the sets defined in the XML */
96 xbt_dict_t set_list = NULL;
97
98 xbt_dict_t current_property_set = NULL;
99
100 /* For the route:multi tag */
101 xbt_dict_t route_table = NULL;
102 xbt_dict_t route_multi_table = NULL;
103 xbt_dynar_t route_multi_elements = NULL;
104 static xbt_dynar_t route_link_list = NULL;
105 xbt_dynar_t links = NULL;
106 xbt_dynar_t keys = NULL;
107
108 xbt_dict_t random_data_list = NULL;
109
110 static xbt_dynar_t surf_input_buffer_stack = NULL;
111 static xbt_dynar_t surf_file_to_parse_stack = NULL;
112
113 static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t);
114
115 YY_BUFFER_STATE surf_input_buffer;
116 FILE *surf_file_to_parse = NULL;
117
118 static void convert_route_multi_to_routes(void);
119 static void parse_route_elem(void);
120 static void parse_Stag_foreach(void);
121 static void parse_sets(void);
122 static void parse_Stag_route_multi(void);
123 static void parse_Etag_route_multi(void);
124 static void parse_Stag_trace(void);
125 static void parse_Etag_trace(void);
126 static void parse_Stag_trace_c_connect(void);
127 static void init_randomness(void);
128 static void add_randomness(void);
129
130 void surf_parse_free_callbacks(void)
131 {
132   xbt_dynar_free(&STag_surfxml_platform_cb_list);
133   xbt_dynar_free(&ETag_surfxml_platform_cb_list);
134   xbt_dynar_free(&STag_surfxml_host_cb_list);
135   xbt_dynar_free(&ETag_surfxml_host_cb_list);
136   xbt_dynar_free(&STag_surfxml_router_cb_list);
137   xbt_dynar_free(&ETag_surfxml_router_cb_list);
138   xbt_dynar_free(&STag_surfxml_link_cb_list);
139   xbt_dynar_free(&ETag_surfxml_link_cb_list);
140   xbt_dynar_free(&STag_surfxml_route_cb_list);
141   xbt_dynar_free(&ETag_surfxml_route_cb_list);
142   xbt_dynar_free(&STag_surfxml_link_c_ctn_cb_list);
143   xbt_dynar_free(&ETag_surfxml_link_c_ctn_cb_list);
144   xbt_dynar_free(&STag_surfxml_process_cb_list);
145   xbt_dynar_free(&ETag_surfxml_process_cb_list);
146   xbt_dynar_free(&STag_surfxml_argument_cb_list);
147   xbt_dynar_free(&ETag_surfxml_argument_cb_list);
148   xbt_dynar_free(&STag_surfxml_prop_cb_list);
149   xbt_dynar_free(&ETag_surfxml_prop_cb_list);
150   xbt_dynar_free(&STag_surfxml_set_cb_list);
151   xbt_dynar_free(&ETag_surfxml_set_cb_list);
152   xbt_dynar_free(&STag_surfxml_foreach_cb_list);
153   xbt_dynar_free(&ETag_surfxml_foreach_cb_list);
154   xbt_dynar_free(&STag_surfxml_route_c_multi_cb_list);
155   xbt_dynar_free(&ETag_surfxml_route_c_multi_cb_list);
156   xbt_dynar_free(&STag_surfxml_cluster_cb_list);
157   xbt_dynar_free(&ETag_surfxml_cluster_cb_list);
158   xbt_dynar_free(&STag_surfxml_trace_cb_list);
159   xbt_dynar_free(&ETag_surfxml_trace_cb_list);
160   xbt_dynar_free(&STag_surfxml_trace_c_connect_cb_list);
161   xbt_dynar_free(&ETag_surfxml_trace_c_connect_cb_list);
162   xbt_dynar_free(&STag_surfxml_random_cb_list);
163   xbt_dynar_free(&ETag_surfxml_random_cb_list);
164 }
165
166 void surf_parse_reset_parser(void)
167 {
168   surf_parse_free_callbacks();
169   STag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
170   ETag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
171   STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
172   ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
173   STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
174   ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
175   STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
176   ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
177   STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
178   ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
179   STag_surfxml_link_c_ctn_cb_list =
180     xbt_dynar_new(sizeof(void_f_void_t), NULL);
181   ETag_surfxml_link_c_ctn_cb_list =
182     xbt_dynar_new(sizeof(void_f_void_t), NULL);
183   STag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
184   ETag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
185   STag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
186   ETag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
187   STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
188   ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
189   STag_surfxml_set_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
190   ETag_surfxml_set_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
191   STag_surfxml_foreach_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
192   ETag_surfxml_foreach_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
193   STag_surfxml_route_c_multi_cb_list =
194     xbt_dynar_new(sizeof(void_f_void_t), NULL);
195   ETag_surfxml_route_c_multi_cb_list =
196     xbt_dynar_new(sizeof(void_f_void_t), NULL);
197   STag_surfxml_cluster_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
198   ETag_surfxml_cluster_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
199   STag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
200   ETag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
201   STag_surfxml_trace_c_connect_cb_list =
202     xbt_dynar_new(sizeof(void_f_void_t), NULL);
203   ETag_surfxml_trace_c_connect_cb_list =
204     xbt_dynar_new(sizeof(void_f_void_t), NULL);
205   STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
206   ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
207 }
208
209 void STag_surfxml_include(void)
210 {
211   xbt_dynar_push(surf_input_buffer_stack, &surf_input_buffer);
212   xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse);
213
214   surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r");
215   xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n",
216               A_surfxml_include_file);
217   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10);
218   surf_parse__switch_to_buffer(surf_input_buffer);
219   printf("STAG\n");
220   fflush(NULL);
221 }
222
223 void ETag_surfxml_include(void)
224 {
225   printf("ETAG\n");
226   fflush(NULL);
227   surf_parse__delete_buffer(surf_input_buffer);
228   fclose(surf_file_to_parse);
229   xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse);
230   xbt_dynar_pop(surf_input_buffer_stack, &surf_input_buffer);
231 }
232
233 void STag_surfxml_platform(void)
234 {
235   double version = 0.0;
236
237   sscanf(A_surfxml_platform_version, "%lg", &version);
238
239   xbt_assert0((version >= 1.0), "******* BIG FAT WARNING *********\n "
240               "You're using an ancient XML file. "
241               "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
242               "instead of MBytes, MFlops and seconds. "
243               "A script (surfxml_update.pl) to help you convert your old "
244               "platform files "
245               "is available in the contrib/platform_generation directory "
246               "of the simgrid repository. Please check also out the "
247               "SURF section of the ChangeLog for the 3.1 version. "
248               "Last, do not forget to also update your values for "
249               "the calls to MSG_task_create (if any).");
250   xbt_assert0((version >= 2.0), "******* BIG FAT WARNING *********\n "
251               "You're using an old XML file. "
252               "A script (surfxml_update.pl) to help you convert your old "
253               "platform files "
254               "is available in the contrib/platform_generation directory "
255               "of the simgrid repository.");
256
257   surfxml_call_cb_functions(STag_surfxml_platform_cb_list);
258
259 }
260
261 void ETag_surfxml_platform(void)
262 {
263   convert_route_multi_to_routes();
264
265   surfxml_call_cb_functions(ETag_surfxml_platform_cb_list);
266
267   xbt_dict_free(&random_data_list);
268 }
269
270 void STag_surfxml_host(void)
271 {
272   surfxml_call_cb_functions(STag_surfxml_host_cb_list);
273 }
274
275 void ETag_surfxml_host(void)
276 {
277   surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
278 }
279
280 void STag_surfxml_router(void)
281 {
282   surfxml_call_cb_functions(STag_surfxml_router_cb_list);
283 }
284
285 void ETag_surfxml_router(void)
286 {
287   surfxml_call_cb_functions(ETag_surfxml_router_cb_list);
288 }
289
290 void STag_surfxml_link(void)
291 {
292   surfxml_call_cb_functions(STag_surfxml_link_cb_list);
293 }
294
295 void ETag_surfxml_link(void)
296 {
297   surfxml_call_cb_functions(ETag_surfxml_link_cb_list);
298 }
299
300 void STag_surfxml_route(void)
301 {
302   surfxml_call_cb_functions(STag_surfxml_route_cb_list);
303 }
304
305 void ETag_surfxml_route(void)
306 {
307   surfxml_call_cb_functions(ETag_surfxml_route_cb_list);
308 }
309
310 void STag_surfxml_link_c_ctn(void)
311 {
312   surfxml_call_cb_functions(STag_surfxml_link_c_ctn_cb_list);
313 }
314
315 void ETag_surfxml_link_c_ctn(void)
316 {
317   surfxml_call_cb_functions(ETag_surfxml_link_c_ctn_cb_list);
318 }
319
320 void STag_surfxml_process(void)
321 {
322   surfxml_call_cb_functions(STag_surfxml_process_cb_list);
323 }
324
325 void ETag_surfxml_process(void)
326 {
327   surfxml_call_cb_functions(ETag_surfxml_process_cb_list);
328 }
329
330 void STag_surfxml_argument(void)
331 {
332   surfxml_call_cb_functions(STag_surfxml_argument_cb_list);
333 }
334
335 void ETag_surfxml_argument(void)
336 {
337   surfxml_call_cb_functions(ETag_surfxml_argument_cb_list);
338 }
339
340 void STag_surfxml_prop(void)
341 {
342   surfxml_call_cb_functions(STag_surfxml_prop_cb_list);
343 }
344
345 void ETag_surfxml_prop(void)
346 {
347   surfxml_call_cb_functions(ETag_surfxml_prop_cb_list);
348 }
349
350 void STag_surfxml_set(void)
351 {
352   surfxml_call_cb_functions(STag_surfxml_set_cb_list);
353 }
354
355 void ETag_surfxml_set(void)
356 {
357   surfxml_call_cb_functions(ETag_surfxml_set_cb_list);
358 }
359
360 void STag_surfxml_foreach(void)
361 {
362   /* Save the current buffer */
363   surfxml_bufferstack_push(0);
364   surfxml_call_cb_functions(STag_surfxml_foreach_cb_list);
365 }
366
367 void ETag_surfxml_foreach(void)
368 {
369   surfxml_call_cb_functions(ETag_surfxml_foreach_cb_list);
370
371   /* free the temporary dynar and restore original */
372   xbt_dynar_free(&STag_surfxml_host_cb_list);
373   STag_surfxml_host_cb_list = main_STag_surfxml_host_cb_list;
374
375   /* free the temporary dynar and restore original */
376   xbt_dynar_free(&STag_surfxml_link_cb_list);
377   STag_surfxml_link_cb_list = main_STag_surfxml_link_cb_list;
378 }
379
380 void STag_surfxml_route_c_multi(void)
381 {
382   surfxml_call_cb_functions(STag_surfxml_route_c_multi_cb_list);
383 }
384
385 void ETag_surfxml_route_c_multi(void)
386 {
387   surfxml_call_cb_functions(ETag_surfxml_route_c_multi_cb_list);
388 }
389
390 void STag_surfxml_cluster(void)
391 {
392   surfxml_call_cb_functions(STag_surfxml_cluster_cb_list);
393 }
394
395 void ETag_surfxml_cluster(void)
396 {
397   surfxml_call_cb_functions(ETag_surfxml_cluster_cb_list);
398 }
399
400 void STag_surfxml_trace(void)
401 {
402   surfxml_call_cb_functions(STag_surfxml_trace_cb_list);
403 }
404
405 void ETag_surfxml_trace(void)
406 {
407   surfxml_call_cb_functions(ETag_surfxml_trace_cb_list);
408 }
409
410 void STag_surfxml_trace_c_connect(void)
411 {
412   surfxml_call_cb_functions(STag_surfxml_trace_c_connect_cb_list);
413 }
414
415 void ETag_surfxml_trace_c_connect(void)
416 {
417   surfxml_call_cb_functions(ETag_surfxml_trace_c_connect_cb_list);
418 }
419
420 void STag_surfxml_random(void)
421 {
422   surfxml_call_cb_functions(STag_surfxml_random_cb_list);
423 }
424
425 void ETag_surfxml_random(void)
426 {
427   surfxml_call_cb_functions(ETag_surfxml_random_cb_list);
428 }
429
430 void surf_parse_open(const char *file)
431 {
432   static int warned = 0;        /* warn only once */
433   if (!file) {
434     if (!warned) {
435       WARN0
436         ("Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.");
437       warned = 1;
438     }
439     return;
440   }
441   if (!surf_input_buffer_stack)
442     surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
443   if (!surf_file_to_parse_stack)
444     surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
445
446   surf_file_to_parse = surf_fopen(file, "r");
447   xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file);
448   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10);
449   surf_parse__switch_to_buffer(surf_input_buffer);
450   surf_parse_lineno = 1;
451 }
452
453 void surf_parse_close(void)
454 {
455   if (surf_input_buffer_stack)
456     xbt_dynar_free(&surf_input_buffer_stack);
457   if (surf_file_to_parse_stack)
458     xbt_dynar_free(&surf_file_to_parse_stack);
459
460   if (surf_file_to_parse) {
461     surf_parse__delete_buffer(surf_input_buffer);
462     fclose(surf_file_to_parse);
463   }
464 }
465
466
467 static int _surf_parse(void)
468 {
469   return surf_parse_lex();
470 }
471
472 int_f_void_t surf_parse = _surf_parse;
473
474 void surf_parse_error(char *msg)
475 {
476   fprintf(stderr, "Parse error on line %d: %s\n", surf_parse_lineno, msg);
477   abort();
478 }
479
480
481 void surf_parse_get_double(double *value, const char *string)
482 {
483   int ret = 0;
484
485   ret = sscanf(string, "%lg", value);
486   if (ret != 1)
487     surf_parse_error(bprintf("%s is not a double", string));
488 }
489
490 void surf_parse_get_int(int *value, const char *string)
491 {
492   int ret = 0;
493
494   ret = sscanf(string, "%d", value);
495   if (ret != 1)
496     surf_parse_error(bprintf("%s is not an integer", string));
497 }
498
499 void parse_properties(void)
500 {
501   char *value = NULL;
502
503   if (!current_property_set)
504     current_property_set = xbt_dict_new();
505
506   value = xbt_strdup(A_surfxml_prop_value);
507   xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
508 }
509
510 void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
511 {
512   xbt_dynar_push(cb_list, &function);
513 }
514
515 static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list)
516 {
517   unsigned int iterator;
518   void_f_void_t fun;
519   xbt_dynar_foreach(cb_list, iterator, fun) {
520     (*fun) ();
521   }
522 }
523
524 static void parse_route_set_endpoints(void)
525 {
526   route_link_list = xbt_dynar_new(sizeof(char *), NULL);
527 }
528
529 static void init_data(void)
530 {
531   xbt_dict_free(&route_table);
532   xbt_dynar_free(&route_link_list);
533   route_table = xbt_dict_new();
534
535   if (!surfxml_bufferstack_stack)
536     surfxml_bufferstack_stack = xbt_dynar_new(sizeof(char *), NULL);
537   route_multi_table = xbt_dict_new();
538   route_multi_elements = xbt_dynar_new(sizeof(char *), NULL);
539   traces_set_list = xbt_dict_new();
540   if (set_list == NULL)
541     set_list = xbt_dict_new();
542
543   trace_connect_list_host_avail = xbt_dict_new();
544   trace_connect_list_power = xbt_dict_new();
545   trace_connect_list_link_avail = xbt_dict_new();
546   trace_connect_list_bandwidth = xbt_dict_new();
547   trace_connect_list_latency = xbt_dict_new();
548
549   random_data_list = xbt_dict_new();
550   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
551   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
552   surfxml_add_callback(STag_surfxml_route_cb_list,
553                        &parse_route_set_endpoints);
554   surfxml_add_callback(STag_surfxml_set_cb_list, &parse_sets);
555   surfxml_add_callback(STag_surfxml_route_c_multi_cb_list,
556                        &parse_Stag_route_multi);
557   surfxml_add_callback(ETag_surfxml_route_c_multi_cb_list,
558                        &parse_Etag_route_multi);
559   surfxml_add_callback(STag_surfxml_foreach_cb_list, &parse_Stag_foreach);
560   surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_Stag_trace);
561   surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_Etag_trace);
562   surfxml_add_callback(STag_surfxml_trace_c_connect_cb_list,
563                        &parse_Stag_trace_c_connect);
564   surfxml_add_callback(STag_surfxml_random_cb_list, &init_randomness);
565   surfxml_add_callback(ETag_surfxml_random_cb_list, &add_randomness);
566 }
567
568 static void free_data(void)
569 {
570   char *key, *data;
571   xbt_dict_cursor_t cursor = NULL;
572   char *name;
573   unsigned int cpt = 0;
574
575   xbt_dict_foreach(route_table, cursor, key, data) {
576     xbt_dynar_t links = (xbt_dynar_t) data;
577     char *name;
578     unsigned int cpt = 0;
579
580     xbt_dynar_foreach(links, cpt, name) free(name);
581     xbt_dynar_free(&links);
582   }
583   xbt_dict_free(&route_table);
584   route_link_list = NULL;
585
586   xbt_dict_free(&route_multi_table);
587
588   xbt_dynar_foreach(route_multi_elements, cpt, name) free(name);
589   xbt_dynar_free(&route_multi_elements);
590
591   xbt_dict_foreach(set_list, cursor, key, data) {
592     xbt_dynar_t set = (xbt_dynar_t) data;
593
594     xbt_dynar_foreach(set, cpt, name) free(name);
595     xbt_dynar_free(&set);
596   }
597   xbt_dict_free(&set_list);
598
599   xbt_dynar_free(&surfxml_bufferstack_stack);
600
601   xbt_dict_free(&traces_set_list);
602   xbt_dict_free(&trace_connect_list_host_avail);
603   xbt_dict_free(&trace_connect_list_power);
604   xbt_dict_free(&trace_connect_list_link_avail);
605   xbt_dict_free(&trace_connect_list_bandwidth);
606   xbt_dict_free(&trace_connect_list_latency);
607   xbt_dict_free(&traces_set_list);
608 }
609
610 void parse_platform_file(const char *file)
611 {
612   surf_parse_open(file);
613   init_data();
614   xbt_assert1((!(*surf_parse) ()), "Parse error in %s", file);
615   free_data();
616   surf_parse_close();
617 }
618
619 /* Functions to bypass route tag. Used by the route:multi tag */
620
621 static void parse_make_temporary_route(const char *src, const char *dst,
622                                        int action)
623 {
624   int AX_ptr = 0;
625
626   A_surfxml_route_action = action;
627   SURFXML_BUFFER_SET(route_src, src);
628   SURFXML_BUFFER_SET(route_dst, dst);
629 }
630
631 /* Functions for the sets and foreach tags */
632
633 static void parse_sets(void)
634 {
635   char *id, *suffix, *prefix, *radical;
636   int start, end;
637   xbt_dynar_t radical_elements;
638   xbt_dynar_t radical_ends;
639   xbt_dynar_t current_set;
640   char *value, *groups;
641   int i;
642   unsigned int iter;
643
644   id = xbt_strdup(A_surfxml_set_id);
645   prefix = xbt_strdup(A_surfxml_set_prefix);
646   suffix = xbt_strdup(A_surfxml_set_suffix);
647   radical = xbt_strdup(A_surfxml_set_radical);
648
649   if (xbt_dict_get_or_null(set_list, id))
650     surf_parse_error(bprintf
651                      ("Set '%s' declared several times in the platform file.",
652                       id));
653
654   current_set = xbt_dynar_new(sizeof(char *), NULL);
655
656   radical_elements = xbt_str_split(radical, ",");
657   xbt_dynar_foreach(radical_elements, iter, groups) {
658
659     radical_ends = xbt_str_split(groups, "-");
660     switch (xbt_dynar_length(radical_ends)) {
661     case 1:
662       surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
663       value = bprintf("%s%d%s", prefix, start, suffix);
664       xbt_dynar_push(current_set, &value);
665       break;
666
667     case 2:
668
669       surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
670       surf_parse_get_int(&end, xbt_dynar_get_as(radical_ends, 1, char *));
671
672
673       for (i = start; i <= end; i++) {
674         value = bprintf("%s%d%s", prefix, i, suffix);
675         xbt_dynar_push(current_set, &value);
676       }
677       break;
678
679     default:
680       surf_parse_error(xbt_strdup("Malformed radical"));
681     }
682
683     xbt_dynar_free(&radical_ends);
684   }
685
686   xbt_dict_set(set_list, id, current_set, NULL);
687
688   xbt_dynar_free(&radical_elements);
689   free(radical);
690   free(suffix);
691   free(prefix);
692   free(id);
693 }
694
695 static void parse_host_foreach(void){
696   xbt_dynar_t names = NULL;
697   unsigned int cpt = 0;
698   char *name;
699   xbt_dict_cursor_t cursor = NULL;
700   char *key, *data;
701
702   const char *surfxml_host_power = A_surfxml_host_power;
703   const char *surfxml_host_availability = A_surfxml_host_availability;
704   const char *surfxml_host_availability_file = A_surfxml_host_availability_file;
705   const char *surfxml_host_state_file = A_surfxml_host_state_file;
706
707
708   xbt_dict_t cluster_host_props = current_property_set;
709
710   names = xbt_dict_get_or_null(set_list, foreach_set_name);
711   if (!names)
712     surf_parse_error(bprintf("Set name '%s' used in <foreach> not found.",
713                              foreach_set_name));
714   if (strcmp(A_surfxml_host_id, "$1"))
715     surf_parse_error(bprintf
716                      ("The host id within <foreach> should point to the foreach set_id (use $1 instead of %s)",
717                       A_surfxml_host_id));
718
719
720   /* foreach name in set call the main host callback */
721   xbt_dynar_foreach(names, cpt, name) {
722     int AX_ptr = 0; /* needed by the SURFXML_BUFFER_SET macro */
723
724     surfxml_bufferstack_push(1);
725
726     SURFXML_BUFFER_SET(host_id, name);
727     SURFXML_BUFFER_SET(host_power, surfxml_host_power /*hostPower */ );
728     SURFXML_BUFFER_SET(host_availability, surfxml_host_availability);
729     SURFXML_BUFFER_SET(host_availability_file, surfxml_host_availability_file);
730     SURFXML_BUFFER_SET(host_state_file, surfxml_host_state_file);
731
732     surfxml_call_cb_functions(main_STag_surfxml_host_cb_list);
733
734     xbt_dict_foreach(cluster_host_props, cursor, key, data) {
735       xbt_dict_set(current_property_set, xbt_strdup(key), xbt_strdup(data),
736                    free);
737     }
738
739     /* Call the (unmodified) callbacks of </host>, if any */
740     surfxml_call_cb_functions(ETag_surfxml_host_cb_list);
741     surfxml_bufferstack_pop(1);
742   }
743
744   current_property_set = xbt_dict_new();
745
746   surfxml_bufferstack_pop(0);
747 }
748
749 static void parse_link_foreach(void) {
750   const char *surfxml_link_bandwidth = A_surfxml_link_bandwidth;
751   const char *surfxml_link_bandwidth_file = A_surfxml_link_bandwidth_file;
752   const char *surfxml_link_latency = A_surfxml_link_latency;
753   const char *surfxml_link_latency_file = A_surfxml_link_latency_file;
754   const char *surfxml_link_state_file = A_surfxml_link_state_file;
755
756   xbt_dynar_t names = NULL;
757   unsigned int cpt = 0;
758   char *name;
759   xbt_dict_cursor_t cursor = NULL;
760   char *key, *data;
761
762   xbt_dict_t cluster_link_props = current_property_set;
763
764   names = xbt_dict_get_or_null(set_list, foreach_set_name);
765   if (!names)
766     surf_parse_error(bprintf("Set name '%s' used in <foreach> not found.",
767                              foreach_set_name));
768   if (strcmp(A_surfxml_link_id, "$1"))
769     surf_parse_error(bprintf
770                      ("The host id within <foreach> should point to the foreach set_id (use $1 instead of %s)",
771                       A_surfxml_link_id));
772
773   /* for each name in set call the main link callback */
774   xbt_dynar_foreach(names, cpt, name) {
775     int AX_ptr = 0; /* needed by the SURFXML_BUFFER_SET */
776
777     surfxml_bufferstack_push(1);
778
779     SURFXML_BUFFER_SET(link_id, name);
780     SURFXML_BUFFER_SET(link_bandwidth, surfxml_link_bandwidth);
781     SURFXML_BUFFER_SET(link_bandwidth_file, surfxml_link_bandwidth_file);
782     SURFXML_BUFFER_SET(link_latency, surfxml_link_latency);
783     SURFXML_BUFFER_SET(link_latency_file, surfxml_link_latency_file);
784     SURFXML_BUFFER_SET(link_state_file, surfxml_link_state_file);
785
786     surfxml_call_cb_functions(main_STag_surfxml_link_cb_list);
787
788     xbt_dict_foreach(cluster_link_props, cursor, key, data) {
789       xbt_dict_set(current_property_set, xbt_strdup(key), xbt_strdup(data),
790                    free);
791     }
792
793     /* Call the (unmodified) callbacks of </link>, if any */
794     surfxml_call_cb_functions(ETag_surfxml_link_cb_list);
795     surfxml_bufferstack_pop(1);
796   }
797
798   current_property_set = xbt_dict_new();
799
800   surfxml_bufferstack_pop(0);
801   free(foreach_set_name);
802   foreach_set_name = NULL;
803 }
804
805 static void parse_Stag_foreach(void)
806 {
807   /* save the host & link callbacks */
808   main_STag_surfxml_host_cb_list = STag_surfxml_host_cb_list;
809   main_STag_surfxml_link_cb_list = STag_surfxml_link_cb_list;
810
811   /* redefine host & link callbacks to be used only by the foreach tag */
812   STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
813   STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
814
815   surfxml_add_callback(STag_surfxml_host_cb_list, &parse_host_foreach);
816   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_foreach);
817
818   /* get set name */
819   foreach_set_name = xbt_strdup(A_surfxml_foreach_set_id);
820 }
821
822 /* Route:multi functions */
823
824 static int route_multi_size = 0;
825 static char *src_name, *dst_name;
826 static int is_symmetric_route;
827
828 static void parse_route_elem(void)
829 {
830   char *val;
831
832   val = xbt_strdup(A_surfxml_link_c_ctn_id);
833
834   xbt_dynar_push(route_link_list, &val);
835   //INFO2("Push %s (size now:%ld)",val,xbt_dynar_length(route_link_list));
836 }
837
838 static void parse_Stag_route_multi(void)
839 {
840   src_name = xbt_strdup(A_surfxml_route_c_multi_src);
841   dst_name = xbt_strdup(A_surfxml_route_c_multi_dst);
842   route_action = A_surfxml_route_c_multi_action;
843   is_symmetric_route = A_surfxml_route_c_multi_symmetric;
844   route_multi_size++;
845
846   route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
847 }
848
849 /*
850    This function is used to append or override the contents of an already existing route in the case a new one with its name is found.
851    The decision is based upon the value of action specified in the xml route:multi attribute action
852  */
853 void manage_route(xbt_dict_t routing_table, const char *route_name,
854                   int action, int isMultiRoute)
855 {
856   unsigned int cpt;
857   xbt_dynar_t links;
858   char *value;
859
860   /* get already existing list if it exists */
861   links = xbt_dict_get_or_null(routing_table, route_name);
862   DEBUG3("ROUTE: %s (action:%s; len:%ld)", route_name,
863       (action==A_surfxml_route_action_OVERRIDE?"override":(
864           action==A_surfxml_route_action_PREPEND?"prepend":"postpend")),
865        (links?xbt_dynar_length(links):0));
866
867   if (links != NULL) {
868     switch (action) {
869     case A_surfxml_route_action_PREPEND:       /* add existing links at the end; route_link_list + links */
870       xbt_dynar_foreach(links, cpt, value) {
871         xbt_dynar_push(route_link_list, &value);
872       }
873       xbt_dynar_free(&links);
874       break;
875     case A_surfxml_route_action_POSTPEND:      /* add existing links in front; links + route_link_list */
876       xbt_dynar_foreach(route_link_list, cpt, value) {
877         xbt_dynar_push(links, &value);
878       }
879       xbt_dynar_free(&route_link_list);
880       route_link_list = links;
881       break;
882     case A_surfxml_route_action_OVERRIDE:
883       xbt_dynar_free(&links);
884       break;
885     default:
886       xbt_die(bprintf("While dealing with routes of %s, got action=%d. Please report this bug.",
887           route_name,action));
888       break;
889     }
890   }
891   /* this is the final route; do not add if name is a set; add only if name is in set list */
892   if (!isMultiRoute) {
893     xbt_dict_set(routing_table, route_name, route_link_list, NULL);
894   }
895 }
896
897 static void parse_Etag_route_multi(void)
898 {
899   char *route_name;
900
901   route_name =
902     bprintf("%s#%s#%d#%d#%d", src_name, dst_name, route_action,
903             is_symmetric_route, route_multi_size);
904
905   xbt_dynar_push(route_multi_elements, &route_name);
906
907   /* Add route */
908   xbt_dict_set(route_multi_table, route_name, route_link_list, NULL);
909   /* add symmetric if it is the case */
910   if (is_symmetric_route == 1) {
911     char *symmetric_name =
912       bprintf("%s#%s#%d#%d#%d", dst_name, src_name, route_action,
913               !is_symmetric_route, route_multi_size);
914
915     xbt_dict_set(route_multi_table, symmetric_name, route_link_list, NULL);
916     xbt_dynar_push(route_multi_elements, &symmetric_name);
917     is_symmetric_route = 0;
918   }
919   free(src_name);
920   free(dst_name);
921 }
922
923 static void add_multi_links(const char *src, const char *dst,
924                             xbt_dynar_t links, const char *src_name,
925                             const char *dst_name)
926 {
927   unsigned int cpt;
928   char *value, *val;
929
930   surfxml_bufferstack_push(1);
931
932   parse_make_temporary_route(src_name, dst_name, route_action);
933   surfxml_call_cb_functions(STag_surfxml_route_cb_list);
934   DEBUG2("\tADDING ROUTE: %s -> %s", src_name, dst_name);
935   /* Build link list */
936   xbt_dynar_foreach(links, cpt, value) {
937     if (strcmp(value, src) == 0)
938       val = xbt_strdup(src_name);
939     else if (strcmp(value, dst) == 0)
940       val = xbt_strdup(dst_name);
941     else if (strcmp(value, "$dst") == 0)
942       val = xbt_strdup(dst_name);
943     else if (strcmp(value, "$src") == 0)
944       val = xbt_strdup(src_name);
945     else
946       val = xbt_strdup(value);
947     DEBUG1("\t\tELEMENT: %s", val);
948     xbt_dynar_push(route_link_list, &val);
949   }
950   surfxml_call_cb_functions(ETag_surfxml_route_cb_list);
951   surfxml_bufferstack_pop(1);
952 }
953
954 static void convert_route_multi_to_routes(void)
955 {
956   xbt_dict_cursor_t cursor_w;
957   int symmetric;
958   unsigned int cpt, cpt2, cursor;
959   char *src_host_name, *dst_host_name, *key, *src, *dst, *val, *key_w,
960     *data_w;
961   const char *sep = "#";
962   xbt_dict_t set = NULL;
963   xbt_dynar_t src_names = NULL, dst_names = NULL, links;
964
965   if (!route_multi_elements)
966     return;
967
968   if (surf_cpu_model)
969     set = surf_model_resource_set(surf_cpu_model);
970   if (surf_workstation_model != NULL &&
971       surf_model_resource_set(surf_workstation_model) != NULL &&
972       xbt_dict_length(surf_model_resource_set(surf_workstation_model)) > 0)
973     set = surf_model_resource_set(surf_workstation_model);
974
975
976   surfxml_bufferstack_push(0);
977   /* Get all routes in the exact order they were entered in the platform file */
978   xbt_dynar_foreach(route_multi_elements, cursor, key) {
979     /* Get links for the route */
980     links = (xbt_dynar_t) xbt_dict_get_or_null(route_multi_table, key);
981     keys = xbt_str_split_str(key, sep);
982     /* Get route ends */
983     src = xbt_dynar_get_as(keys, 0, char *);
984     dst = xbt_dynar_get_as(keys, 1, char *);
985     route_action = atoi(xbt_dynar_get_as(keys, 2, char *));
986     symmetric = atoi(xbt_dynar_get_as(keys, 3, char *));
987
988     /* Create the dynar of src and dst hosts for the new routes */
989     /* NOTE: src and dst can be either set names or simple host names */
990     src_names = (xbt_dynar_t) xbt_dict_get_or_null(set_list, src);
991     dst_names = (xbt_dynar_t) xbt_dict_get_or_null(set_list, dst);
992     /* Add to dynar even if they are simple names */
993     if (src_names == NULL) {
994       src_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
995       val = xbt_strdup(src);
996       xbt_dynar_push(src_names, &val);
997       if (strcmp(val, "$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
998         THROW3(unknown_error, 0,
999                "(In route:multi (%s -> %s) source %s does not exist (not a set or a host)",
1000                src, dst, src);
1001     }
1002     if (dst_names == NULL) {
1003       dst_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
1004       val = xbt_strdup(dst);
1005       if (strcmp(val, "$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
1006         THROW3(unknown_error, 0,
1007                "(In route:multi (%s -> %s) destination %s does not exist (not a set or a host)",
1008                src, dst, dst);
1009       xbt_dynar_push(dst_names, &val);
1010     }
1011
1012     /* Build the routes */
1013     DEBUG2("ADDING MULTI ROUTE: %s -> %s", xbt_dynar_get_as(keys, 0, char *),
1014            xbt_dynar_get_as(keys, 1, char *));
1015     xbt_dynar_foreach(src_names, cpt, src_host_name) {
1016       xbt_dynar_foreach(dst_names, cpt2, dst_host_name) {
1017         /* If dst is $* then set this route to have its dst point to all hosts */
1018         if (strcmp(src_host_name, "$*") != 0
1019             && strcmp(dst_host_name, "$*") == 0) {
1020           xbt_dict_foreach(set, cursor_w, key_w, data_w) {
1021             //int n = xbt_dynar_member(src_names, (char*)key_w);
1022             add_multi_links(src, dst, links, src_host_name, key_w);
1023           }
1024         }
1025         /* If src is $* then set this route to have its dst point to all hosts */
1026         if (strcmp(src_host_name, "$*") == 0
1027             && strcmp(dst_host_name, "$*") != 0) {
1028           xbt_dict_foreach(set, cursor_w, key_w, data_w) {
1029             // if (!symmetric || (symmetric && !contains(dst_names, key_w)))
1030             add_multi_links(src, dst, links, key_w, dst_host_name);
1031           }
1032         }
1033         /* if none of them are equal to $* */
1034         if (strcmp(src_host_name, "$*") != 0
1035             && strcmp(dst_host_name, "$*") != 0) {
1036           add_multi_links(src, dst, links, src_host_name, dst_host_name);
1037         }
1038       }
1039     }
1040     xbt_dynar_free(&keys);
1041   }
1042   surfxml_bufferstack_pop(0);
1043 }
1044
1045
1046 /* Trace management functions */
1047
1048 static double trace_periodicity = -1.0;
1049 static char *trace_file = NULL;
1050 static char *trace_id;
1051
1052 static void parse_Stag_trace(void)
1053 {
1054   trace_id = strdup(A_surfxml_trace_id);
1055   trace_file = strdup(A_surfxml_trace_file);
1056   surf_parse_get_double(&trace_periodicity, A_surfxml_trace_periodicity);
1057 }
1058
1059 static void parse_Etag_trace(void)
1060 {
1061   tmgr_trace_t trace;
1062   if (!trace_file || strcmp(trace_file, "") != 0) {
1063     trace = tmgr_trace_new(trace_file);
1064   } else {
1065     if (strcmp(surfxml_pcdata, "") == 0)
1066       trace = NULL;
1067     else
1068       trace =
1069         tmgr_trace_new_from_string(trace_id, surfxml_pcdata,
1070                                    trace_periodicity);
1071   }
1072   xbt_dict_set(traces_set_list, trace_id, (void *) trace, NULL);
1073 }
1074
1075 static void parse_Stag_trace_c_connect(void)
1076 {
1077   xbt_assert2(xbt_dict_get_or_null
1078               (traces_set_list, A_surfxml_trace_c_connect_trace),
1079               "Cannot connect trace %s to %s: trace unknown",
1080               A_surfxml_trace_c_connect_trace,
1081               A_surfxml_trace_c_connect_element);
1082
1083   switch (A_surfxml_trace_c_connect_kind) {
1084   case A_surfxml_trace_c_connect_kind_HOST_AVAIL:
1085     xbt_dict_set(trace_connect_list_host_avail,
1086                  A_surfxml_trace_c_connect_trace,
1087                  xbt_strdup(A_surfxml_trace_c_connect_element), free);
1088     break;
1089   case A_surfxml_trace_c_connect_kind_POWER:
1090     xbt_dict_set(trace_connect_list_power, A_surfxml_trace_c_connect_trace,
1091                  xbt_strdup(A_surfxml_trace_c_connect_element), free);
1092     break;
1093   case A_surfxml_trace_c_connect_kind_LINK_AVAIL:
1094     xbt_dict_set(trace_connect_list_link_avail,
1095                  A_surfxml_trace_c_connect_trace,
1096                  xbt_strdup(A_surfxml_trace_c_connect_element), free);
1097     break;
1098   case A_surfxml_trace_c_connect_kind_BANDWIDTH:
1099     xbt_dict_set(trace_connect_list_bandwidth,
1100                  A_surfxml_trace_c_connect_trace,
1101                  xbt_strdup(A_surfxml_trace_c_connect_element), free);
1102     break;
1103   case A_surfxml_trace_c_connect_kind_LATENCY:
1104     xbt_dict_set(trace_connect_list_latency, A_surfxml_trace_c_connect_trace,
1105                  xbt_strdup(A_surfxml_trace_c_connect_element), free);
1106     break;
1107   default:
1108     xbt_die(bprintf("Cannot connect trace %s to %s: kind of trace unknown",
1109                     A_surfxml_trace_c_connect_trace,
1110                     A_surfxml_trace_c_connect_element));
1111   }
1112 }
1113
1114 /* Random tag functions */
1115
1116 double get_cpu_power(const char *power)
1117 {
1118   double power_scale = 0.0;
1119   const char *p, *q;
1120   char *generator;
1121   random_data_t random = NULL;
1122   /* randomness is inserted like this: power="$rand(my_random)" */
1123   if (((p = strstr(power, "$rand(")) != NULL)
1124       && ((q = strstr(power, ")")) != NULL)) {
1125     if (p < q) {
1126       generator = xbt_malloc(q - (p + 6) + 1);
1127       memcpy(generator, p + 6, q - (p + 6));
1128       generator[q - (p + 6)] = '\0';
1129       xbt_assert1((random =
1130                    xbt_dict_get_or_null(random_data_list, generator)),
1131                   "Random generator %s undefined", generator);
1132       power_scale = random_generate(random);
1133     }
1134   } else {
1135     surf_parse_get_double(&power_scale, power);
1136   }
1137   return power_scale;
1138 }
1139
1140 double random_min, random_max, random_mean, random_std_deviation,
1141   random_generator;
1142 char *random_id;
1143
1144 static void init_randomness(void)
1145 {
1146   random_id = A_surfxml_random_id;
1147   surf_parse_get_double(&random_min, A_surfxml_random_min);
1148   surf_parse_get_double(&random_max, A_surfxml_random_max);
1149   surf_parse_get_double(&random_mean, A_surfxml_random_mean);
1150   surf_parse_get_double(&random_std_deviation,
1151                         A_surfxml_random_std_deviation);
1152   random_generator = A_surfxml_random_generator;
1153 }
1154
1155 static void add_randomness(void)
1156 {
1157   /* If needed aditional properties can be added by using the prop tag */
1158   random_data_t random =
1159     random_new(random_generator, 0, random_min, random_max, random_mean,
1160                random_std_deviation);
1161   xbt_dict_set(random_data_list, random_id, (void *) random, NULL);
1162 }