Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update_actions_state
[simgrid.git] / src / surf / network_constant.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 "surf_private.h"
9 #include "xbt/dict.h"
10 #include "xbt/str.h"
11 #include "xbt/log.h"
12
13 #define CONSTANT_VALUE 1.0
14 typedef struct network_card_Constant {
15   char *name;
16   int id;
17 } s_network_card_Constant_t, *network_card_Constant_t;
18
19 typedef struct network_link_Constant {
20   surf_model_t model;   /* Any such object, added in a trace
21                                    should start by this field!!! */
22   xbt_dict_t properties;
23   /* Using this object with the public part of
24      model does not make sense */
25   char *name;
26   double bw_current;
27   tmgr_trace_event_t bw_event;
28   double lat_current;
29   tmgr_trace_event_t lat_event;
30   e_surf_link_state_t state_current;
31   tmgr_trace_event_t state_event;
32   lmm_constraint_t constraint;
33 } s_link_Constant_t, *link_Constant_t;
34
35 typedef struct surf_action_network_Constant {
36   s_surf_action_t generic_action;
37   double latency;
38   double lat_current;
39   lmm_variable_t variable;
40   double rate;
41   int suspended;
42   network_card_Constant_t src;
43   network_card_Constant_t dst;
44 } s_surf_action_network_Constant_t, *surf_action_network_Constant_t;
45
46 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_network);
47
48 static lmm_system_t network_maxmin_system = NULL;
49 static void (*network_solve) (lmm_system_t) = NULL;
50
51 static xbt_dict_t network_card_set = NULL;
52
53 static int card_number = 0;
54 static int host_number = 0;
55 static link_Constant_t **routing_table = NULL;
56 static int *routing_table_size = NULL;
57 static link_Constant_t loopback = NULL;
58
59 #define ROUTE(i,j) routing_table[(i)+(j)*card_number]
60 #define ROUTE_SIZE(i,j) routing_table_size[(i)+(j)*card_number]
61
62 static void create_routing_table(void)
63 {
64   routing_table =
65       xbt_new0(link_Constant_t *, /*card_number * card_number */ host_number * host_number);
66   routing_table_size = xbt_new0(int, /*card_number * card_number*/ host_number * host_number);
67 }
68
69 static void link_free(void *nw_link)
70 {
71   free(((link_Constant_t) nw_link)->name);
72   free(nw_link);
73 }
74
75 static link_Constant_t link_new(char *name,
76                             double bw_initial,
77                             tmgr_trace_t bw_trace,
78                             double lat_initial,
79                             tmgr_trace_t lat_trace,
80                             e_surf_link_state_t
81                             state_initial,
82                             tmgr_trace_t state_trace,
83                             e_surf_link_sharing_policy_t
84                             policy, xbt_dict_t properties)
85 {
86   link_Constant_t nw_link = xbt_new0(s_link_Constant_t, 1);
87   xbt_assert1(!xbt_dict_get_or_null(link_set, name), 
88               "Link '%s' declared several times in the platform file.", name);   
89
90   nw_link->model = (surf_model_t) surf_network_model;
91   nw_link->name = name;
92   nw_link->bw_current = bw_initial;
93   if (bw_trace)
94     nw_link->bw_event =
95         tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
96   nw_link->lat_current = lat_initial;
97   if (lat_trace)
98     nw_link->lat_event =
99         tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
100   nw_link->state_current = state_initial;
101   if (state_trace)
102     nw_link->state_event =
103         tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
104
105   nw_link->constraint =
106       lmm_constraint_new(network_maxmin_system, nw_link,
107                          nw_link->bw_current);
108
109   if (policy == SURF_LINK_FATPIPE)
110     lmm_constraint_shared(nw_link->constraint);
111
112   nw_link->properties = properties;
113
114   current_property_set = properties;
115
116   xbt_dict_set(link_set, name, nw_link, link_free);
117
118   return nw_link;
119 }
120
121 static void network_card_free(void *nw_card)
122 {
123   free(((network_card_Constant_t) nw_card)->name);
124   free(nw_card);
125 }
126
127 static int network_card_new(const char *card_name)
128 {
129   network_card_Constant_t card =
130       xbt_dict_get_or_null(network_card_set, card_name);
131
132   if (!card) {
133     card = xbt_new0(s_network_card_Constant_t, 1);
134     card->name = xbt_strdup(card_name);
135     card->id = card_number++;
136     xbt_dict_set(network_card_set, card_name, card, network_card_free);
137   }
138   return card->id;
139 }
140
141 static void route_new(int src_id, int dst_id,
142                       link_Constant_t * link_list, int nb_link)
143 {
144   ROUTE_SIZE(src_id, dst_id) = nb_link;
145   ROUTE(src_id, dst_id) = link_list =
146       xbt_realloc(link_list, sizeof(link_Constant_t) * nb_link);
147 }
148
149 static void parse_link_init(void)
150 {
151   char *name_link;
152   double bw_initial;
153   tmgr_trace_t bw_trace;
154   double lat_initial;
155   tmgr_trace_t lat_trace;
156   e_surf_link_state_t state_initial_link = SURF_LINK_ON;
157   e_surf_link_sharing_policy_t policy_initial_link = SURF_LINK_SHARED;
158   tmgr_trace_t state_trace;
159
160   name_link = xbt_strdup(A_surfxml_link_id);
161   surf_parse_get_double(&bw_initial, A_surfxml_link_bandwidth);
162   surf_parse_get_trace(&bw_trace, A_surfxml_link_bandwidth_file);
163   surf_parse_get_double(&lat_initial, A_surfxml_link_latency);
164   surf_parse_get_trace(&lat_trace, A_surfxml_link_latency_file);
165
166   xbt_assert0((A_surfxml_link_state ==
167                A_surfxml_link_state_ON)
168               || (A_surfxml_link_state ==
169                   A_surfxml_link_state_OFF), "Invalid state");
170   if (A_surfxml_link_state == A_surfxml_link_state_ON)
171     state_initial_link = SURF_LINK_ON;
172   else if (A_surfxml_link_state ==
173            A_surfxml_link_state_OFF)
174     state_initial_link = SURF_LINK_OFF;
175
176   if (A_surfxml_link_sharing_policy ==
177       A_surfxml_link_sharing_policy_SHARED)
178     policy_initial_link = SURF_LINK_SHARED;
179   else if (A_surfxml_link_sharing_policy ==
180            A_surfxml_link_sharing_policy_FATPIPE)
181     policy_initial_link = SURF_LINK_FATPIPE;
182
183   surf_parse_get_trace(&state_trace, A_surfxml_link_state_file);
184
185   link_new(name_link, bw_initial, bw_trace,
186                    lat_initial, lat_trace, state_initial_link, state_trace,
187                    policy_initial_link, xbt_dict_new());
188
189 }
190
191 static int src_id = -1;
192 static int dst_id = -1;
193
194 static void parse_route_set_endpoints(void)
195 {
196   src_id = network_card_new(A_surfxml_route_src);
197   dst_id = network_card_new(A_surfxml_route_dst);
198   route_action = A_surfxml_route_action;
199   route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
200 }
201
202 static void parse_route_set_route(void)
203 {
204   char *name;
205   if (src_id != -1 && dst_id != -1) {
206     name = bprintf("%x#%x",src_id, dst_id);
207     manage_route(route_table, name, route_action, 0);
208     free(name);    
209   }
210 }
211
212 static void add_loopback(void)
213 {
214   int i;
215   /* Adding loopback if needed */
216   for (i = 0; i < host_number; i++)
217     if (!ROUTE_SIZE(i, i)) {
218       if (!loopback)
219         loopback = link_new(xbt_strdup("__MSG_loopback__"),
220                                     498000000, NULL, 0.000015, NULL,
221                                     SURF_LINK_ON, NULL,
222                                     SURF_LINK_FATPIPE,NULL);
223       ROUTE_SIZE(i, i) = 1;
224       ROUTE(i, i) = xbt_new0(link_Constant_t, 1);
225       ROUTE(i, i)[0] = loopback;
226     }
227 }
228
229 static void add_route(void)
230 {
231   xbt_ex_t e;
232   int nb_link = 0;
233   unsigned int cpt = 0;    
234   int link_list_capacity = 0;
235   link_Constant_t *link_list = NULL;
236   xbt_dict_cursor_t cursor = NULL;
237   char *key,*data, *end;
238   const char *sep = "#";
239   xbt_dynar_t links, keys;
240
241   if (routing_table == NULL) create_routing_table();
242
243   xbt_dict_foreach(route_table, cursor, key, data) {
244           char* link = NULL;
245     nb_link = 0;
246     links = (xbt_dynar_t)data;
247     keys = xbt_str_split_str(key, sep);
248
249     link_list_capacity = xbt_dynar_length(links);
250     link_list = xbt_new(link_Constant_t, link_list_capacity);
251
252     src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
253     dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
254  
255     xbt_dynar_foreach (links, cpt, link) {
256       TRY {
257         link_list[nb_link++] = xbt_dict_get(link_set, link);
258       }
259       CATCH(e) {
260         RETHROW1("Link %s not found (dict raised this exception: %s)", link);
261       }     
262     }
263     route_new(src_id, dst_id, link_list, nb_link);
264    }
265
266    xbt_dict_free(&route_table);
267
268 }
269
270 static void count_hosts(void)
271 {
272    host_number++;
273 }
274
275
276 static void add_traces(void) {
277    xbt_dict_cursor_t cursor=NULL;
278    char *trace_name,*elm;
279    
280    static int called = 0;
281    if (called) return;
282    called = 1;
283
284    /* connect all traces relative to network */
285    xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
286       tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
287       link_Constant_t link = xbt_dict_get_or_null(link_set, elm);
288       
289       xbt_assert1(link, "Link %s undefined", elm);
290       xbt_assert1(trace, "Trace %s undefined", trace_name);
291       
292       link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
293    }
294
295    xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
296       tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
297       link_Constant_t link = xbt_dict_get_or_null(link_set, elm);
298       
299       xbt_assert1(link, "Link %s undefined", elm);
300       xbt_assert1(trace, "Trace %s undefined", trace_name);
301       
302       link->bw_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
303    }
304    
305    xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
306       tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
307       link_Constant_t link = xbt_dict_get_or_null(link_set, elm);
308       
309       xbt_assert1(link, "Link %s undefined", elm);
310       xbt_assert1(trace, "Trace %s undefined", trace_name);
311       
312       link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
313    }
314
315    xbt_dict_free(&trace_connect_list_host_avail);
316    xbt_dict_free(&trace_connect_list_power);
317    xbt_dict_free(&trace_connect_list_link_avail);
318    xbt_dict_free(&trace_connect_list_bandwidth);
319    xbt_dict_free(&trace_connect_list_latency);
320    
321    xbt_dict_free(&traces_set_list); 
322 }
323
324 static void define_callbacks(const char *file)
325 {
326   /* Figuring out the network links */
327   surfxml_add_callback(STag_surfxml_host_cb_list, &count_hosts);
328   surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
329   surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
330   surfxml_add_callback(STag_surfxml_route_cb_list, &parse_route_set_endpoints);
331   surfxml_add_callback(ETag_surfxml_link_c_ctn_cb_list, &parse_route_elem);
332   surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
333   surfxml_add_callback(STag_surfxml_platform_cb_list, &init_data);
334   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
335   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
336   surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
337   surfxml_add_callback(STag_surfxml_set_cb_list, &parse_sets);
338   surfxml_add_callback(STag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_endpoints);
339   surfxml_add_callback(ETag_surfxml_route_c_multi_cb_list, &parse_route_multi_set_route);
340   surfxml_add_callback(STag_surfxml_foreach_cb_list, &parse_foreach);
341   surfxml_add_callback(STag_surfxml_cluster_cb_list, &parse_cluster);
342   surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_trace_init);
343   surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_trace_finalize);
344   surfxml_add_callback(STag_surfxml_trace_c_connect_cb_list, &parse_trace_c_connect);
345 }
346
347 static void *name_service(const char *name)
348 {
349   network_card_Constant_t card = xbt_dict_get_or_null(network_card_set, name);
350   return card;
351 }
352
353 static const char *get_resource_name(void *resource_id)
354 {
355   return ((network_card_Constant_t) resource_id)->name;
356 }
357
358 static int resource_used(void *resource_id)
359 {
360   return lmm_constraint_used(network_maxmin_system,
361                              ((link_Constant_t) resource_id)->
362                              constraint);
363 }
364
365 static int action_free(surf_action_t action)
366 {
367   action->using--;
368   if (!action->using) {
369     xbt_swag_remove(action, action->state_set);
370     if (((surf_action_network_Constant_t) action)->variable)
371       lmm_variable_free(network_maxmin_system,
372                         ((surf_action_network_Constant_t) action)->variable);
373     free(action);
374     return 1;
375   }
376   return 0;
377 }
378
379 static void action_use(surf_action_t action)
380 {
381   action->using++;
382 }
383
384 static void action_cancel(surf_action_t action)
385 {
386   return;
387 }
388
389 static void action_recycle(surf_action_t action)
390 {
391   return;
392 }
393
394 static void action_change_state(surf_action_t action,
395                                 e_surf_action_state_t state)
396 {
397 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
398 /*     if(((surf_action_network_Constant_t)action)->variable) { */
399 /*       lmm_variable_disable(network_maxmin_system, ((surf_action_network_Constant_t)action)->variable); */
400 /*       ((surf_action_network_Constant_t)action)->variable = NULL; */
401 /*     } */
402
403   surf_action_change_state(action, state);
404   return;
405 }
406
407 static double share_resources(double now)
408 {
409   s_surf_action_network_Constant_t s_action;
410   surf_action_network_Constant_t action = NULL;
411   xbt_swag_t running_actions =
412       surf_network_model->common_public->states.running_action_set;
413   double min;
414
415   min = generic_maxmin_share_resources(running_actions,
416                                        xbt_swag_offset(s_action,
417                                                        variable),
418                                        network_maxmin_system,
419                                        network_solve);
420
421   xbt_swag_foreach(action, running_actions) {
422     if (action->latency > 0) {
423       if (min < 0)
424         min = action->latency;
425       else if (action->latency < min)
426         min = action->latency;
427     }
428   }
429
430   return min;
431 }
432
433 static void update_actions_state(double now, double delta)
434 {
435   double deltap = 0.0;
436   surf_action_network_Constant_t action = NULL;
437   surf_action_network_Constant_t next_action = NULL;
438   xbt_swag_t running_actions =
439       surf_network_model->common_public->states.running_action_set;
440
441   xbt_swag_foreach_safe(action, next_action, running_actions) {
442     deltap = delta;
443     if (action->latency > 0) {
444       if (action->latency > deltap) {
445         double_update(&(action->latency), deltap);
446         deltap = 0.0;
447       } else {
448         double_update(&(deltap), action->latency);
449         action->latency = 0.0;
450       }
451     }
452     double_update(&(action->generic_action.remains),
453                   action->generic_action.cost * deltap/ CONSTANT_VALUE);
454     if (action->generic_action.max_duration != NO_MAX_DURATION)
455       double_update(&(action->generic_action.max_duration), delta);
456
457     if (action->generic_action.remains <= 0) {
458       action->generic_action.finish = surf_get_clock();
459       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
460     } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
461                (action->generic_action.max_duration <= 0)) {
462       action->generic_action.finish = surf_get_clock();
463       action_change_state((surf_action_t) action, SURF_ACTION_DONE);
464     } 
465   }
466
467   return;
468 }
469
470 static void update_resource_state(void *id,
471                                   tmgr_trace_event_t event_type,
472                                   double value)
473 {
474   link_Constant_t nw_link = id;
475   /*   printf("[" "%lg" "] Asking to update network card \"%s\" with value " */
476   /*     "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
477   /*     value, event_type); */
478
479   if (event_type == nw_link->bw_event) {
480     nw_link->bw_current = value;
481     lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
482                                 nw_link->bw_current);
483   } else if (event_type == nw_link->lat_event) {
484     double delta = value - nw_link->lat_current;
485     lmm_variable_t var = NULL;
486     surf_action_network_Constant_t action = NULL;
487
488     nw_link->lat_current = value;
489     while (lmm_get_var_from_cnst
490            (network_maxmin_system, nw_link->constraint, &var)) {
491       action = lmm_variable_id(var);
492       action->lat_current += delta;
493       if (action->rate < 0)
494         lmm_update_variable_bound(network_maxmin_system, action->variable,
495                                   SG_TCP_CTE_GAMMA / (2.0 *
496                                                       action->
497                                                       lat_current));
498       else
499         lmm_update_variable_bound(network_maxmin_system, action->variable,
500                                   min(action->rate,
501                                       SG_TCP_CTE_GAMMA / (2.0 *
502                                                           action->
503                                                           lat_current)));
504       if (!(action->suspended))
505         lmm_update_variable_weight(network_maxmin_system, action->variable,
506                                    action->lat_current);
507       lmm_update_variable_latency(network_maxmin_system, action->variable,
508                                   delta);
509     }
510   } else if (event_type == nw_link->state_event) {
511     if (value > 0)
512       nw_link->state_current = SURF_LINK_ON;
513     else
514       nw_link->state_current = SURF_LINK_OFF;
515   } else {
516     CRITICAL0("Unknown event ! \n");
517     xbt_abort();
518   }
519
520   return;
521 }
522
523 static surf_action_t communicate(void *src, void *dst, double size,
524                                  double rate)
525 {
526   surf_action_network_Constant_t action = NULL;
527   network_card_Constant_t card_src = src;
528   network_card_Constant_t card_dst = dst;
529
530   XBT_IN4("(%s,%s,%g,%g)", card_src->name, card_dst->name, size, rate);
531
532   action = xbt_new0(s_surf_action_network_Constant_t, 1);
533
534   action->generic_action.using = 1;
535   action->generic_action.cost = size;
536   action->generic_action.remains = size;
537   action->generic_action.max_duration = NO_MAX_DURATION;
538   action->generic_action.start = surf_get_clock();
539   action->generic_action.finish = -1.0;
540   action->generic_action.model_type =
541       (surf_model_t) surf_network_model;
542   action->suspended = 0;
543   action->generic_action.state_set =
544       surf_network_model->common_public->states.running_action_set;
545
546   xbt_swag_insert(action, action->generic_action.state_set);
547   action->rate = rate;
548
549   action->latency = CONSTANT_VALUE;
550   action->lat_current = action->latency;
551
552   XBT_OUT;
553
554   return (surf_action_t) action;
555 }
556
557 /* returns an array of link_Constant_t */
558 static const void **get_route(void *src, void *dst)
559 {
560   network_card_Constant_t card_src = src;
561   network_card_Constant_t card_dst = dst;
562   return (const void **) ROUTE(card_src->id, card_dst->id);
563 }
564
565 static int get_route_size(void *src, void *dst)
566 {
567   network_card_Constant_t card_src = src;
568   network_card_Constant_t card_dst = dst;
569   return ROUTE_SIZE(card_src->id, card_dst->id);
570 }
571
572 static const char *get_link_name(const void *link)
573 {
574   return ((link_Constant_t) link)->name;
575 }
576
577 static double get_link_bandwidth(const void *link)
578 {
579   return ((link_Constant_t) link)->bw_current;
580 }
581
582 static double get_link_latency(const void *link)
583 {
584   return ((link_Constant_t) link)->lat_current;
585 }
586
587 static xbt_dict_t get_properties(void *link)
588 {
589  return ((link_Constant_t) link)->properties;
590 }
591
592 static void action_suspend(surf_action_t action)
593 {
594   ((surf_action_network_Constant_t) action)->suspended = 1;
595   lmm_update_variable_weight(network_maxmin_system,
596                              ((surf_action_network_Constant_t) action)->
597                              variable, 0.0);
598 }
599
600 static void action_resume(surf_action_t action)
601 {
602   if (((surf_action_network_Constant_t) action)->suspended) {
603     lmm_update_variable_weight(network_maxmin_system,
604                                ((surf_action_network_Constant_t) action)->
605                                variable,
606                                ((surf_action_network_Constant_t) action)->
607                                lat_current);
608     ((surf_action_network_Constant_t) action)->suspended = 0;
609   }
610 }
611
612 static int action_is_suspended(surf_action_t action)
613 {
614   return ((surf_action_network_Constant_t) action)->suspended;
615 }
616
617 static void action_set_max_duration(surf_action_t action, double duration)
618 {
619   action->max_duration = duration;
620 }
621
622 static void finalize(void)
623 {
624   int i, j;
625
626   xbt_dict_free(&network_card_set);
627   xbt_dict_free(&link_set);
628   xbt_swag_free(surf_network_model->common_public->states.
629                 ready_action_set);
630   xbt_swag_free(surf_network_model->common_public->states.
631                 running_action_set);
632   xbt_swag_free(surf_network_model->common_public->states.
633                 failed_action_set);
634   xbt_swag_free(surf_network_model->common_public->states.
635                 done_action_set);
636   free(surf_network_model->common_public);
637   free(surf_network_model->common_private);
638   free(surf_network_model->extension_public);
639
640   free(surf_network_model);
641   surf_network_model = NULL;
642
643   loopback = NULL;
644   for (i = 0; i < card_number; i++)
645     for (j = 0; j < card_number; j++)
646       free(ROUTE(i, j));
647   free(routing_table);
648   routing_table = NULL;
649   free(routing_table_size);
650   routing_table_size = NULL;
651   card_number = 0;
652 }
653
654 static void surf_network_model_init_internal(void)
655 {
656   s_surf_action_t action;
657
658   surf_network_model = xbt_new0(s_surf_network_model_t, 1);
659
660   surf_network_model->common_private =
661       xbt_new0(s_surf_model_private_t, 1);
662   surf_network_model->common_public =
663       xbt_new0(s_surf_model_public_t, 1);
664   surf_network_model->extension_public =
665       xbt_new0(s_surf_network_model_extension_public_t, 1);
666
667   surf_network_model->common_public->states.ready_action_set =
668       xbt_swag_new(xbt_swag_offset(action, state_hookup));
669   surf_network_model->common_public->states.running_action_set =
670       xbt_swag_new(xbt_swag_offset(action, state_hookup));
671   surf_network_model->common_public->states.failed_action_set =
672       xbt_swag_new(xbt_swag_offset(action, state_hookup));
673   surf_network_model->common_public->states.done_action_set =
674       xbt_swag_new(xbt_swag_offset(action, state_hookup));
675
676   surf_network_model->common_public->name_service = name_service;
677   surf_network_model->common_public->get_resource_name =
678       get_resource_name;
679   surf_network_model->common_public->action_get_state =
680       surf_action_get_state;
681   surf_network_model->common_public->action_get_start_time =
682       surf_action_get_start_time;
683   surf_network_model->common_public->action_get_finish_time =
684       surf_action_get_finish_time;
685   surf_network_model->common_public->action_free = action_free;
686   surf_network_model->common_public->action_use = action_use;
687   surf_network_model->common_public->action_cancel = action_cancel;
688   surf_network_model->common_public->action_recycle = action_recycle;
689   surf_network_model->common_public->action_change_state =
690       action_change_state;
691   surf_network_model->common_public->action_set_data =
692       surf_action_set_data;
693   surf_network_model->common_public->name = "network";
694
695   surf_network_model->common_private->resource_used = resource_used;
696   surf_network_model->common_private->share_resources = share_resources;
697   surf_network_model->common_private->update_actions_state =
698       update_actions_state;
699   surf_network_model->common_private->update_resource_state =
700       update_resource_state;
701   surf_network_model->common_private->finalize = finalize;
702
703   surf_network_model->common_public->suspend = action_suspend;
704   surf_network_model->common_public->resume = action_resume;
705   surf_network_model->common_public->is_suspended = action_is_suspended;
706   surf_cpu_model->common_public->set_max_duration =
707       action_set_max_duration;
708
709   surf_network_model->extension_public->communicate = communicate;
710   surf_network_model->extension_public->get_route = get_route;
711   surf_network_model->extension_public->get_route_size = get_route_size;
712   surf_network_model->extension_public->get_link_name = get_link_name;
713   surf_network_model->extension_public->get_link_bandwidth =
714       get_link_bandwidth;
715   surf_network_model->extension_public->get_link_latency =
716       get_link_latency;
717
718   surf_network_model->common_public->get_properties =  get_properties;
719
720   link_set = xbt_dict_new();
721   network_card_set = xbt_dict_new();
722
723   if (!network_maxmin_system)
724     network_maxmin_system = lmm_system_new();
725 }
726
727 void surf_network_model_init_Constant(const char *filename)
728 {
729
730   if (surf_network_model)
731     return;
732   surf_network_model_init_internal();
733   define_callbacks(filename);
734   xbt_dynar_push(model_list, &surf_network_model);
735   network_solve = lmm_solve;
736
737   update_model_description(surf_network_model_description,
738                               surf_network_model_description_size,
739                               "Constant",
740                               (surf_model_t) surf_network_model);
741 }