0 Votes

Fire move

Last modified by Omid Abouali on 2026/09/14 14:56

Previous (Introduction to Python)     |     Back to Start    |     Next (Customized reports)

Fire Move with Python

In this example, you will use the IDA Tunnel Python API to move fire. 

This exercise uses files from the examples zip file

Step 1: Setup the API

  • First, you need to set up the API. For this, you need to find the file util.py and set the variable path_to_tunnel to point to the bin folder in your IDA Tunnel installation (or another folder if you have IDA Tunnel installed elsewhere):

path_to_tunnel = "C:\\Program Files (x86)\\IDA Tunnel <YOUR IDA VERSION>\\bin\\"  

Note 1: Replace <YOUR IDA VERSION> with your IDA tunnel version, e.g., 2.0 or 2.1 beta 1.

Note 2: If you use a Windows system, always use double backslashes \\ for specifying paths. 

  • Save the util.py after changing it.
  • Second, you also need to go to Services in Windows and make sure that the IDAMessageBrokerService is running. You can find Services by simply searching it in the Windows search bar.

services_search.png

services_present.png

services_present2.png

Step 2: Looking at an example Python script

Now, let's look at the example in Fire_Move.py. It automatically moves fire to desired locations.  

Note 3: Replace <USER DIR> in the following path with your user directory where the downloaded examples are saved to.

  •  Before running the script, you can choose to either use our provided system named 1.IDM (in folder "example\\tunnels") or prepare an example system for the report yourself. For the latter, open IDA Tunnel and create a new system. Save the system in our provided folder, and make sure the system name is 1.IDM. 
  • Copy and paste the 1.IDM several times, rename them as 2.IDM, 3.IDM, etc. The number of copies depends on the number of tasks (Ntasks) you want to execute in parallel or in serial correspond to the number of cases for various fire location and entry traffic.
  • Now you can open the script Fire_Move.py. Find and set the variable file_path to point to the folder as,

file_path = "C:\\<USER DIR>\\example\\Fire Move\\tunnels\\"

Note 3: Replace <USER DIR> with your user directory where the downloaded examples are saved to. 

  • Define file_paths which points to all the systems, i.e., 1.IDM, 2.IDM, 3.IDM, etc. The number of readings will depend on the number of tasks (Ntasks) you specify.

file_paths = [file_path + str(i ) + ".IDM" for i in range(1, Ntasks + 1)]

  •  Define result_paths that point to the systems you will be saving your results to. With the following line, the same file_path will be used for saving, but the names of the saved systems will be result1.IDM, result2.IDM, etc. 

result_paths = [file_path + "result" + str(i ) + ".IDM" for i in range(1, Ntasks + 1)]

 Note 4: The defined file_paths and result_paths are for the convenience of running our script in parallel and serial manners. You can explicitly define your own paths as, e.g., file_paths = [".\\example\\Fire Move\\tunnels\\a.IDM", ".\\example\\Fire Move\\tunnels\\b.IDM" ]

  • To run the script, open the command prompt terminal by searching cmd.exe in the Windows search bar.

cmd_search.png

cmd_present.png

  • Then go to IDA Tunnel distributed python directory by typing:

>> cd "C:\\Program Files (x86)\\IDA Tunnel <YOUR IDA VERSION>\\bin\\python"

  • Now you can run the Fire_Move.py script by typing:

>> python.exe "C:\\<USER DIR>\\example\\Fire Move\\fire_move_example_util.py"

  • Several simulations will be started, so be a bit patient.
  • The given mode = "serial", Ntasks = 2 will start IDA Tunnel tasks in a consecutive (serial) manner. The task to perform in this example is (a) reading in systems one after another until all systems are opened; (b) starting changing the fire location and traffic entry, then saving and running the system.
  • Let the script finish, then change mode = "parallel" and rerun the Fire_Move.py 
  • This time, 2 IDA Tunnel tasks will execute simultaneously (parallel) to read the systems, change the fire location and traffic entry, and then save the systems. (Note: If there is no pop-out IDA Tunnel window, the only workaround is to use The Conda Python Distribution, see Introduction to Python)

Important: Make sure you have sufficient number of .IDM files for trying serial/parallel use of IDA Tunnel API. For instance, if your Ntasks = 10, you should have 10 IDM files available for reading (1.IDM, 2.IDM to 9.IDM). However, you can avoid creating multiple .IDM files by explicitly claiming your own path of reading.

Previous (Introduction to Python)     |     Back to Start    |     Next (Customized reports)