X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5ef0fb1245e9d6d3efea3b0940fcce04d9b19478..5d02d342bf2942a5e97d9d3599cbb7d94f3285a9:/testsuite/surf/maxmin_usage.c diff --git a/testsuite/surf/maxmin_usage.c b/testsuite/surf/maxmin_usage.c index d5c267f73e..96f2703f5f 100644 --- a/testsuite/surf/maxmin_usage.c +++ b/testsuite/surf/maxmin_usage.c @@ -1,20 +1,30 @@ +/* $Id$ */ + /* A few tests for the maxmin library */ -/* Authors: Arnaud Legrand */ +/* 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. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ #include #include #include "surf/maxmin.h" +#include "xbt/log.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; @@ -25,10 +35,6 @@ lmm_variable_t R_2 = NULL; lmm_variable_t R_3 = NULL; -void test(void); -void test(void) -{ - Sys = lmm_system_new(); L1 = lmm_constraint_new(Sys, (void *) "L1", 1.0); L2 = lmm_constraint_new(Sys, (void *) "L2", 10.0); @@ -49,37 +55,72 @@ void test(void) lmm_expand(Sys, L3, R_3, 1.0); -#define AFFICHE(var) printf(#var " = %Lg\n",lmm_variable_getvalue(var)); - AFFICHE(R_1_2_3); - AFFICHE(R_1); - AFFICHE(R_2); - AFFICHE(R_3); + PRINT_VAR(R_1_2_3); + PRINT_VAR(R_1); + PRINT_VAR(R_2); + PRINT_VAR(R_3); - printf("\n"); + DEBUG0("\n"); lmm_solve(Sys); - AFFICHE(R_1_2_3); - AFFICHE(R_1); - AFFICHE(R_2); - AFFICHE(R_3); - printf("\n"); + PRINT_VAR(R_1_2_3); + PRINT_VAR(R_1); + PRINT_VAR(R_2); + PRINT_VAR(R_3); + DEBUG0("\n"); - lmm_update_variable_weight(R_1_2_3,.5); + lmm_update_variable_weight(Sys,R_1_2_3,.5); lmm_solve(Sys); - AFFICHE(R_1_2_3); - AFFICHE(R_1); - AFFICHE(R_2); - AFFICHE(R_3); -#undef AFFICHE + 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) +{ + lmm_system_t Sys = NULL ; + lmm_constraint_t CPU1 = NULL; + lmm_constraint_t CPU2 = NULL; + + lmm_variable_t T1 = NULL; + lmm_variable_t T2 = NULL; + + Sys = lmm_system_new(); + CPU1 = lmm_constraint_new(Sys, (void *) "CPU1", 200.0); + CPU2 = lmm_constraint_new(Sys, (void *) "CPU2", 100.0); + + T1 = lmm_variable_new(Sys, (void *) "T1", 1.0 , -1.0 , 1); + T2 = lmm_variable_new(Sys, (void *) "T2", 1.0 , -1.0 , 1); + + lmm_expand(Sys, CPU1, T1, 1.0); + lmm_expand(Sys, CPU2, T2, 1.0); + + PRINT_VAR(T1); + PRINT_VAR(T2); + + DEBUG0("\n"); + lmm_solve(Sys); + + PRINT_VAR(T1); + PRINT_VAR(T2); + + DEBUG0("\n"); + + lmm_system_free(Sys); +} int main(int argc, char **argv) { + DEBUG0("***** Test 1 ***** \n"); test(); + DEBUG0("***** Test 2 ***** \n"); + test2(); + return 0; }