Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
isolating latency bounded functions with ifdef's
[simgrid.git] / src / include / surf / maxmin.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_H
8 #define _SURF_MAXMIN_H
9
10 #include <math.h>
11 #include "portable.h"
12 #include "xbt/misc.h"
13 #include "surf/datatypes.h"
14
15 #define MAXMIN_PRECISION 0.00001
16 static XBT_INLINE void double_update(double *variable, double value)
17 {
18   *variable -= value;
19   if (*variable < MAXMIN_PRECISION)
20     *variable = 0.0;
21 }
22
23 static XBT_INLINE int double_positive(double value)
24 {
25   return (value > MAXMIN_PRECISION);
26 }
27
28 static XBT_INLINE int double_equals(double value1, double value2)
29 {
30   return (fabs(value1 - value2) < MAXMIN_PRECISION);
31 }
32
33 XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
34 XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
35      void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
36
37 XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
38                                                 double bound_value);
39      void lmm_constraint_shared(lmm_constraint_t cnst);
40      int lmm_constraint_is_shared(lmm_constraint_t cnst);
41
42      void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
43
44 XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
45                                             double weight_value,
46                                             double bound,
47                                             int number_of_constraints);
48      void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
49 XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
50 XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
51
52 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
53                             lmm_variable_t var, double value);
54      void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
55                          lmm_variable_t var, double value);
56      void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
57                              lmm_variable_t var, double value);
58
59      lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
60                                             lmm_variable_t var, int num);
61      int lmm_get_number_of_cnst_from_var(lmm_system_t sys,
62                                          lmm_variable_t var);
63      lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
64                                           lmm_constraint_t cnst,
65                                           lmm_element_t * elem);
66
67      lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
68      lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys,
69                                                      lmm_constraint_t cnst);
70 #ifdef HAVE_LATENCY_BOUND_TRACKING
71      XBT_PUBLIC(int) lmm_is_variable_limited_by_latency(lmm_variable_t var);
72 #endif
73
74      void *lmm_constraint_id(lmm_constraint_t cnst);
75      void *lmm_variable_id(lmm_variable_t var);
76
77      void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
78                      lmm_variable_t var, double value);
79      void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
80                                     double bound);
81
82
83 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys,
84                                             lmm_variable_t var,
85                                             double weight);
86      double lmm_get_variable_weight(lmm_variable_t var);
87
88 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys,
89                                              lmm_constraint_t cnst,
90                                              double bound);
91
92      int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
93
94
95 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
96
97 XBT_PUBLIC(void) lagrange_solve(lmm_system_t sys);
98 XBT_PUBLIC(void) bottleneck_solve(lmm_system_t sys);
99
100 /**
101  * Default functions associated to the chosen protocol. When
102  * using the lagrangian approach.
103  */
104
105 XBT_PUBLIC(void) lmm_set_default_protocol_function(double (*func_f)
106                                                    (lmm_variable_t var, double x),
107                                                    double (*func_fp)
108                                                    (lmm_variable_t var, double x),
109                                                    double (*func_fpi)
110                                                    (lmm_variable_t var, double x));
111
112 XBT_PUBLIC(double func_reno_f) (lmm_variable_t var, double x);
113 XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
114 XBT_PUBLIC(double func_reno_fpi) (lmm_variable_t var, double x);
115
116 XBT_PUBLIC(double func_reno2_f) (lmm_variable_t var, double x);
117 XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
118 XBT_PUBLIC(double func_reno2_fpi) (lmm_variable_t var, double x);
119
120 XBT_PUBLIC(double func_vegas_f) (lmm_variable_t var, double x);
121 XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
122 XBT_PUBLIC(double func_vegas_fpi) (lmm_variable_t var, double x);
123
124
125 #endif /* _SURF_MAXMIN_H */