44
55package org .matsim .contrib .drt .extension .benchmark ;
66
7- import org .matsim .contrib .drt .extension .benchmark .InsertionStrategy .DetourPathCalculatorType ;
87import org .matsim .contrib .drt .extension .benchmark .InsertionStrategy .InsertionSearchStrategy ;
98import org .matsim .contrib .drt .extension .benchmark .InsertionStrategy .RequestInserterType ;
109import org .matsim .contrib .drt .extension .benchmark .scenario .SyntheticBenchmarkScenario ;
2322import org .matsim .core .config .CommandLine .ConfigurationException ;
2423import org .matsim .core .config .Config ;
2524import org .matsim .core .config .ConfigUtils ;
25+ import org .matsim .core .config .groups .ControllerConfigGroup ;
2626import org .matsim .core .controler .Controler ;
2727
2828import java .nio .file .Path ;
@@ -117,34 +117,32 @@ public static void runBenchmark(DrtBenchmarkConfigGroup config) {
117117 int vehicles = agents * config .getVehiclesPerHundredAgents () / 100 ;
118118
119119 for (InsertionSearchStrategy searchStrategy : config .getInsertionSearchStrategies ()) {
120- for (DetourPathCalculatorType pathCalcType : config .getDetourPathCalculatorTypes ()) {
120+ for (ControllerConfigGroup . RoutingAlgorithmType routingType : config .getRoutingAlgorithmTypes ()) {
121121 for (RequestInserterType inserterType : config .getRequestInserterTypes ()) {
122122
123123 if (inserterType == RequestInserterType .Parallel ) {
124- // Parallel inserter: expand partitioner × collectionPeriod combinations
125124 for (int collectionPeriod : config .getCollectionPeriods ()) {
126125 for (VehiclesPartitioner vp : config .getVehiclePartitioners ()) {
127126 for (RequestsPartitioner rp : config .getRequestPartitioners ()) {
128127
129128 String scenarioName = String .format ("Parallel_%s_%s_%s_%s_cp%d_%dk" ,
130- searchStrategy .name (), pathCalcType .name (),
129+ searchStrategy .name (), routingType .name (),
131130 shortName (vp ), shortName (rp ),
132131 collectionPeriod , agents / 1000 );
133132 String outputDir = String .format ("%s/%s/%s" ,
134133 config .getOutputDirectory (), timestamp , scenarioName );
135134
136- // Capture for lambda
137135 final int fAgents = agents , fVehicles = vehicles , fCp = collectionPeriod ;
138136 final VehiclesPartitioner fVp = vp ;
139137 final RequestsPartitioner fRp = rp ;
140138 final InsertionSearchStrategy fSearch = searchStrategy ;
141- final DetourPathCalculatorType fPathCalc = pathCalcType ;
139+ final ControllerConfigGroup . RoutingAlgorithmType fRoutingType = routingType ;
142140 final DrtBenchmarkConfigGroup fConfig = config ;
143141
144142 runner .addScenario (scenarioName , () -> {
145143 DrtInsertionSearchParams searchParams = createSearchParams (fSearch );
146144 Controler c = buildControler (fConfig , fAgents , fVehicles ,
147- outputDir , searchParams , fPathCalc );
145+ outputDir , searchParams , fRoutingType );
148146
149147 var drtCfg = MultiModeDrtConfigGroup .get (c .getConfig ())
150148 .getModalElements ().iterator ().next ();
@@ -170,19 +168,19 @@ public static void runBenchmark(DrtBenchmarkConfigGroup config) {
170168 } else {
171169 // Default (sequential) inserter
172170 String scenarioName = String .format ("Default_%s_%s_%dk" ,
173- searchStrategy .name (), pathCalcType .name (), agents / 1000 );
171+ searchStrategy .name (), routingType .name (), agents / 1000 );
174172 String outputDir = String .format ("%s/%s/%s" ,
175173 config .getOutputDirectory (), timestamp , scenarioName );
176174
177175 final int fAgents = agents , fVehicles = vehicles ;
178176 final InsertionSearchStrategy fSearch = searchStrategy ;
179- final DetourPathCalculatorType fPathCalc = pathCalcType ;
177+ final ControllerConfigGroup . RoutingAlgorithmType fRoutingType = routingType ;
180178 final DrtBenchmarkConfigGroup fConfig = config ;
181179
182180 runner .addScenario (scenarioName , () -> {
183181 DrtInsertionSearchParams searchParams = createSearchParams (fSearch );
184182 Controler c = buildControler (fConfig , fAgents , fVehicles ,
185- outputDir , searchParams , fPathCalc );
183+ outputDir , searchParams , fRoutingType );
186184
187185 var drtCfg = MultiModeDrtConfigGroup .get (c .getConfig ())
188186 .getModalElements ().iterator ().next ();
@@ -200,17 +198,13 @@ public static void runBenchmark(DrtBenchmarkConfigGroup config) {
200198 runner .run ();
201199 }
202200
203- // =========================================================================
204- // Helper methods
205- // =========================================================================
206-
207201 /**
208- * Builds a Controler with the given insertion search params and detour path calculator type .
202+ * Builds a Controler and sets the routing algorithm type directly on the controller config .
209203 */
210204 private static Controler buildControler (DrtBenchmarkConfigGroup config , int agents ,
211205 int vehicles , String outputDir ,
212206 DrtInsertionSearchParams searchParams ,
213- DetourPathCalculatorType pathCalcType ) {
207+ ControllerConfigGroup . RoutingAlgorithmType routingAlgorithmType ) {
214208 var builder = SyntheticBenchmarkScenario .builder ()
215209 .agents (agents )
216210 .vehicles (vehicles )
@@ -223,11 +217,7 @@ private static Controler buildControler(DrtBenchmarkConfigGroup config, int agen
223217 }
224218
225219 Controler c = builder .build ();
226-
227- var drtCfg = MultiModeDrtConfigGroup .get (c .getConfig ())
228- .getModalElements ().iterator ().next ();
229- drtCfg .setUseCHForInsertionSearch (pathCalcType == DetourPathCalculatorType .CH );
230-
220+ c .getConfig ().controller ().setRoutingAlgorithmType (routingAlgorithmType );
231221 return c ;
232222 }
233223
@@ -260,7 +250,7 @@ private static void printConfig(DrtBenchmarkConfigGroup config) {
260250 System .out .println ("Vehicles per 100 agents: " + config .getVehiclesPerHundredAgents ());
261251 System .out .println ("Request Inserter Types: " + config .getRequestInserterTypesString ());
262252 System .out .println ("Insertion Search Strategies: " + config .getInsertionSearchStrategiesString ());
263- System .out .println ("Detour Path Calculators : " + config .getDetourPathCalculatorTypesString ());
253+ System .out .println ("Routing Algorithm Types : " + config .getDetourPathCalculatorTypesString ());
264254 System .out .println ("Vehicle Partitioners (Parallel): " + config .getVehiclePartitionersString ());
265255 System .out .println ("Request Partitioners (Parallel): " + config .getRequestPartitionersString ());
266256 System .out .println ("Collection Periods (Parallel): " + config .getCollectionPeriods ());
@@ -276,16 +266,16 @@ private static void printConfig(DrtBenchmarkConfigGroup config) {
276266
277267 int agentCount = config .getAgentCounts ().size ();
278268 int searchCount = config .getInsertionSearchStrategies ().size ();
279- int pathCalcCount = config .getDetourPathCalculatorTypes ().size ();
269+ int routingTypeCount = config .getRoutingAlgorithmTypes ().size ();
280270 int parallelCombinations = config .getVehiclePartitioners ().size ()
281271 * config .getRequestPartitioners ().size ()
282272 * config .getCollectionPeriods ().size ();
283273 int totalScenarios = 0 ;
284274 for (RequestInserterType inserterType : config .getRequestInserterTypes ()) {
285275 if (inserterType == RequestInserterType .Parallel ) {
286- totalScenarios += agentCount * searchCount * pathCalcCount * parallelCombinations ;
276+ totalScenarios += agentCount * searchCount * routingTypeCount * parallelCombinations ;
287277 } else {
288- totalScenarios += agentCount * searchCount * pathCalcCount ;
278+ totalScenarios += agentCount * searchCount * routingTypeCount ;
289279 }
290280 }
291281 System .out .println ("Total scenarios to run: " + totalScenarios );
0 commit comments