Skip to content

Commit

Permalink
Add support for parking time function based on the destination zone_data
Browse files Browse the repository at this point in the history
  • Loading branch information
samakinen committed Nov 9, 2024
1 parent f82cff5 commit 1c359b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Scripts/parameters/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

from collections import namedtuple
from typing import Dict, List, Union

import numpy as np
import pandas as pd

from datahandling.zonedata import ZoneData
RoadClass = namedtuple(
"RoadClass",
(
Expand Down Expand Up @@ -171,6 +176,11 @@
}
# Default distance unit cost [eur/km]
dist_unit_cost = 0.12
# Parking time function
def parking_time(zone_data: ZoneData) -> pd.Series:
density: pd.Series = (zone_data['population'] + zone_data['workplaces']) / zone_data['zone_area']
return 0.05993817*np.sqrt(density) + 5.24176150

# Default distance unit time for trucks and trailer trucks [min/km]
freight_dist_unit_time = 0.2
# Boarding penalties for different transit modes
Expand Down
11 changes: 11 additions & 0 deletions Scripts/transform/impedance_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import parameters.impedance_transformation as param
from parameters.assignment import assignment_classes
try:
from parameters.assignment import parking_time
except ImportError:
parking_time = None


class ImpedanceTransformer:
Expand Down Expand Up @@ -55,4 +59,11 @@ def transform(self, purpose, impedance):
for i in range(1, len(purpose.sub_bounds)):
trips_per_month[purpose.sub_bounds[i], :] = trips_month[i]
day_imp["transit"]["cost"] /= trips_per_month
# Add parking time to car matrices
if parking_time is not None:
ptime = parking_time(purpose.zone_data).to_numpy()[cols]
ptime = numpy.clip(ptime, 0, 30)
car_modes = [k for k in day_imp.keys() if k in ('car', 'car_work', 'car_transit')]
for k in car_modes:
day_imp[k]['time'] += ptime[None,:]
return day_imp

0 comments on commit 1c359b9

Please sign in to comment.