Skip to content

Commit

Permalink
Addded selected_link_volumes option for SOLA Path Analysis (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesVaughan authored Sep 18, 2024
1 parent 8326175 commit a8631b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions TMGToolbox/src/XTMF_internal/multi_class_road_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class MultiClassRoadAssignment(_m.Tool()):
ResultAttributes = _m.Attribute(str)
xtmf_AnalysisAttributes = _m.Attribute(str)
xtmf_AnalysisAttributesMatrixId = _m.Attribute(str)
xtmf_AnalysisSelectedLinkVolumes = _m.Attribute(str)
xtmf_AggregationOperator = _m.Attribute(str)
xtmf_LowerBound = _m.Attribute(str)
xtmf_UpperBound = _m.Attribute(str)
Expand Down Expand Up @@ -168,6 +169,7 @@ def __call__(
ResultAttributes,
xtmf_AnalysisAttributes,
xtmf_AnalysisAttributesMatrixId,
xtmf_AnalysisSelectedLinkVolumes,
xtmf_AggregationOperator,
xtmf_LowerBound,
xtmf_UpperBound,
Expand Down Expand Up @@ -197,6 +199,7 @@ def __call__(
self.LinkTollAttributeId = [x for x in LinkTollAttributeId.split(",")]
AnalysisAttributes = [x for x in xtmf_AnalysisAttributes.split("|")]
AnalysisAttributesMatrixId = [x for x in xtmf_AnalysisAttributesMatrixId.split("|")]
AnalysisSelectedLinkVolumes = [x for x in xtmf_AnalysisSelectedLinkVolumes.split("|")]
operators = [x for x in xtmf_AggregationOperator.split("|")]
lowerBounds = [x for x in xtmf_LowerBound.split("|")]
upperBounds = [x for x in xtmf_UpperBound.split("|")]
Expand All @@ -205,6 +208,7 @@ def __call__(
mulitplyPathValue = [x for x in xtmf_MultiplyPathPropByValue.split("|")]
self.ClassAnalysisAttributes = []
self.ClassAnalysisAttributesMatrix = []
self.ClassAnalysisSelectedLinkVolumes = []
self.ClassAnalysisOperators = []
self.ClassAnalysisLowerBounds = []
self.ClassAnalysisUpperBounds = []
Expand All @@ -215,6 +219,7 @@ def __call__(
for i in range(len(self.Demand_List)):
self.ClassAnalysisAttributes.append([x for x in AnalysisAttributes[i].split(",")])
self.ClassAnalysisAttributesMatrix.append([x for x in AnalysisAttributesMatrixId[i].split(",")])
self.ClassAnalysisSelectedLinkVolumes.append([x for x in AnalysisSelectedLinkVolumes[i].split(",")])
self.ClassAnalysisOperators.append([x for x in operators[i].split(",")])
self.ClassAnalysisLowerBounds.append([x for x in lowerBounds[i].split(",")])
self.ClassAnalysisUpperBounds.append([x for x in upperBounds[i].split(",")])
Expand All @@ -228,6 +233,9 @@ def __call__(
if self.ClassAnalysisAttributesMatrix[i][j] == "mf0" or self.ClassAnalysisAttributesMatrix[i][j] == "":
# make mf0 matrices None for better use in spec
self.ClassAnalysisAttributesMatrix[i][j] = None
if self.ClassAnalysisSelectedLinkVolumes[i][j] == "":
# make mf0 matrices None for better use in spec
self.ClassAnalysisSelectedLinkVolumes[i][j] = None
try:
self.ClassAnalysisLowerBounds[i][j] = float(self.ClassAnalysisLowerBounds[i][j])
self.ClassAnalysisUpperBounds[i][j] = float(self.ClassAnalysisUpperBounds[i][j])
Expand Down Expand Up @@ -391,6 +399,7 @@ def get_attribute_name(at):
attributeDefined = False
allAttributes = []
allMatrices = []
selectedLinkVolumes = []
operators = []
lowerBounds = []
upperBounds = []
Expand All @@ -401,6 +410,7 @@ def get_attribute_name(at):
for i in range(len(self.Demand_List)):
allAttributes.append([])
allMatrices.append([])
selectedLinkVolumes.append([])
operators.append([])
lowerBounds.append([])
upperBounds.append([])
Expand All @@ -411,6 +421,7 @@ def get_attribute_name(at):
_m.logbook_write("Cost matrix defined for class %s" % self.ClassNames[i])
allAttributes[i].append(costAttribute[i].id)
allMatrices[i].append(self.CostMatrixId[i])
selectedLinkVolumes[i].append(None)
operators[i].append("+")
lowerBounds[i].append(None)
upperBounds[i].append(None)
Expand All @@ -424,6 +435,7 @@ def get_attribute_name(at):
_m.logbook_write("Toll matrix defined for class %s" % self.ClassNames[i])
allAttributes[i].append(self.LinkTollAttributeId[i])
allMatrices[i].append(self.TollsMatrixId[i])
selectedLinkVolumes[i].append(None)
operators[i].append("+")
lowerBounds[i].append(None)
upperBounds[i].append(None)
Expand All @@ -438,6 +450,7 @@ def get_attribute_name(at):
_m.logbook_write("Additional matrix for attribute %s defined for class %s" % (self.ClassAnalysisAttributes[i][j], self.ClassNames[i]))
allAttributes[i].append(self.ClassAnalysisAttributes[i][j])
allMatrices[i].append(self.ClassAnalysisAttributesMatrix[i][j])
selectedLinkVolumes[i].append(self.ClassAnalysisSelectedLinkVolumes[i][j])
operators[i].append(self.ClassAnalysisOperators[i][j])
lowerBounds[i].append(self.ClassAnalysisLowerBounds[i][j])
upperBounds[i].append(self.ClassAnalysisUpperBounds[i][j])
Expand Down Expand Up @@ -470,6 +483,7 @@ def get_attribute_name(at):
self.normGap,
self.PerformanceFlag,
self.TimesMatrixId,
selectedLinkVolumes
)
report = self._tracker.runTool(trafficAssignmentTool, spec, scenario=self.Scenario)
assignmentComplete = True
Expand Down
6 changes: 5 additions & 1 deletion TMGToolbox/src/common/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ def _getPrimarySOLASpec(
normGap,
PerformanceFlag,
TimesMatrixId,
selectedLinkVolumes = None,
):

if PerformanceFlag:
Expand Down Expand Up @@ -994,7 +995,10 @@ def _getPrimarySOLASpec(
"path_value": multiplyPathValue[i][j],
},
},
"results": {"od_values": matrices[i][j]},
"results": {
"od_values": matrices[i][j],
"selected_link_volumes": (selectedLinkVolumes[i][j] if selectedLinkVolumes is not None else None)
},
"analyzed_demand": None,
}
SOLA_path_analysis[i].append(path)
Expand Down

0 comments on commit a8631b9

Please sign in to comment.