projects
/
sort-networks.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
54e981b
)
sn-evolution: Add the "-m" option.
author
Florian Forster
<octo@leeloo.octo.it>
Tue, 1 Feb 2011 07:43:10 +0000
(08:43 +0100)
committer
Florian Forster
<octo@leeloo.octo.it>
Tue, 1 Feb 2011 07:43:10 +0000
(08:43 +0100)
src/sn-evolution.c
patch
|
blob
|
history
diff --git
a/src/sn-evolution.c
b/src/sn-evolution.c
index
72bd141
..
9f63506
100644
(file)
--- a/
src/sn-evolution.c
+++ b/
src/sn-evolution.c
@@
-33,6
+33,7
@@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
+#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
@@
-65,6
+66,13
@@
static int stats_interval = 0;
static int max_population_size = 128;
static population_t *population;
static int max_population_size = 128;
static population_t *population;
+static enum
+{
+ MERGER_ODDEVEN,
+ MERGER_BITONIC,
+ MERGER_RANDOM
+} selected_merger = MERGER_ODDEVEN;
+
static int evolution_threads_num = 4;
static int do_loop = 0;
static int evolution_threads_num = 4;
static int do_loop = 0;
@@
-84,6
+92,8
@@
static void exit_usage (const char *name)
" -p <num> Size of the population (default: 128)\n"
" -P <peer> Send individuals to <peer> (may be repeated)\n"
" -t <num> Number of threads (default: 4)\n"
" -p <num> Size of the population (default: 128)\n"
" -P <peer> Send individuals to <peer> (may be repeated)\n"
" -t <num> Number of threads (default: 4)\n"
+ " -m <merger> Specify the merging network to use.\n"
+ " Available: \"oddeven\", \"bitonic\", \"random\"\n"
"\n",
name);
exit (1);
"\n",
name);
exit (1);
@@
-93,7
+103,7
@@
int read_options (int argc, char **argv)
{
int option;
{
int option;
- while ((option = getopt (argc, argv, "i:o:p:P:s:t:h")) != -1)
+ while ((option = getopt (argc, argv, "i:o:p:P:s:t:
m:
h")) != -1)
{
switch (option)
{
{
switch (option)
{
@@
-153,6
+163,19
@@
int read_options (int argc, char **argv)
break;
}
break;
}
+ case 'm':
+ {
+ if (strcasecmp ("oddeven", optarg) == 0)
+ selected_merger = MERGER_ODDEVEN;
+ else if (strcasecmp ("bitonic", optarg) == 0)
+ selected_merger = MERGER_BITONIC;
+ else if (strcasecmp ("random", optarg) == 0)
+ selected_merger = MERGER_RANDOM;
+ else
+ fprintf (stderr, "Not a valid merging strategy: \"%s\"\n", optarg);
+ break;
+ }
+
case 'h':
default:
exit_usage (argv[0]);
case 'h':
default:
exit_usage (argv[0]);
@@
-230,7
+253,12
@@
static int create_offspring (void)
assert (p1 != NULL);
/* combine the two parents */
assert (p1 != NULL);
/* combine the two parents */
- n = sn_network_combine (p0, p1);
+ if ((selected_merger == MERGER_ODDEVEN)
+ || ((selected_merger == MERGER_RANDOM)
+ && (sn_bounded_random (0, 1) == 0)))
+ n = sn_network_combine_odd_even_merge (p0, p1);
+ else
+ n = sn_network_combine_bitonic_merge (p0, p1);
sn_network_destroy (p0);
sn_network_destroy (p1);
sn_network_destroy (p0);
sn_network_destroy (p1);