def compute_values(): payoff_matrix = PrisonersDilemmaPayoff() delta = 0.9 mu = 0.0005 for pair in strategy_combinations: print("Strategy one: " + str(pair[0])) print("Strategy two: " + str(pair[1])) print() mult_sim_time = time() mult_sim = mult_simulate_payoff(pair[0], pair[1], payoff_matrix, delta, mistake_probability=mu, estimator_stdev=0.2) mult_sim_time = time() - mult_sim_time print("Multiprocessed simulated value = " + str(mult_sim)) print("Time taken " + str(mult_sim_time)) calc_naive_time = time() calc_naive = calculate_payoff_with_mistakes(pair[0], pair[1], payoff_matrix, delta, mu, 1e-5, 'naive') calc_naive_time = time() - calc_naive_time print("Calculated value (naive) = " + str(calc_naive)) print("Time taken " + str(calc_naive_time)) mult_calc_naive_time = time() mult_calc_naive = mult_calculate_payoff(pair[0], pair[1], payoff_matrix, delta, mu, 1e-5, 'naive') mult_calc_naive_time = time() - mult_calc_naive_time print("Multiprocessed calculated value (naive) = " + str(mult_calc_naive)) print("Time taken " + str(mult_calc_naive_time)) print()
def compute_values(): payoff_matrix = PrisonersDilemmaPayoff() delta = 0.9 mu = 0.0005 sim_time = time() sim = simulate_payoff(AllC, AllC, payoff_matrix, delta, mistake_probability=mu, estimator_stdev=0.4) sim_time = time() - sim_time print("Simulated value = " + str(sim)) print("Time taken " + str(sim_time)) mult_sim_time = time() mult_sim = mult_simulate_payoff(AllC, AllC, payoff_matrix, delta, mistake_probability=mu, estimator_stdev=0.4) mult_sim_time = time() - mult_sim_time print("Multiprocessed simulated value = " + str(mult_sim)) print("Time taken " + str(mult_sim_time)) calc_simple_time = time() calc_simple = [0., 0.] no_mistake = [0., 0.] one_mistake = [0., 0.] two_mistakes = [0., 0.] for i in range(0, 100000): for k in [0, 1]: no_mistake[k] = ((1 - mu) ** 2) * (payoff_matrix.CC)[k] two_mistakes[k] = (mu ** 2) * (payoff_matrix.DD)[k] one_mistake[k] = (mu * (1 - mu)) * ((payoff_matrix.CD)[k] + (payoff_matrix.DC)[k]) calc_simple[k] += (delta ** i) * (no_mistake[k] + one_mistake[k] + two_mistakes[k]) calc_simple[0] *= (1 - delta) calc_simple[1] *= (1 - delta) calc_simple_time = time() - calc_simple_time print("Calculated value (simplified) = " + str(calc_simple)) print("Time taken " + str(calc_simple_time)) calc_naive_time = time() calc_naive = calculate_payoff_with_mistakes(AllC, AllC, payoff_matrix, delta, mu, 1e-5) calc_naive_time = time() - calc_naive_time print("Calculated value = " + str(calc_naive)) print("Time taken " + str(calc_naive_time)) mult_calc_naive_time = time() mult_calc_naive = mult_calculate_payoff(AllC, AllC, payoff_matrix, delta, mu, 1e-5) mult_calc_naive_time = time() - mult_calc_naive_time print("Multiprocessed calculated value = " + str(mult_calc_naive)) print("Time taken " + str(mult_calc_naive_time)) expected_only_time = time() expected_only_value = expected_only(AllC, AllC, payoff_matrix, delta, mu, 1e-5) expected_only_time = time() - expected_only_time print("Expected value only calculated value = " + str(expected_only_value)) print("Time taken " + str(expected_only_time))