Scenario Generation

 1import realtwin as rt
 2
 3# Please refer to the official documentation for more details on RealTwin preparation before running the simulation
 4# # https://real-twin.readthedocs.io/en/latest/index.html
 5
 6if __name__ == '__main__':
 7
 8    # Step 1: Prepare your configuration file (in YAML format)
 9    CONFIG_FILE = "./realtwin_config.yaml"
10
11    # Step 2: initialize the realtwin object
12    twin = rt.RealTwin(input_config_file=CONFIG_FILE, verbose=True)
13
14    # Step 3: check simulator env: if SUMO, VISSIM, Aimsun, etc... are installed
15    twin.env_setup(sel_sim=["SUMO", "VISSIM"])
16
17    # Step 4: Create Matchup Table from SUMO network
18    updated_sumo_net = r"./datasets/example2/chatt.net.xml"
19    twin.generate_inputs(incl_sumo_net=updated_sumo_net)
20
21    # BEFORE step 5, there are three steps to be performed:
22    # 1. Prepare Traffic Demand and save it to Traffic Folder in input directory
23    # 2. Prepare Control Data (Signal) and save it to Control Folder in input directory
24    # 3. Manually fill in the Matchup Table in the input directory
25
26    # Step 5: generate abstract scenario
27    twin.generate_abstract_scenario()
28
29    # AFTER step 5, Double-check the Matchup Table in the input directory to ensure it is correct.
30
31    # Step 6: generate scenarios
32    twin.generate_concrete_scenario()
33
34    # Step 7: simulate the scenario
35    twin.prepare_simulation()
36
37    # Step 8: perform calibration, Available algorithms: GA: Genetic Algorithm, SA: Simulated Annealing, TS: Tabu Search
38    twin.calibrate(sel_algo={"turn_inflow": "GA", "behavior": "GA"})
39
40    # Step 9 (ongoing): post-process the simulation results
41    twin.post_process()  # keyword arguments can be passed to specify the post-processing options
42
43    # Step 10 (ongoing): visualize the simulation results
44    twin.visualize()  # keyword arguments can be passed to specify the visualization options