-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRunFabilandTest.java
More file actions
142 lines (113 loc) · 5.99 KB
/
RunFabilandTest.java
File metadata and controls
142 lines (113 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package run;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.population.Population;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.population.routes.PopulationComparison;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;
import static org.matsim.utils.eventsfilecomparison.ComparisonResult.FILES_ARE_EQUAL;
//@ExtendWith(MatsimTestUtils.class)
public class RunFabilandTest{
private static final Logger log = LogManager.getLogger( RunFabilandTest.class );
@RegisterExtension
public MatsimTestUtils utils = new MatsimTestUtils();
@Test
public void testMain(){
final String inputDirectory = utils.getInputDirectory();
try {
String [] args = {"./scenario/test.properties",
"./scenario/config_cap30_1-l_nes_smc.xml",
// "--config:controler.outputDirectory", utils.getOutputDirectory(), // has no effect; evidently overwritten by code
"--config:controler.lastIteration", "2"
// (I made this "2" because with "1" it failed quite often with a failing binary search. Seems to be fixed
// with the changed random number generator (see comments in SimpleCommuteModeChoiceMatsimScenarioAssembler),
// but I do not want to commit again new regression test files. So leaving it at "2". kai, jun'23
} ;
RunFabiland.main( args ) ;
log.info("############################################");
log.info("############################################");
// yyyyyy in the following, base/matsim/2 seems to be complete, but base/matsim/0 and base/matsim/1 not.
// yy I don't even know what these are ... are these iterations, or "years" of transport model runs?
// --> should be the latter
// --> "2" was from older
{
Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( expected, inputDirectory + "0.output_plans.xml.gz" );
Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( actual, "scenario/scenOutput/base/matsim/0/0.output_plans.xml.gz" );
PopulationComparison.Result result2 = PopulationComparison.compare( expected, actual );
Assertions.assertEquals( PopulationComparison.Result.equal, result2 );
boolean result = PopulationUtils.comparePopulations( expected, actual );
Assertions.assertTrue( result );
}
{
String expected = inputDirectory + "/0.output_events.xml.gz" ;
String actual = "scenario/scenOutput/base/matsim/0/0.output_events.xml.gz" ;
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( FILES_ARE_EQUAL, result );
}
log.info("############################################");
log.info("############################################");
{
Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( expected, inputDirectory + "1.0.plans.xml.gz" );
Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( actual, "scenario/scenOutput/base/matsim/1/ITERS/it.0/1.0.plans.xml.gz" );
boolean result = PopulationUtils.comparePopulations( expected, actual );
Assertions.assertTrue( result );
}
{
String expected = inputDirectory + "/1.0.events.xml.gz" ;
String actual = "scenario/scenOutput/base/matsim/1/ITERS/it.0/1.0.events.xml.gz" ;
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( FILES_ARE_EQUAL, result );
}
log.info("############################################");
log.info("############################################");
{
Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( expected, inputDirectory + "1.output_plans.xml.gz" );
Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
PopulationUtils.readPopulation( actual, "scenario/scenOutput/base/matsim/1/1.output_plans.xml.gz" );
boolean result = PopulationUtils.comparePopulations( expected, actual );
Assertions.assertTrue( result );
}
{
String expected = inputDirectory + "/1.output_events.xml.gz" ;
String actual = "scenario/scenOutput/base/matsim/1/1.output_events.xml.gz" ;
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( FILES_ARE_EQUAL, result );
}
log.info("############################################");
log.info("############################################");
// {
// Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
// PopulationUtils.readPopulation( expected, utils.getInputDirectory() + "10.output_plans.xml.gz" );
//
// Population actual = PopulationUtils.createPopulation( ConfigUtils.createConfig() ) ;
// PopulationUtils.readPopulation( actual, "scenario/scenOutput/base/matsim/10/10.output_plans.xml.gz" );
//
// boolean result = PopulationUtils.comparePopulations( expected, actual );
// Assert.assertTrue( result );
// }
// {
// String expected = utils.getInputDirectory() + "/10.output_events.xml.gz" ;
// String actual = "scenario/scenOutput/base/matsim/10/10.output_events.xml.gz" ;
// EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
// Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
// }
} catch ( Exception ee ) {
log.fatal("there was an exception: \n" + ee ) ;
ee.printStackTrace();
// if one catches an exception, then one needs to explicitly fail the test:
Assertions.fail();
}
}
}