Skip to content

Commit

Permalink
Disable select link (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Moss committed Sep 4, 2023
1 parent 3f6d2ed commit 0cd3d48
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
1 change: 1 addition & 0 deletions aequilibrae/paths/results/assignment_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def get_load_results(self) -> AequilibraeData:
def get_sl_results(self) -> AequilibraeData:
# Set up the name for each column. Each set of select links has a column for ab, ba, total flows
# for each subclass contained in the TrafficClass
raise NotImplementedError("Select link is currently disabled. See issue #442")
fields = [
e
for name in self._selected_links.keys()
Expand Down
6 changes: 6 additions & 0 deletions aequilibrae/paths/traffic_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@ def select_link_flows(self) -> Dict[str, pd.DataFrame]:
"""
Returns a dataframe of the select link flows for each class
"""

raise NotImplementedError("Select link is currently disabled. See issue #442")
class_flows = [] # stores the df for each class
for cls in self.classes:
# Save OD_matrices
Expand All @@ -713,6 +715,7 @@ def save_select_link_flows(self, table_name: str, project=None) -> None:
Defaults to the active project
"""

raise NotImplementedError("Select link is currently disabled. See issue #442")
if not project:
project = self.project or get_active_project()
df = self.select_link_flows()
Expand Down Expand Up @@ -745,6 +748,7 @@ def save_select_link_matrices(self, file_name: str) -> None:
Saves the Select Link matrices for each TrafficClass in the current TrafficAssignment class
"""

raise NotImplementedError("Select link is currently disabled. See issue #442")
for cls in self.classes:
# Save OD_matrices
if cls._selected_links is None:
Expand All @@ -766,5 +770,7 @@ def save_select_link_results(self, name: str) -> None:
:Arguments:
**name** (:obj:`str`): name of the matrices
"""

raise NotImplementedError("Select link is currently disabled. See issue #442")
self.save_select_link_flows(name)
self.save_select_link_matrices(name)
1 change: 1 addition & 0 deletions aequilibrae/paths/traffic_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def set_select_links(self, links: Dict[str, List[Tuple[int, int]]]):
:Arguments:
**links** (:obj:`Union[None, Dict[str, List[Tuple[int, int]]]]`): name of link set and
Link IDs and directions to be used in select link analysis"""
raise NotImplementedError("Select link is currently disabled. See issue #442")
self._selected_links = {}
for name, link_set in links.items():
if len(name.split(" ")) != 1:
Expand Down
76 changes: 38 additions & 38 deletions docs/source/examples/full_workflows/plot_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,44 +324,44 @@
assig.max_iter = 500
assig.rgap_target = 0.00001

#%%
# **OPTIONAL**

# If we want to execute select link analysis on a particular TrafficClass, we set the links we are analyzing.
# The format of the input select links is a dictionary (str: list[tuple]).
# Each entry represents a separate set of selected links to compute. The str name will name the set of links.
# The list[tuple] is the list of links being selected, of the form (link_id, direction), as it occurs in the Graph.
# Direction can be 0, 1, -1. 0 denotes bi-directionality
# For example, let's use Select Link on two sets of links:

# %%
select_links = {
"Leaving node 1": [(1, 1), (2, 1)],
"Random nodes": [(3, 1), (5, 1)],
}
# We call this command on the class we are analyzing with our dictionary of values
assigclass.set_select_links(select_links)

assig.execute() # we then execute the assignment

# %%
# Now let us save our select link results, all we need to do is provide it with a name
# In addition to exporting the select link flows, it also exports the Select Link matrices in OMX format.
assig.save_select_link_results("select_link_analysis")

# %%
# Say we just want to save our select link flows, we can call:
assig.save_select_link_flows("just_flows")

# Or if we just want the SL matrices:
assig.save_select_link_matrices("just_matrices")
# Internally, the save_select_link_results calls both of these methods at once.

# We could export it to CSV or AequilibraE data, but let's put it directly into the results database
assig.save_results("future_year_assignment")

# And save the skims
assig.save_skims("future_year_assignment_skims", which_ones="all", format="omx")
# #%%
# # **OPTIONAL**

# # If we want to execute select link analysis on a particular TrafficClass, we set the links we are analyzing.
# # The format of the input select links is a dictionary (str: list[tuple]).
# # Each entry represents a separate set of selected links to compute. The str name will name the set of links.
# # The list[tuple] is the list of links being selected, of the form (link_id, direction), as it occurs in the Graph.
# # Direction can be 0, 1, -1. 0 denotes bi-directionality
# # For example, let's use Select Link on two sets of links:

# # %%
# select_links = {
# "Leaving node 1": [(1, 1), (2, 1)],
# "Random nodes": [(3, 1), (5, 1)],
# }
# # We call this command on the class we are analyzing with our dictionary of values
# assigclass.set_select_links(select_links)

# assig.execute() # we then execute the assignment

# # %%
# # Now let us save our select link results, all we need to do is provide it with a name
# # In addition to exporting the select link flows, it also exports the Select Link matrices in OMX format.
# assig.save_select_link_results("select_link_analysis")

# # %%
# # Say we just want to save our select link flows, we can call:
# assig.save_select_link_flows("just_flows")

# # Or if we just want the SL matrices:
# assig.save_select_link_matrices("just_matrices")
# # Internally, the save_select_link_results calls both of these methods at once.

# # We could export it to CSV or AequilibraE data, but let's put it directly into the results database
# assig.save_results("future_year_assignment")

# # And save the skims
# assig.save_skims("future_year_assignment_skims", which_ones="all", format="omx")

#%%
# We can also plot convergence
Expand Down
3 changes: 2 additions & 1 deletion tests/aequilibrae/paths/test_select_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from os.path import join, dirname
from shutil import copytree
from tempfile import gettempdir
from unittest import TestCase
from unittest import TestCase, skip
import numpy as np
import pandas as pd

from aequilibrae import TrafficAssignment, TrafficClass, Graph, Project, PathResults
from ...data import siouxfalls_project


@skip("Select link is currently disabled. See issue #442")
class TestSelectLink(TestCase):
def setUp(self) -> None:
os.environ["PATH"] = os.path.join(gettempdir(), "temp_data") + ";" + os.environ["PATH"]
Expand Down

0 comments on commit 0cd3d48

Please sign in to comment.