Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stupid me! Bug fix in the maxmin algorithm (occurs only when using
[simgrid.git] / testsuite / surf / sdp_usage.c
1 /*      $Id$     */
2
3 /* A few tests for the maxmin library                                       */
4
5 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #ifdef __BORLANDC__
11 #pragma hdrstop
12 #endif
13
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include "surf/maxmin.h"
17
18 #include "xbt/log.h"
19 #include "xbt/module.h"
20 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
21
22 #define PRINT_VAR(var) DEBUG1(#var " = %g\n",lmm_variable_getvalue(var));
23
24 /*                               */
25 /*        ______                 */
26 /*  ==l1==  L2  ==L3==           */
27 /*        ------                 */
28 /*                               */
29
30 void test(void);
31 void test(void)
32 {
33   lmm_system_t Sys = NULL ;
34   lmm_constraint_t L1 = NULL;
35   lmm_constraint_t L2 = NULL;
36   lmm_constraint_t L3 = NULL;
37
38   lmm_variable_t R_1_2_3 = NULL;
39   lmm_variable_t R_1 = NULL;
40   lmm_variable_t R_2 = NULL;
41   lmm_variable_t R_3 = NULL;
42
43   Sys = lmm_system_new();
44   L1 = lmm_constraint_new(Sys, (void *) "L1", 1.0);
45   L2 = lmm_constraint_new(Sys, (void *) "L2", 10.0);
46   L3 = lmm_constraint_new(Sys, (void *) "L3", 1.0);
47
48   R_1_2_3 = lmm_variable_new(Sys, (void *) "R 1->2->3", 1.0 , -1.0 , 3);
49   R_1 = lmm_variable_new(Sys, (void *) "R 1", 1.0 , -1.0 , 1);
50   R_2 = lmm_variable_new(Sys, (void *) "R 2", 1.0 , -1.0 , 1);
51   R_3 = lmm_variable_new(Sys, (void *) "R 3", 1.0 , -1.0 , 1);
52
53   lmm_expand(Sys, L1, R_1_2_3, 1.0);
54   lmm_expand(Sys, L2, R_1_2_3, 1.0);
55   lmm_expand(Sys, L3, R_1_2_3, 1.0);
56
57   lmm_expand(Sys, L1, R_1, 1.0);
58
59   lmm_expand(Sys, L2, R_2, 1.0);
60
61   lmm_expand(Sys, L3, R_3, 1.0);
62
63   PRINT_VAR(R_1_2_3);
64   PRINT_VAR(R_1);
65   PRINT_VAR(R_2);
66   PRINT_VAR(R_3);
67
68   DEBUG0("\n");
69   lmm_solve(Sys);
70
71   PRINT_VAR(R_1_2_3);
72   PRINT_VAR(R_1);
73   PRINT_VAR(R_2);
74   PRINT_VAR(R_3);
75   DEBUG0("\n");
76
77
78   lmm_update_variable_weight(Sys,R_1_2_3,.5);
79   sdp_solve(Sys);
80
81   PRINT_VAR(R_1_2_3);
82   PRINT_VAR(R_1);
83   PRINT_VAR(R_2);
84   PRINT_VAR(R_3);
85
86   lmm_system_free(Sys);
87
88
89 void test2(void);
90 void test2(void)
91 {
92 }
93
94 #ifdef __BORLANDC__
95 #pragma argsused
96 #endif
97
98 int main(int argc, char **argv)
99 {
100   xbt_init(&argc,argv);
101
102   DEBUG0("***** Test 1 ***** \n");
103   test();
104 /*   DEBUG0("***** Test 2 ***** \n"); */
105 /*   test2(); */
106
107   return 0;
108 }