@@ -394,11 +394,13 @@ def _load_output_matrices(self, allMatrixDictsList, matrix_name_list):
394394 def _init_analysis_matrices (self , parameters , time_period_count ):
395395 number_of_time_periods = time_period_count
396396 for tc in parameters ['TrafficClasses' ]:
397- if len ( tc [ 'PathAnalyses' ]) > 0 :
397+ if 'PathAnalyses' in tc :
398398 # Currently only 1 PAth Analysis is supported per class
399- if (len (tc ['PathAnalyses' ]) > 1 ):
400- raise Exception ("Only one Path Analysis is currently supported per traffic class!" )
401- matrix_number = tc ['PathAnalyses' ][0 ]['StartMatrixNumber' ]
399+ matrix_number = tc ['PathAnalyses' ]['StartMatrixNumber' ]
400+ for inc in range (0 , 24 ):
401+ _ = self ._get_or_create ("mf" + str (matrix_number + inc ))
402+ elif 'traversal_analysis' in tc :
403+ matrix_number = tc ['traversal_analysis' ]['StartMatrixNumber' ]
402404 for inc in range (0 , 24 ):
403405 _ = self ._get_or_create ("mf" + str (matrix_number + inc ))
404406 return
@@ -632,36 +634,55 @@ def convert_bound(bound_str):
632634 return None if bound_str == "None" else float (bound_str )
633635
634636 def append_path_analyes (stta_class , parameters , i ):
635- ret = []
636- paths = Parameters ['TrafficClasses' ][i ]['PathAnalyses' ]
637- for j in range (len (paths )):
638- analysis = {
639- "link_component" : paths [j ]['AttributeId' ],
640- # There is no turn component for STTA
641- "operator" : paths [j ]['AggregationOperator' ],
642- "selection_threshold" : {
643- "lower" : convert_bound (paths [j ]['LowerBound' ]),
644- "upper" : convert_bound (paths [j ]['UpperBound' ])
645- },
646- "path_to_od_composition" : {
647- "considered_paths" : paths [j ]['PathSelection' ],
648- "multiply_path_proportions_by" : {
649- "analyzed_demand" : paths [j ]['MultiplyPathByDemand' ],
650- "path_value" : paths [j ]['MultiplyPathByValue' ],
637+ tc = Parameters ['TrafficClasses' ]
638+ if not ('PathAnalyses' in tc ):
639+ return
640+
641+ path = tc ['PathAnalyses' ]
642+ analysis = {
643+ "link_component" : path ['AttributeId' ],
644+ # There is no turn component for STTA
645+ "operator" : path ['AggregationOperator' ],
646+ "selection_threshold" : {
647+ "lower" : convert_bound (path ['LowerBound' ]),
648+ "upper" : convert_bound (path ['UpperBound' ])
651649 },
650+ "path_to_od_composition" : {
651+ "considered_paths" : path ['PathSelection' ],
652+ "multiply_path_proportions_by" : {
653+ "analyzed_demand" : path ['MultiplyPathByDemand' ],
654+ "path_value" : path ['MultiplyPathByValue' ],
652655 },
656+ },
657+ }
658+ stta_class ['path_analysis' ] = analysis
659+ stta_class ['analysis' ] = {
660+ 'analyzed_demand' : None ,
661+ 'results' : {
662+ "od_values" : 'mf' + str (path ['StartMatrixNumber' ]),
663+ "selected_link_volumes" : None
664+ }
665+ }
666+ return
667+
668+ def append_traversal_analysis (stta_class , parameters , i ):
669+ tc = Parameters ['TrafficClasses' ][i ]
670+ # if there is no traversal analysis to run, just continue on
671+ if not ('traversal_analysis' in tc ):
672+ return 0
673+ traversal_spec = tc ['traversal_analysis' ]
674+ stta_class ['traversal_analysis' ] = {
675+ 'link_gates' : traversal_spec ['link_gates' ],
676+ 'gate_pairs_threshold' : traversal_spec ['gate_pairs_threshold' ],
653677 }
654- ret .append (analysis )
655- if ret :
656- stta_class ['path_analysis' ] = ret [0 ]
657- stta_class ['analysis' ] = {
678+ stta_class ['analysis' ] = {
658679 'analyzed_demand' : None ,
659680 "results" : {
660- "od_values" : 'mf' + str (paths [ 0 ] ['StartMatrixNumber' ]),
681+ "od_values" : 'mf' + str (traversal_spec ['StartMatrixNumber' ]),
661682 "selected_link_volumes" : None
662683 }
663684 }
664- return
685+ return traversal_spec [ 'MaxCPUCores' ]
665686
666687 STTA_class_generator = []
667688 for i , matrix_dict in enumerate (allMatrixDictsList ):
@@ -680,6 +701,12 @@ def append_path_analyes(stta_class, parameters, i):
680701 },
681702 }
682703 append_path_analyes (stta_class , Parameters , i )
704+ max_cores = append_traversal_analysis (stta_class , Parameters , i )
705+ # We need this logic because traversal analyses do not spread across different CCXs efficiently
706+ # in the Zen architecture leading to performance degradation.
707+ if max_cores > 0 :
708+ current_cores = STTA_spec ['performance_settings' ]['number_of_processors' ]
709+ STTA_spec ['performance_settings' ]['number_of_processors' ] = min (max_cores , current_cores )
683710 STTA_class_generator .append (stta_class )
684711 STTA_spec ["classes" ] = STTA_class_generator
685712
0 commit comments