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

modify transportation script to avoid importing brails #351

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
38 changes: 32 additions & 6 deletions modules/systemPerformance/ResidualDemand/transportation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,39 @@
from sklearn.feature_extraction.text import TfidfVectorizer
from scipy.spatial.distance import cdist
from shapely.wkt import loads
from brails.utils.geoTools import haversine_dist
from brails.workflow.TransportationElementHandler import (
ROADLANES_MAP,
ROADSPEED_MAP,
calculate_road_capacity,
)
# from brails.utils.geoTools import haversine_dist
# from brails.workflow.TransportationElementHandler import (
# ROADLANES_MAP,
# ROADSPEED_MAP,
# calculate_road_capacity,
# )

## The below functions are mannually copied from brails to avoid importing brails

ROADLANES_MAP = {'S1100': 4, "S1200": 2, "S1400": 1, "S1500": 1, "S1630": 1,
"S1640": 1, "S1710": 1, "S1720": 1, "S1730": 1, "S1740": 1,
"S1750": 1, "S1780": 1, "S1810": 1, "S1820": 1, "S1830": 1}

ROADSPEED_MAP = {'S1100': 70, "S1200": 55, "S1400": 25, "S1500": 25,
"S1630": 25, "S1640": 25, "S1710": 25, "S1720": 25,
"S1730": 25, "S1740": 10, "S1750": 10, "S1780": 10,
"S1810": 10, "S1820": 10, "S1830": 10}
def calculate_road_capacity(nlanes: int,
traffic_volume_per_lane: int = 1800
) -> int:
"""
Calculate road capacity from number of lanes & traffic volume/lane.

Parameters__
nlanes (int): The number of lanes on the road.
traffic_volume_per_lane (int, optional): The traffic volume
capacity per lane. Default is 1800 vehicles.

Returns__
int: The total road capacity, which is the product of the number
of lanes and the traffic volume per lane.
"""
return nlanes * traffic_volume_per_lane

class TransportationPerformance(ABC): # noqa: B024
"""
Expand Down
Loading