Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revert "Added a get Df function in order to implement beta*df during share_resources."
[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
49 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
50                 lmm_variable_t var, double value);
51 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
52                     lmm_variable_t var, double value);
53 void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
54                         lmm_variable_t var, double value);
55
56 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
57                                        lmm_variable_t var, int num);
58 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
59 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
60                                      lmm_constraint_t cnst,
61                                      lmm_element_t * elem);
62
63 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
64 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
65
66 void *lmm_constraint_id(lmm_constraint_t cnst);
67 void *lmm_variable_id(lmm_variable_t var);
68
69 void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
70                 lmm_variable_t var, double value);
71 void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
72                                double bound);
73
74
75 XBT_PUBLIC(void) lmm_update_variable_latency(lmm_system_t sys, lmm_variable_t var,
76                                  double delta);
77
78
79
80 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
81                                 double weight);
82 double lmm_get_variable_weight(lmm_variable_t var);
83
84 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
85                                  double bound);
86
87 int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
88
89
90 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
91
92 #ifdef HAVE_SDP
93 XBT_PUBLIC(void) sdp_solve(lmm_system_t sys);
94 #endif /* HAVE_SDP */
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)  (lmm_variable_t var, double x),
105                                        double (* func_fp) (lmm_variable_t var, double x),
106                                        double (* func_fpi)(lmm_variable_t var, double x));
107
108 XBT_PUBLIC(double func_reno_f)  (lmm_variable_t var, double x);
109 XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
110 XBT_PUBLIC(double func_reno_fpi)(lmm_variable_t var, double x);
111
112 XBT_PUBLIC(double func_reno2_f)  (lmm_variable_t var, double x);
113 XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
114 XBT_PUBLIC(double func_reno2_fpi)(lmm_variable_t var, double x);
115
116 XBT_PUBLIC(double func_vegas_f)  (lmm_variable_t var, double x);
117 XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
118 XBT_PUBLIC(double func_vegas_fpi)(lmm_variable_t var, double x);
119
120
121 #endif                          /* _SURF_MAXMIN_H */