/**
- * collectd - src/sn-evolution.c
- * Copyright (C) 2008,2009 Florian octo Forster
+ * 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
* under the terms of the GNU General Public License as published by the
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at verplant.org>
+ * Florian octo Forster <ff at octo.it>
**/
#ifndef _ISOC99_SOURCE
# 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>
#include "sn_network.h"
#include "sn_random.h"
+#if !defined(__GNUC__) || !__GNUC__
+# define __attribute__(x) /**/
+#endif
+
#define SNE_MIN(a,b) ((a) < (b) ? (a) : (b))
#define SNE_MAX(a,b) ((a) > (b) ? (a) : (b))
-/* Yes, this is ugly, but the GNU libc doesn't export it with the above flags.
- * */
-char *strdup (const char *s);
-
static uint64_t iteration_counter = 0;
static int inputs_num = -1;
static int do_loop = 0;
-static void sigint_handler (int signal)
+static int weight_overall = 50;
+static int weight_fails = 2;
+static int weight_stages = 1;
+
+static void sigint_handler (__attribute__((unused)) int signal)
{
do_loop++;
} /* void sigint_handler */
} /* while (42) */
/* All tests successfull */
- return (SN_NETWORK_STAGE_NUM (n) + patterns_failed);
+ return (weight_overall + (weight_stages * SN_NETWORK_STAGE_NUM (n)) + (weight_fails * patterns_failed));
} /* }}} int rate_network */
static sn_comparator_t get_random_comparator (void) /* {{{ */
return (0);
} /* int create_offspring */
-static void *evolution_thread (void *arg)
+static void *evolution_thread (__attribute__((unused)) void *arg)
{
while (do_loop == 0)
{
printf ("Best after approximately %i iterations: "
"%i comparators in %i stages. Rating: %i (%i not sorted).\n",
iter, comparators_num, stages_num, rating,
- rating - stages_num);
+ (rating - (weight_overall + (weight_stages * stages_num))) / weight_fails);
}
}