Gelato is a [MATSim](https://github.com/matsim-org/matsim-libs/tree/master#readme)-flavoured reference implementation
of a sustainable mobility Key Performance Indicators (KPI) framework (see
[here](https://medium.com/arupcitymodelling/gelato-tasty-sustainability-kpis-for-transport-models-80ad80f3e5db) for a
detailed description). Gelato turns MATSim outputs into transport sustainability KPI metrics and exists to provide a
runnable application to better understand and explore the framework. As such, it should be regarded as a by-product of
the framework rather than a work in its own right.
The KPI metrics generated by Gelato provide a snapshot summary of a
given MATSim model, and help compare different MATSim models and scenarios against each other.
# Installation
If you have Docker installed and would prefer to use Gelato via Docker rather than
locally installing the prerequisite dependencies and building and running the Java
application from the command line, skip to the
"[Using Gelato via Docker](#using-gelato-via-docker)" section.
Alternatively, you can grab the latest pre-built, runnable Gelato jar file from the
[releases page](https://github.com/arup-group/gelato/releases), make sure you have the necessary
[prerequisites](#prerequisites) installed and then skip straight to the "[Usage](#usage)" section.
To find out how to build Gelato from source and then run it without using Docker, read on...
## Prerequisites
In order to build and run Gelato locally, your environment must already have available:
#### JDK >= 17
- Start [here](https://www.oracle.com/java/technologies/downloads/) or [here](https://jdk.java.net/)
- If you want to run Gelato from a pre-built jar file rather than build it yourself, you can install a JRE
rather than a full JDK
#### Maven
- Start [here](https://maven.apache.org/)
- Only required if you're building Gelato from source
## Building
To compile everything, run all unit tests and linting checks, and build a runnable jar file that includes all
the necessary dependencies, clone this repo, and then from the directory you cloned it into:
```shell
mvn clean package
```
This will generate a new jar file in the `target` directory that is named according to the Gelato
version number and the latest git commit level - `gelato-0.0.1-alpha-with-dependencies-230f897.jar`
is the runnable jar in the example below:
```shell
ls -talh target
```
```
total 48
-rw-r--r--@ 1 mickyfitz staff 83M 13 Dec 15:17 gelato-0.0.1-alpha-with-dependencies-230f897.jar
drwxr-xr-x@ 12 mickyfitz staff 384B 13 Dec 15:17 .
-rw-r--r--@ 1 mickyfitz staff 28K 13 Dec 15:17 gelato-0.0.1-alpha.jar
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 maven-archiver
-rw-r--r--@ 1 mickyfitz staff 14K 13 Dec 15:17 jacoco.exec
drwxr-xr-x@ 4 mickyfitz staff 128B 13 Dec 15:17 surefire-reports
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 test-classes
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 generated-test-sources
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 classes
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 maven-status
drwxr-xr-x@ 3 mickyfitz staff 96B 13 Dec 15:17 generated-sources
drwxr-xr-x@ 15 mickyfitz staff 480B 13 Dec 15:17 ..
```
# Usage
You can run Gelato from the command line, directly from the jar file. The CLI is quite discoverable:
```shell
java -jar target/gelato-0.0.1-alpha-with-dependencies-230f897.jar --help
```
```
Usage: MatsimKpiGenerator [-hV] -mc=
| Affordability | `kpi-affordability.csv.gz` | Ratio of average spend on transport of low income agents : overall average spend on transport of all agents | Using leg logs and monetary scoring values per mode and person's subpopulation (per distance unit and constant), and/or Person Money Events, compute monetary cost for each leg. We compute total and average daily spend on transport by income brackets (numeric values for income are required) or subpopulation, if not available, (if `low income` subpopulation is available, otherwise only intermediate output is generated). Read more: [KPI Data Requirements and Expectations: Affordability](KPI_Data_Requirements_and_Expectations.md#affordability). | `intermediate-affordability.csv.gz` |
|
| Congestion | `kpi-congestion.csv.gz` | Delays in road traffic and in public transport during peak hours compared to free flow travel | Capture free-flow time at the link level, subtract congested time from this value. Congested time is the difference between link entry and exit time. | `intermediate-congestion.csv.gz` |
| Global Environment | GHG Emissions | `kpi-ghg-emissions.csv.gz` | Total Emissions emitted by vehicles | Total kilometres travelled by vehicles multiplied by default emission factors of 0.222 kg C02/km (car) and 1.372 kg CO2/km (bus), respectively; or as set by you - read more in [KPI Data Requirements and Expectations: GHG Emissions](KPI_Data_Requirements_and_Expectations.md#ghg-emissions). | `intermediate-ghg-emissions.csv.gz` |
|
| Mobility Space Usage | `kpi-mobility-space-usage{-per-activity-type}.csv.gz` | Estimated parking space demand per capita | Number of persons at facilities, per activity type, who arrived there by car. We use a parking space factor of 11.5 ([link](https://www.interparking-france.com/en/what-are-the-dimensions-of-a-parking-space/)) to calculate total parking demand and weigh it by number of trips. | `intermediate-mobility-space-usage.csv.gz` |
|
| PT Wait Time | `kpi-pt-wait-time.csv.gz` | Average time waiting for a PT boarding | Average trip wait times by transport mode. | `intermediate-pt-wait-time.csv.gz` |
|
| Travel Time | `kpi-travel-time.csv.gz` | Average travel time across all trips, in minutes | Using trip logs, convert travel time to minutes, average across the trips. | `intermediate-travel-time.csv.gz` |
| Parameter | Modal Split | `kpi-modal-split.csv.gz` | Modal split of dominant (by distance) trip modes | Using trip logs, calculate the number of trips for each mode, as well as the percentage. This metric will not be scaled, but viewed in tandem with the other KPIs. | None |
| Parameter | Occupancy Rate | `kpi-occupancy-rate.csv.gz` | Average load factor of vehicles of all modes | Track boarding/alighting events at vehicle level and combine with the vehicle log to calculate distances, then aggregate to average occupancy by mode. | `intermediate-occupancy-rate.csv.gz` |
| Parameter | Passenger KM | `kpi-passenger-km.csv.gz` | Total distance travelled by all persons | Sum the total distance travelled as recorded in the trip logs. | `intermediate-passenger-km.csv.gz` |
| Parameter | Speed | `kpi-speed.csv.gz` | Network link length divided by travel time | Calculate average speed for each network link in hourly bins. | None |
| Parameter | Vehicle KM | `kpi-vehicle-km.csv.gz` | Total distance travelled by all moving vehicles | Sum the total distance travelled as recorded in the link log. | `intermediate-vehicle-km.csv.gz` |
## Intermediate Data
Gelato generates a number of "intermediate" files that represent the intermediate, disaggregate output of
various KPI calculations:
| File | Description | Corresponding KPI File |
|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| `intermediate-access-to-mobility-services.csv.gz` | Home locations for each person, true/false columns to identify access to bus and rail stops, and whether the agent used transit. | `kpi-access-to-mobility-services-access-to-{bus,rail,pt-and-pt-used}.csv.gz` |
| `intermediate-affordability.csv.gz` | Total and average daily monetary cost of travel across agent income bracket (or subpopulation if income is not available). Overall values are also reported. | `kpi-affordability.csv.gz` |
| `intermediate-congestion.csv.gz` | Average delay ratio for travel time on each link, for each mode, across all hours of the modelled day, given the link was used within that hour by vehicle(s) of that mode. | `kpi-congestion.csv.gz` |
| `intermediate-ghg-emissions.csv.gz` | Total emissions and emissions per capita (total emissions divided by total persons in sim) | `kpi-ghg-emissions.csv.gz` |
| `intermediate-mobility-space-usage.csv.gz` | Parking space demand per facility and activity type. Max occupancy and total trips are also given. | `kpi-mobility-space-usage{-per-activity-type}.csv.gz` |
| `intermediate-occupancy-rate.csv.gz` | Average occupancy of each vehicle, across the modelled day, given that vehicle has travelled. Capacity of the vehicle is reported for convenience. | `kpi-occupancy-rate.csv.gz` |
| `intermediate-pt-wait-time.csv.gz` | Average waiting time, in seconds, for each transit stop and transit mode, across hours of the modelled day (given the transit stop was used for travel). | `kpi-pt-wait-time.csv.gz` |
| `intermediate-passenger-km.csv.gz` | Total kilometres travelled by each person during the modelled day. | `kpi-passenger-km.csv.gz` |
| `intermediate-travel-time.csv.gz` | Average travel time, in minutes, by trip purpose. | `kpi-travel-time.csv.gz` |
| `intermediate-vehicle-km.csv.gz` | Total kilometres travelled by each vehicle during the modelled day. The mode of the vehicle is reported for convenience. | `kpi-vehicle-km.csv.gz` |
## Supporting Data
In addition to KPI and intermediate files, Gelato also generates a number of "supporting data" files containing the
data aggregations used as inputs to the KPI calculations. These files allow the user to perform their own ad-hoc
analyses without having to parse and collate raw MATSim output data. Supporting data files use the naming scheme
`supporting-data-