Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cutter doc and files to support cutting TE #1

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

syhwawa
Copy link

@syhwawa syhwawa commented Sep 16, 2024

As discussed in the previous PR in the Magellan repo here, I have moved all the relevant files to this repo for easier maintenance in the future.

This PR includes two key documentation files, some Python scripts used in the cutting process, and example MATSim config files to help users track the workflow:

  1. cutting-scenarios-Transport-East.md: This is a general guide on how to run the cutter. It includes instructions on setting up and executing the cutter for the Transport East (TE) simulations.
  2. matsim-cutter-debug-notes.md: This file contains detailed notes on how we debugged the cutter, including two remaining questions. It provides a reference for others to follow or troubleshoot as needed.

Additionally, I added some other files:

  • The Python scripts included were used during the debugging process.
  • The MATSim config examples are attached to demonstrate different stages of the cutting process.

All relevant files from the Magellan repo have been copied here. Feel free to delete the original PR, and I assume we can continue working on this one.

@syhwawa syhwawa requested review from mfitz and KasiaKoz September 16, 2024 15:04
Copy link

@KasiaKoz KasiaKoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and questions. I think you can probably ignore the ones in docs/cutting-scenarios-CML/matsim-cutter-debug-notes.md as those are just running notes that don't need to be polished? Up to you tbh

@@ -136,7 +138,10 @@ public ModeAwareTripProcessor provideModeAwareTripProcessor(RoutingConfigGroup r

if (transitConfig.isUseTransit()) {
// TODO: This may not only be "pt"!
tripProcessor.setProcessor(TransportMode.pt, transitTripProcessor);
List<String> transitModes = Arrays.asList("pt", "bus", "rail", "subway", "ferry", "taxi", "tram");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "pt" should be TransportMode.pt and the rest of the pt modes should probably come from the mode mapping part of the SBB config

Comment on lines +8 to +17
Here is an example of 10% populations statisitcs before cutting:
```
Population Stats:
+--------------+--------+
| stat | total |
+--------------+--------+
| hhs | 398691 |
| persons | 398691 |
+--------------+--------+
Modes:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have combined the tables so you can see the number next to each other, so:

'Here is an example of 10% populations statistics before and after cutting:'

Population Stats:
+--------------+---------------+--------------+
|         stat | total before  | total after  |
+--------------+---------------+--------------+
|          hhs |       398,691 |       15,367 |
|      persons |       398,691 |       15,367 |
+--------------+---------------+--------------+

etc.

Before starting the cutting procedure, the following files need to be prepared:

- MATSim configurations and simulation inputs
- Network car geometry for snapping facilities to activities
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add a note here that this is available in genet's standard outputs

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember anymore, but what projection should this file be in?

For cutting 0.01% sims: `/mnt/efs/analysis/ys/matsim_cutter/input_files_locations_facilities/matsim_config_cutter.xml`
For cutting the 10% sims: `/mnt/efs/analysis/ys/matsim_cutter/input_files_locations_facilities_10pc_20240909/matsim_config_cutter_no_intermodal_bike.xml`

The example running command is saved in a bash script: `/mnt/efs/analysis/ys/matsim_cutter/run_cutter.sh`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bash script counts as code, right? :D why is it on efs, can we have this script included in this repo and point to that instead?

Comment on lines +268 to +279

For cutting 0.01% sims:
```sh
java -Xmx12G -cp "core-1.5.0.jar:libs/matsim-2024.0/matsim-2024.0.jar:libs/matsim-2024.0/libs/*" \
org.eqasim.core.scenario.cutter.RunScenarioCutter \
--config-path /mnt/efs/analysis/ys/matsim_cutter/input_files_locations_facilities/matsim_config_cutter.xml \
--output-path output_20240729_001pct \
--extent-path /mnt/efs/analysis/ys/matsim_cutter/cut_shape_file/te_bury_st_edmund_27700.shp \
--config:plans.inputPlansFile /mnt/efs/analysis/ys/matsim_cutter/input_files_locations_facilities/output_plans.xml\
--prefix TE_cutter_ \
--threads 4
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, are those the contents of that bash script above? might not be worth referencing the path on efs if the command is here, or make it clear those are the contents, in case someone decides to spend time looking for it..(I was tempted) 😅

Comment on lines +108 to +111
- My local runtime params (running in IntelliJ):

```
--config-path /Users/mickyfitz/matsim-cutter/cutter-inputs/te/matsim_config_cutter_intermodal_bike.xml
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, these are args for intelij, but would be good to include the class I think it's using org.eqasim.core.scenario.cutter.RunScenarioCutter ?

- Some model metadata:
- network nodes: 447,610
- network links: 985,170
- number of agents:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing info on agents

Comment on lines +21 to +22
is_strongly_connected = nx.is_strongly_connected(G_directed)
print(f"Is the directed graph strongly connected? {is_strongly_connected}")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish you had spoken to me about before diving into this. We have code in genet to test these things. Also, this is not enough - the network has to be strongly connected for modal subgraphs of the graph (so you have to test for just car links (and walk and bike if needed to be routed but not applicable here). In a network links geojson you will have all links, including PT, which will not be strongly connected, which is expected and ok.

print(f"Is the directed graph strongly connected? {is_strongly_connected}")

# Find connected components
connected_components = list(nx.connected_components(G_undirected))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't really be analysing undirected network graphs, because that's not fit for our purpose. To get connected components of a directed graph you need to use the method: nx.strongly_connected_components

isolated_nodes = [node for node, degree in G_directed.degree() if degree == 0]
print(f"Number of isolated nodes: {len(isolated_nodes)}")

dead_end_nodes = [node for node, degree in G_directed.degree() if degree == 1]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a directed graph you have to distinguish between in and out degrees. A dead end (sink node) can have any number for in degree (loads of links going in) but none coming out, so you're only looking for nodes with out degree of 0. Here's a genet method for that and unreachable nodes (source nodes) https://github.com/arup-group/genet/blob/afa6e0f2219f8e1069fe56667e4d6517210780ab/src/genet/validate/network.py#L13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants