-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.py
32 lines (24 loc) · 1.01 KB
/
init.py
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
import numpy as np
from individual import Individual
def bin(chromo_size, pop_size, lower_bound=0, upper_bound=2):
chromos = []
for ind in range(pop_size):
chromos.append(np.random.randint(2, size=chromo_size))
return [Individual(chromo) for chromo in chromos]
def int(chromo_size, pop_size, lower_bound=0, upper_bound=10):
chromos = []
for ind in range(pop_size):
chromos.append(np.random.randint(lower_bound, upper_bound, size=100))
return [Individual(chromo) for chromo in chromos]
def int_perm(chromo_size, pop_size, lower_bound=0, upper_bound=10):
chromos = []
for ind in range(pop_size):
chromos.append(np.random.permutation(chromo_size))
return [Individual(chromo) for chromo in chromos]
def real(chromo_size, pop_size, lower_bound=0, upper_bound=10):
chromos = []
for ind in range(pop_size):
chromos.append(
np.random.uniform(lower_bound, upper_bound, size=chromo_size)
)
return [Individual(chromo) for chromo in chromos]