Skip to content

Commit

Permalink
Resolving some MATSim version conflict issues (now using 12 instead o…
Browse files Browse the repository at this point in the history
…f 11)
  • Loading branch information
CorinStaves committed Jan 13, 2021
1 parent 5ddfdae commit dc95092
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 41 deletions.
1 change: 0 additions & 1 deletion analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
<svnRevision>${buildNumber}</svnRevision>
<geotools.version>13.0</geotools.version>
<skipTestJar>false</skipTestJar> <!--Overridden in the bintray profile-->
<matsimVersion>0.10.0-SNAPSHOT</matsimVersion>
<jackson.version>2.9.5</jackson.version>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.tum.bgu.msm.container.DataContainer;
import de.tum.bgu.msm.data.Zone;
import de.tum.bgu.msm.properties.Properties;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Network;
import org.matsim.core.config.Config;
Expand All @@ -18,6 +19,7 @@
import org.matsim.core.router.util.LeastCostPathCalculatorFactory;
import org.matsim.core.router.util.TravelDisutility;
import org.matsim.core.router.util.TravelTime;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.pt.transitSchedule.api.TransitSchedule;

import java.util.Collection;
Expand Down Expand Up @@ -135,8 +137,9 @@ MultiNodePathCalculator createFreeSpeedMultiNodePathCalculator() {
TripRouter createTripRouter() {
final RoutingModule carRoutingModule;
if (config.plansCalcRoute().isInsertingAccessEgressWalk()) {
Scenario scenario = ScenarioUtils.createScenario(config);
carRoutingModule = DefaultRoutingModules.createAccessEgressNetworkRouter(
TransportMode.car, PopulationUtils.getFactory(), carNetwork, leastCostPathCalculatorFactory.createPathCalculator(carNetwork, travelDisutility, travelTime), config.plansCalcRoute());
TransportMode.car, leastCostPathCalculatorFactory.createPathCalculator(carNetwork, travelDisutility, travelTime), scenario, carNetwork, DefaultRoutingModules.createTeleportationRouter(TransportMode.walk, scenario, config.plansCalcRoute().getOrCreateModeRoutingParams(TransportMode.walk)));
} else {
carRoutingModule = DefaultRoutingModules.createPureNetworkRouter(
TransportMode.car, PopulationUtils.getFactory(), carNetwork, leastCostPathCalculatorFactory.createPathCalculator(carNetwork, travelDisutility, travelTime));
Expand All @@ -145,7 +148,7 @@ TripRouter createTripRouter() {

if (schedule != null && config.transit().isUseTransit()) {
final RoutingModule teleportationRoutingModule = DefaultRoutingModules.createTeleportationRouter(
TransportMode.walk, PopulationUtils.getFactory(), config.plansCalcRoute().getOrCreateModeRoutingParams(TransportMode.walk));
TransportMode.walk, ScenarioUtils.createScenario(config), config.plansCalcRoute().getOrCreateModeRoutingParams(TransportMode.walk));
final SwissRailRaptor swissRailRaptor = createSwissRailRaptor(RaptorStaticConfig.RaptorOptimization.OneToOneRouting);
ptRoutingModule = new SwissRailRaptorRoutingModule(swissRailRaptor, schedule, ptNetwork, teleportationRoutingModule);
} else {
Expand Down Expand Up @@ -176,7 +179,7 @@ LeastCostPathCalculator createLeastCostPathCalculator() {

RoutingModule getTeleportationRouter(String mode) {
return DefaultRoutingModules.createTeleportationRouter(
mode, PopulationUtils.getFactory(), config.plansCalcRoute().getOrCreateModeRoutingParams(mode));
mode, ScenarioUtils.createScenario(config), config.plansCalcRoute().getOrCreateModeRoutingParams(mode));
}

SwissRailRaptorData getRaptorData(RaptorStaticConfig.RaptorOptimization optimization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public IndexedDoubleMatrix2D createTeleportedSkim(Collection<Zone> zones, String

if (!planElements.isEmpty()) {
final Leg lastLeg = (Leg) planElements.get(planElements.size() - 1);
arrivalTime = lastLeg.getDepartureTime() + lastLeg.getTravelTime();
arrivalTime = lastLeg.getDepartureTime().seconds() + lastLeg.getTravelTime().seconds();
}

double time = arrivalTime - peakHour_s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public double getTravelTime(Location origin, Location destination, double timeOf

if (!planElements.isEmpty()) {
final Leg lastLeg = (Leg) planElements.get(planElements.size() - 1);
arrivalTime = lastLeg.getDepartureTime() + lastLeg.getTravelTime();
arrivalTime = lastLeg.getDepartureTime().seconds() + lastLeg.getTravelTime().seconds();
}

double time = arrivalTime - timeOfDay_s;
Expand All @@ -157,10 +157,10 @@ public double getGeneralizedTravelCosts(Location origin, Location destination, d
} else if (routingModule instanceof SwissRailRaptorRoutingModule || routingModule instanceof FreespeedFactorRoutingModule) {
for (PlanElement pe : planElements) {
if (pe instanceof Leg) {
double time = ((Leg) pe).getTravelTime();
double time = ((Leg) pe).getTravelTime().orElse(-1);

// overrides individual parameters per person; use default scoring parameters
if (Time.getUndefinedTime() != time) {
if (time >= 0) {
utility += time * (cnScoringGroup.getModes().get(mode).getMarginalUtilityOfTraveling() - cnScoringGroup.getPerforming_utils_hr()) / 3600;
}
Double dist = ((Leg) pe).getRoute().getDistance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.network.Node;
import org.matsim.contrib.accessibility.AccessibilityAttributes;
import org.matsim.contrib.accessibility.AccessibilityConfigGroup;
import org.matsim.contrib.accessibility.interfaces.FacilityDataExchangeInterface;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.FacilitiesConfigGroup;
import org.matsim.core.controler.Controler;
Expand Down Expand Up @@ -68,7 +66,8 @@ public void prepareAccessibility(Scenario scenario, Controler controler) {
final ActivityFacilities opportunities = scenario.getActivityFacilities();
int i = 0;
for (ActivityFacility activityFacility : zoneRepresentativeCoords.getFacilities().values()) {
activityFacility.getAttributes().putAttribute(AccessibilityAttributes.WEIGHT, zonePopulationMap.get(activityFacility.getId()));
//TODO: re-implement accessibility module matsim
// activityFacility.getAttributes().putAttribute(AccessibilityAttributes.WEIGHT, zonePopulationMap.get(activityFacility.getId()));
opportunities.addActivityFacility(activityFacility);
i++;
}
Expand Down Expand Up @@ -108,7 +107,8 @@ public void prepareAccessibility(Scenario scenario, Controler controler) {
// Accessibility module

org.matsim.contrib.accessibility.AccessibilityModule module = new org.matsim.contrib.accessibility.AccessibilityModule();
module.addFacilityDataExchangeListener((FacilityDataExchangeInterface) dataContainer.getAccessibility());
//TODO: re-implement accessiblity module
// module.addFacilityDataExchangeListener((FacilityDataExchangeInterface) dataContainer.getAccessibility());
controler.addOverridingModule(module);
// End accessibility module
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.apache.log4j.Logger;
import org.jfree.util.Log;
import org.matsim.api.core.v01.Id;
import org.matsim.contrib.accessibility.interfaces.FacilityDataExchangeInterface;
//import org.matsim.contrib.accessibility.interfaces.FacilityDataExchangeInterface;
import org.matsim.core.utils.collections.Tuple;
import org.matsim.facilities.ActivityFacility;

Expand All @@ -20,7 +20,7 @@
/**
* @author dziemke
**/
public class MatsimAccessibility implements Accessibility, FacilityDataExchangeInterface {
public class MatsimAccessibility implements Accessibility {
private static final Logger logger = Logger.getLogger(MatsimAccessibility.class);

private final GeoData geoData;
Expand All @@ -36,14 +36,14 @@ public MatsimAccessibility(GeoData geoData) {
}

// FacilityDataExchangeInterface methods
@Override
// @Override
public void setFacilityAccessibilities(ActivityFacility measurePoint, Double timeOfDay, Map<String, Double> accessibilities){
if (timeOfDay == 8 * 60. * 60.) { // TODO Find better way for this check
accessibilitiesMap.put(new Tuple<ActivityFacility, Double>(measurePoint, timeOfDay), accessibilities);
}
}

@Override
// @Override
public void finish() { }

// Accessibility interface methods
Expand Down
2 changes: 1 addition & 1 deletion extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTestJar>false</skipTestJar> <!--Overridden in the bintray profile-->
<jackson.version>2.9.5</jackson.version>
<matsimVersion>11.0</matsimVersion>
<matsimVersion>12.0</matsimVersion>
</properties>


Expand Down
4 changes: 2 additions & 2 deletions siloCore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
<dependency>
<groupId>com.github.msmobility</groupId>
<artifactId>mito</artifactId>
<version>v28102020</version>
<version>master</version>
<exclusions>
<exclusion>
<groupId>javax.media</groupId>
Expand Down Expand Up @@ -416,7 +416,7 @@
<svnRevision>${buildNumber}</svnRevision>
<geotools.version>20.2</geotools.version>
<skipTestJar>false</skipTestJar> <!--Overridden in the bintray profile-->
<matsimVersion>11.0</matsimVersion>
<matsimVersion>12.0</matsimVersion>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
9 changes: 3 additions & 6 deletions siloCore/src/main/java/de/tum/bgu/msm/utils/SiloUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import omx.OmxMatrix;
import omx.hdf5.OmxHdf5Datatype;
import org.apache.commons.lang3.SystemUtils;
import org.apache.log4j.Appender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.*;
import org.matsim.core.controler.Controler;

import java.io.*;
Expand Down Expand Up @@ -72,10 +69,10 @@ public static Properties siloInitialization(String propertiesPath) {
*/
private static void initLogging(String outputDirectory) throws IOException {
Logger root = Logger.getRootLogger();
FileAppender appender = new FileAppender(Controler.DEFAULTLOG4JLAYOUT, outputDirectory + System.getProperty("file.separator")+ LOG_FILE_NAME, false);
FileAppender appender = new FileAppender(new SimpleLayout(), outputDirectory + System.getProperty("file.separator")+ LOG_FILE_NAME, false);
appender.setName(LOG_FILE_NAME);
root.addAppender(appender);
FileAppender warnErrorAppender = new FileAppender(Controler.DEFAULTLOG4JLAYOUT, outputDirectory + System.getProperty("file.separator")+ LOG_WARN_FILE_NAME, false);
FileAppender warnErrorAppender = new FileAppender(new SimpleLayout(), outputDirectory + System.getProperty("file.separator")+ LOG_WARN_FILE_NAME, false);
warnErrorAppender.setName(LOG_WARN_FILE_NAME);
warnErrorAppender.setThreshold(Level.WARN);
root.addAppender(warnErrorAppender);
Expand Down
1 change: 0 additions & 1 deletion synthetic-population/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@
<svnRevision>${buildNumber}</svnRevision>
<geotools.version>13.0</geotools.version>
<skipTestJar>false</skipTestJar> <!--Overridden in the bintray profile-->
<matsimVersion>0.10.0-SNAPSHOT</matsimVersion>
<jackson.version>2.9.5</jackson.version>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
package de.tum.bgu.msm.transportModel.matsim;

import ch.sbb.matsim.routing.pt.raptor.*;
import com.google.common.collect.Lists;
import org.junit.Ignore;
import org.junit.Test;
import org.matsim.api.core.v01.Coord;
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.population.Activity;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.PlanElement;
import org.matsim.api.core.v01.population.Population;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.OutputDirectoryHierarchy;
import org.matsim.core.network.io.MatsimNetworkReader;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.router.*;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.RoutingModule;
import org.matsim.core.router.TeleportationRoutingModule;
import org.matsim.core.router.TripRouter;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.facilities.ActivityFacilitiesFactory;
import org.matsim.facilities.ActivityFacilitiesFactoryImpl;
import org.matsim.facilities.ActivityFacility;
import org.matsim.facilities.Facility;
import org.matsim.pt.PtConstants;
import org.matsim.pt.transitSchedule.api.TransitScheduleReader;
import org.matsim.pt.transitSchedule.api.TransitStopFacility;
import org.matsim.vehicles.VehicleReaderV1;

import javax.inject.Provider;
import java.util.List;
import java.util.Map;

public class SBBTest {
Expand Down Expand Up @@ -91,10 +82,9 @@ public void test() {
TeleportationRoutingModule teleportationRoutingModule =
new TeleportationRoutingModule(
TransportMode.transit_walk,
PopulationUtils.getFactory(),
ScenarioUtils.createScenario(config),
1.4,
1.3);

RaptorStaticConfig raptorConfig = RaptorUtils.createStaticConfig(config);
raptorConfig.setOptimization(RaptorStaticConfig.RaptorOptimization.OneToAllRouting);
SwissRailRaptorData raptorData = SwissRailRaptorData.create(scenario.getTransitSchedule(), raptorConfig, scenario.getNetwork());
Expand Down
2 changes: 1 addition & 1 deletion useCases/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@
<svnRevision>${buildNumber}</svnRevision>
<skipTestJar>false</skipTestJar> <!--Overridden in the bintray profile-->
<jackson.version>2.9.5</jackson.version>
<matsimVersion>11.0</matsimVersion>
<matsimVersion>12.0</matsimVersion>
</properties>
</project>

0 comments on commit dc95092

Please sign in to comment.