-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimplest_simulator_old.py
More file actions
68 lines (52 loc) · 1.62 KB
/
simplest_simulator_old.py
File metadata and controls
68 lines (52 loc) · 1.62 KB
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
65
66
67
68
#encoding: utf-8
import sys
sys.path.append('./Plugins/')
import argparse
import environment
from util import *
from data_parse_util import *
import population
from random_inst import FixedRandom
from ExamplePlugin import ExamplePlugin
from pathlib import Path
import time
arg_parser = argparse.ArgumentParser(description="Population Dynamics Simulation.")
arg_parser.add_argument('--f', metavar="F", type=str, default = '', help='Simulation file.')
args = vars(arg_parser.parse_args())
FixedRandom()
'''
Data Loading
'''
data_input_file_path = args['f']
env_graph = generate_EnvironmentGraph(data_input_file_path)
'''
Parameters
'''
#how many steps each day has
days = 3
day_duration = 24
env_graph.routine_day_length = day_duration
simulation_steps = days * day_duration
'''
Load Plugins Examples
'''
plug = ExamplePlugin(env_graph)
plug.example_parameter = 'bar'
env_graph.LoadPlugin(plug)
'''
Simulation
'''
for i in range(simulation_steps):
print(i, end='\r')
# Routine/Repeating Global Action Invoke example
# Updates Node Routines and Repeating Global Actions
# These are defined in the input environment descriptor
env_graph.update_time_step(i % day_duration, i)
# Direct Action Invoke example
# if i == 50:
# dummy_action = TimeAction('push_population', {'region':'example1', 'node':'example2', 'quantity':50})
# env_graph.direct_action_invoke(dummy_action)
# Next frame queue action example
# if i == 60:
# dummy_action = TimeAction('push_population', {'region':'example1', 'node':'example2', 'quantity':50})
# env_graph.queue_next_frame_action(dummy_action)