sn-evolution: Disable mutation.
[sort-networks.git] / src / sn-evolution.c
index 6d06850..72bd141 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * collectd - src/sn-evolution.c
+ * libsortnetwork - src/sn-evolution.c
  * Copyright (C) 2008-2010  Florian octo Forster
  *
  * This program is free software; you can redistribute it and/or modify it
 # define _ISOC99_SOURCE
 #endif
 #ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
+# define _POSIX_C_SOURCE 200809L
+#endif
+#ifndef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 700
 #endif
 
 #include <stdlib.h>
@@ -46,9 +49,9 @@
 #include "sn_network.h"
 #include "sn_random.h"
 
-/* Yes, this is ugly, but the GNU libc doesn't export it with the above flags.
- * */
-char *strdup (const char *s);
+#if !defined(__GNUC__) || !__GNUC__
+# define __attribute__(x) /**/
+#endif
 
 static uint64_t iteration_counter = 0;
 static int inputs_num = 16;
@@ -66,7 +69,7 @@ static int evolution_threads_num = 4;
 
 static int do_loop = 0;
 
-static void sigint_handler (int signal)
+static void sigint_handler (int signal __attribute__((unused)))
 {
   do_loop++;
 } /* void sigint_handler */
@@ -174,6 +177,7 @@ static int rate_network (const sn_network_t *n)
   return (rate);
 } /* int rate_network */
 
+#if 0
 static int mutate_network (sn_network_t *n)
 {
   sn_network_t *n_copy;
@@ -211,6 +215,7 @@ static int mutate_network (sn_network_t *n)
 
   return (0);
 } /* int mutate_network */
+#endif
 
 static int create_offspring (void)
 {
@@ -225,7 +230,7 @@ static int create_offspring (void)
   assert (p1 != NULL);
 
   /* combine the two parents */
-  n = sn_network_combine (p0, p1, inputs_num_is_power_of_two);
+  n = sn_network_combine (p0, p1);
 
   sn_network_destroy (p0);
   sn_network_destroy (p1);
@@ -249,8 +254,10 @@ static int create_offspring (void)
 
   assert (SN_NETWORK_INPUT_NUM (n) == inputs_num);
 
+#if 0
   if ((SN_NETWORK_INPUT_NUM (n) <= 16) && (sn_bounded_random (0, 100) <= 1))
     mutate_network (n);
+#endif
 
   population_insert (population, n);
 
@@ -259,7 +266,7 @@ static int create_offspring (void)
   return (0);
 } /* int create_offspring */
 
-static void *evolution_thread (void *arg)
+static void *evolution_thread (void *arg __attribute__((unused)))
 {
   while (do_loop == 0)
   {