Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CpuCas01 in C++
[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 "surf/solver.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_light {
28   double remaining_over_usage;
29   lmm_constraint_t cnst;
30 } s_lmm_constraint_light_t;
31
32 typedef struct lmm_constraint {
33   /* hookup to system */
34   s_xbt_swag_hookup_t constraint_set_hookup;
35   s_xbt_swag_hookup_t active_constraint_set_hookup;
36   s_xbt_swag_hookup_t modified_constraint_set_hookup;
37   s_xbt_swag_hookup_t saturated_constraint_set_hookup;
38
39   s_xbt_swag_t element_set;     /* a list of lmm_element_t */
40   s_xbt_swag_t active_element_set;      /* a list of lmm_element_t */
41   double remaining;
42   double usage;
43   double bound;
44   int shared;
45   void *id;
46   int id_int;
47   double lambda;
48   double new_lambda;
49   lmm_constraint_light_t cnst_light;
50 } s_lmm_constraint_t;
51
52 typedef struct lmm_variable {
53   /* hookup to system */
54   s_xbt_swag_hookup_t variable_set_hookup;
55   s_xbt_swag_hookup_t saturated_variable_set_hookup;
56
57   s_lmm_element_t *cnsts;
58   int cnsts_size;
59   int cnsts_number;
60   double weight;
61   double bound;
62   double value;
63   void *id;
64   int id_int;
65   unsigned visited;             /* used by lmm_update_modified_set */
66   /* \begin{For Lagrange only} */
67   double mu;
68   double new_mu;
69   double (*func_f) (struct lmm_variable * var, double x);       /* (f)    */
70   double (*func_fp) (struct lmm_variable * var, double x);      /* (f')    */
71   double (*func_fpi) (struct lmm_variable * var, double x);     /* (f')^{-1}    */
72   /* \end{For Lagrange only} */
73 } s_lmm_variable_t;
74
75 typedef struct lmm_system {
76   int modified;
77   int selective_update_active;  /* flag to update partially the system only selecting changed portions */
78   unsigned visited_counter;     /* used by lmm_update_modified_set */
79   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
80   s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
81
82   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
83   s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
84
85   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
86   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
87
88   xbt_swag_t keep_track;
89
90   xbt_mallocator_t variable_mallocator;
91 } s_lmm_system_t;
92
93 #define extract_variable(sys) xbt_swag_extract(&(sys->variable_set))
94 #define extract_constraint(sys) xbt_swag_extract(&(sys->constraint_set))
95 #define insert_constraint(sys,cnst) xbt_swag_insert(cnst,&(sys->constraint_set))
96 #define remove_variable(sys,var) do {xbt_swag_remove(var,&(sys->variable_set));\
97                                  xbt_swag_remove(var,&(sys->saturated_variable_set));} while(0)
98 #define remove_constraint(sys,cnst) do {xbt_swag_remove(cnst,&(sys->constraint_set));\
99                                         xbt_swag_remove(cnst,&(sys->saturated_constraint_set));} while(0)
100 #define make_constraint_active(sys,cnst) xbt_swag_insert(cnst,&(sys->active_constraint_set))
101 #define make_constraint_inactive(sys,cnst) \
102   do { xbt_swag_remove(cnst, &sys->active_constraint_set);              \
103     xbt_swag_remove(cnst, &sys->modified_constraint_set); } while (0)
104
105 void lmm_print(lmm_system_t sys);
106
107 extern double (*func_f_def) (lmm_variable_t, double);
108 extern double (*func_fp_def) (lmm_variable_t, double);
109 extern double (*func_fpi_def) (lmm_variable_t, double);
110
111 #endif                          /* _SURF_MAXMIN_PRIVATE_H */