Skip to content

Commit

Permalink
Revert "Olusanya (#358)"
Browse files Browse the repository at this point in the history
This reverts commit 78259e1.
  • Loading branch information
Jens West committed Aug 27, 2021
1 parent 78259e1 commit 87fa835
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 39 deletions.
44 changes: 18 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,46 @@ This repository contains python files for Helmet 4.1 Model System. Source codes

## Usage

You can run HELMET 4.1 from the command line or by using [helmet-ui](https://github.com/HSLdevcom/helmet-ui).
In this chapter, we will guide you how to install HELMET 4.1 to work with Inro EMME software from the command line.
The user is not expected to install any new software apart from [helmet-model-system](https://github.com/HSLdevcom/helmet-model-system) and EMME.
In this chapter, we will guide you how to install HELMET 4.1 to work with INRO Emme software. The user is not expected to install any new software apart from [helmet-model-system](https://github.com/HSLdevcom/helmet-model-system) and [helmet-ui](https://github.com/HSLdevcom/helmet-ui).

If you do not have an Emme license or you wish to develop HELMET 4.1 further, please scroll down to [Development](#development) chapter.

### Setup

From this repository, copy the contents of the [Scripts](Scripts) folder to your computer.
In production, we are using Python 3.7 which is supported by and installed together with INRO Emme 4.5 software.

In production, we are using Python 3.7 which is supported by and installed together with INRO Emme software.
We are using those Python dependencies that come with Inro EMME installation.
To get access to these dependencies, you need to add them to your local PATH variable:
We are using those Python dependencies that come with INRO Emme installation. To get access to these dependencies, you need to add them to your local PATH variable:

1. Open Control Panel.
2. Go to User Accounts, then click again User Accounts, then select from the left hand menu "Change my environment variables".
3. From the top box ("User variables for USERNAME"), find and select "Path" variable, and click "Edit...".
4. Click "New" and write `%EMMEPATH%\Programs`.
5. Click "New" and write `%EMMEPATH%\Python37`.
6. Click "New" and write `%EMMEPATH%\Python37\Scripts`.
7. Click OK in the "Edit environment variable" window, and then click OK again in the "Environment Variables" window.
5. 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 test_assignment.py
```

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):
Next, you need to initialize an Emme project:

1. Open Emme desktop application.
2. Create new project in which the path should match your project name and path.
3. Follow [external instructions](https://hsldevcom.github.io/helmet-ui/sijopankki.html) to configure the details of the Emme project.
Now, your working folder is filled with Emme project specific folders and files.
2. Create new project called `helmet-model-system` in which the path should match your project name and path.
- The wizard should create you a (large binary) file called `helmet-model-system.emp` inside your project folder
3. Follow external instructions to configure the details of the Emme project. Now, your working folder is filled with Emme project specific folders and files.
4. From this repository, copy the contents of the [Scripts](Scripts) folder to the "Scripts" folder in the Emme project.

### Running

Before running from the command line, set the configurations in [dev-config.json](Scripts/dev-config.json).
Instructions on the configuration settings are found [here](Scripts#running-the-model-system).
Then, open command line to your local Scripts folder:
You can run HELMET 4.1 from the command line or by using [helmet-ui](https://github.com/HSLdevcom/helmet-ui). Before running from the command line, set the configurations in [dev-config.json](Scripts/dev-config.json). Then, open command line to your Emme project and type:

```
cd Scripts
python helmet.py
```

Emme assignment can be tested without further configuration:

```
cd Scripts
python test_assignment.py
```

## Development

If you do not have INRO Emme 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](https://git-scm.com/downloads) is highly recommended!
Expand Down
8 changes: 4 additions & 4 deletions Scripts/assignment/assignment_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def assign(self, matrices, iteration):
elif iteration==1:
if not self._save_matrices:
self._set_car_and_transit_vdfs()
self._calc_background_traffic()
self._assign_cars(param.stopping_criteria_coarse)
self._calc_extra_wait_time()
self._assign_transit()
Expand All @@ -121,14 +120,15 @@ def assign(self, matrices, iteration):
self._calc_extra_wait_time()
self._assign_transit()
elif iteration=="last":
self._set_bike_vdfs()
self._assign_bikes(self.result_mtx["dist"]["bike"]["id"], "all")
self._set_car_and_transit_vdfs()
if not self._save_matrices:
self._set_car_and_transit_vdfs()
self._calc_background_traffic()
self._assign_cars(param.stopping_criteria_fine)
self._calc_boarding_penalties(is_last_iteration=True)
self._calc_extra_wait_time()
self._assign_congested_transit()
self._set_bike_vdfs()
self._assign_bikes(self.result_mtx["dist"]["bike"]["id"], "all")
else:
raise ValueError("Iteration number not valid")

Expand Down
4 changes: 2 additions & 2 deletions Scripts/cba.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ def run_cost_benefit_analysis(scenario_0, scenario_1, year, workbook):
transit_mile_diff = (read(TRANSIT_KMS_FILE, scenario_1)
- read(TRANSIT_KMS_FILE, scenario_0))
for mode in TRANSIT_AGGREGATIONS:
transit_mile_diff.loc[mode] = 0
transit_mile_diff[mode] = 0
for submode in TRANSIT_AGGREGATIONS[mode]:
transit_mile_diff.loc[mode] += transit_mile_diff.loc[submode]
transit_mile_diff[mode] += transit_mile_diff[submode]
ws = workbook["Tuottajahyodyt"]
cols = CELL_INDICES["transit_miles"]["cols"]
rows = CELL_INDICES["transit_miles"]["rows"][year]
Expand Down
9 changes: 3 additions & 6 deletions Scripts/datahandling/resultdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,10 @@ def print_line(self, line, filename):
filename : str
Name of file where text is pushed (can contain other text)
"""
try:
buffer = self._line_buffer[filename]
except KeyError:
buffer = open(
if filename not in self._line_buffer:
self._line_buffer[filename] = open(
os.path.join(self.path, "{}.txt".format(filename)), 'w')
self._line_buffer[filename] = buffer
buffer.write(line + "\n")
self._line_buffer[filename].write(line + "\n")

def print_matrix(self, data, filename, sheetname):
"""Save 2-d matrix data to buffer (printed to file when flushing).
Expand Down
2 changes: 1 addition & 1 deletion Scripts/modelsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _add_internal_demand(self, previous_iter_impedance, is_last_iteration):
purpose_impedance = self.imptrans.transform(
purpose, previous_iter_impedance)
purpose.calc_prob(purpose_impedance)
if is_last_iteration and purpose.name not in ("sop", "so"):
if is_last_iteration and purpose.dest != "source":
purpose.accessibility_model.calc_accessibility(
purpose_impedance)

Expand Down

0 comments on commit 87fa835

Please sign in to comment.