1
1
package org .eqasim ;
2
2
3
+ import com .google .inject .Inject ;
4
+ import com .google .inject .Provider ;
3
5
import org .apache .commons .io .FileUtils ;
4
6
import org .eqasim .core .analysis .run .RunLegAnalysis ;
5
7
import org .eqasim .core .analysis .run .RunPublicTransportLegAnalysis ;
13
15
import org .eqasim .core .simulation .modes .drt .analysis .run .RunDrtPassengerAnalysis ;
14
16
import org .eqasim .core .simulation .modes .drt .analysis .run .RunDrtVehicleAnalysis ;
15
17
import org .eqasim .core .simulation .modes .feeder_drt .analysis .run .RunFeederDrtPassengerAnalysis ;
18
+ import org .eqasim .core .simulation .modes .feeder_drt .mode_choice .FeederDrtModeAvailabilityWrapper ;
16
19
import org .eqasim .core .simulation .modes .feeder_drt .utils .AdaptConfigForFeederDrt ;
17
20
import org .eqasim .core .tools .*;
18
21
import org .eqasim .core .simulation .modes .drt .utils .AdaptConfigForDrt ;
22
25
import org .junit .Test ;
23
26
import org .matsim .api .core .v01 .Scenario ;
24
27
import org .matsim .api .core .v01 .TransportMode ;
28
+ import org .matsim .contribs .discrete_mode_choice .model .mode_availability .ModeAvailability ;
25
29
import org .matsim .core .config .CommandLine ;
26
30
import org .matsim .core .config .Config ;
27
31
import org .matsim .core .config .ConfigUtils ;
@@ -49,7 +53,7 @@ public void tearDown() throws IOException {
49
53
FileUtils .deleteDirectory (new File ("melun_test" ));
50
54
}
51
55
52
- private void runMelunSimulation (String configPath , String outputPath , Collection < String > extraModes ) {
56
+ private void runMelunSimulation (String configPath , String outputPath ) {
53
57
EqasimConfigurator eqasimConfigurator = new EqasimConfigurator ();
54
58
Config config = ConfigUtils .loadConfig (configPath , eqasimConfigurator .getConfigGroups ());
55
59
((ControlerConfigGroup ) config .getModules ().get (ControlerConfigGroup .GROUP_NAME )).setOutputDirectory (outputPath );
@@ -69,19 +73,25 @@ private void runMelunSimulation(String configPath, String outputPath, Collection
69
73
@ Override
70
74
protected void installEqasimExtension () {
71
75
bind (ModeParameters .class );
72
- bindModeAvailability ("DefaultModeAvailability" ).toProvider (() -> (person , trips ) -> {
73
- Set <String > modes = new HashSet <>();
74
- modes .add (TransportMode .walk );
75
- modes .add (TransportMode .pt );
76
- modes .add (TransportMode .car );
77
- modes .add (TransportMode .bike );
78
- // Add special mode "car_passenger" if applicable
79
- Boolean isCarPassenger = (Boolean ) person .getAttributes ().getAttribute ("isPassenger" );
80
- if (isCarPassenger ) {
81
- modes .add ("car_passenger" );
76
+ bindModeAvailability ("DefaultModeAvailability" ).toProvider (new Provider <>() {
77
+ @ Inject
78
+ private Config config ;
79
+ @ Override
80
+ public ModeAvailability get () {
81
+ return new FeederDrtModeAvailabilityWrapper (config , (person , trips ) -> {
82
+ Set <String > modes = new HashSet <>();
83
+ modes .add (TransportMode .walk );
84
+ modes .add (TransportMode .pt );
85
+ modes .add (TransportMode .car );
86
+ modes .add (TransportMode .bike );
87
+ // Add special mode "car_passenger" if applicable
88
+ Boolean isCarPassenger = (Boolean ) person .getAttributes ().getAttribute ("isPassenger" );
89
+ if (isCarPassenger ) {
90
+ modes .add ("car_passenger" );
91
+ }
92
+ return modes ;
93
+ });
82
94
}
83
- modes .addAll (extraModes );
84
- return modes ;
85
95
}).asEagerSingleton ();
86
96
}
87
97
});
@@ -194,7 +204,7 @@ public void testDrt() throws IOException, CommandLine.ConfigurationException {
194
204
"--vehicles-paths" , "melun_test/input/drt_vehicles_a.xml.gz,melun_test/input/drt_vehicles_b.xml.gz"
195
205
});
196
206
197
- runMelunSimulation ("melun_test/input/config_drt.xml" , "melun_test/output_drt" , List . of ( "drt_a" , "drt_b" ) );
207
+ runMelunSimulation ("melun_test/input/config_drt.xml" , "melun_test/output_drt" );
198
208
199
209
RunDrtPassengerAnalysis .main (new String [] {
200
210
"--events-path" , "melun_test/output_drt/output_events.xml.gz" ,
@@ -243,7 +253,7 @@ public void testFeeder() throws IOException, CommandLine.ConfigurationException
243
253
"--access-egress-transit-stop-modes" , "rail|tram|subway"
244
254
});
245
255
246
- runMelunSimulation ("melun_test/input/config_feeder.xml" , "melun_test/output_feeder" , List . of ( "feeder_a" , "feeder_b" ) );
256
+ runMelunSimulation ("melun_test/input/config_feeder.xml" , "melun_test/output_feeder" );
247
257
248
258
RunFeederDrtPassengerAnalysis .main (new String [] {
249
259
"--config-path" , "melun_test/input/config_feeder.xml" ,
@@ -260,12 +270,12 @@ public void testEpsilon() throws CommandLine.ConfigurationException {
260
270
"--output-config-path" , "melun_test/input/config_epsilon.xml"
261
271
});
262
272
263
- runMelunSimulation ("melun_test/input/config_epsilon.xml" , "melun_test/output_epsilon" , Collections . emptyList () );
273
+ runMelunSimulation ("melun_test/input/config_epsilon.xml" , "melun_test/output_epsilon" );
264
274
}
265
275
266
276
@ Test
267
277
public void testPipeline () throws Exception {
268
- runMelunSimulation ("melun_test/input/config.xml" , "melun_test/output" , Collections . emptyList () );
278
+ runMelunSimulation ("melun_test/input/config.xml" , "melun_test/output" );
269
279
runAnalyses ();
270
280
runExports ();
271
281
}
0 commit comments