Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update the double extern declaration bis
[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, *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 saturated_constraint_set_hookup;
32
33   s_xbt_swag_t element_set;     /* a list of lmm_mat_element_t */
34   s_xbt_swag_t active_element_set;      /* a list of lmm_mat_element_t */
35   double bound;
36   double remaining;
37   int shared;
38   double usage;
39   void *id;
40 } s_lmm_constraint_t;
41
42 typedef struct lmm_variable {
43   /* hookup to system */
44   s_xbt_swag_hookup_t variable_set_hookup;
45   s_xbt_swag_hookup_t saturated_variable_set_hookup;
46
47   s_lmm_element_t *cnsts;
48   int cnsts_size;
49   int cnsts_number;
50   double weight;
51   double bound;
52   double value;
53   void *id;
54   int index;
55 } s_lmm_variable_t;
56
57 typedef struct lmm_system {
58   int modified;
59   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
60   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
61
62   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
63
64   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
65   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
66
67   xbt_mallocator_t variable_mallocator;
68 } s_lmm_system_t;
69
70 #define extract_variable(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->variable_set)),&(sys->variable_set))
71 #define extract_constraint(sys) xbt_swag_remove(xbt_swag_getFirst(&(sys->constraint_set)),&(sys->constraint_set))
72 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
73 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
74                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
75 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
76                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
77 #define remove_active_constraint(sys,cnst) xbt_swag_remove(cnst,&(sys->active_constraint_set))
78 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
79 #define make_constraint_inactive(sys,cnst) remove_active_constraint(sys,cnst)
80
81 static void lmm_var_free(lmm_system_t sys, lmm_variable_t var);
82 static void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
83
84 void lmm_print(lmm_system_t sys);
85
86 #endif                          /* _SURF_MAXMIN_PRIVATE_H */