Skip to content

Commit

Permalink
Update to MATSim 15 (#173)
Browse files Browse the repository at this point in the history
* fixing imports

* update IdF emission to matsim 15 (#175)

* update workflow version

* Matsim 15 (#186)

* update IdF emission to matsim 15

* update log4j import

* make sure Osm mapping is used on osm:way:highway tag

* add matsim-examples to pom to get hbefa-41 sample for emissions tests

* make the desired pollutant list defined in the commandline

* test the emissions part

* fix logger imports

* update DrtConfigGroup members accessors

* add Matsim 15 and emissions update to CHANGELOG.md

* Fix imports for VDF

* fix imports for mode choice

* fix updated routing mode handling in analysis

* adding compatible version of corsica scenario 1pm

---------

Co-authored-by: Valentin LE BESCOND <[email protected]>
Co-authored-by: Valentin LE BESCOND <[email protected]>
  • Loading branch information
3 people authored Mar 7, 2024
1 parent cb21340 commit 09c830f
Show file tree
Hide file tree
Showing 44 changed files with 412 additions and 409 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.11
java-version: 17
- name: Build with Maven
run: mvn test -B -Dmatsim.preferLocalDtds=true
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ included in the (note yet determined) next version number.

**Development version**

- Updated to MATSim 15
- Improve emissions tools and add tests
- Add support for multi-stage taxi trips in Sao Paulo
- fix: make compatible with downstream population pipelines
- Ensure outside activity id doesn't already exist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.analysis.DefaultPersonAnalysisFilter;
import org.eqasim.core.analysis.DistanceUnit;
import org.eqasim.core.analysis.PersonAnalysisFilter;
Expand All @@ -28,7 +29,7 @@
import org.matsim.facilities.MatsimFacilitiesReader;

public class RunLegAnalysis {
private final static Logger logger = Logger.getLogger(RunLegAnalysis.class);
private final static Logger logger = LogManager.getLogger(RunLegAnalysis.class);

static public void main(String[] args) throws IOException, ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.analysis.DefaultPersonAnalysisFilter;
import org.eqasim.core.analysis.DistanceUnit;
import org.eqasim.core.analysis.PersonAnalysisFilter;
Expand All @@ -30,7 +31,7 @@
import org.matsim.facilities.MatsimFacilitiesReader;

public class RunTripAnalysis {
private final static Logger logger = Logger.getLogger(RunTripAnalysis.class);
private final static Logger logger = LogManager.getLogger(RunTripAnalysis.class);

static public void main(String[] args) throws IOException, ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void handleEvent(ActivityEndEvent event) {
public void handleEvent(PersonDepartureEvent event) {
if (personFilter.analyzePerson(event.getPersonId())) {
Leg leg = factory.createLeg(event.getLegMode());
leg.getAttributes().putAttribute("routingMode", event.getRoutingMode());
leg.setRoutingMode(event.getRoutingMode());
ongoing.get(event.getPersonId()).elements.add(leg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.matsim.facilities.Facility;
import org.matsim.utils.objectattributes.attributable.Attributes;
import org.matsim.utils.objectattributes.attributable.AttributesImpl;
import org.matsim.utils.objectattributes.attributable.AttributesUtils;

import ch.sbb.matsim.routing.pt.raptor.RaptorRoute;
import ch.sbb.matsim.routing.pt.raptor.RaptorRoute.RoutePart;
Expand All @@ -26,7 +28,7 @@ public double calculateHeadway_min(Facility originFacility, Facility destination
double latestDepartureTime = departureTime + afterDepartureOffset;

List<RaptorRoute> routes = raptor.calcRoutes(originFacility, destinationFacilty, earliestDepartureTime,
departureTime, latestDepartureTime, null, new Attributes());
departureTime, latestDepartureTime, null, new AttributesImpl());

int numberOfPtRoutes = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.events.GenericEvent;
import org.matsim.api.core.v01.events.HasPersonId;
import org.matsim.api.core.v01.population.Person;
import org.matsim.core.api.internal.HasPersonId;
import org.matsim.pt.transitSchedule.api.TransitLine;
import org.matsim.pt.transitSchedule.api.TransitRoute;
import org.matsim.pt.transitSchedule.api.TransitStopFacility;
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/eqasim/core/misc/ParallelProgress.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.eqasim.core.misc;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class ParallelProgress {
private final Logger logger = Logger.getLogger(ParallelProgress.class);
private final Logger logger = LogManager.getLogger(ParallelProgress.class);

private final Thread thread;
private final long totalCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import java.util.HashSet;
import java.util.Iterator;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.scenario.cutter.extent.ScenarioExtent;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.population.Activity;
Expand All @@ -16,7 +17,7 @@
import org.matsim.facilities.ActivityFacility;

public class FacilitiesCutter {
private final static Logger log = Logger.getLogger(FacilitiesCutter.class);
private final static Logger log = LogManager.getLogger(FacilitiesCutter.class);

private final ScenarioExtent extent;
private final Collection<Id<ActivityFacility>> usedFacilityIds = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import java.util.Optional;
import java.util.Set;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.scenario.cutter.extent.ScenarioExtent;
import org.eqasim.core.scenario.cutter.extent.ShapeScenarioExtent;
import org.matsim.api.core.v01.Id;
Expand Down Expand Up @@ -36,7 +37,7 @@
import org.matsim.pt.transitSchedule.api.TransitStopFacility;

public class NetworkCutter {
private final static Logger log = Logger.getLogger(NetworkCutter.class);
private final static Logger log = LogManager.getLogger(NetworkCutter.class);

private final ScenarioExtent extent;
private final MinimumNetworkFinder minimumNetworkFinder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.scenario.cutter.extent.ScenarioExtent;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Link;
Expand All @@ -25,7 +26,7 @@
import org.matsim.pt.transitSchedule.api.TransitStopFacility;

public class TransitScheduleCutter {
private final static Logger log = Logger.getLogger(TransitScheduleCutter.class);
private final static Logger log = LogManager.getLogger(TransitScheduleCutter.class);

private final ScenarioExtent extent;
private final StopSequenceCrossingPointFinder crossingPointFinder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import java.util.HashSet;
import java.util.Set;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.pt.transitSchedule.api.Departure;
import org.matsim.pt.transitSchedule.api.TransitLine;
import org.matsim.pt.transitSchedule.api.TransitRoute;
Expand All @@ -12,7 +13,7 @@
import org.matsim.vehicles.Vehicles;

public class TransitVehiclesCutter {
private final static Logger log = Logger.getLogger(TransitVehiclesCutter.class);
private final static Logger log = LogManager.getLogger(TransitVehiclesCutter.class);

private final TransitSchedule schedule;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.eqasim.core.scenario.preparation;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.utils.geometry.CoordUtils;

public class AdjustLinkLength {
private final Logger logger = Logger.getLogger(AdjustLinkLength.class);
private final Logger logger = LogManager.getLogger(AdjustLinkLength.class);

public void run(Network network) {
int infiniteSpeedCount = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.eqasim.core.scenario.validation;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
Expand All @@ -15,7 +16,7 @@
import org.matsim.facilities.ActivityFacility;

public class ScenarioValidator {
private final static Logger logger = Logger.getLogger(ScenarioValidator.class);
private final static Logger logger = LogManager.getLogger(ScenarioValidator.class);

public boolean checkSpatialConsistency(Scenario scenario) {
boolean errorsFound = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import java.io.OutputStreamWriter;
import java.nio.file.Files;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.analysis.trips.TripListener;
import org.eqasim.core.components.config.EqasimConfigGroup;
import org.matsim.core.config.groups.ControlerConfigGroup;
Expand All @@ -25,7 +26,7 @@

@Singleton
public class CalibrationOutputListener implements IterationEndsListener, ShutdownListener {
private final Logger logger = Logger.getLogger(CalibrationOutputListener.class);
private final Logger logger = LogManager.getLogger(CalibrationOutputListener.class);

private static final String OUTPUT_FILE_NAME_JSON = "calibration.json";
private static final String OUTPUT_FILE_NAME_HTML = "calibration.html";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.core.config.CommandLine;
import org.matsim.core.config.CommandLine.ConfigurationException;

Expand All @@ -16,7 +17,7 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

public interface ParameterDefinition {
final static Logger logger = Logger.getLogger(ParameterDefinition.class);
final static Logger logger = LogManager.getLogger(ParameterDefinition.class);

static public void applyCommandLine(String prefix, CommandLine cmd, ParameterDefinition parameterDefinition) {
Map<String, String> values = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Provides;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.components.config.EqasimConfigGroup;
import org.eqasim.core.simulation.mode_choice.AbstractEqasimExtension;
import org.eqasim.core.simulation.mode_choice.utilities.UtilityEstimator;
Expand All @@ -15,7 +16,7 @@

public class EpsilonModule extends AbstractEqasimExtension {

public static final Logger logger = Logger.getLogger(EpsilonModule.class);
public static final Logger logger = LogManager.getLogger(EpsilonModule.class);

public static final String EPSILON_UTILITY_PREFIX = "epsilon_";
@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,29 @@ public static void adapt(Config config, Map<String, String> vehiclesPathByDrtMod

for(String drtMode: vehiclesPathByDrtMode.keySet()) {
DrtConfigGroup drtConfigGroup = new DrtConfigGroup();
drtConfigGroup.setMode(drtMode);
drtConfigGroup.setOperationalScheme(DrtConfigGroup.OperationalScheme.valueOf(operationalSchemes.get(drtMode)));
drtConfigGroup.setStopDuration(15.0);
drtConfigGroup.setMaxWaitTime(600);
drtConfigGroup.setMaxTravelTimeAlpha(1.5);
drtConfigGroup.setMaxTravelTimeBeta(300.0);
drtConfigGroup.setVehiclesFile(vehiclesPathByDrtMode.get(drtMode));
drtConfigGroup.mode = drtMode;
drtConfigGroup.operationalScheme = DrtConfigGroup.OperationalScheme.valueOf(operationalSchemes.get(drtMode));
drtConfigGroup.stopDuration = 15.0;
drtConfigGroup.maxWaitTime = 600;
drtConfigGroup.maxTravelTimeAlpha = 1.5;
drtConfigGroup.maxTravelTimeBeta = 300.0;
drtConfigGroup.vehiclesFile = vehiclesPathByDrtMode.get(drtMode);

DrtInsertionSearchParams searchParams = new ExtensiveInsertionSearchParams();
drtConfigGroup.addDrtInsertionSearchParams(searchParams);

RebalancingParams rebalancingParams = new RebalancingParams();
rebalancingParams.setInterval(1800);
rebalancingParams.interval =1800;
rebalancingParams.addParameterSet(new PlusOneRebalancingStrategyParams());
drtConfigGroup.addParameterSet(rebalancingParams);

DrtZonalSystemParams drtZonalSystemParams = new DrtZonalSystemParams();
drtZonalSystemParams.setZonesGeneration(DrtZonalSystemParams.ZoneGeneration.GridFromNetwork);
drtZonalSystemParams.setCellSize(500.0);
drtZonalSystemParams.setTargetLinkSelection(DrtZonalSystemParams.TargetLinkSelection.mostCentral);
drtZonalSystemParams.zonesGeneration = DrtZonalSystemParams.ZoneGeneration.GridFromNetwork;
drtZonalSystemParams.cellSize = 500.0;
drtZonalSystemParams.targetLinkSelection = DrtZonalSystemParams.TargetLinkSelection.mostCentral;
drtConfigGroup.addParameterSet(drtZonalSystemParams);

multiModeDrtConfigGroup.addDrtConfig(drtConfigGroup);
multiModeDrtConfigGroup.addParameterSet(drtConfigGroup);

// Set up choice model
EqasimConfigGroup eqasimConfig = EqasimConfigGroup.get(config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.eqasim.core.simulation.modes.drt.utils;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
Expand All @@ -15,7 +16,7 @@
import java.util.Random;

public class CreateDrtVehicles {
private final static Logger logger = Logger.getLogger(CreateDrtVehicles.class);
private final static Logger logger = LogManager.getLogger(CreateDrtVehicles.class);

public final static long DEFAULT_RANDOM_SEED = 1234;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.eqasim.core.tools;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Identifiable;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Activity;
Expand All @@ -16,7 +17,7 @@

public class RemovePersonsWithActivityTypes {

private static final Logger logger = Logger.getLogger(RemovePersonsWithActivityTypes.class);
private static final Logger logger = LogManager.getLogger(RemovePersonsWithActivityTypes.class);

public static void main(String[] args) throws CommandLine.ConfigurationException {
CommandLine commandLine = new CommandLine.Builder(args).requireOptions("input-path", "output-path", "activity-types").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import java.util.Set;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eqasim.core.components.headway.HeadwayCalculator;
import org.eqasim.core.components.headway.HeadwayImputerModule;
import org.eqasim.core.misc.InjectorBuilder;
Expand Down Expand Up @@ -50,7 +51,7 @@
import ch.sbb.matsim.config.SwissRailRaptorConfigGroup;

public class RunBatchPublicTransportRouter {
private final static Logger logger = Logger.getLogger(RunBatchPublicTransportRouter.class);
private final static Logger logger = LogManager.getLogger(RunBatchPublicTransportRouter.class);

static public void main(String[] args) throws ConfigurationException, JsonGenerationException, JsonMappingException,
IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.matsim.core.router.RoutingRequest;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.core.utils.timing.TimeInterpretationModule;
import org.matsim.utils.objectattributes.attributable.Attributes;
import org.matsim.utils.objectattributes.attributable.AttributesImpl;

import com.google.inject.Inject;
import com.google.inject.Injector;
Expand Down Expand Up @@ -200,7 +200,7 @@ static private void appendTrip(List<DiscreteModeChoiceTrip> trips, String preced
destinationActivity.setMaximumDuration(3600.0);

DiscreteModeChoiceTrip trip = new DiscreteModeChoiceTrip(originActivity, destinationActivity, "walk",
Collections.emptyList(), 0, trips.size(), trips.size(), new Attributes());
Collections.emptyList(), 0, trips.size(), trips.size(), new AttributesImpl());
trips.add(trip);
}

Expand Down
Loading

0 comments on commit 09c830f

Please sign in to comment.