Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Max-min solver written ! :) Seems to be working fine !
[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 #include "surf/maxmin.h"
7 #include "xbt/swag.h"
8
9 typedef struct lmm_element {
10   /* hookup to constraint */
11   s_xbt_swag_hookup_t element_set_hookup;
12   s_xbt_swag_hookup_t active_element_set_hookup;
13
14   lmm_constraint_t constraint;
15   lmm_variable_t variable;
16   FLOAT value;  
17 } s_lmm_element_t, *lmm_element_t;
18 #define insert_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->element_set))
19 #define insert_active_elem_in_constraint(elem) xbt_swag_insert(elem,&(elem->constraint->active_element_set))
20 #define remove_active_elem_in_constraint(elem) xbt_swag_extract(elem,&(elem->constraint->active_element_set))
21
22 typedef struct lmm_constraint {
23   /* hookup to system */
24   s_xbt_swag_hookup_t constraint_set_hookup;
25   s_xbt_swag_hookup_t active_constraint_set_hookup;
26   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
27
28   s_xbt_swag_t element_set;     /* a list of lmm_mat_element_t */
29   s_xbt_swag_t active_element_set;      /* a list of lmm_mat_element_t */
30   FLOAT bound;
31   FLOAT remaining;
32   FLOAT usage;
33   char *id;
34 } s_lmm_constraint_t;
35
36 typedef struct lmm_variable {
37   /* hookup to system */
38   s_xbt_swag_hookup_t variable_set_hookup;
39   s_xbt_swag_hookup_t saturated_variable_set_hookup;
40
41   s_lmm_element_t *cnsts;
42   int cnsts_size;
43   int cnsts_number;
44   FLOAT weight;
45   FLOAT bound;
46   FLOAT value;
47   char *id;
48 } s_lmm_variable_t;
49
50 typedef struct lmm_system {
51   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
52   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
53
54   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
55
56   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
57   s_xbt_swag_t saturated_constraint_set;/* a list of lmm_constraint_t_t */
58 } s_lmm_system_t;
59
60 #define extract_variable(sys) xbt_swag_extract(xbt_swag_getFirst(&(sys->variable_set)),&(sys->variable_set))
61 #define extract_constraint(sys) xbt_swag_extract(xbt_swag_getFirst(&(sys->constraint_set)),&(sys->constraint_set))
62 #define insert_variable(sys,var) xbt_swag_insert(var,&(sys->variable_set))
63 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
64 #define remove_variable(sys,var) do {xbt_swag_extract(var,&(sys->variable_set));\
65                                  xbt_swag_extract(var,&(sys->saturated_variable_set));} while(0)
66 #define remove_constraint(sys,cnst) do {xbt_swag_extract(cnst,&(sys->constraint_set));\
67                                         xbt_swag_extract(cnst,&(sys->saturated_constraint_set));} while(0)
68 #define remove_active_constraint(sys,cnst) xbt_swag_extract(cnst,&(sys->active_constraint_set))
69 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
70 #define make_constraint_inactive(sys,cnst) remove_active_constraint(sys,cnst)
71
72 static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
73 static void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
74
75 /* #define UNDEFINED_VALUE -1.0 */
76 #define UNUSED_CONSTRAINT -2.0