From d34a6ab6a2c8e386b4687c5d8e9326fc5d45be81 Mon Sep 17 00:00:00 2001 From: Niclas Dobbertin Date: Sun, 27 Aug 2023 13:16:20 +0200 Subject: add 7th proc, constrained sampling --- master_thesis/frensch_procedures.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'master_thesis/frensch_procedures.py') diff --git a/master_thesis/frensch_procedures.py b/master_thesis/frensch_procedures.py index 66f1c8c..42c6f14 100644 --- a/master_thesis/frensch_procedures.py +++ b/master_thesis/frensch_procedures.py @@ -98,9 +98,32 @@ class WaterSample: 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"Index 6: {self.index6_str()} = {self.index6()}") print(f"Overall Quality: {self.overall_str()} = {self.overall()}") +# No step should produce a negative number, greater/lesser of comparisons should not +# use equal numbers +def constrained_WaterSample(): + water_sample = random_WaterSample() + resample = True + while resample: + water_sample = random_WaterSample() + resample = False + # check for negative results + for proc in water_sample.procedure_dict().keys(): + if water_sample.procedure_dict()[proc][0]() < 0: + resample = True + # check for greater/lesser equality + # procedure 5 + if (water_sample.toxin[2] - water_sample.toxin[1]) == water_sample.lime[2]: + resample = True + # procedure 6 + if (water_sample.lime[0] + water_sample.toxin[0]) == water_sample.algae: + resample = True + return water_sample + + def random_WaterSample(): solid = random.randint(1, 9) algae = random.randint(1, 9) -- cgit v1.2.3