Skip to content

Commit

Permalink
Merge pull request #47 from matsim-org/switch-to-2024-release
Browse files Browse the repository at this point in the history
Switch matsim version to 2024
  • Loading branch information
Janekdererste authored Apr 18, 2024
2 parents 9d5fbd7 + cd498ad commit a574684
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 42 deletions.
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<properties>
<!-- Options: stable build based on pull requests (e.g. 15.0-PR2344), weekly (e.g. 15.0-2023w01) or official (e.g. 14.0) releases -->
<!-- <matsim.version>16.0-PR2509</matsim.version>-->
<matsim.version>15.0</matsim.version>
<matsim.version>2024.0</matsim.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand Down Expand Up @@ -54,10 +54,9 @@
</dependency>

<dependency>
<!-- Include the JUnit testing library. Not transitive. -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>

Expand Down
24 changes: 1 addition & 23 deletions src/main/java/org/matsim/project/RunMatsim.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,12 @@
* *********************************************************************** */
package org.matsim.project;

import com.google.inject.internal.asm.$Type;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Link;
import org.matsim.contrib.otfvis.OTFVisLiveModule;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup;
import org.matsim.core.config.groups.PlansCalcRouteConfigGroup;
import org.matsim.core.config.groups.QSimConfigGroup;
import org.matsim.core.config.groups.QSimConfigGroup.SnapshotStyle;
import org.matsim.core.config.groups.QSimConfigGroup.TrafficDynamics;
import org.matsim.core.config.groups.QSimConfigGroup.VehiclesSource;
import org.matsim.core.config.groups.StrategyConfigGroup;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy;
import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting;
import org.matsim.core.replanning.strategies.DefaultPlanStrategiesModule;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.collections.CollectionUtils;
import org.matsim.vehicles.VehicleType;
import org.matsim.vehicles.VehicleUtils;
import org.matsim.vis.otfvis.OTFVisConfigGroup;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;

/**
* @author nagel
Expand All @@ -62,7 +40,7 @@ public static void main(String[] args) {
config = ConfigUtils.loadConfig( args );
}

config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );
config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );

// possibly modify config here

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/matsim/project/RunMatsimApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) {
@Override
protected Config prepareConfig(Config config) {

config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );
config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );

// possibly modify config here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main( String[] args ){
URL url = IOUtils.extendUrl( context, "config.xml" );

Config config = ConfigUtils.loadConfig( url );
config.controler().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );
config.controller().setOverwriteFileSetting( OverwriteFileSetting.deleteDirectoryIfExists );

// ---

Expand Down
25 changes: 13 additions & 12 deletions src/test/java/org/matsim/project/RunMatsimTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
package org.matsim.project;

import org.apache.logging.log4j.LogManager;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.population.Person;
import org.matsim.api.core.v01.population.Population;
Expand All @@ -31,17 +30,21 @@
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;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

/**
* @author nagel
*
*/
public class RunMatsimTest {

@Rule public MatsimTestUtils utils = new MatsimTestUtils() ;

@RegisterExtension
public MatsimTestUtils utils = new MatsimTestUtils() ;

@Test
// @Ignore("OTFVis does not work on build server") PLEASE DO NOT DO THIS. Rather comment out OTFVis line in RunMatsim#main. kai, oct'22
Expand All @@ -65,7 +68,7 @@ public final void test() {
for ( Id<Person> personId : expected.getPersons().keySet()) {
double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore();
double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore();
Assert.assertEquals("Scores of person=" + personId + " are different", scoreReference, scoreCurrent, MatsimTestUtils.EPSILON);
assertEquals(scoreReference, scoreCurrent, 0.001, "Scores of person=" + personId + " are different");
}


Expand All @@ -77,17 +80,15 @@ public final void test() {
{
String expected = utils.getInputDirectory() + "/output_events.xml.gz" ;
String actual = utils.getOutputDirectory() + "/output_events.xml.gz" ;
EventsFileComparator.Result result = EventsUtils.compareEventsFiles( expected, actual );
Assert.assertEquals( EventsFileComparator.Result.FILES_ARE_EQUAL, result );
ComparisonResult result = EventsUtils.compareEventsFiles( expected, actual );
assertEquals( ComparisonResult.FILES_ARE_EQUAL, result );
}

} catch ( Exception ee ) {
LogManager.getLogger(this.getClass() ).fatal("there was an exception: \n" + ee ) ;

// if one catches an exception, then one needs to explicitly fail the test:
Assert.fail();
fail();
}


}
}

0 comments on commit a574684

Please sign in to comment.