summaryrefslogtreecommitdiff
path: root/genalg.h
diff options
context:
space:
mode:
Diffstat (limited to 'genalg.h')
-rw-r--r--genalg.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/genalg.h b/genalg.h
new file mode 100644
index 0000000..33066bb
--- /dev/null
+++ b/genalg.h
@@ -0,0 +1,34 @@
+#ifndef GENALG_H
+#define GENALG_H
+
+
+typedef struct genalg_t {
+ void ** population;
+ size_t pop_count;
+
+ double (*fitness)(void*);
+ void * (*create_child)(void*);
+ void (*org_free)(void*);
+} genalg_t;
+
+
+struct genalg_stats_t {
+ double mean, variance;
+ double min, max;
+ void * best;
+};
+
+
+genalg_t * ga_create(
+ size_t pop_count,
+ double (*fitness)(void*),
+ void * (*create_child)(void*),
+ void (*org_free)(void*)
+);
+void ga_free(genalg_t *ga);
+void * ga_tournament_select(genalg_t *ga, int tournament_sz);
+struct genalg_stats_t ga_population_statistics(genalg_t *ga);
+int ga_replace_population(genalg_t *ga, int tournament_sz, int keep);
+
+
+#endif