-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchromo.h
63 lines (51 loc) · 1.25 KB
/
chromo.h
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
/**
* chromo.h
* Author: Jan Viktorin <xvikto03 (at) stud.fit.vutbr.cz>
*/
#ifndef CHROMO_H
#define CHROMO_H
#include <stdlib.h>
#include <stdio.h>
/**
* Chromosome abstraction.
*/
struct chromo_t;
/**
* Allocation of a new chromosome.
* Can allocate an array of chromosomes.
*/
struct chromo_t *chromo_alloc(size_t count);
/**
* Free of a chromosome dynamically allocated.
*/
void chromo_free(struct chromo_t *c);
/**
* Creates deep copy of the `src` chromosome. The `dst`
* chromosome must be allocated. This functions just copies
* the contents, it doesn't allocate memory.
* It doesn't copy anything when the pointers have the same
* target location.
*/
void chromo_copy(struct chromo_t *dst, const struct chromo_t *src);
/**
* Returns i-th chromosome in the array.
*/
struct chromo_t *chromo_at(struct chromo_t *array, size_t i);
/**
* Generates a random chromosome.
*/
void chromo_gen(struct chromo_t *c);
/**
* Mutates the given chromosome.
*/
void chromo_mut(struct chromo_t *c);
/**
* Prints the chromosome to the given stream.
*/
void chromo_print(FILE *fout, const struct chromo_t *c);
/**
* Parses a chromosome from the given stream.
* It returns zero when successful.
*/
int chromo_parse(FILE *fin, struct chromo_t *c);
#endif