-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
64 lines (53 loc) · 1.91 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import logic.sim as simulation
import logic.helper as hlp
import argparse
def main():
print("Let the Pooling Games begin!")
parser = argparse.ArgumentParser(description='Pooling Games')
hlp.add_script_arguments(parser)
args = parser.parse_args()
sim = simulation.Simulation(
n=args.n,
k=args.k,
a0=args.a0,
stake_distr_source=args.stake_distr_source,
agent_profile_distr=args.agent_profile_distr,
inactive_stake_fraction=args.inactive_stake_fraction,
inactive_stake_fraction_known=args.inactive_stake_fraction_known,
relative_utility_threshold=args.relative_utility_threshold,
absolute_utility_threshold=args.absolute_utility_threshold,
seed=args.seed,
pareto_param=args.pareto_param,
max_iterations=args.max_iterations,
cost_min=args.cost_min,
cost_max=args.cost_max,
extra_pool_cost_fraction=args.extra_pool_cost_fraction,
agent_activation_order=args.agent_activation_order,
# total stake
iterations_after_convergence=args.iterations_after_convergence,
reward_scheme=args.reward_scheme,
execution_id=args.execution_id,
# seq_id
# parent_dir
metrics=args.metrics,
generate_graphs=args.generate_graphs,
input_from_file=args.input_from_file
)
profiling = args.profile_code
if profiling:
import cProfile
from pstats import Stats
pr = cProfile.Profile()
pr.enable()
sim.run_model()
if sim.has_converged():
print('Reached equilibrium at step: ', sim.equilibrium_steps)
else:
print('Maximum iterations reached without convergence to an equilibrium.')
if profiling:
pr.disable()
stats = Stats(pr)
print("\n----- Profiling results -----")
stats.sort_stats('tottime').print_stats(10)
if __name__ == "__main__":
main()