Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : break forgotten in switch
[simgrid.git] / src / surf / maxmin_private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. 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 "surf/maxmin.h"
11 #include "xbt/swag.h"
12 #include "xbt/mallocator.h"
13
14 typedef struct lmm_element {
15   /* hookup to constraint */
16   s_xbt_swag_hookup_t element_set_hookup;
17   s_xbt_swag_hookup_t active_element_set_hookup;
18
19   lmm_constraint_t constraint;
20   lmm_variable_t variable;
21   double value;
22 } s_lmm_element_t;
23 #define make_elem_active(elem) xbt_swag_insert_at_head(elem,&(elem->constraint->active_element_set))
24 #define make_elem_inactive(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
25
26 typedef struct lmm_constraint {
27   /* hookup to system */
28   s_xbt_swag_hookup_t constraint_set_hookup;
29   s_xbt_swag_hookup_t active_constraint_set_hookup;
30   s_xbt_swag_hookup_t modified_constraint_set_hookup;
31   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
32
33   s_xbt_swag_t element_set;     /* a list of lmm_element_t */
34   s_xbt_swag_t active_element_set;      /* a list of lmm_element_t */
35   double bound;
36   double lambda;
37   double new_lambda;
38   double remaining;
39   double usage;
40   void *id;
41   int id_int;
42   int shared;
43 } s_lmm_constraint_t;
44
45 typedef struct lmm_variable {
46   /* hookup to system */
47   s_xbt_swag_hookup_t variable_set_hookup;
48   s_xbt_swag_hookup_t saturated_variable_set_hookup;
49
50   s_lmm_element_t *cnsts;
51   int cnsts_size;
52   int cnsts_number;
53   double weight;
54   double bound;
55   double value;
56   void *id;
57   int id_int;
58   unsigned visited;             /* used by lmm_update_modified_set */
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   unsigned visited_counter;     /* used by lmm_update_modified_set */
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_extract(&(sys->variable_set))
85 #define extract_constraint(sys) xbt_swag_extract(&(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 make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
92 #define make_constraint_inactive(sys,cnst) \
93   do { xbt_swag_remove(cnst, &sys->active_constraint_set);              \
94     xbt_swag_remove(cnst, &sys->modified_constraint_set); } while (0)
95
96 static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
97 static XBT_INLINE void lmm_cnst_free(lmm_system_t sys,
98                                      lmm_constraint_t cnst);
99
100 void lmm_print(lmm_system_t sys);
101
102 extern double (*func_f_def) (lmm_variable_t, double);
103 extern double (*func_fp_def) (lmm_variable_t, double);
104 extern double (*func_fpi_def) (lmm_variable_t, double);
105
106 #endif                          /* _SURF_MAXMIN_PRIVATE_H */