Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Moving sdp tests in maxmin_usage (to have the same set of tests).
authorvelho <velho@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 14 Feb 2007 16:46:56 +0000 (16:46 +0000)
committervelho <velho@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 14 Feb 2007 16:46:56 +0000 (16:46 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3150 48e7efb5-ca39-0410-a469-dd3cf9ba447f

testsuite/Makefile.am
testsuite/surf/maxmin_usage.c
testsuite/surf/sdp_usage.c [deleted file]
testsuite/surf/surf_usage.c

index 067041a..bf66d9d 100644 (file)
@@ -1,5 +1,5 @@
 INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/src/include
-AM_CFLAGS=-g 
+AM_CFLAGS=-g
 
 CLEANFILES = *~ test a.out *.o gras/datadesc_usage.out datadesc_usage.out\
   testgraph.xml testgraph.dot
@@ -35,9 +35,9 @@ RL_tests =                                              \
 SG_tests =                                              \
        surf/maxmin_usage surf/maxmin_bench \
        surf/trace_usage surf/surf_usage surf/surf_usage2
-if HAVE_SDP
-  SG_tests+=surf/sdp_usage surf/sdp_bench
-endif
+#if HAVE_SDP
+#  SG_tests+=surf/sdp_usage
+#endif
 
 simdag_tests = simdag/sd_test
 
@@ -67,10 +67,10 @@ surf_maxmin_bench_LDADD=      $(LDADD_SG)
 surf_trace_usage_LDADD=       $(LDADD_SG)
 surf_surf_usage_LDADD=        $(LDADD_SG)
 surf_surf_usage2_LDADD=       $(LDADD_SG)
-if HAVE_SDP
-surf_sdp_usage_LDADD=         $(LDADD_SG)
-surf_sdp_bench_LDADD=         $(LDADD_SG)
-endif
+#if HAVE_SDP
+#surf_sdp_usage_LDADD=         $(LDADD_SG)
+#surf_sdp_bench_LDADD=         $(LDADD_SG)
+#endif
 
 gras_trp_tcp_client_LDADD=     $(LDADD_RL)
 gras_trp_tcp_server_LDADD=     $(LDADD_RL)
index a5f0798..d2946dc 100644 (file)
 #pragma hdrstop
 #endif
 
-#include <stdlib.h>
-#include <stdio.h>
+#include "xbt/sysdep.h"
 #include "surf/maxmin.h"
 
 #include "xbt/log.h"
 #include "xbt/module.h"
 XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
 
-#define PRINT_VAR(var) DEBUG1(#var " = %g\n",lmm_variable_getvalue(var));
+#define PRINT_VAR(var) DEBUG1(#var " = %g",lmm_variable_getvalue(var));
 
 /*                               */
 /*        ______                 */
@@ -27,8 +26,13 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
 /*        ------                 */
 /*                               */
 
-void test(void);
-void test(void)
+typedef enum {
+  MAXMIN,
+  SDP 
+} method_t;
+
+void test1(method_t method);
+void test1(method_t method)
 {
   lmm_system_t Sys = NULL ;
   lmm_constraint_t L1 = NULL;
@@ -66,28 +70,34 @@ void test(void)
   PRINT_VAR(R_3);
 
   DEBUG0("\n");
-  lmm_solve(Sys);
+  if(method==MAXMIN)
+    lmm_solve(Sys);
+#ifdef HAVE_SDP
+  else if(method==SDP)
+    sdp_solve(Sys);    
+#endif
+  else 
+    xbt_assert0(0,"Invalid method");
 
   PRINT_VAR(R_1_2_3);
   PRINT_VAR(R_1);
   PRINT_VAR(R_2);
   PRINT_VAR(R_3);
-  DEBUG0("\n");
+/*   DEBUG0("\n"); */
 
+/*   lmm_update_variable_weight(Sys,R_1_2_3,.5); */
+/*   lmm_solve(Sys); */
 
-  lmm_update_variable_weight(Sys,R_1_2_3,.5);
-  lmm_solve(Sys);
-
-  PRINT_VAR(R_1_2_3);
-  PRINT_VAR(R_1);
-  PRINT_VAR(R_2);
-  PRINT_VAR(R_3);
+/*   PRINT_VAR(R_1_2_3); */
+/*   PRINT_VAR(R_1); */
+/*   PRINT_VAR(R_2); */
+/*   PRINT_VAR(R_3); */
 
   lmm_system_free(Sys);
 } 
 
-void test2(void);
-void test2(void)
+void test2(method_t method);
+void test2(method_t method)
 {
   lmm_system_t Sys = NULL ;
   lmm_constraint_t CPU1 = NULL;
@@ -110,7 +120,14 @@ void test2(void)
   PRINT_VAR(T2);
 
   DEBUG0("\n");
-  lmm_solve(Sys);
+  if(method==MAXMIN)
+    lmm_solve(Sys);
+#ifdef HAVE_SDP
+  else if(method==SDP)
+    sdp_solve(Sys);    
+#endif
+  else 
+    xbt_assert0(0,"Invalid method");
 
   PRINT_VAR(T1);
   PRINT_VAR(T2);
@@ -120,6 +137,166 @@ void test2(void)
   lmm_system_free(Sys);
 }
 
+void test3(method_t method);
+void test3(method_t method)
+{
+  int flows=11;  //flows and conexions are synonnims ?
+  int links=10;  //topology info
+  
+  //just to be carefull
+  int i = 0;
+  int j = 0;
+
+  double **A;
+  A = (double **)calloc(links+5, sizeof(double));
+  for(i=0 ; i< links+5; i++){
+    A[i] = (double *)calloc(flows+5, sizeof(double));
+
+    for(j=0 ; j< flows+5; j++){
+      A[i][j] = 0.0;
+
+      if(i >= links || j >= flows){
+         A[i][j] = 0.0;
+      }
+    }
+  }
+
+  //matrix that store the constraints/topollogy
+  /*double A[15][16]=
+    {{0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,    0, 0, 0, 0, 0},
+     {0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0,    0, 0, 0, 0, 0},
+     {0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,    0, 0, 0, 0, 0},
+     {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,    0, 0, 0, 0, 0},
+     {1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0,    0, 0, 0, 0, 0},
+     {1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0,    0, 0, 0, 0, 0},
+     {1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,    0, 0, 0, 0, 0},
+     {0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1,    0, 0, 0, 0, 0},
+     {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,    0, 0, 0, 0, 0},
+     {0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0,    0, 0, 0, 0, 0},
+     
+     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    1, 0, 0, 0, 0},
+     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 1, 0, 0, 0},
+     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 1, 0, 0},
+     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 1, 0},
+     {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 1}
+     }; */
+
+  A[0][1]  = 1.0;
+  A[0][7]  = 1.0;
+  
+  A[1][1]  = 1.0;
+  A[1][7]  = 1.0;
+  A[1][8]  = 1.0;
+
+  A[2][1]  = 1.0;
+  A[2][8]  = 1.0;
+
+  A[2][1]  = 1.0;
+  A[2][8]  = 1.0;
+
+  A[3][8]  = 1.0;
+
+  A[4][0]  = 1.0;
+  A[4][3]  = 1.0;
+  A[4][9]  = 1.0;
+
+  A[5][0]  = 1.0;
+  A[5][3]  = 1.0;
+  A[5][4]  = 1.0;
+  A[5][9]  = 1.0;
+
+  A[6][0]  = 1.0;
+  A[6][4]  = 1.0;
+  A[6][9]  = 1.0;
+  A[6][10] = 1.0;
+
+  A[7][2]  = 1.0;
+  A[7][4]  = 1.0;
+  A[7][6]  = 1.0;
+  A[7][9]  = 1.0;
+  A[7][10] = 1.0;
+
+  A[8][2]  = 1.0;
+  A[8][10] = 1.0;
+
+  A[9][5]  = 1.0;
+  A[9][6]  = 1.0;
+  A[9][9]  = 1.0;
+
+  
+  A[10][11] = 1.0;
+  A[11][12] = 1.0;
+  A[12][13] = 1.0;
+  A[13][14] = 1.0;
+  A[14][15] = 1.0;
+
+  //array to add the the constraints of fictiv variables
+  double B[15] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+           1, 1, 1, 1, 1};
+
+
+  lmm_system_t Sys = NULL ;
+  lmm_constraint_t *tmp_cnst = NULL;
+  lmm_variable_t   *tmp_var  = NULL;
+  char tmp_name[13];
+
+
+  Sys = lmm_system_new();
+  
+  
+  /*
+   * Creates the constraints
+   */
+  tmp_cnst = calloc(15, sizeof(lmm_constraint_t));
+  for(i=0; i<15; i++){
+    sprintf(tmp_name, "C_%03d", i); 
+    tmp_cnst[i] = lmm_constraint_new(Sys, (void *) tmp_name, B[i]);
+  }
+
+
+  /*
+   * Creates the variables
+   */
+  tmp_var = calloc(16, sizeof(lmm_variable_t));
+  for(j=0; j<16; j++){
+    sprintf(tmp_name, "X_%03d", j); 
+    tmp_var[j] = lmm_variable_new(Sys, (void *) tmp_name, 1.0, -1.0 , 15);
+  }
+
+  /*
+   * Link constraints and variables
+   */
+  for(i=0;i<15;i++) { 
+    for(j=0; j<16; j++){
+      if(A[i][j]){
+       lmm_expand(Sys, tmp_cnst[i], tmp_var[j], 1.0); 
+      }
+    }
+  }
+
+  for(j=0; j<16; j++){
+    PRINT_VAR(tmp_var[j]);
+  }
+
+  if(method==MAXMIN)
+    lmm_solve(Sys);
+#ifdef HAVE_SDP
+  else if(method==SDP)
+    sdp_solve(Sys);    
+#endif
+  else 
+    xbt_assert0(0,"Invalid method");
+
+  for(j=0; j<16; j++){
+    PRINT_VAR(tmp_var[j]);
+  }
+
+  free(tmp_var);
+  free(tmp_cnst);
+  lmm_system_free(Sys);
+}
+
 #ifdef __BORLANDC__
 #pragma argsused
 #endif
@@ -128,10 +305,24 @@ int main(int argc, char **argv)
 {
   xbt_init(&argc,argv);
 
-  DEBUG0("***** Test 1 ***** \n");
-  test();
-  DEBUG0("***** Test 2 ***** \n");
-  test2();
+  DEBUG0("***** Test 1 (Max-Min) ***** \n");
+  test1(MAXMIN);
+#ifdef HAVE_SDP
+  DEBUG0("***** Test 1 (SDP) ***** \n");
+  test1(SDP);
+#endif
+  DEBUG0("***** Test 2 (Max-Min) ***** \n");
+  test2(MAXMIN);
+#ifdef HAVE_SDP
+  DEBUG0("***** Test 2 (SDP) ***** \n");
+  test2(SDP);
+#endif
+  DEBUG0("***** Test 3 (Max-Min) ***** \n");
+  test3(MAXMIN);
+#ifdef HAVE_SDP
+  DEBUG0("***** Test 3 (SDP) ***** \n");
+  test3(SDP);
+#endif
 
   return 0;
 }
diff --git a/testsuite/surf/sdp_usage.c b/testsuite/surf/sdp_usage.c
deleted file mode 100644 (file)
index 256dec7..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*     $Id$     */
-
-/* A few tests for the maxmin library                                       */
-
-/* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifdef __BORLANDC__
-#pragma hdrstop
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "surf/maxmin.h"
-
-#include "xbt/log.h"
-#include "xbt/module.h"
-XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,"Messages specific for surf example");
-
-#define PRINT_VAR(var) DEBUG1(#var " = %g\n",lmm_variable_getvalue(var));
-
-/*                               */
-/*        ______                 */
-/*  ==l1==  L2  ==L3==           */
-/*        ------                 */
-/*                               */
-
-void test(void);
-void test(void)
-{
-  lmm_system_t Sys = NULL ;
-  lmm_constraint_t L1 = NULL;
-  lmm_constraint_t L2 = NULL;
-  lmm_constraint_t L3 = NULL;
-
-  lmm_variable_t R_1_2_3 = NULL;
-  lmm_variable_t R_1 = NULL;
-  lmm_variable_t R_2 = NULL;
-  lmm_variable_t R_3 = NULL;
-
-  Sys = lmm_system_new();
-  L1 = lmm_constraint_new(Sys, (void *) "L1", 1.0);
-  L2 = lmm_constraint_new(Sys, (void *) "L2", 10.0);
-  L3 = lmm_constraint_new(Sys, (void *) "L3", 1.0);
-
-  R_1_2_3 = lmm_variable_new(Sys, (void *) "R 1->2->3", 1.0 , -1.0 , 3);
-  R_1 = lmm_variable_new(Sys, (void *) "R 1", 1.0 , -1.0 , 1);
-  R_2 = lmm_variable_new(Sys, (void *) "R 2", 1.0 , -1.0 , 1);
-  R_3 = lmm_variable_new(Sys, (void *) "R 3", 1.0 , -1.0 , 1);
-
-  lmm_expand(Sys, L1, R_1_2_3, 1.0);
-  lmm_expand(Sys, L2, R_1_2_3, 1.0);
-  lmm_expand(Sys, L3, R_1_2_3, 1.0);
-
-  lmm_expand(Sys, L1, R_1, 1.0);
-
-  lmm_expand(Sys, L2, R_2, 1.0);
-
-  lmm_expand(Sys, L3, R_3, 1.0);
-
-  PRINT_VAR(R_1_2_3);
-  PRINT_VAR(R_1);
-  PRINT_VAR(R_2);
-  PRINT_VAR(R_3);
-
-  DEBUG0("\n");
-  sdp_solve(Sys);
-
-  PRINT_VAR(R_1_2_3);
-  PRINT_VAR(R_1);
-  PRINT_VAR(R_2);
-  PRINT_VAR(R_3);
-  DEBUG0("\n");
-
-  lmm_update_variable_weight(Sys,R_1_2_3,.5);
-  sdp_solve(Sys);
-
-  PRINT_VAR(R_1_2_3);
-  PRINT_VAR(R_1);
-  PRINT_VAR(R_2);
-  PRINT_VAR(R_3);
-
-  lmm_system_free(Sys);
-} 
-
-void test2(void);
-void test2(void)
-{
-}
-
-#ifdef __BORLANDC__
-#pragma argsused
-#endif
-
-int main(int argc, char **argv)
-{
-  xbt_init(&argc,argv);
-
-  DEBUG0("***** Test 1 ***** \n");
-  test();
-/*   DEBUG0("***** Test 2 ***** \n"); */
-/*   test2(); */
-
-  return 0;
-}
index 7296f60..36ebd7a 100644 (file)
@@ -36,7 +36,6 @@ const char *string_action(e_surf_action_state_t state)
   }
 }
 
-
 void test(char *platform);
 void test(char *platform)
 {