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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#!/usr/bin/env python3
from __future__ import annotations
import random
class WaterSample:
def __init__(
self,
solid: int,
algae: int,
lime: tuple[int, int, int, int],
toxin: tuple[int, int, int, int],
):
self.solid = solid
self.algae = algae
self.lime = lime
self.toxin = toxin
def procedure_dict(self):
procedures = {
"1": (self.index1, self.index1_str),
"2": (self.index2, self.index2_str),
"3": (self.index3, self.index3_str),
"4": (self.index4, self.index4_str),
"5": (self.index5, self.index5_str),
"6": (self.index6, self.index6_str),
"overall": (self.overall, self.overall_str),
}
return procedures
def select_procedures(self):
procedures = [
(self.index1, self.index1_str),
(self.index2, self.index2_str),
(self.index3, self.index3_str),
(self.index4, self.index4_str),
(self.index5, self.index5_str),
(self.index6, self.index6_str),
]
random.shuffle(procedures)
training_procedures = procedures[:-1]
training_procedures.append((self.overall, self.overall_str))
return training_procedures, procedures[-1]
def index1(self):
return (self.lime[3] - self.lime[1]) * self.solid
def index1_str(self):
return "(Lime_4 - Lime_2) * Solid"
def index2(self):
return (2 * self.algae) + min(self.lime)
def index2_str(self):
return "(2 * Algae) + Lime_min"
def index3(self):
return max(self.toxin) + min(self.toxin)
def index3_str(self):
return "Toxin_max + Toxin_min"
def index4(self):
return (self.solid * 2) - self.toxin[3]
def index4_str(self):
return "(Solid * 2) - Toxin_4"
def index5(self):
return max(self.lime[2], (self.toxin[2] - self.toxin[1]))
def index5_str(self):
return "Greater of [(Toxin_3 - Toxin_2), Lime_3]"
def index6(self):
return min(self.algae, (self.lime[0] + self.toxin[0]))
def index6_str(self):
return "Lesser of [Algae, (Lime_1 + Toxin_1)]"
def overall(self):
return 100 - max(
self.index1(), self.index2(), self.index3(), self.index4(), self.index5()
)
def overall_str(self):
return "100 - Index_max"
def print_all(self):
print(f"Solid: {self.solid}")
print(f"Algae: {self.algae}")
print(f"Lime: {self.lime}")
print(f"Toxin: {self.toxin}")
print(f"Index 1: {self.index1_str()} = {self.index1()}")
print(f"Index 2: {self.index2_str()} = {self.index2()}")
print(f"Index 3: {self.index3_str()} = {self.index3()}")
print(f"Index 4: {self.index4_str()} = {self.index4()}")
print(f"Index 5: {self.index5_str()} = {self.index5()}")
print(f"Overall Quality: {self.overall_str()} = {self.overall()}")
def random_WaterSample():
solid = random.randint(1, 9)
algae = random.randint(1, 9)
lime = tuple(random.randint(1, 9) for _ in range(4))
toxin = tuple(random.randint(1, 9) for _ in range(4))
return WaterSample(solid, algae, lime, toxin)
|