Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compilation broken.
[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 1e-9
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
71      XBT_PUBLIC(int) lmm_is_variable_limited_by_latency(lmm_variable_t var);
72
73      void *lmm_constraint_id(lmm_constraint_t cnst);
74      void *lmm_variable_id(lmm_variable_t var);
75
76      void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
77                      lmm_variable_t var, double value);
78      void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
79                                     double bound);
80
81
82 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys,
83                                             lmm_variable_t var,
84                                             double weight);
85      double lmm_get_variable_weight(lmm_variable_t var);
86
87 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys,
88                                              lmm_constraint_t cnst,
89                                              double bound);
90
91      int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
92
93
94 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
95
96 XBT_PUBLIC(void) lagrange_solve(lmm_system_t sys);
97 XBT_PUBLIC(void) bottleneck_solve(lmm_system_t sys);
98
99 /**
100  * Default functions associated to the chosen protocol. When
101  * using the lagrangian approach.
102  */
103
104 XBT_PUBLIC(void) lmm_set_default_protocol_function(double (*func_f)
105                                                    (lmm_variable_t var, double x),
106                                                    double (*func_fp)
107                                                    (lmm_variable_t var, double x),
108                                                    double (*func_fpi)
109                                                    (lmm_variable_t var, double x));
110
111 XBT_PUBLIC(double func_reno_f) (lmm_variable_t var, double x);
112 XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
113 XBT_PUBLIC(double func_reno_fpi) (lmm_variable_t var, double x);
114
115 XBT_PUBLIC(double func_reno2_f) (lmm_variable_t var, double x);
116 XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
117 XBT_PUBLIC(double func_reno2_fpi) (lmm_variable_t var, double x);
118
119 XBT_PUBLIC(double func_vegas_f) (lmm_variable_t var, double x);
120 XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
121 XBT_PUBLIC(double func_vegas_fpi) (lmm_variable_t var, double x);
122
123
124 #endif /* _SURF_MAXMIN_H */