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 / maxmin_private.h
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 #ifndef _SURF_MAXMIN_PRIVATE_H
9 #define _SURF_MAXMIN_PRIVATE_H
10
11 #include "surf/maxmin.h"
12 #include "xbt/swag.h"
13 #include "xbt/mallocator.h"
14
15 typedef struct lmm_element {
16   /* hookup to constraint */
17   s_xbt_swag_hookup_t element_set_hookup;
18   s_xbt_swag_hookup_t active_element_set_hookup;
19
20   lmm_constraint_t constraint;
21   lmm_variable_t variable;
22   double value;
23 } s_lmm_element_t;
24 #define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
25 #define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
26
27 typedef struct lmm_constraint {
28   /* hookup to system */
29   s_xbt_swag_hookup_t constraint_set_hookup;
30   s_xbt_swag_hookup_t active_constraint_set_hookup;
31   s_xbt_swag_hookup_t modified_constraint_set_hookup;
32   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
33
34   s_xbt_swag_t element_set;     /* a list of lmm_mat_element_t */
35   s_xbt_swag_t active_element_set;      /* a list of lmm_mat_element_t */
36   double bound;
37   double lambda;
38   double new_lambda;
39   double remaining;
40   int shared;
41   double usage;
42   void *id;
43   int id_int;
44 } s_lmm_constraint_t;
45
46 typedef struct lmm_variable {
47   /* hookup to system */
48   s_xbt_swag_hookup_t variable_set_hookup;
49   s_xbt_swag_hookup_t saturated_variable_set_hookup;
50
51   s_lmm_element_t *cnsts;
52   int cnsts_size;
53   int cnsts_number;
54   double weight;
55   double bound;
56   double value;
57   void *id;
58   int id_int;
59   /* \begin{For Lagrange only} */
60   double mu;
61   double new_mu;
62   double (*func_f) (struct lmm_variable * var, double x);       /* (f)    */
63   double (*func_fp) (struct lmm_variable * var, double x);      /* (f')    */
64   double (*func_fpi) (struct lmm_variable * var, double x);     /* (f')^{-1}    */
65   /* \end{For Lagrange only} */
66 } s_lmm_variable_t;
67
68 typedef struct lmm_system {
69   int modified;
70   int selective_update_active;  /* flag to update partially the system only selecting changed portions */
71
72   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
73   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
74
75   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
76   s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
77
78   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
79   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
80
81   xbt_mallocator_t variable_mallocator;
82 } s_lmm_system_t;
83
84 #define extract_variable(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->variable_set)),&(sys->variable_set))
85 #define extract_constraint(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->constraint_set)),&(sys->constraint_set))
86 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
87 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
88                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
89 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
90                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
91 #define remove_active_constraint(sys,cnst) xbt_swag_remove(cnst,&(sys->active_constraint_set))
92 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
93 #define make_constraint_inactive(sys,cnst) remove_active_constraint(sys,cnst)
94
95 static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
96 static XBT_INLINE void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
97
98 void lmm_print(lmm_system_t sys);
99
100 extern double (*func_f_def) (lmm_variable_t, double);
101 extern double (*func_fp_def) (lmm_variable_t, double);
102 extern double (*func_fpi_def) (lmm_variable_t, double);
103
104 #endif /* _SURF_MAXMIN_PRIVATE_H */