-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgene.py
35 lines (24 loc) · 917 Bytes
/
gene.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
33
34
35
import typing
class Gene:
def __init__(self, value: list[typing.Any], fitness: float | None = None):
assert value is not None and len(value) > 0
self.value = value
self.fitness = fitness
def __repr__(self):
return "Gene(value={}, fitness={})".format(self.value, self.fitness)
def __str__(self):
return "Gene(value={}, fitness={})".format(self.value, self.fitness)
def __eq__(self, other):
return self.value == other.value
def __hash__(self):
return hash(self.value)
def __lt__(self, other):
return self.fitness < other.fitness
def __le__(self, other):
return self.fitness <= other.fitness
def __gt__(self, other):
return self.fitness > other.fitness
def __ge__(self, other):
return self.fitness >= other.fitness
def __ne__(self, other):
return self.value != other.value