Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the trace library and fixed a few source of potential bugs in heap.
[simgrid.git] / testsuite / surf / maxmin_usage.c
1 /* A few tests for the maxmin library                                       */
2
3 /* Authors: Arnaud Legrand                                                  */
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 #include <stdlib.h>
9 #include <stdio.h>
10 #include "surf/maxmin.h"
11
12 /*                               */
13 /*        ______                 */
14 /*  ==l1==  L2  ==L3==           */
15 /*        ------                 */
16 /*                               */
17
18   lmm_system_t Sys = NULL ;
19   lmm_constraint_t L1 = NULL;
20   lmm_constraint_t L2 = NULL;
21   lmm_constraint_t L3 = NULL;
22
23   lmm_variable_t R_1_2_3 = NULL;
24   lmm_variable_t R_1 = NULL;
25   lmm_variable_t R_2 = NULL;
26   lmm_variable_t R_3 = NULL;
27
28 void test(void);
29 void test(void)
30 {
31
32   Sys = lmm_system_new();
33   L1 = lmm_constraint_new(Sys, (void *) "L1", 1.0);
34   L2 = lmm_constraint_new(Sys, (void *) "L2", 10.0);
35   L3 = lmm_constraint_new(Sys, (void *) "L3", 1.0);
36
37   R_1_2_3 = lmm_variable_new(Sys, (void *) "R 1->2->3", 1.0 , -1.0 , 3);
38   R_1 = lmm_variable_new(Sys, (void *) "R 1", 1.0 , -1.0 , 1);
39   R_2 = lmm_variable_new(Sys, (void *) "R 2", 1.0 , -1.0 , 1);
40   R_3 = lmm_variable_new(Sys, (void *) "R 3", 1.0 , -1.0 , 1);
41
42   lmm_expand(Sys, L1, R_1_2_3, 1.0);
43   lmm_expand(Sys, L2, R_1_2_3, 1.0);
44   lmm_expand(Sys, L3, R_1_2_3, 1.0);
45
46   lmm_expand(Sys, L1, R_1, 1.0);
47
48   lmm_expand(Sys, L2, R_2, 1.0);
49
50   lmm_expand(Sys, L3, R_3, 1.0);
51
52 #define AFFICHE(var) printf(#var " = %Lg\n",lmm_variable_getvalue(var));
53   AFFICHE(R_1_2_3);
54   AFFICHE(R_1);
55   AFFICHE(R_2);
56   AFFICHE(R_3);
57
58   printf("\n");
59   lmm_solve(Sys);
60
61   AFFICHE(R_1_2_3);
62   AFFICHE(R_1);
63   AFFICHE(R_2);
64   AFFICHE(R_3);
65   printf("\n");
66
67
68   lmm_update_variable_weight(R_1_2_3,.5);
69   lmm_solve(Sys);
70
71   AFFICHE(R_1_2_3);
72   AFFICHE(R_1);
73   AFFICHE(R_2);
74   AFFICHE(R_3);
75 #undef AFFICHE
76
77   lmm_system_free(Sys);
78
79
80
81 int main(int argc, char **argv)
82 {
83   test();
84   return 0;
85 }