diff options
author | Niclas Dobbertin <niclas.dobbertin@mailbox.org> | 2023-08-27 13:16:20 +0200 |
---|---|---|
committer | Niclas Dobbertin <niclas.dobbertin@mailbox.org> | 2023-08-27 13:16:20 +0200 |
commit | d34a6ab6a2c8e386b4687c5d8e9326fc5d45be81 (patch) | |
tree | 7ba01885c575c81c5572b7e1e450732de07e80d9 /master_thesis/frensch_procedures.py | |
parent | 8601458648311902aec5a3bb079066e39027e51f (diff) |
add 7th proc, constrained sampling
Diffstat (limited to 'master_thesis/frensch_procedures.py')
-rw-r--r-- | master_thesis/frensch_procedures.py | 23 |
1 files changed, 23 insertions, 0 deletions
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) |