This repository contains python files for Helmet 4.1 Model System. Source codes can be found in the Scripts-folder.
You can run HELMET 4.1 from the command line or by using helmet-ui. In this chapter, we will guide you how to install HELMET 4.1 to work with Bentley OpenPaths EMME software from the command line. The user is not expected to install any new software apart from helmet-model-system and OpenPaths EMME.
If you do not have an Bentley OpenPaths license or you wish to develop HELMET 4.1 further, please scroll down to Development chapter.
From this repository, copy the contents of the Scripts folder to your computer.
In production, we are using Python 3.11 which is supported by and installed together with Bentley OpenPaths EMME software. We are using those Python dependencies that come with Bentley OpenPaths EMME installation. To get access to these dependencies, you need to add them to your local PATH variable:
- Open Control Panel.
- Go to User Accounts, then click again User Accounts, then select from the left hand menu "Change my environment variables".
- From the top box ("User variables for USERNAME"), find and select "Path" variable, and click "Edit...".
- Click "New" and write
%EMMEPATH%\Programs
. - Click "New" and write
%EMMEPATH%\Python311
. - Click "New" and write
%EMMEPATH%\Python311\Scripts
. - Click OK in the "Edit environment variable" window, and then click OK again in the "Environment Variables" window.
EMME assignment can be tested without further configuration. Open command line to your local Scripts folder and write:
python -m tests.emme_only.test_assignment
This will create a small EMME test network and run test assignments on it.
You can also initialize a proper EMME project (if you do not want to use the test network):
- Open OpenPaths EMME desktop application.
- Create new project in which the path should match your project name and path.
- Follow external instructions to configure the details of the EMME project. Now, your working folder is filled with EMME project specific folders and files.
Before running from the command line, you can set standard configurations in dev-config.json. Instructions on the configuration settings are found here. Then, open command line to your local Scripts folder:
python helmet.py
Run parameters can be added to the command line call.
Run python helmet.py --help
to see parameter syntax.
If you do not have Bentley OpenPaths license or you wish to develop HELMET 4.1 source code, you need to set up a development environment. Although not covered here, installing Git is highly recommended!
We are using Python 3.11 because it is supported by Bentley OpenPaths EMME 24 software.
- Install Python 3.11.
- Add the path were you installed python (e.g.,
C:\Python311
) andC:\Python311\Scripts
to your local PATH variable in "Environment Variables". - Open a new Command Prompt and type
python --version
. You should getPython 3.11.9
or some other Python 3.11 version.
pip
is the recommended package installer for Python.
The normal Python installation routine installs pip
to C:\Python311\Scripts
.
Type pip --version
to Command Prompt to check if pip
is installed and in your PATH.
The command should return pip 24.1 from c:\python311\lib\site-packages\pip (python 3.11)
(pip
version may vary).
We are using pipenv
to import the same open source libraries which Bentley OpenPaths EMME software uses.
pipenv
isolates our environment from the other global Python modules and makes sure we don't break anything with our setup.
Optional introduction to pipenv
can be found from Python docs
or Jonathan Cutrer's blog.
- Open Command Prompt.
- Install
pipenv
by runningpython -m pip install --user pipenv
.pipenv
should now be installed in%APPDATA%\Python\Python311\Scripts
(e.g.C:\Users\USERNAME\AppData\Roaming\Python\Python311\Scripts
). - Add
%APPDATA%\Python\Python311\Scripts
to your local PATH variable.- Open Control Panel.
- Go to User Accounts, then click again User Accounts, then select from the left hand menu "Change my environment variables".
- From the top box ("User variables for USERNAME"), find and select "Path" variable, and click "Edit...".
- Click "New" and write
%APPDATA%\Python\Python311\Scripts
. - Click OK in the "Edit environment variable" window, and then click OK again in the "Environment Variables" window.
- Close and reopen Command Prompt and check that
pipenv
is recognised by typingpipenv --version
. It should returnpipenv, version 2024.0.1
(pipenv
version may vary). - Download helmet-model-system repository and open a Command Prompt to its "Scripts" folder.
- Install dependencies from
Pipfile
:- First setup:
pipenv --python 3.11 install --dev
- Additional syncing if new packages are added:
pipenv --python 3.11 sync --dev
- First setup:
- Depending on your operating system, rename either
.env-win
(Windows) or.env-nix
(Linux) to.env
. In Windows, you can do this in Command Propmpt by typingcopy .env-win .env
.
Now, you should have a virtual environment in C:\Users\USERNAME\.virtualenvs\Scripts-xxxxxxxx\Lib\site-packages
.
Use pipenv
when executing scripts. For example:
cd Scripts
pipenv run python helmet.py
Refer to this manual: https://hsldevcom.github.io/helmet-docs/kaytto-ohje.html#helmet-asennus.
- Download latest version of helmet-model-system in
Projektin asetukset
(edit: or set this manually tohelmet-model-system\Scripts
folder which you probably downloaded when installing Python environment!). - Find out where that version is saved by hovering over the text box (for example:
C:\Users\xxx\helmet-model-system-v4.1.3-24-04-1684924655775
) - Open
dev-config.json
inside that previous folder and modify OPTIONAL_FLAGS argument:-
`"OPTIONAL_FLAGS": ["DO_NOT_USE_EMME"]`
-
- Click "Projektin asetukset" button
- Python from previous virtual environment, for example
C:\Users\xxx\.virtualenvs\Scripts-AJXyDTuP\Scripts\python.exe
- helmet-model-system was set previously
- Projektin kansiopolku: your choice
- Lähtödata:
helmet-model-system\tests\test_data\Base_input_data
- Tulokset: your choice (copy Matrices folder from to the location) or
helmet-model-system\tests\test_data\Results
- Python from previous virtual environment, for example
- "Uusi Helmet-skenaario" button
- Skenaarion nimi: your choice
- Emme-projekti: create an empty (dummy) text file and save it with file extension
.emp
- Liikenneverkon sisältävä skenaario: default
- Syöttötiedot:
helmet-model-system\tests\test_data\Scenario_input_data\2030_test
- Iteraatioiden enimmäismäärä: default (do not cross "loppusijoittelu")
- The rest can have default values (edited)
- In case your scenario name is not
test
, copy thehelmet-model-system\tests\test_data\Results\test\Matrices
folder to[your-result-folder]\[your-scenario-name]\Matrices
. - Select scenario with checkbox and click
Käynnistä (1) skenaariota
. When running the first model run again and again, just do #2. When you create more scenarios, always copy matrices (#1) first to a new location. (This is a demo model thing that needs to be done because we are independent of EMME.)
Alternatively, you can run the mock assignment with the help of command line
- Make sure your virtual environment is activated (As described in Environment and Dependencies)
- Adjust the following variables in
dev-config.json
(while replacing the YOUR_PATH variable with absolute path to the helmet-model-system folder)"SCENARIO_NAME": "test"
,"RESULTS_PATH": "YOUR_PATH\\helmet-model-system\\Scripts\\tests\\test_data\\Results"
,"BASELINE_DATA_PATH": "YOUR_PATH\\helmet-model-system\\Scripts\\tests\\test_data\\Base_input_data"
,"FORECAST_DATA_PATH": "YOUR_PATH\\helmet-model-system\\Scripts\\tests\\test_data\\Scenario_input_data\\2030_test"
,
- Type the following to the command line:
pipenv run python helmet.py --do-not-use-emme
. You can also use the shorterpipenv run python helmet.py -m
.
The following extensions are recommended when developing with Visual Studio Code:
Alternatively, these test views seem to work with any version of the Python and Python Debugger extensions:
A couple of tips to get it all working:
- Remember to first setup your development environment. After that, open "Scripts" folder in Visual Studio Code, and select your virtual environment from bottom left Python interpreter list.
- To configure tests, click
Ctrl-Shift-P
, typePython: Configure tests
, selectpytest
framework, andtests
as the directory containing tests. Tests should appear in the Test Explorer (click the chemistry bottle from the left).
OpenPaths EMME supports OpenMatrix library for exporting matrices.
- More info here: https://github.com/osPlanning/omx/wiki/EMME
- Python source codes: https://github.com/osPlanning/omx-python
- Useful tool for exporting from cmd line: https://github.com/bstabler/EMXtoOMX