def make_attractor_states_dictionary(self): self.attractor_states_dict={} for state in self.state_list: if state.in_attractor==True: if self.view_states_as_binary: self.attractor_states_dict[state.as_string()]=[(self.step_automata(state)).as_string(),state.weight] else: self.attractor_states_dict[state.as_int()]=[(self.step_automata(state)).as_int(),state.weight]
def step_automata(self,state): new_state_string="" for bool_fun_number in range(self.N): bool_fun_inputs="" for state_element_number in range(self.K): bool_fun_inputs += \ state.as_string()[self.links_list[bool_fun_number][state_element_number]] new_state_string+=self.functions_list[bool_fun_number].evaluate(bool_fun_inputs) return State(new_state_string)
def p_stay_in_basin(self, state): basin_number = state.basin_number basin_size = self.attractor_dict[basin_number][1] state_number = state.state_number state_str = state.as_string() stay_cases = 0 perturbations_amount = len(state_str) for i in range(perturbations_amount): inverted_bit = str(1 - int(state_str[i])) perverted_state_str = state_str[:i] + inverted_bit + state_str[i+1:] perverted_state = State(perverted_state_str) if self.state_list[perverted_state.state_number].basin_number == \ basin_number: stay_cases += 1 return stay_cases / float(perturbations_amount)
def next_state(self,state): next_state_string=self.state_span[state.as_string()] next_state_number=State(next_state_string).state_number next_state_object=self.state_list[next_state_number] return next_state_object