#CFLAGS = -Wall -Werror -std=c99 -O0 -g -pthread
APPLICATIONS = sn-apply sn-batcher sn-check-bf sn-cut sn-cut-loop \
- sn-evolution sn-find-9 sn-merge \
+ sn-evolution sn-evolution2 sn-find-9 sn-merge \
sn-normalize sn-oddevenmerge sn-show sn-tex
-POPULATION_CFLAGS = -I/tmp/sifnfors/libpopulation/include
+POPULATION_CFLAGS = -I/tmp/libpopulation/include
-POPULATION_LDFLAGS = -L/tmp/sifnfors/libpopulation/lib -Wl,--rpath -Wl,/tmp/sifnfors/libpopulation/lib -lpopulation
+POPULATION_LDFLAGS = -L/tmp/libpopulation/lib -Wl,--rpath -Wl,/tmp/libpopulation/lib -lpopulation
all: $(APPLICATIONS)
sn-evolution: sn-evolution.c sn_network.o sn_stage.o sn_comparator.o sn_population.o sn_random.o
sn-evolution2: CFLAGS += $(POPULATION_CFLAGS)
-sn-evolution2: LDFLAGS += $(POPULATION_LDFLAGS)
+sn-evolution2: LDFLAGS += $(POPULATION_LDFLAGS) -lm
sn-evolution2: sn-evolution2.c sn_network.o sn_stage.o sn_comparator.o sn_population.o sn_random.o
sn-find-9: sn-find-9.c sn_network.o sn_stage.o sn_comparator.o sn_random.o
#include <assert.h>
#include <limits.h>
+#include <math.h>
+
#include <pthread.h>
#include <population.h>
static int mutate_network (sn_comparator_t *comparators, int comparators_num)
{
+ static int old_comparators_num = -1;
+ static int cut_off = 1000000;
+
int i;
+ if (old_comparators_num != comparators_num)
+ {
+ double p;
+
+ p = powl (0.5, (1.0 / ((double) comparators_num)));
+ cut_off = (int) (((double) 1000000) * p);
+
+ old_comparators_num = comparators_num;
+ }
+
for (i = 0; i < comparators_num; i++)
- if (sn_bounded_random (0, 1000000) >= 972655)
+ if (sn_bounded_random (0, 1000000) >= cut_off)
comparators[i] = get_random_comparator ();
return (0);