Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4a2950b6f8e2c3e5d7ba151ac2061ad98cfce9fd
[simgrid.git] / src / include / surf / maxmin.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_H
9 #define _SURF_MAXMIN_H
10
11 #include "portable.h"
12 #include "xbt/misc.h"
13
14 #define MAXMIN_PRECISION 0.00001
15 static XBT_INLINE void double_update(double *variable, double value) 
16 {
17   *variable -= value;
18   if(*variable< MAXMIN_PRECISION) *variable = 0.0;
19 }
20
21 static XBT_INLINE int double_positive(double value) 
22 {
23   return (value>MAXMIN_PRECISION);
24 }
25
26 typedef struct lmm_element *lmm_element_t;
27 typedef struct lmm_variable *lmm_variable_t;
28 typedef struct lmm_constraint *lmm_constraint_t;
29 typedef struct lmm_system *lmm_system_t;
30
31 XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
32 XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
33 void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
34
35 XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
36                                     double bound_value);
37 void lmm_constraint_shared(lmm_constraint_t cnst);
38 int lmm_constraint_is_shared(lmm_constraint_t cnst);
39
40 void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
41
42 XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
43                                 double weight_value,
44                                 double bound, int number_of_constraints);
45 void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
46 XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
47 XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
48 XBT_PUBLIC(double) lmm_variable_getdf(lmm_variable_t var);
49
50 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
51                 lmm_variable_t var, double value);
52 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
53                     lmm_variable_t var, double value);
54 void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
55                         lmm_variable_t var, double value);
56
57 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
58                                        lmm_variable_t var, int num);
59 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
60 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
61                                      lmm_constraint_t cnst,
62                                      lmm_element_t * elem);
63
64 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
65 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
66
67 void *lmm_constraint_id(lmm_constraint_t cnst);
68 void *lmm_variable_id(lmm_variable_t var);
69
70 void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
71                 lmm_variable_t var, double value);
72 void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
73                                double bound);
74
75
76 XBT_PUBLIC(void) lmm_update_variable_latency(lmm_system_t sys, lmm_variable_t var,
77                                  double delta);
78
79
80
81 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
82                                 double weight);
83 double lmm_get_variable_weight(lmm_variable_t var);
84
85 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
86                                  double bound);
87
88 int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
89
90
91 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
92
93 #ifdef HAVE_SDP
94 XBT_PUBLIC(void) sdp_solve(lmm_system_t sys);
95 #endif /* HAVE_SDP */
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)  (lmm_variable_t var, double x),
106                                        double (* func_fp) (lmm_variable_t var, double x),
107                                        double (* func_fpi)(lmm_variable_t var, double x));
108
109 XBT_PUBLIC(double func_reno_f)  (lmm_variable_t var, double x);
110 XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
111 XBT_PUBLIC(double func_reno_fpi)(lmm_variable_t var, double x);
112
113 XBT_PUBLIC(double func_reno2_f)  (lmm_variable_t var, double x);
114 XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
115 XBT_PUBLIC(double func_reno2_fpi)(lmm_variable_t var, double x);
116
117 XBT_PUBLIC(double func_vegas_f)  (lmm_variable_t var, double x);
118 XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
119 XBT_PUBLIC(double func_vegas_fpi)(lmm_variable_t var, double x);
120
121
122 #endif                          /* _SURF_MAXMIN_H */