diff options
Diffstat (limited to 'modeling/model_env.py')
-rw-r--r-- | modeling/model_env.py | 132 |
1 files changed, 89 insertions, 43 deletions
diff --git a/modeling/model_env.py b/modeling/model_env.py index 1ad9495..433b2da 100644 --- a/modeling/model_env.py +++ b/modeling/model_env.py @@ -2,20 +2,50 @@ import random -from modeling import frensch_procedures +import frensch_procedures class Stimuli: - current_stimulus_id = 0 + # 6 = overall + procedure_ids = ["1", "2", "3", "4", "5", "6"] + current_stimulus_id = -1 + order_list = [] + training_order_list = [] + test_order_list = [] def __init__(self, condition, training_N=75, test_N=50): self.condition = condition self.training_N = training_N self.test_N = test_N + self.training_order = random.sample( + self.procedure_ids, k=len(self.procedure_ids) + ) + self.test_proc = self.training_order[-1] + self.training_order = self.training_order[:-1] + self.training_order.append("overall") + + self.test_order = self.training_order.copy() + self.test_order[2] = self.test_proc + def generate_stimuli(self): - self.training_stimuli = frensch_procedures.constrained_WaterSample() - self.test_stimuli = frensch_procedures.constrained_WaterSample() + self.training_samples = [] + for _ in range(self.training_N): + self.training_samples.append(frensch_procedures.constrained_WaterSample()) + self.training_stimuli = self.generate_environments( + self.training_samples, self.training_order + ) + + self.test_samples = [] + for _ in range(self.test_N): + self.test_samples.append(frensch_procedures.constrained_WaterSample()) + self.test_stimuli = self.generate_environments( + self.test_samples, self.test_order + ) + + if self.condition == "random": + self.training_order_list = self.order_list[:self.training_N] + self.test_order_list = self.order_list[self.training_N:] def next_stimulus(self): self.current_stimulus_id += 1 @@ -24,56 +54,72 @@ class Stimuli: else: return self.test_stimuli[self.current_stimulus_id - self.training_N] + def update_current_stimulus(self, key, value): + if self.current_stimulus_id < self.training_N: + self.training_stimuli[self.current_stimulus_id][key]["text"] = value + return self.training_stimuli[self.current_stimulus_id] + else: + self.test_stimuli[self.current_stimulus_id - self.training_N][key][ + "text" + ] = value + return self.test_stimuli[self.current_stimulus_id - self.training_N] - def update_current_stimulus(self, ): - pass - def generate_environments(self): + def generate_environments(self, water_samples, order): envs = [] - screen = {} - self.generate_variables(screen) - self.generate_procedures(screen) - - envs.append(screen) + for sample in water_samples: + screen = {} + self.generate_variables(screen, sample) + if self.condition == "random": + order_cut = order[:-1] + random.shuffle(order_cut) + order_cut.append(order[-1]) + order = order_cut + self.order_list.append(order) + else: + self.order_list.append(order) + self.generate_procedures(screen, order) + + envs.append(screen) return envs - def generate_procedures(self, screen): - procs = ["procs1", "procs2", "procs3", "procs4", "procs5", "procs6"] - screen["Procedure1"] = {"text": procs[0], "position": (0, 100)} - screen["Procedure2"] = {"text": procs[1], "position": (0, 200)} - screen["Procedure3"] = {"text": procs[2], "position": (0, 300)} - screen["Procedure4"] = {"text": procs[3], "position": (0, 400)} - screen["Procedure5"] = {"text": procs[4], "position": (0, 500)} - - screen["ProcedureOverall"] = {"text": "proc_overall", "position": (0, 600)} - - screen["Answers"] = {"text": "Answers", "position": (100, 100)} - screen["Answer1"] = {"text": 1, "position": (100, 200)} - screen["Answer2"] = {"text": 2, "position": (100, 300)} - screen["Answer3"] = {"text": 3, "position": (100, 400)} - screen["Answer4"] = {"text": 4, "position": (100, 500)} - screen["Answer5"] = {"text": 5, "position": (100, 600)} - - screen["AnswerOverall"] = {"text": "proc_overall", "position": (100, 700)} - - def generate_variables(self, screen): + def generate_procedures(self, screen, order): + procs = ["proc1", "proc2", "proc3", "proc4", "proc5", "proc6"] + screen["Procedures"] = {"text": "Formeln", "position": (0, 100)} + screen["Procedure1"] = {"text": procs[int(order[0]) - 1], "position": (0, 200)} + screen["Procedure2"] = {"text": procs[int(order[1]) - 1], "position": (0, 300)} + screen["Procedure3"] = {"text": procs[int(order[2]) - 1], "position": (0, 400)} + screen["Procedure4"] = {"text": procs[int(order[3]) - 1], "position": (0, 500)} + screen["Procedure5"] = {"text": procs[int(order[4]) - 1], "position": (0, 600)} + + screen["ProcedureOverall"] = {"text": "proc_overall", "position": (0, 700)} + + screen["Answers"] = {"text": "Kennwerte", "position": (100, 100)} + screen["Answer1"] = {"text": "null", "position": (100, 200)} + screen["Answer2"] = {"text": "null", "position": (100, 300)} + screen["Answer3"] = {"text": "null", "position": (100, 400)} + screen["Answer4"] = {"text": "null", "position": (100, 500)} + screen["Answer5"] = {"text": "null", "position": (100, 600)} + # Answer overall + screen["Answer6"] = {"text": "null", "position": (100, 700)} + + def generate_variables(self, screen, sample): # Variables screen["Algen"] = {"text": "Algen", "position": (400, 100)} - screen["AlgenVar"] = {"text": "3", "position": (400, 200)} + screen["AlgenVar"] = {"text": sample.algae, "position": (400, 200)} screen["Mineralien"] = {"text": "Mineralien", "position": (500, 100)} - screen["MineralienVar"] = {"text": "9", "position": (500, 200)} + screen["MineralienVar"] = {"text": sample.solid, "position": (500, 200)} screen["Gifte"] = {"text": "Gifte", "position": (600, 100)} - screen["GifteVar1"] = {"text": "3", "position": (600, 200)} - screen["GifteVar2"] = {"text": "1", "position": (600, 300)} - screen["GifteVar3"] = {"text": "8", "position": (600, 400)} - screen["GifteVar4"] = {"text": "6", "position": (600, 500)} + screen["GifteVar1"] = {"text": sample.toxin[0], "position": (600, 200)} + screen["GifteVar2"] = {"text": sample.toxin[1], "position": (600, 300)} + screen["GifteVar3"] = {"text": sample.toxin[2], "position": (600, 400)} + screen["GifteVar4"] = {"text": sample.toxin[3], "position": (600, 500)} screen["Sandstein"] = {"text": "Sandstein", "position": (700, 100)} - screen["SandsteinVar1"] = {"text": "3", "position": (700, 200)} - screen["SandsteinVar2"] = {"text": "4", "position": (700, 300)} - screen["SandsteinVar3"] = {"text": "5", "position": (700, 400)} - screen["SandsteinVar4"] = {"text": "6", "position": (700, 500)} - + screen["SandsteinVar1"] = {"text": sample.lime[0], "position": (700, 200)} + screen["SandsteinVar2"] = {"text": sample.lime[1], "position": (700, 300)} + screen["SandsteinVar3"] = {"text": sample.lime[2], "position": (700, 400)} + screen["SandsteinVar4"] = {"text": sample.lime[3], "position": (700, 500)} |