-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcgp.h
More file actions
72 lines (59 loc) · 1.4 KB
/
Copy pathcgp.h
File metadata and controls
72 lines (59 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* cgp.h
* Author: Jan Viktorin <xvikto03 (at) stud.fit.vutbr.cz>
*/
#ifndef CGP_H
#define CGP_H
#include "chromo.h"
#include "fitness.h"
#include <stdlib.h>
/**
* CGP state.
*/
struct cgp_t {
struct chromo_t *c;
fitness_t *f;
int found_best;
size_t gener;
};
/**
* Initializes CGP state.
*/
int cgp_init(struct cgp_t *cgp);
/**
* Finalizes CGP state (cleans up resources).
*/
void cgp_fini(struct cgp_t *cgp);
/**
* Generates a population at random and evaluates it.
*/
int cgp_gen_popul(struct cgp_t *cgp);
/**
* Generates the initial population based on the given chromosomes.
* If zero chromosomes given the effect is the same as `cgp_gen_popul`.
*/
int cgp_gen_popul_from(struct cgp_t *cgp, struct chromo_t *c, size_t count);
/**
* Says true when the CGP is done.
* The generated population must be evaluated when calling
* this function.
*/
int cgp_done(const struct cgp_t *cgp);
/**
* Generates next population.
*/
int cgp_next_popul(struct cgp_t *cgp);
/**
* Evaluates current population (cgp->gener > 0) by a fitness function.
*/
int cgp_eval_popul(struct cgp_t *cgp);
/**
* USer defined walking function.
*/
typedef void (*cgp_walk_f)(size_t i, const struct chromo_t *, fitness_t, void *);
/**
* Walks the current population. User can pass a context information
* that is passed during the walk.
*/
void cgp_walk_popul(struct cgp_t *cgp, cgp_walk_f walkf, void *ctx);
#endif