Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SDP compiling now, added header portable.h to header file and sdp.
[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
39 void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
40
41 XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
42                                 double weight_value,
43                                 double bound, int number_of_constraints);
44 void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
45 XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
46 XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
47
48 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
49                 lmm_variable_t var, double value);
50 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
51                     lmm_variable_t var, double value);
52 void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
53                         lmm_variable_t var, double value);
54
55 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
56                                        lmm_variable_t var, int num);
57 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
58 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
59                                      lmm_constraint_t cnst,
60                                      lmm_element_t * elem);
61
62 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
63 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
64
65 void *lmm_constraint_id(lmm_constraint_t cnst);
66 void *lmm_variable_id(lmm_variable_t var);
67
68 void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
69                 lmm_variable_t var, double value);
70 void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
71                                double bound);
72
73
74 XBT_PUBLIC(void) lmm_update_variable_latency(lmm_system_t sys, lmm_variable_t var,
75                                  double delta);
76
77
78
79 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
80                                 double weight);
81 double lmm_get_variable_weight(lmm_variable_t var);
82
83 XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst,
84                                  double bound);
85
86 int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
87
88
89 XBT_PUBLIC(void) lmm_solve(lmm_system_t sys);
90
91 #ifdef HAVE_SDP
92 XBT_PUBLIC(void) sdp_solve(lmm_system_t sys);
93 #endif /* HAVE_SDP */
94
95 XBT_PUBLIC(void) lagrange_solve(lmm_system_t sys);
96 XBT_PUBLIC(void) bottleneck_solve(lmm_system_t sys);
97
98 /**
99  * Default functions associated to the chosen protocol. When
100  * using the lagrangian approach.
101  */
102
103 XBT_PUBLIC(void) lmm_set_default_protocol_function(double (* func_f)  (lmm_variable_t var, double x),
104                                        double (* func_fp) (lmm_variable_t var, double x),
105                                        double (* func_fpi)(lmm_variable_t var, double x));
106
107 XBT_PUBLIC(double func_reno_f)  (lmm_variable_t var, double x);
108 XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
109 XBT_PUBLIC(double func_reno_fpi)(lmm_variable_t var, double x);
110
111 XBT_PUBLIC(double func_reno2_f)  (lmm_variable_t var, double x);
112 XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
113 XBT_PUBLIC(double func_reno2_fpi)(lmm_variable_t var, double x);
114
115 XBT_PUBLIC(double func_vegas_f)  (lmm_variable_t var, double x);
116 XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
117 XBT_PUBLIC(double func_vegas_fpi)(lmm_variable_t var, double x);
118
119
120 #endif                          /* _SURF_MAXMIN_H */