Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
If a system has not been modified between two successive calls to lmm_solve,
[simgrid.git] / src / surf / maxmin_private.h
1 /* Authors: Arnaud Legrand                                                  */
2
3 /* This program is free software; you can redistribute it and/or modify it
4    under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef _SURF_MAXMIN_PRIVATE_H
7 #define _SURF_MAXMIN_PRIVATE_H
8
9 #include "surf/maxmin.h"
10 #include "xbt/swag.h"
11
12 typedef struct lmm_element {
13   /* hookup to constraint */
14   s_xbt_swag_hookup_t element_set_hookup;
15   s_xbt_swag_hookup_t active_element_set_hookup;
16
17   lmm_constraint_t constraint;
18   lmm_variable_t variable;
19   xbt_maxmin_float_t value;
20 } s_lmm_element_t, *lmm_element_t;
21 #define insert_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->element_set))
22 #define insert_active_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->active_element_set))
23 #define remove_active_elem_in_constraint(elem) xbt_swag_remove(elem,&(elem->constraint->active_element_set))
24
25 typedef struct lmm_constraint {
26   /* hookup to system */
27   s_xbt_swag_hookup_t constraint_set_hookup;
28   s_xbt_swag_hookup_t active_constraint_set_hookup;
29   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
30
31   s_xbt_swag_t element_set;     /* a list of lmm_mat_element_t */
32   s_xbt_swag_t active_element_set;      /* a list of lmm_mat_element_t */
33   xbt_maxmin_float_t bound;
34   xbt_maxmin_float_t remaining;
35   xbt_maxmin_float_t usage;
36   void *id;
37 } s_lmm_constraint_t;
38
39 typedef struct lmm_variable {
40   /* hookup to system */
41   s_xbt_swag_hookup_t variable_set_hookup;
42   s_xbt_swag_hookup_t saturated_variable_set_hookup;
43
44   s_lmm_element_t *cnsts;
45   int cnsts_size;
46   int cnsts_number;
47   xbt_maxmin_float_t weight;
48   xbt_maxmin_float_t bound;
49   xbt_maxmin_float_t value;
50   void *id;
51 } s_lmm_variable_t;
52
53 typedef struct lmm_system {
54   int modified;
55   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
56   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
57
58   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
59
60   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
61   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
62 } s_lmm_system_t;
63
64 #define extract_variable(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->variable_set)),&(sys->variable_set))
65 #define extract_constraint(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->constraint_set)),&(sys->constraint_set))
66 #define insert_variable(sys,var) xbt_swag_insert(var,&(sys->variable_set))
67 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
68 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
69                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
70 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
71                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
72 #define remove_active_constraint(sys,cnst) xbt_swag_remove(cnst,&(sys->active_constraint_set))
73 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
74 #define make_constraint_inactive(sys,cnst) remove_active_constraint(sys,cnst)
75
76 static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
77 static void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
78
79 #endif                          /* _SURF_MAXMIN_PRIVATE_H */