Skip to content

Assign bikes as F mode#584

Merged
hsl-petrhaj merged 6 commits intohelmet5-experimentalfrom
assign-bikes-as-F-mode
Apr 24, 2025
Merged

Assign bikes as F mode#584
hsl-petrhaj merged 6 commits intohelmet5-experimentalfrom
assign-bikes-as-F-mode

Conversation

@hsl-petrhaj
Copy link
Contributor

@hsl-petrhaj hsl-petrhaj commented Apr 14, 2025

As of now, bike assignment is done as "h" mode. This creates issues with turning restrictions, because the information about turning restrictions is kept in the "h" mode. However, on links like "hcvky", "h" mode is removed for bike assignment and at the same time any possible turning restrictions for cars are removed as well. Once we proceed into car assignment, "cvky" turns back into "hcvky", but the turning restriction is missing - it disappears.
As a remedy, I propose to do the bike assignment properly, as a "F" mode subnetwork of the "h" mode main network. Due to backwards compatilbility, "F" mode is only used as virtual "AUX_AUTO" mode. "f" mode on the other hand is "AUX_TRANSIT". There probably used to be some idea in the past to use transit assignment for bikes, but it remained unimplemented.
When I implemented the change, some things did not work out of the box, there needs to be valid vdf, valid number of lanes and valid time_auto travel time. They are not used in the assignments to my understanding, but they are required for the initial checks. All these adjustments are part of this PR.
This PR should close this issue:
#583

Note: I am only pushing this into Helmet 5 as olusanya had this behavior since the beginning.

… the model run and mostly invisible to the end user. The reason for the solution is backwards compatibility.
@hsl-petrhaj hsl-petrhaj changed the title Assign bikes as f mode Assign bikes as F mode Apr 14, 2025
@hsl-petrhaj hsl-petrhaj linked an issue Apr 14, 2025 that may be closed by this pull request
@hsl-petrhaj hsl-petrhaj added the help wanted Extra attention is needed label Apr 14, 2025
Copy link
Collaborator

@zptro zptro left a comment

Choose a reason for hiding this comment

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

To my understanding, you would achieve the same result simply by

  1. allowing h on all links (and never disallowing it)
  2. changing mode in bike assignment to f

Please explain if I have overlooked some problem with this simpler approach.

By the way, do you know if having h allowed on all links in car assignment affects performance?

Comment on lines +772 to +778
#Add h mode everywhere just to be sure
network = self.emme_scenario.get_network()
main_mode = network.mode(param.main_mode)
for link in network.links():
link.modes |= {main_mode}
self.emme_scenario.publish_network(network)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you do this here, when it has nothing to do with pedestrian assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is more like a fix for the older networks to bring them to newer standard.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, so maybe you could move this fix to some more natural place, like prepare()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I moved them to prepare. Prepare does not seem to be used for mock assignment, but that does not seem to be a big issue as of now.

Comment on lines 381 to 382
if car_mode in link.modes:
link.modes |= {main_mode}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You have already allowed main_mode on all links, so this is unnecessary now, is it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can indeed be dropped.

self.event_handler.on_assignment_started(self, iteration, matrices)
self._set_emmebank_matrices(matrices, iteration=="last")
if iteration=="init":
self._create_bike_auto_mode()
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you need this new mode for? Can you not simply use f?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

f mode is aux_transit, not aux_auto. I think aux_transit is not accepted in car assignment. Or would it be a good idea to change it during the model run?

Copy link
Collaborator

@zptro zptro Apr 15, 2025

Choose a reason for hiding this comment

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

Ah, you are right! So why not just change f into aux_auto? I see no reason to have it as aux_transit anymore.

Originally, bike LOS was taken from pedestrian assignment (which is technically transit assignment), but when we started developing the bike assignment, we realized that car assignment would work better. I did not change f into aux_auto of pure laziness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, after discussing this issue with the development team we decided to change the "f" mode to AUX_AUTO and adjust the scenarios accordingly. "F" mode will not be used. This will be backwards incompatible, but the change is easy to do if there is need to run older scenarios.

@hsl-petrhaj
Copy link
Contributor Author

To my understanding, you would achieve the same result simply by

1. allowing `h` on all links (and never disallowing it)

2. changing mode in bike assignment to `f`

Please explain if I have overlooked some problem with this simpler approach.

By the way, do you know if having h allowed on all links in car assignment affects performance?

Simpler approach with h mode everywhere would not eliminate bikes where they do not belong.

About performance, I have not tested it, but since we are mostly using subnetworks in the car assignment I don't see how it would affect performance except for the first step - creating the subnet (which is done only once).

@zptro
Copy link
Collaborator

zptro commented Apr 15, 2025

About performance, I have not tested it, but since we are mostly using subnetworks in the car assignment I don't see how it would affect performance except for the first step - creating the subnet (which is done only once).

Are you sure gradient search is not performed for all links where the main mode is allowed? My guess would be that it is.

…tion to existing one) to f mode (existing bike mode that would be AUX_AUTO from now on).
@hsl-petrhaj
Copy link
Contributor Author

hsl-petrhaj commented Apr 15, 2025

About performance, I have not tested it, but since we are mostly using subnetworks in the car assignment I don't see how it would affect performance except for the first step - creating the subnet (which is done only once).

Are you sure gradient search is not performed for all links where the main mode is allowed? My guess would be that it is.

I am not sure where to look for evidence on this. However the "big model" tests did not show any noticeable extra delay, if there is, it is probably in seconds.

@hsl-petrhaj hsl-petrhaj merged commit 9a33598 into helmet5-experimental Apr 24, 2025
2 checks passed
@s-hiitola s-hiitola deleted the assign-bikes-as-F-mode branch December 10, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues with turning restrictions

2 participants