Skip to content

Feat/bike hills modeling #578

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

Draft
wants to merge 15 commits into
base: helmet-5
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Scripts/assignment/assignment_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict:
self._calc_extra_wait_time()
self._assign_transit()
elif iteration==0:
self._set_bike_vdfs()
self._assign_bikes(self.emme_matrices["bike"]["dist"], "all")
self._set_car_and_transit_vdfs()
if not self._separate_emme_scenarios:
self._calc_background_traffic()
Expand Down Expand Up @@ -372,6 +374,13 @@ def _set_car_and_transit_vdfs(self):
def _set_bike_vdfs(self):
log.info("Sets bike functions for scenario {}".format(
self.emme_scenario.id))
# Create time period specific extra function parameters for bike assignment
# TODO: create a combined extra atrribute and use a single extra function parameter
self.emme_project.create_extra_function_parameters(el2=self.extra('car_work'),
el3=self.extra('car_leisure'),
el4=self.extra('van'),
el5=self.extra('truck'),
el6=self.extra('trailer_truck'))
network = self.emme_scenario.get_network()
main_mode = network.mode(param.main_mode)
bike_mode = network.mode(param.bike_mode)
Expand Down
1 change: 1 addition & 0 deletions Scripts/assignment/emme_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def prepare_network(self,
pass
self.emme_project.modeller.emmebank.create_function(
idx, param.volume_delay_funcs[idx])
self.emme_project.create_extra_function_parameters(el1="@kaltevuus")

def init_assign(self,
demand: Dict[str,List[numpy.ndarray]]):
Expand Down
2 changes: 2 additions & 0 deletions Scripts/assignment/emme_bindings/emme_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self,
"inro.emme.transit_assignment.extended.network_results")
self.create_extra_attribute = self.modeller.tool(
"inro.emme.data.extra_attribute.create_extra_attribute")
self.create_extra_function_parameters = self.modeller.tool(
"inro.emme.traffic_assignment.set_extra_function_parameters")

def write(self, message: str):
"""Write to logbook."""
Expand Down
3 changes: 3 additions & 0 deletions Scripts/assignment/emme_bindings/mock_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ def matrix_results(self, *args, **kwargs):
def network_results(self, *args, **kwargs):
pass

def create_extra_function_parameters(self, *args, **kwargs):
pass


Modeller = namedtuple("Modeller", "emmebank")

Expand Down
33 changes: 21 additions & 12 deletions Scripts/parameters/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type", "num_lanes", "volume_delay_func", "lane_capacity",
"free_flow_speed", "bus_delay",
))
# Code derived from three-digit link type xyz, where yz is the road class code
# Code derived from three-digit link type xyz, where yz is the road class code. See dictionary volume_delay_funcs below.
roadclasses = {
21: RoadClass("motorway", "<3", 1, 2100, 113, 0.265),
22: RoadClass("motorway", ">=3", 1, 1900, 113, 0.265),
Expand Down Expand Up @@ -44,7 +44,7 @@
94: "arterial",
95: "local",
}
# Bike delay function ids
# Bike delay function ids, defaults to None. See dictionary volume_delay_funcs below.
bikepath_vdfs = (
{ # 0 - Mixed traffic
None: 78,
Expand All @@ -67,6 +67,7 @@
None: 70,
}
)

# Transit delay function ids
transit_delay_funcs = {
("bus", "bgde"): {
Expand Down Expand Up @@ -97,6 +98,14 @@
+ "(ul1-get(2))))*(get(2).le.put(ul1*{}))*length+(get(2).gt."
+ "get(3))*({}*get(1)*length+{}*(get(2)-get(3))*length)")
buslane = "((lanes-1).max.0.8)"
vdf_bikes = ("length * (60/((5.max.({} + (el1.lt.0) * (1.56 * el1) +"
+" (el1.gt.0) * (1.3 * el1))).min.({}*1.3)))")
vdf_bikes_baana = ("length*(60/((5.max.({} + (el1.lt.0) * (1.56 * el1) +"
+" (el1.gt.0) * (1.3 * el1))).min.35))")
vdf_bikes_mixed_lane = "(length * (60/((5.max.({flat} + (el1.lt.0) * (1.56 * el1) + (el1.gt.0) * (1.3 * el1)) + (-5).max.{vol}.min.5).min.({flat}*1.5))))"

b_volume_mixed = "(-1.962 * ln(4*(el2+el3+el4+el5+el6+10)/1000) * 0.689)"
b_volume_lane = "(-1.962 * ln(4*(el2+el3+el4+el5+el6+10)/1000) * 0.807)"
volume_delay_funcs = {
# Car functions
"fd1": vdf_temp.format(0.02, "lanes", 0.975, 1.78, 0.0075),
Expand All @@ -111,16 +120,16 @@
"fd10": vdf_temp.format(0.3, buslane, 0.810, 2.28, 0.0170),
"fd99": "length * 1.3",
# Bike functions
"fd70": "length*(60/19)",
"fd71": "length*(60/17)",
"fd72": "length*(60/17)",
"fd73": "length*(60/16)",
"fd74": "length*(60/15)",
"fd75": "length*(60/15)",
"fd76": "length*(60/12)",
"fd77": "length*(60/10)",
"fd78": "length*(60/12)",
"fd98": "length*(60/12)",
"fd70": vdf_bikes_baana.format(19),
"fd71": vdf_bikes.format(17, 17),
"fd72": vdf_bikes.format(17, 17),
"fd73": vdf_bikes.format(16, 16),
"fd74": vdf_bikes.format(15, 15),
"fd75": vdf_bikes_mixed_lane.format(flat=12, vol=b_volume_lane),
"fd76": vdf_bikes_mixed_lane.format(flat=12, vol=b_volume_mixed),
"fd77": vdf_bikes_mixed_lane.format(flat=10, vol=b_volume_mixed),
"fd78": vdf_bikes_mixed_lane.format(flat=10, vol=b_volume_mixed),
"fd98": vdf_bikes.format(12, 12),
# Transit functions
## Bus, no bus lane
"ft01": "us2*length+timau",
Expand Down
Loading
Loading