Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixup the is_first semantic (does not change anything, but you're first the first...
[simgrid.git] / src / surf / network.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 "network_private.h"
9 #include "xbt/log.h"
10
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf,
12                                 "Logging specific to the SURF network module");
13
14 surf_network_model_t surf_network_model = NULL;
15 static lmm_system_t network_maxmin_system = NULL;
16 static void (*network_solve) (lmm_system_t) = NULL;
17
18 xbt_dict_t link_set = NULL;
19 xbt_dict_t network_card_set = NULL;
20
21 int card_number = 0;
22 link_CM02_t **routing_table = NULL;
23 int *routing_table_size = NULL;
24 static link_CM02_t loopback = NULL;
25
26 static void create_routing_table(void)
27 {
28   routing_table =
29       xbt_new0(link_CM02_t *, card_number * card_number);
30   routing_table_size = xbt_new0(int, card_number * card_number);
31 }
32
33 static void link_free(void *nw_link)
34 {
35   free(((link_CM02_t) nw_link)->name);
36   free(nw_link);
37 }
38
39 static link_CM02_t link_new(char *name,
40                                             double bw_initial,
41                                             tmgr_trace_t bw_trace,
42                                             double lat_initial,
43                                             tmgr_trace_t lat_trace,
44                                             e_surf_link_state_t
45                                             state_initial,
46                                             tmgr_trace_t state_trace,
47                                             e_surf_link_sharing_policy_t
48                                             policy, xbt_dict_t properties)
49 {
50   link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1);
51
52
53   nw_link->model = (surf_model_t) surf_network_model;
54   nw_link->name = name;
55   nw_link->bw_current = bw_initial;
56   if (bw_trace)
57     nw_link->bw_event =
58         tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
59   nw_link->lat_current = lat_initial;
60   if (lat_trace)
61     nw_link->lat_event =
62         tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
63   nw_link->state_current = state_initial;
64   if (state_trace)
65     nw_link->state_event =
66         tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
67
68   nw_link->constraint =
69       lmm_constraint_new(network_maxmin_system, nw_link,
70                          nw_link->bw_current);
71
72   if (policy == SURF_LINK_FATPIPE)
73     lmm_constraint_shared(nw_link->constraint);
74
75   nw_link->properties = properties;
76
77   current_property_set = properties;
78
79   xbt_dict_set(link_set, name, nw_link, link_free);
80
81   return nw_link;
82 }
83
84 static void network_card_free(void *nw_card)
85 {
86   free(((network_card_CM02_t) nw_card)->name);
87   free(nw_card);
88 }
89
90 static int network_card_new(const char *card_name)
91 {
92   network_card_CM02_t card =
93       xbt_dict_get_or_null(network_card_set, card_name);
94
95   if (!card) {
96     card = xbt_new0(s_network_card_CM02_t, 1);
97     card->name = xbt_strdup(card_name);
98     card->id = card_number++;
99     xbt_dict_set(network_card_set, card_name, card, network_card_free);
100   }
101   return card->id;
102 }
103
104 static void route_new(int src_id, int dst_id,
105                       link_CM02_t * link_list, int nb_link)
106 {
107   ROUTE_SIZE(src_id, dst_id) = nb_link;
108   ROUTE(src_id, dst_id) = link_list =
109       xbt_realloc(link_list, sizeof(link_CM02_t) * nb_link);
110 }
111
112 static void parse_link_init(void)
113 {
114   char *name_link;
115   double bw_initial;
116   tmgr_trace_t bw_trace;
117   double lat_initial;
118   tmgr_trace_t lat_trace;
119   e_surf_link_state_t state_initial_link = SURF_LINK_ON;
120   e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
121   tmgr_trace_t state_trace;
122
123   name_link = xbt_strdup(A_surfxml_link_id);
124   surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth);
125   surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file);
126   surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
127   surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file);
128
129   xbt_assert0((A_surfxml_link_state ==
130                A_surfxml_link_state_ON)
131               || (A_surfxml_link_state ==
132                   A_surfxml_link_state_OFF), "Invalid state");
133   if (A_surfxml_link_state == A_surfxml_link_state_ON)
134     state_initial_link = SURF_LINK_ON;
135   else if (A_surfxml_link_state ==
136            A_surfxml_link_state_OFF)
137     state_initial_link = SURF_LINK_OFF;
138
139   if (A_surfxml_link_sharing_policy ==
140       A_surfxml_link_sharing_policy_SHARED)
141     policy_initial_link = SURF_LINK_SHARED;
142   else if (A_surfxml_link_sharing_policy ==
143            A_surfxml_link_sharing_policy_FATPIPE)
144     policy_initial_link = SURF_LINK_FATPIPE;
145
146   surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
147
148   link_new(name_link, bw_initial, bw_trace,
149                    lat_initial, lat_trace, state_initial_link, state_trace,
150                    policy_initial_link, xbt_dict_new());
151
152 }
153
154 static int nb_link;
155 static int link_list_capacity;
156 static link_CM02_t *link_list = NULL;
157 static int src_id = -1;
158 static int dst_id = -1;
159
160 static void parse_route_set_endpoints(void)
161 {
162
163   src_id = network_card_new(A_surfxml_route_src);
164   dst_id = network_card_new(A_surfxml_route_dst);
165   nb_link = 0;
166   link_list_capacity = 20;
167   link_list = xbt_new(link_CM02_t, link_list_capacity);
168 }
169
170 static void parse_route_elem(void)
171 {
172
173   if (nb_link == link_list_capacity) {
174     link_list_capacity *= 2;
175     link_list =
176         xbt_realloc(link_list,
177                     (link_list_capacity) * sizeof(link_CM02_t));
178   }
179   link_list[nb_link++] =
180       xbt_dict_get_or_null(link_set, A_surfxml_link_c_ctn_id);
181 }
182
183 static void parse_route_set_route(void)
184 {
185   route_new(src_id, dst_id, link_list, nb_link);
186 }
187
188 static void parse_file(const char *file)
189 {
190   int i;
191 /*
192   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
193   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
194   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
195   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
196   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
197 */
198   /* Figuring out the network links */
199   surf_parse_reset_parser();
200   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
201   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
202   surf_parse_open(file);
203   xbt_assert1((!surf_parse()), "Parse error in %s", file);
204   surf_parse_close();
205
206   /* Figuring out the network cards used */
207   surf_parse_reset_parser();
208   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
209   surf_parse_open(file);
210   xbt_assert1((!surf_parse()), "Parse error in %s", file);
211   surf_parse_close();
212
213   create_routing_table();
214
215   /* Building the routes */
216   surf_parse_reset_parser();
217   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
218   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
219   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
220   surf_parse_open(file);
221   xbt_assert1((!surf_parse()), "Parse error in %s", file);
222   surf_parse_close();
223
224   /* Adding loopback if needed */
225
226   for (i = 0; i < card_number; i++)
227     if (!ROUTE_SIZE(i, i)) {
228       if (!loopback)
229         loopback = link_new(xbt_strdup("__MSG_loopback__"),
230                                     498000000, NULL, 0.000015, NULL,
231                                     SURF_LINK_ON, NULL,
232                                     SURF_LINK_FATPIPE,NULL);
233       ROUTE_SIZE(i, i) = 1;
234       ROUTE(i, i) = xbt_new0(link_CM02_t, 1);
235       ROUTE(i, i)[0] = loopback;
236     }
237 }
238
239 static void *name_service(const char *name)
240 {
241   network_card_CM02_t card = xbt_dict_get_or_null(network_card_set, name);
242   return card;
243 }
244
245 static const char *get_resource_name(void *resource_id)
246 {
247   return ((network_card_CM02_t) resource_id)->name;
248 }
249
250 static int resource_used(void *resource_id)
251 {
252   return lmm_constraint_used(network_maxmin_system,
253                              ((link_CM02_t) resource_id)->
254                              constraint);
255 }
256
257 static int action_free(surf_action_t action)
258 {
259   action->using--;
260   if (!action->using) {
261     xbt_swag_remove(action, action->state_set);
262     if (((surf_action_network_CM02_t) action)->variable)
263       lmm_variable_free(network_maxmin_system,
264                         ((surf_action_network_CM02_t) action)->variable);
265     free(action);
266     return 1;
267   }
268   return 0;
269 }
270
271 static void action_use(surf_action_t action)
272 {
273   action->using++;
274 }
275
276 static void action_cancel(surf_action_t action)
277 {
278   return;
279 }
280
281 static void action_recycle(surf_action_t action)
282 {
283   return;
284 }
285
286 static void action_change_state(surf_action_t action,
287                                 e_surf_action_state_t state)
288 {
289 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
290 /*     if(((surf_action_network_CM02_t)action)->variable) { */
291 /*       lmm_variable_disable(network_maxmin_system, ((surf_action_network_CM02_t)action)->variable); */
292 /*       ((surf_action_network_CM02_t)action)->variable = NULL; */
293 /*     } */
294
295   surf_action_change_state(action, state);
296   return;
297 }
298
299 static double share_resources(double now)
300 {
301   s_surf_action_network_CM02_t s_action;
302   surf_action_network_CM02_t action = NULL;
303   xbt_swag_t running_actions =
304       surf_network_model->common_public->states.running_action_set;
305   double min;
306
307   min = generic_maxmin_share_resources(running_actions,
308                                        xbt_swag_offset(s_action,
309                                                        variable),
310                                        network_maxmin_system,
311                                        network_solve);
312
313   xbt_swag_foreach(action, running_actions) {
314     if (action->latency > 0) {
315       if (min < 0)
316         min = action->latency;
317       else if (action->latency < min)
318         min = action->latency;
319     }
320   }
321
322   return min;
323 }
324
325 static void update_actions_state(double now, double delta)
326 {
327   double deltap = 0.0;
328   surf_action_network_CM02_t action = NULL;
329   surf_action_network_CM02_t next_action = NULL;
330   xbt_swag_t running_actions =
331       surf_network_model->common_public->states.running_action_set;
332   /*
333      xbt_swag_t failed_actions =
334      surf_network_model->common_public->states.failed_action_set;
335    */
336
337   xbt_swag_foreach_safe(action, next_action, running_actions) {
338     deltap = delta;
339     if (action->latency > 0) {
340       if (action->latency > deltap) {
341         double_update(&(action->latency), deltap);
342         deltap = 0.0;
343       } else {
344         double_update(&(deltap), action->latency);
345         action->latency = 0.0;
346       }
347       if ((action->latency == 0.0) && !(action->suspended))
348         lmm_update_variable_weight(network_maxmin_system, action->variable,
349                                    action->lat_current);
350     }
351     double_update(&(action->generic_action.remains),
352                   lmm_variable_getvalue(action->variable) * deltap);
353     if (action->generic_action.max_duration != NO_MAX_DURATION)
354       double_update(&(action->generic_action.max_duration), delta);
355
356     /*   if(action->generic_action.remains<.00001) action->generic_action.remains=0; */
357
358     if ((action->generic_action.remains <= 0) &&
359         (lmm_get_variable_weight(action->variable) > 0)) {
360       action->generic_action.finish = surf_get_clock();
361       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
362     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
363                (action->generic_action.max_duration <= 0)) {
364       action->generic_action.finish = surf_get_clock();
365       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
366     } else {                    /* Need to check that none of the model has failed */
367       lmm_constraint_t cnst = NULL;
368       int i = 0;
369       link_CM02_t nw_link = NULL;
370
371       while ((cnst =
372               lmm_get_cnst_from_var(network_maxmin_system,
373                                     action->variable, i++))) {
374         nw_link = lmm_constraint_id(cnst);
375         if (nw_link->state_current == SURF_LINK_OFF) {
376           action->generic_action.finish = surf_get_clock();
377           action_change_state((surf_action_t) action, SURF_ACTION_FAILED);
378           break;
379         }
380       }
381     }
382   }
383
384   return;
385 }
386
387 static void update_resource_state(void *id,
388                                   tmgr_trace_event_t event_type,
389                                   double value)
390 {
391   link_CM02_t nw_link = id;
392   /*   printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
393   /*     "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
394   /*     value, event_type); */
395
396   if (event_type == nw_link->bw_event) {
397     nw_link->bw_current = value;
398     lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
399                                 nw_link->bw_current);
400   } else if (event_type == nw_link->lat_event) {
401     double delta = value - nw_link->lat_current;
402     lmm_variable_t var = NULL;
403     surf_action_network_CM02_t action = NULL;
404
405     nw_link->lat_current = value;
406     while (lmm_get_var_from_cnst
407            (network_maxmin_system, nw_link->constraint, &var)) {
408       action = lmm_variable_id(var);
409       action->lat_current += delta;
410       if (action->rate < 0)
411         lmm_update_variable_bound(network_maxmin_system, action->variable,
412                                   SG_TCP_CTE_GAMMA / (2.0 *
413                                                       action->
414                                                       lat_current));
415       else
416         lmm_update_variable_bound(network_maxmin_system, action->variable,
417                                   min(action->rate,
418                                       SG_TCP_CTE_GAMMA / (2.0 *
419                                                           action->
420                                                           lat_current)));
421       if (!(action->suspended))
422         lmm_update_variable_weight(network_maxmin_system, action->variable,
423                                    action->lat_current);
424       lmm_update_variable_latency(network_maxmin_system, action->variable,
425                                   delta);
426     }
427   } else if (event_type == nw_link->state_event) {
428     if (value > 0)
429       nw_link->state_current = SURF_LINK_ON;
430     else
431       nw_link->state_current = SURF_LINK_OFF;
432   } else {
433     CRITICAL0("Unknown event ! \n");
434     xbt_abort();
435   }
436
437   return;
438 }
439
440 static surf_action_t communicate(void *src, void *dst, double size,
441                                  double rate)
442 {
443   surf_action_network_CM02_t action = NULL;
444   network_card_CM02_t card_src = src;
445   network_card_CM02_t card_dst = dst;
446   int route_size = ROUTE_SIZE(card_src->id, card_dst->id);
447   link_CM02_t *route = ROUTE(card_src->id, card_dst->id);
448   int i;
449
450   XBT_IN4("(%s,%s,%g,%g)", card_src->name, card_dst->name, size, rate);
451   xbt_assert2(route_size,
452               "You're trying to send data from %s to %s but there is no connexion between these two cards.",
453               card_src->name, card_dst->name);
454
455   action = xbt_new0(s_surf_action_network_CM02_t, 1);
456
457   action->generic_action.using = 1;
458   action->generic_action.cost = size;
459   action->generic_action.remains = size;
460   action->generic_action.max_duration = NO_MAX_DURATION;
461   action->generic_action.start = surf_get_clock();
462   action->generic_action.finish = -1.0;
463   action->generic_action.model_type =
464       (surf_model_t) surf_network_model;
465   action->suspended = 0;        /* Should be useless because of the 
466                                    calloc but it seems to help valgrind... */
467   action->generic_action.state_set =
468       surf_network_model->common_public->states.running_action_set;
469
470   xbt_swag_insert(action, action->generic_action.state_set);
471   action->rate = rate;
472
473   action->latency = 0.0;
474   for (i = 0; i < route_size; i++)
475     action->latency += route[i]->lat_current;
476   action->lat_current = action->latency;
477
478   if (action->latency > 0)
479     action->variable =
480         lmm_variable_new(network_maxmin_system, action, 0.0, -1.0,
481                          route_size);
482   else
483     action->variable =
484         lmm_variable_new(network_maxmin_system, action, 1.0, -1.0,
485                          route_size);
486
487   if (action->rate < 0) {
488     if (action->lat_current > 0)
489       lmm_update_variable_bound(network_maxmin_system, action->variable,
490                                 SG_TCP_CTE_GAMMA / (2.0 *
491                                                     action->lat_current));
492     else
493       lmm_update_variable_bound(network_maxmin_system, action->variable,
494                                 -1.0);
495   } else {
496     if (action->lat_current > 0)
497       lmm_update_variable_bound(network_maxmin_system, action->variable,
498                                 min(action->rate,
499                                     SG_TCP_CTE_GAMMA / (2.0 *
500                                                         action->
501                                                         lat_current)));
502     else
503       lmm_update_variable_bound(network_maxmin_system, action->variable,
504                                 action->rate);
505   }
506   lmm_update_variable_latency(network_maxmin_system, action->variable,
507                               action->latency);
508
509   for (i = 0; i < route_size; i++)
510     lmm_expand(network_maxmin_system, route[i]->constraint,
511                action->variable, 1.0);
512   XBT_OUT;
513
514   return (surf_action_t) action;
515 }
516
517 /* returns an array of link_CM02_t */
518 static const void **get_route(void *src, void *dst)
519 {
520   network_card_CM02_t card_src = src;
521   network_card_CM02_t card_dst = dst;
522   return (const void **) ROUTE(card_src->id, card_dst->id);
523 }
524
525 static int get_route_size(void *src, void *dst)
526 {
527   network_card_CM02_t card_src = src;
528   network_card_CM02_t card_dst = dst;
529   return ROUTE_SIZE(card_src->id, card_dst->id);
530 }
531
532 static const char *get_link_name(const void *link)
533 {
534   return ((link_CM02_t) link)->name;
535 }
536
537 static double get_link_bandwidth(const void *link)
538 {
539   return ((link_CM02_t) link)->bw_current;
540 }
541
542 static double get_link_latency(const void *link)
543 {
544   return ((link_CM02_t) link)->lat_current;
545 }
546
547 static xbt_dict_t get_link_property_list(void *link)
548 {
549  return ((link_CM02_t) link)->properties;
550 }
551
552 static void action_suspend(surf_action_t action)
553 {
554   ((surf_action_network_CM02_t) action)->suspended = 1;
555   lmm_update_variable_weight(network_maxmin_system,
556                              ((surf_action_network_CM02_t) action)->
557                              variable, 0.0);
558 }
559
560 static void action_resume(surf_action_t action)
561 {
562   if (((surf_action_network_CM02_t) action)->suspended) {
563     lmm_update_variable_weight(network_maxmin_system,
564                                ((surf_action_network_CM02_t) action)->
565                                variable,
566                                ((surf_action_network_CM02_t) action)->
567                                lat_current);
568     ((surf_action_network_CM02_t) action)->suspended = 0;
569   }
570 }
571
572 static int action_is_suspended(surf_action_t action)
573 {
574   return ((surf_action_network_CM02_t) action)->suspended;
575 }
576
577 static void action_set_max_duration(surf_action_t action, double duration)
578 {
579   action->max_duration = duration;
580 }
581
582 static void finalize(void)
583 {
584   int i, j;
585
586   xbt_dict_free(&network_card_set);
587   xbt_dict_free(&link_set);
588   xbt_swag_free(surf_network_model->common_public->states.
589                 ready_action_set);
590   xbt_swag_free(surf_network_model->common_public->states.
591                 running_action_set);
592   xbt_swag_free(surf_network_model->common_public->states.
593                 failed_action_set);
594   xbt_swag_free(surf_network_model->common_public->states.
595                 done_action_set);
596   free(surf_network_model->common_public);
597   free(surf_network_model->common_private);
598   free(surf_network_model->extension_public);
599
600   free(surf_network_model);
601   surf_network_model = NULL;
602
603   loopback = NULL;
604   for (i = 0; i < card_number; i++)
605     for (j = 0; j < card_number; j++)
606       free(ROUTE(i, j));
607   free(routing_table);
608   routing_table = NULL;
609   free(routing_table_size);
610   routing_table_size = NULL;
611   card_number = 0;
612 }
613
614 static void surf_network_model_init_internal(void)
615 {
616   s_surf_action_t action;
617
618   surf_network_model = xbt_new0(s_surf_network_model_t, 1);
619
620   surf_network_model->common_private =
621       xbt_new0(s_surf_model_private_t, 1);
622   surf_network_model->common_public =
623       xbt_new0(s_surf_model_public_t, 1);
624   surf_network_model->extension_public =
625       xbt_new0(s_surf_network_model_extension_public_t, 1);
626
627   surf_network_model->common_public->states.ready_action_set =
628       xbt_swag_new(xbt_swag_offset(action, state_hookup));
629   surf_network_model->common_public->states.running_action_set =
630       xbt_swag_new(xbt_swag_offset(action, state_hookup));
631   surf_network_model->common_public->states.failed_action_set =
632       xbt_swag_new(xbt_swag_offset(action, state_hookup));
633   surf_network_model->common_public->states.done_action_set =
634       xbt_swag_new(xbt_swag_offset(action, state_hookup));
635
636   surf_network_model->common_public->name_service = name_service;
637   surf_network_model->common_public->get_resource_name =
638       get_resource_name;
639   surf_network_model->common_public->action_get_state =
640       surf_action_get_state;
641   surf_network_model->common_public->action_get_start_time =
642       surf_action_get_start_time;
643   surf_network_model->common_public->action_get_finish_time =
644       surf_action_get_finish_time;
645   surf_network_model->common_public->action_free = action_free;
646   surf_network_model->common_public->action_use = action_use;
647   surf_network_model->common_public->action_cancel = action_cancel;
648   surf_network_model->common_public->action_recycle = action_recycle;
649   surf_network_model->common_public->action_change_state =
650       action_change_state;
651   surf_network_model->common_public->action_set_data =
652       surf_action_set_data;
653   surf_network_model->common_public->name = "network";
654
655   surf_network_model->common_private->resource_used = resource_used;
656   surf_network_model->common_private->share_resources = share_resources;
657   surf_network_model->common_private->update_actions_state =
658       update_actions_state;
659   surf_network_model->common_private->update_resource_state =
660       update_resource_state;
661   surf_network_model->common_private->finalize = finalize;
662
663   surf_network_model->common_public->suspend = action_suspend;
664   surf_network_model->common_public->resume = action_resume;
665   surf_network_model->common_public->is_suspended = action_is_suspended;
666   surf_cpu_model->common_public->set_max_duration =
667       action_set_max_duration;
668
669   surf_network_model->extension_public->communicate = communicate;
670   surf_network_model->extension_public->get_route = get_route;
671   surf_network_model->extension_public->get_route_size = get_route_size;
672   surf_network_model->extension_public->get_link_name = get_link_name;
673   surf_network_model->extension_public->get_link_bandwidth =
674       get_link_bandwidth;
675   surf_network_model->extension_public->get_link_latency =
676       get_link_latency;
677   /*for the props of the link*/
678   surf_network_model->common_public->get_link_properties =  get_link_property_list;
679
680   link_set = xbt_dict_new();
681   network_card_set = xbt_dict_new();
682
683   if (!network_maxmin_system)
684     network_maxmin_system = lmm_system_new();
685 }
686
687 /***************************************************************************/
688 /* The nice TCP sharing model designed by Loris Marchal and Henri Casanova */
689 /***************************************************************************/
690 /* @TechReport{      rr-lip2002-40, */
691 /*   author        = {Henri Casanova and Loris Marchal}, */
692 /*   institution   = {LIP}, */
693 /*   title         = {A Network Model for Simulation of Grid Application}, */
694 /*   number        = {2002-40}, */
695 /*   month         = {oct}, */
696 /*   year          = {2002} */
697 /* } */
698 void surf_network_model_init_CM02(const char *filename)
699 {
700
701   if (surf_network_model)
702     return;
703   surf_network_model_init_internal();
704   parse_file(filename);
705   xbt_dynar_push(model_list, &surf_network_model);
706   network_solve = lmm_solve;
707
708   update_model_description(surf_network_model_description,
709                               surf_network_model_description_size,
710                               "CM02",
711                               (surf_model_t) surf_network_model);
712 }
713
714 void surf_network_model_init_Reno(const char *filename)
715 {
716   if (surf_network_model)
717     return;
718   surf_network_model_init_internal();
719   parse_file(filename);
720
721   xbt_dynar_push(model_list, &surf_network_model);
722   lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
723                                     func_reno_fpi);
724   network_solve = lagrange_solve;
725
726   update_model_description(surf_network_model_description,
727                               surf_network_model_description_size,
728                               "Reno",
729                               (surf_model_t) surf_network_model);
730 }
731
732 void surf_network_model_init_Vegas(const char *filename)
733 {
734   if (surf_network_model)
735     return;
736   surf_network_model_init_internal();
737   parse_file(filename);
738
739   xbt_dynar_push(model_list, &surf_network_model);
740   lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
741                                     func_vegas_fpi);
742   network_solve = lagrange_solve;
743
744   update_model_description(surf_network_model_description,
745                               surf_network_model_description_size,
746                               "Vegas",
747                               (surf_model_t) surf_network_model);
748 }
749
750 #ifdef HAVE_SDP
751 void surf_network_model_init_SDP(const char *filename)
752 {
753   if (surf_network_model)
754     return;
755   surf_network_model_init_internal();
756   parse_file(filename);
757
758   xbt_dynar_push(model_list, &surf_network_model);
759   network_solve = sdp_solve;
760
761   update_model_description(surf_network_model_description,
762                               surf_network_model_description_size,
763                               "SDP",
764                               (surf_model_t) surf_network_model);
765 }
766 #endif