Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a new "max-min" like sharing for parallel tasks.
[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 "xbt/misc.h"
12 #include "portable.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_variable *lmm_variable_t;
27 typedef struct lmm_constraint *lmm_constraint_t;
28 typedef struct lmm_system *lmm_system_t;
29
30 XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
31 XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
32 void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
33
34 XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
35                                     double bound_value);
36 void lmm_constraint_shared(lmm_constraint_t cnst);
37
38 void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
39
40 XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
41                                 double weight_value,
42                                 double bound, int number_of_constraints);
43 void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
44 XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
45
46 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
47                 lmm_variable_t var, double value);
48 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
49                     lmm_variable_t var, double value);
50 void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
51                         lmm_variable_t var, double value);
52
53 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
54                                        lmm_variable_t var, int num);
55 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
56 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
57                                      lmm_constraint_t cnst,
58                                      lmm_variable_t * var);
59
60 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
61 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
62
63 void *lmm_constraint_id(lmm_constraint_t cnst);
64 void *lmm_variable_id(lmm_variable_t var);
65
66 void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
67                 lmm_variable_t var, double value);
68 void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
69                                double bound);
70
71
72 XBT_PUBLIC(void) lmm_update_variable_latency(lmm_system_t sys, lmm_variable_t var,
73                                  double delta);
74
75
76
77 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
78                                 double weight);
79 double lmm_get_variable_weight(lmm_variable_t var);
80
81 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
82                                  double bound);
83
84 int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
85
86
87 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
88
89 #ifdef HAVE_SDP
90 XBT_PUBLIC(void) sdp_solve(lmm_system_t sys);
91 #endif /* HAVE_SDP */
92
93 XBT_PUBLIC(void) lagrange_solve(lmm_system_t sys);
94 XBT_PUBLIC(void) bottleneck_solve(lmm_system_t sys);
95
96 /**
97  * Default functions associated to the chosen protocol. When
98  * using the lagrangian approach.
99  */
100
101 XBT_PUBLIC(void) lmm_set_default_protocol_function(double (* func_f)  (lmm_variable_t var, double x),
102                                        double (* func_fp) (lmm_variable_t var, double x),
103                                        double (* func_fpi)(lmm_variable_t var, double x));
104
105 double func_reno_f  (lmm_variable_t var, double x);
106 double func_reno_fp (lmm_variable_t var, double x);
107 double func_reno_fpi(lmm_variable_t var, double x);
108
109 double func_vegas_f  (lmm_variable_t var, double x);
110 double func_vegas_fp (lmm_variable_t var, double x);
111 double func_vegas_fpi(lmm_variable_t var, double x);
112
113
114 #endif                          /* _SURF_MAXMIN_H */