Skip to content

Commit

Permalink
Merge branch 'master' into detour-constraint-minor-update
Browse files Browse the repository at this point in the history
  • Loading branch information
luchengqi7 authored Mar 18, 2024
2 parents 0912633 + 95bdede commit 1c94d9d
Show file tree
Hide file tree
Showing 44 changed files with 1,106 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result.FILES_ARE_EQUAL;
import static org.matsim.utils.eventsfilecomparison.ComparisonResult.FILES_ARE_EQUAL;

/**
* @author dziemke
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

import java.net.URL;

Expand Down Expand Up @@ -81,8 +81,8 @@ public void install(){
throw new RuntimeException(e) ;
}
final String expected = utils.getClassInputDirectory() + emissionEventsFileName;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, resultingEvents);
Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles(expected, resultingEvents);
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

import java.net.URL;

Expand Down Expand Up @@ -58,8 +58,8 @@ final void testAverage_vehTypeV1() {

String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result);
}

@Test
Expand All @@ -80,8 +80,8 @@ final void testAverage_vehTypeV2() {

String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result);
}

/**
Expand All @@ -106,8 +106,8 @@ final void testAverage_vehTypeV2b() {

String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result);

}

Expand All @@ -130,7 +130,7 @@ final void testAverage_vehTypeV2_HBEFA4() {

String expected = utils.getInputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
String actual = utils.getOutputDirectory() + RunAverageEmissionToolOfflineExample.emissionEventsFilename;
Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class RunEvExampleTest{

Expand Down Expand Up @@ -39,8 +39,8 @@ public class RunEvExampleTest{
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}

} catch ( Exception ee ) {
Expand Down Expand Up @@ -72,8 +72,8 @@ public class RunEvExampleTest{
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}

} catch ( Exception ee ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class RunEvExampleWithLTHConsumptionModelTest{

Expand Down Expand Up @@ -43,8 +39,8 @@ void runTest(){
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result );
}

} catch ( Exception ee ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class RunChessboardIT {

Expand Down Expand Up @@ -60,8 +60,8 @@ void runChessboard() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result );
}
} catch (Exception ee ) {
ee.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

/**
* @author jbischoff
Expand Down Expand Up @@ -108,8 +108,8 @@ void testRunParkingDistanceMemoryStrategy() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz";
String actual = utils.getOutputDirectory() + "/output_events.xml.gz";
EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -146,8 +146,8 @@ void testRunParkingNearestParkingSpotStrategy() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz";
String actual = utils.getOutputDirectory() + "/output_events.xml.gz";
EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator.Result;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class RunWithParkingProxyIT {
private static final Logger log = LogManager.getLogger(RunWithParkingProxyIT.class);
Expand All @@ -50,8 +50,8 @@ void testMain(){
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
Result result = EventsUtils.compareEventsFiles( expected, actual );
if(!result.equals(Result.FILES_ARE_EQUAL)) {
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
if(!result.equals(ComparisonResult.FILES_ARE_EQUAL)) {
throw new RuntimeException("Events comparison ended with result " + result.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

/**
* @author vsp-gleich
Expand All @@ -55,7 +55,7 @@ final void testMain() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, EventsUtils.compareEventsFiles( expected, actual ));
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, EventsUtils.compareEventsFiles( expected, actual ));
}
{
final Population expected = PopulationUtils.createPopulation( ConfigUtils.createConfig() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;

import static org.matsim.utils.eventsfilecomparison.EventsFileComparator.*;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

/**
* @author aneumann
Expand Down Expand Up @@ -125,7 +124,7 @@ private void runQSimWithSignals(final Scenario scenario) {

eventsXmlWriter.closeFile();
// Assert.assertEquals("different events files", EventsFileComparator.compareAndReturnInt(this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut), 0);
Assertions.assertEquals( Result.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut ) );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( this.testUtils.getInputDirectory() + EVENTSFILE, eventsOut ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

import java.io.File;

Expand Down Expand Up @@ -88,7 +89,7 @@ void testSignalSystems() {
//iteration 0
String iterationOutput = controlerOutputDir + "ITERS/it.0/";

Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL,
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL,
new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz",
iterationOutput + "0.events.xml.gz"),
"different events files after iteration 0 "
Expand All @@ -113,7 +114,7 @@ void testSignalSystems() {
//iteration 10
String iterationOutput = controlerOutputDir + "ITERS/it.10/";

Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL,
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL,
new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz" ),
"different event files after iteration 10"
);
Expand Down Expand Up @@ -181,7 +182,7 @@ void testSignalSystemsWTryEndTimeThenDuration() {
//iteration 0
String iterationOutput = controlerOutputDir + "ITERS/it.0/";

Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL,
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL,
new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "0.events.xml.gz",
iterationOutput + "0.events.xml.gz"),
"different events files after iteration 0 "
Expand All @@ -206,7 +207,7 @@ void testSignalSystemsWTryEndTimeThenDuration() {
//iteration 10
String iterationOutput = controlerOutputDir + "ITERS/it.10/";

Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL,
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL,
new EventsFileComparator().setIgnoringCoordinates( true ).runComparison( inputDirectory + "10.events.xml.gz", iterationOutput + "10.events.xml.gz"),
"different event files after iteration 10"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

import java.io.File;
import java.util.Objects;
Expand Down Expand Up @@ -119,7 +119,7 @@ void testMainRunAndResults() {
// compare events
String expected = utils.getPackageInputDirectory() + "test.output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "test.output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

/**
* @author michalm
Expand Down Expand Up @@ -73,8 +73,8 @@ private void runScenario(String configPath) {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz";
String actual = utils.getOutputDirectory() + "/output_events.xml.gz";
EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class TaxiOptimizerTests {
public static void runBenchmark(boolean vehicleDiversion, AbstractTaxiOptimizerParams taxiOptimizerParams, MatsimTestUtils utils) {
Expand Down Expand Up @@ -70,8 +70,8 @@ public static void runBenchmark(boolean vehicleDiversion, AbstractTaxiOptimizerP
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz";
String actual = utils.getOutputDirectory() + "/output_events.xml.gz";
EventsFileComparator.Result result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(EventsFileComparator.Result.FILES_ARE_EQUAL, result);
ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual);
Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result);
}
}
}
6 changes: 3 additions & 3 deletions contribs/vsp/src/test/java/playground/vsp/ev/UrbanEVIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.matsim.core.events.EventsUtils;
import org.matsim.core.population.PopulationUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.utils.eventsfilecomparison.EventsFileComparator;
import org.matsim.utils.eventsfilecomparison.ComparisonResult;

public class UrbanEVIT {
@RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils();
Expand Down Expand Up @@ -38,8 +38,8 @@ void run() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
Assertions.assertEquals( ComparisonResult.FILES_ARE_EQUAL, result );
}

} catch ( Exception ee ) {
Expand Down
2 changes: 1 addition & 1 deletion matsim/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
test/output
bin
.settings
bin
target
output
out
src/main/java/.gitignore
/output_fastCapacityUpdate_false/
/output_fastCapacityUpdate_true/
/nullevents.xml.gz
*.zst
Loading

0 comments on commit 1c94d9d

Please sign in to comment.