Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move some content from AsNone into As (AsNone should die)
[simgrid.git] / src / surf / maxmin_private.hpp
1 /* Copyright (c) 2004-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SURF_MAXMIN_PRIVATE_H
8 #define _SURF_MAXMIN_PRIVATE_H
9
10 #include <xbt/base.h>
11
12 #include "surf/maxmin.h"
13 #include "xbt/swag.h"
14 #include "xbt/mallocator.h"
15 #include "surf_interface.hpp"
16
17 /** @ingroup SURF_lmm
18  * @brief LMM element
19  */
20 typedef struct lmm_element {
21   /* hookup to constraint */
22   s_xbt_swag_hookup_t element_set_hookup;
23   s_xbt_swag_hookup_t active_element_set_hookup;
24
25   lmm_constraint_t constraint;
26   lmm_variable_t variable;
27   double value;
28 } s_lmm_element_t;
29 #define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
30 #define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
31
32 typedef struct lmm_constraint_light {
33   double remaining_over_usage;
34   lmm_constraint_t cnst;
35 } s_lmm_constraint_light_t;
36
37 /** @ingroup SURF_lmm
38  * @brief LMM constraint
39  */
40 typedef struct lmm_constraint {
41   /* hookup to system */
42   s_xbt_swag_hookup_t constraint_set_hookup;
43   s_xbt_swag_hookup_t active_constraint_set_hookup;
44   s_xbt_swag_hookup_t modified_constraint_set_hookup;
45   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
46
47   s_xbt_swag_t element_set;     /* a list of lmm_element_t */
48   s_xbt_swag_t active_element_set;      /* a list of lmm_element_t */
49   double remaining;
50   double usage;
51   double bound;
52   int sharing_policy; /* see @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
53   void *id;
54   int id_int;
55   double lambda;
56   double new_lambda;
57   lmm_constraint_light_t cnst_light;
58 } s_lmm_constraint_t;
59
60 /** @ingroup SURF_lmm
61  * @brief LMM variable
62  */
63 typedef struct lmm_variable {
64   /* hookup to system */
65   s_xbt_swag_hookup_t variable_set_hookup;
66   s_xbt_swag_hookup_t saturated_variable_set_hookup;
67
68   s_lmm_element_t *cnsts;
69   int cnsts_size;
70   int cnsts_number;
71   double weight;
72   double bound;
73   double value;
74   void *id;
75   int id_int;
76   unsigned visited;             /* used by lmm_update_modified_set */
77   /* \begin{For Lagrange only} */
78   double mu;
79   double new_mu;
80   double (*func_f) (struct lmm_variable * var, double x);       /* (f)    */
81   double (*func_fp) (struct lmm_variable * var, double x);      /* (f')    */
82   double (*func_fpi) (struct lmm_variable * var, double x);     /* (f')^{-1}    */
83   /* \end{For Lagrange only} */
84 } s_lmm_variable_t;
85
86 /** @ingroup SURF_lmm
87  * @brief LMM system
88  */
89 typedef struct lmm_system {
90   int modified;
91   int selective_update_active;  /* flag to update partially the system only selecting changed portions */
92   unsigned visited_counter;     /* used by lmm_update_modified_set */
93   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
94   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
95
96   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
97   s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
98
99   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
100   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
101
102   simgrid::surf::ActionLmmListPtr keep_track;
103
104   xbt_mallocator_t variable_mallocator;
105 } s_lmm_system_t;
106
107 #define extract_variable(sys) xbt_swag_extract(&(sys->variable_set))
108 #define extract_constraint(sys) xbt_swag_extract(&(sys->constraint_set))
109 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
110 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
111                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
112 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
113                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
114 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
115 #define make_constraint_inactive(sys,cnst) \
116   do { xbt_swag_remove(cnst, &sys->active_constraint_set);              \
117     xbt_swag_remove(cnst, &sys->modified_constraint_set); } while (0)
118
119 /** @ingroup SURF_lmm
120  * @brief Print informations about a lmm system
121  * 
122  * @param sys A lmm system
123  */
124 XBT_PRIVATE void lmm_print(lmm_system_t sys);
125
126 extern XBT_PRIVATE double (*func_f_def) (lmm_variable_t, double);
127 extern XBT_PRIVATE double (*func_fp_def) (lmm_variable_t, double);
128 extern XBT_PRIVATE double (*func_fpi_def) (lmm_variable_t, double);
129
130 #endif                          /* _SURF_MAXMIN_PRIVATE_H */