Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added the update for the Df parameter (lmm_variable_t), which means the sum of all
[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 static XBT_INLINE void double_update(double *variable, double value) 
14 {
15   *variable -= value;
16   if(*variable< 0.00001) *variable = 0.0;
17 }
18
19 typedef struct lmm_variable *lmm_variable_t;
20 typedef struct lmm_constraint *lmm_constraint_t;
21 typedef struct lmm_system *lmm_system_t;
22
23 XBT_PUBLIC(lmm_system_t) lmm_system_new(void);
24 XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
25 void lmm_variable_disable(lmm_system_t sys, lmm_variable_t var);
26
27 XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void *id,
28                                     double bound_value);
29 void lmm_constraint_shared(lmm_constraint_t cnst);
30
31 void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
32
33 XBT_PUBLIC(lmm_variable_t) lmm_variable_new(lmm_system_t sys, void *id,
34                                 double weight_value,
35                                 double bound, int number_of_constraints);
36 void lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
37 XBT_PUBLIC(double) lmm_variable_getvalue(lmm_variable_t var);
38
39
40 XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
41                 lmm_variable_t var, double value);
42 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
43                     lmm_variable_t var, double value);
44 void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
45                         lmm_variable_t var, double value);
46
47 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t sys,
48                                        lmm_variable_t var, int num);
49 int lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
50 lmm_variable_t lmm_get_var_from_cnst(lmm_system_t sys,
51                                      lmm_constraint_t cnst,
52                                      lmm_variable_t * var);
53
54 lmm_constraint_t lmm_get_first_active_constraint(lmm_system_t sys);
55 lmm_constraint_t lmm_get_next_active_constraint(lmm_system_t sys, lmm_constraint_t cnst);
56
57 void *lmm_constraint_id(lmm_constraint_t cnst);
58 void *lmm_variable_id(lmm_variable_t var);
59
60 void lmm_update(lmm_system_t sys, lmm_constraint_t cnst,
61                 lmm_variable_t var, double value);
62 void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
63                                double bound);
64
65 /** \brief Add the value delta to var->df the sum of latencys.
66  * 
67  *  \param sys the lmm_system_t
68  *  \param var the lmm_variable_t
69  * 
70  *  Add the value delta to var->df (the sum of latencys associated to the
71  *  flow). Whenever this function is called a change is  signed in the system. To
72  *  avoid false system changing detection it is a good idea to test 
73  *  (delta != 0) before calling it.
74  *
75  */
76 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 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 void sdp_solve(lmm_system_t sys);
95 #endif /* HAVE_SDP */
96
97 void lagrange_solve(lmm_system_t sys);
98
99 void lagrange_dicotomi_solve(lmm_system_t sys);
100
101 #endif                          /* _SURF_MAXMIN_H */