-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgenome.py
More file actions
24 lines (22 loc) · 798 Bytes
/
genome.py
File metadata and controls
24 lines (22 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""
genome.py
~~~~~~~~~~~~~
This class stores the set of operations that compose an individual in the
population.
"""
class Genome:
def __init__(self, operations):
self.operations = operations
self.score = 999999
def __str__(self):
# A string representation of the genome takes the sum of the
# Job, Order, Machine and Duration in numeric value
genome_string = ""
numeric_value = 0
ascii_value = ""
for op in self.operations:
numeric_value += op.duration
ascii_value = str(int(numeric_value) % 10)
genome_string += ascii_value
from population import is_valid_permutation
return genome_string[:12] + " " + str(is_valid_permutation(self.operations)) + " " + str(self.score)