-
Notifications
You must be signed in to change notification settings - Fork 0
/
chromosome.h
32 lines (25 loc) · 827 Bytes
/
chromosome.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
#ifndef CHROMOSOME_H
#define CHROMOSOME_H
#include <stddef.h>
typedef struct bin bin_t;
struct bin {
long double fill;
size_t count;
size_t *item_indices;
};
typedef struct chromosome chrom_t;
struct chromosome {
double fitness;
long double bin_cap;
size_t num_bins;
bin_t **bins;
};
chrom_t *rand_first_fit(const long double *item_sizes, size_t num_items,
long double bin_cap);
void chrom_free(chrom_t *chrom);
chrom_t *chrom_copy(const chrom_t *chrom);
chrom_t *chrom_cx(const chrom_t *parent1, const chrom_t *parent2,
const long double *item_sizes, size_t num_items);
void chrom_mutate(chrom_t *chrom, double mutation_rate,
const long double *item_sizes, size_t num_items);
#endif /* !CHROMOSOME_H */