def test_simulated_annealing_runtime(self): import simulations.turkish_vowel_harmony as current_simulation configurations.load_configurations_from_dict( current_simulation.configurations_dict) self.initialise_segment_table('turkish_segment_table.txt') initial_hmm = None initial_rule_set = None initial_hypothesis = Hypothesis.create_initial_hypothesis( current_simulation.data, initial_hmm, initial_rule_set) target_tuple = current_simulation.target_tuple data = current_simulation.data target_rule_set = RuleSet.load_form_flat_list(target_tuple[1]) target_hypothesis = Hypothesis.create_hypothesis( HMM(target_tuple[0]), target_rule_set, data) target_energy = target_hypothesis.get_energy() simulated_annealing = SimulatedAnnealing(initial_hypothesis, target_energy) simulated_annealing.before_loop() # mutate hypothesis for some time before measuring steps for i in range(500): simulated_annealing.make_step() @timeit_best_of_N def make_step_profiled(): simulated_annealing.make_step() make_step_profiled()
def test_hypothesis_mutation_runtime(self): import simulations.turkish_vowel_harmony as current_simulation configurations.load_configurations_from_dict( current_simulation.configurations_dict) self.initialise_segment_table('turkish_segment_table.txt') N_mutations = 100 initial_hmm = None initial_rule_set = None hypothesis = Hypothesis.create_initial_hypothesis( current_simulation.data, initial_hmm, initial_rule_set) @timeit_best_of_N def mutate_N_times(hypothesis, N): current_hypothesis = hypothesis for i in range(N): try: _, current_hypothesis = current_hypothesis.get_neighbor() except Exception: continue mutate_N_times(hypothesis, N_mutations)