- changes
[oweals/gnunet.git] / src / ats / perf_ats_mlp.c
1 /*
2      This file is part of GNUnet.
3      (C) 2010,2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file ats/test_ats_mlp.c
22  * @brief test for the MLP solver
23  * @author Christian Grothoff
24  * @author Matthias Wachs
25
26  */
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_statistics_service.h"
30 #include "gnunet-service-ats_addresses_mlp.h"
31
32 #define VERBOSE GNUNET_YES
33 #define VERBOSE_ARM GNUNET_NO
34
35 #define MLP_MAX_EXEC_DURATION   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
36 #define MLP_MAX_ITERATIONS      INT_MAX
37
38 #define DEF_PEERS 10
39 #define DEF_ADDRESSES_PER_PEER 5
40
41 static unsigned int peers;
42 static unsigned int addresses;
43
44 static int ret;
45
46 struct GNUNET_STATISTICS_Handle * stats;
47
48 //struct GNUNET_CONTAINER_MultiHashMap * addresses;
49
50 struct GAS_MLP_Handle *mlp;
51
52 static void
53 check (void *cls, char *const *args, const char *cfgfile,
54        const struct GNUNET_CONFIGURATION_Handle *cfg)
55 {
56 #if !HAVE_LIBGLPK
57   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
58   ret = 1;
59   return;
60 #endif
61
62   if (peers == 0)
63     peers = DEF_PEERS;
64   if (addresses == 0)
65     addresses = DEF_ADDRESSES_PER_PEER;
66
67   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
68
69   GNUNET_HashCode hash;
70   //memset (&hash, '\0', sizeof (GNUNET_HashCode));
71   //hash.bits[0] = 1;
72   //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "peer %s\n", GNUNET_h2s_full (&hash));
73
74   mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
75   mlp->auto_solve = GNUNET_NO;
76
77
78
79   GAS_mlp_done (mlp);
80
81   ret = 0;
82   return;
83 }
84
85
86 int
87 main (int argc, char *argv[])
88 {
89
90   static char *const argv2[] = { "test_ats_mlp",
91     "-c",
92     "test_ats_api.conf",
93 #if VERBOSE
94     "-L", "DEBUG",
95 #else
96     "-L", "WARNING",
97 #endif
98     NULL
99   };
100
101   static struct GNUNET_GETOPT_CommandLineOption options[] = {
102     {'a', "addresses", NULL,
103      gettext_noop ("addresses per peer"), 1,
104      &GNUNET_GETOPT_set_uint, &addresses},
105     {'p', "peers", NULL,
106      gettext_noop ("peers"), 1,
107      &GNUNET_GETOPT_set_uint, &peers},
108     GNUNET_GETOPT_OPTION_END
109   };
110
111   GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
112                       "test_ats_mlp", "nohelp", options,
113                       &check, NULL);
114
115
116   return ret;
117 }
118
119 /* end of file test_ats_api_bandwidth_consumption.c */