Skip to content

Commit

Permalink
update matsim version
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Dec 3, 2023
1 parent 2a9c8b1 commit ab1c6ab
Show file tree
Hide file tree
Showing 29 changed files with 208 additions and 225 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>matsim-all</artifactId>

<!-- PR-labelled release -->
<version>16.0-PR2738</version>
<version>16.0-PR2976</version>

<!-- snapshot == not recommended: rather use PR-labelled release!-->
<!-- <version>16.0-SNAPSHOT</version>-->
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/matsim/analysis/TravelTimeComparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.matsim.application.options.OutputOptions;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.events.EventsUtils;
import org.matsim.core.router.FastDijkstraFactory;
import org.matsim.core.router.DijkstraFactory;
import org.matsim.core.router.costcalculators.OnlyTimeDependentTravelDisutility;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelTime;
Expand Down Expand Up @@ -73,8 +73,8 @@ public Integer call() throws Exception {

OnlyTimeDependentTravelDisutility util = new OnlyTimeDependentTravelDisutility(tt);

LeastCostPathCalculator congestedRouter = new FastDijkstraFactory(false).createPathCalculator(network, util, tt);
LeastCostPathCalculator freeflowRouter = new FastDijkstraFactory(false).createPathCalculator(network, new OnlyTimeDependentTravelDisutility(fs), fs);
LeastCostPathCalculator congestedRouter = new DijkstraFactory(false).createPathCalculator(network, util, tt);
LeastCostPathCalculator freeflowRouter = new DijkstraFactory(false).createPathCalculator(network, new OnlyTimeDependentTravelDisutility(fs), fs);

data.addColumns(
DoubleColumn.create("simulated", data.rowCount()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public static void main(String[] args) throws IOException {
String plans = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/berlin/berlin-v5.5-10pct/input/berlin-v5.5-10pct.plans.xml.gz";

Config config = RunBerlinScenario.prepareConfig(args);
config.controler().setOutputDirectory(outputFile);
config.controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setLastIteration(500);
config.controller().setOutputDirectory(outputFile);
config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
config.controller().setLastIteration(500);
config.plans().setInputFile(plans);

AccidentsConfigGroup accidentsSettings = ConfigUtils.addOrGetModule(config, AccidentsConfigGroup.class);
accidentsSettings.setEnableAccidentsModule(true);
accidentsSettings.setScaleFactor(10);
config.network().setInputFile(BVWPNetwork);
config.planCalcScore().getModes().get("car").setMonetaryDistanceRate(-0.0004);
config.scoring().getModes().get("car").setMonetaryDistanceRate(-0.0004);

Scenario scenario = RunBerlinScenario.prepareScenario(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ private static Scenario loadScenario(String runDirectory, String runId) {

Config config = ConfigUtils.loadConfig(configFile);

if (!runId.equals(config.controler().getRunId()))
if (!runId.equals(config.controller().getRunId()))
throw new RuntimeException("Given run ID " + runId + " doesn't match the run ID given in the config file. Aborting...");

config.controler().setOutputDirectory(runDirectory);
config.controller().setOutputDirectory(runDirectory);
config.plans().setInputFile(populationFile);
config.network().setInputFile(networkFile);
config.vehicles().setVehiclesFile(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void run() {
config.global().setCoordinateSystem("GK4");
config.network().setInputFile(runDirectory + runId + ".output_network.xml.gz");
config.plans().setInputFile(runDirectory + runId + ".output_plans.xml.gz");
config.controler().setOutputDirectory(runDirectory);
config.controler().setRunId(runId);
config.controller().setOutputDirectory(runDirectory);
config.controller().setRunId(runId);

// adjust the default noise parameters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void run() throws IOException {
config.transit().setVehiclesFile(runDirectory + runId + ".output_transitVehicles.xml.gz");
config.global().setCoordinateSystem("GK4");
config.plans().setInputFile(null);
config.parallelEventHandling().setNumberOfThreads(null);
config.parallelEventHandling().setEstimatedNumberOfEvents(null);
config.eventsManager().setNumberOfThreads(null);
config.eventsManager().setEstimatedNumberOfEvents(null);
config.global().setNumberOfThreads(1);

EmissionsConfigGroup eConfig = ConfigUtils.addOrGetModule(config, EmissionsConfigGroup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ void run() throws IOException {
config.transit().setVehiclesFile(runDirectory + runId + ".output_transitVehicles.xml.gz");
config.global().setCoordinateSystem("EPSG:31468");
config.plans().setInputFile(null);
config.parallelEventHandling().setNumberOfThreads(null);
config.parallelEventHandling().setEstimatedNumberOfEvents(null);
config.eventsManager().setNumberOfThreads(null);
config.eventsManager().setEstimatedNumberOfEvents(null);
config.global().setNumberOfThreads(1);

EmissionsConfigGroup eConfig = ConfigUtils.addOrGetModule(config, EmissionsConfigGroup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void run() {
config.transit().setVehiclesFile(runDirectory + runId + ".output_transitVehicles.xml.gz");
config.global().setCoordinateSystem("GK4");
config.plans().setInputFile(null);
config.parallelEventHandling().setNumberOfThreads(null);
config.parallelEventHandling().setEstimatedNumberOfEvents(null);
config.eventsManager().setNumberOfThreads(null);
config.eventsManager().setEstimatedNumberOfEvents(null);
config.global().setNumberOfThreads(1);

EmissionsConfigGroup eConfig = ConfigUtils.addOrGetModule(config, EmissionsConfigGroup.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.freight.carrier.*;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.population.routes.NetworkRoute;
import org.matsim.core.population.routes.RouteUtils;
import org.matsim.freight.carriers.*;

import java.io.BufferedWriter;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.ConfigWriter;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.TypicalDurationScoreComputation;
import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams;
import org.matsim.core.config.groups.ScoringConfigGroup.TypicalDurationScoreComputation;
import org.matsim.core.population.io.PopulationWriter;
import org.matsim.core.scenario.ScenarioUtils;

Expand Down Expand Up @@ -104,11 +105,11 @@ public void run(String outputPopulationFile, String outputConfigFile, double tim
}

for (ActivityParams actParams : newActivityParams) {
scenario.getConfig().planCalcScore().addActivityParams(actParams);
scenario.getConfig().scoring().addActivityParams(actParams);
}

log.info("New activity parameters: ");
for (ActivityParams actParams : scenario.getConfig().planCalcScore().getActivityParams()) {
for (ActivityParams actParams : scenario.getConfig().scoring().getActivityParams()) {
initialActivityParams.add(actParams);
log.info(" -> " + actParams.getActivityType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ private static void increaseLinkFreespeedIfLower(Link link, double newFreespeed)

private static void runOneIteration(Scenario scenario, String outputDirectory) {
new File(outputDirectory).mkdirs();
scenario.getConfig().controler().setOutputDirectory(outputDirectory);
scenario.getConfig().controler().setLastIteration(0);
scenario.getConfig().controler().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);
scenario.getConfig().controller().setOutputDirectory(outputDirectory);
scenario.getConfig().controller().setLastIteration(0);
scenario.getConfig().controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists);

scenario.getConfig().transit().setUseTransit(true);

Expand Down
38 changes: 19 additions & 19 deletions src/main/java/org/matsim/legacy/run/RunBerlinScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigGroup;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams;
import org.matsim.core.config.groups.PlansCalcRouteConfigGroup;
import org.matsim.core.config.groups.ScoringConfigGroup.ActivityParams;
import org.matsim.core.config.groups.RoutingConfigGroup;
import org.matsim.core.config.groups.QSimConfigGroup.TrafficDynamics;
import org.matsim.core.config.groups.VspExperimentalConfigGroup;
import org.matsim.core.controler.AbstractModule;
Expand All @@ -67,7 +67,7 @@
import java.io.IOException;
import java.util.*;

import static org.matsim.core.config.groups.ControlerConfigGroup.RoutingAlgorithmType.FastAStarLandmarks;
import static org.matsim.core.config.groups.ControllerConfigGroup.RoutingAlgorithmType.AStarLandmarks;

/**
* @author ikaddoura
Expand Down Expand Up @@ -230,33 +230,33 @@ public static Config prepareConfig( RunDrtOpenBerlinScenario.AdditionalInformati

final Config config = ConfigUtils.loadConfig( args[ 0 ], customModulesAll );

config.controler().setRoutingAlgorithmType( FastAStarLandmarks );
config.controller().setRoutingAlgorithmType( AStarLandmarks );

config.subtourModeChoice().setProbaForRandomSingleTripMode( 0.5 );

config.plansCalcRoute().setRoutingRandomness( 3. );
config.plansCalcRoute().removeModeRoutingParams(TransportMode.ride);
config.plansCalcRoute().removeModeRoutingParams(TransportMode.pt);
config.plansCalcRoute().removeModeRoutingParams(TransportMode.bike);
config.plansCalcRoute().removeModeRoutingParams("undefined");
config.routing().setRoutingRandomness( 3. );
config.routing().removeModeRoutingParams(TransportMode.ride);
config.routing().removeModeRoutingParams(TransportMode.pt);
config.routing().removeModeRoutingParams(TransportMode.bike);
config.routing().removeModeRoutingParams("undefined");

config.qsim().setInsertingWaitingVehiclesBeforeDrivingVehicles( true );

// vsp defaults
config.vspExperimental().setVspDefaultsCheckingLevel( VspExperimentalConfigGroup.VspDefaultsCheckingLevel.info );
config.plansCalcRoute().setAccessEgressType(PlansCalcRouteConfigGroup.AccessEgressType.accessEgressModeToLink);
config.routing().setAccessEgressType(RoutingConfigGroup.AccessEgressType.accessEgressModeToLink);
config.qsim().setUsingTravelTimeCheckInTeleportation( true );
config.qsim().setTrafficDynamics( TrafficDynamics.kinematicWaves );

// activities:
for ( long ii = 600 ; ii <= 97200; ii+=600 ) {
config.planCalcScore().addActivityParams( new ActivityParams( "home_" + ii + ".0" ).setTypicalDuration( ii ) );
config.planCalcScore().addActivityParams( new ActivityParams( "work_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(6. * 3600. ).setClosingTime(20. * 3600. ) );
config.planCalcScore().addActivityParams( new ActivityParams( "leisure_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(9. * 3600. ).setClosingTime(27. * 3600. ) );
config.planCalcScore().addActivityParams( new ActivityParams( "shopping_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(8. * 3600. ).setClosingTime(20. * 3600. ) );
config.planCalcScore().addActivityParams( new ActivityParams( "other_" + ii + ".0" ).setTypicalDuration( ii ) );
config.scoring().addActivityParams( new ActivityParams( "home_" + ii + ".0" ).setTypicalDuration( ii ) );
config.scoring().addActivityParams( new ActivityParams( "work_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(6. * 3600. ).setClosingTime(20. * 3600. ) );
config.scoring().addActivityParams( new ActivityParams( "leisure_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(9. * 3600. ).setClosingTime(27. * 3600. ) );
config.scoring().addActivityParams( new ActivityParams( "shopping_" + ii + ".0" ).setTypicalDuration( ii ).setOpeningTime(8. * 3600. ).setClosingTime(20. * 3600. ) );
config.scoring().addActivityParams( new ActivityParams( "other_" + ii + ".0" ).setTypicalDuration( ii ) );
}
config.planCalcScore().addActivityParams( new ActivityParams( "freight" ).setTypicalDuration( 12.*3600. ) );
config.scoring().addActivityParams( new ActivityParams( "freight" ).setTypicalDuration( 12.*3600. ) );

ConfigUtils.applyCommandline( config, typedArgs ) ;

Expand All @@ -267,7 +267,7 @@ public static void runAnalysis(Controler controler) {
Config config = controler.getConfig();

String modesString = "";
for (String mode: config.planCalcScore().getAllModes()) {
for (String mode: config.scoring().getAllModes()) {
modesString = modesString + mode + ",";
}
// remove last ","
Expand All @@ -279,8 +279,8 @@ public static void runAnalysis(Controler controler) {
}

String[] args = new String[] {
config.controler().getOutputDirectory(),
config.controler().getRunId(),
config.controller().getOutputDirectory(),
config.controller().getRunId(),
"null", // TODO: reference run, hard to automate
"null", // TODO: reference run, hard to automate
config.global().getCoordinateSystem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static Config prepareConfig( String [] args, ConfigGroup... customModules

Config config = RunBerlinScenario.prepareConfig(args, customModulesAll);

config.controler().setOutputDirectory("../../shared-svn/projects/accessibility-berlin/output/v4/5000_8h05_school/");
config.controller().setOutputDirectory("../../shared-svn/projects/accessibility-berlin/output/v4/5000_8h05_school/");

File opportunitiesFile = new File("../../shared-svn/projects/accessibility-berlin/osm/berlin/amenities/2018-05-30/facilities_classified.xml");
config.facilities().setInputFile(opportunitiesFile.getAbsolutePath());
Expand All @@ -103,7 +103,7 @@ public static Config prepareConfig( String [] args, ConfigGroup... customModules
acg.setComputingAccessibilityForMode(Modes4Accessibility.pt, true);
acg.setOutputCrs(config.global().getCoordinateSystem());

config.controler().setLastIteration(0);
config.controller().setLastIteration(0);

return config ;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ private static void createQGisOutput(Config config) {
final int populationThreshold = 0;

String osName = System.getProperty("os.name");
String workingDirectory = config.controler().getOutputDirectory();
String workingDirectory = config.controller().getOutputDirectory();
for (String actType : activityTypes) {
String actSpecificWorkingDirectory = workingDirectory + actType + "/";
for (Modes4Accessibility mode : ((AccessibilityConfigGroup) config.getModules().get(AccessibilityConfigGroup.GROUP_NAME)).getIsComputingMode()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
import org.matsim.contrib.bicycle.BicycleConfigGroup;
import org.matsim.contrib.bicycle.Bicycles;
import org.matsim.contrib.bicycle.BicycleModule;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigGroup;
import org.matsim.core.controler.Controler;
Expand Down Expand Up @@ -53,7 +53,9 @@ public static void main(String[] args) {

public static Controler prepareControler( Scenario scenario ) {
Controler controler = RunBerlinScenario.prepareControler( scenario ) ;
Bicycles.addAsOverridingModule(controler);

// Add bicycle module
controler.addOverridingModule(new BicycleModule());

return controler;
}
Expand All @@ -76,10 +78,10 @@ public static Config prepareConfig( String [] args, ConfigGroup... customModules
}

Config config = RunBerlinScenario.prepareConfig( args, customModulesAll ) ;
config.plansCalcRoute().removeModeRoutingParams("bicycle");
config.routing().removeModeRoutingParams("bicycle");

//
config.controler().setLastIteration(0);
config.controller().setLastIteration(0);
//

return config ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.matsim.legacy.run.drt;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
Expand All @@ -38,7 +39,6 @@
import org.matsim.api.core.v01.Coord;
import org.matsim.core.utils.geometry.geotools.MGC;
import org.matsim.core.utils.gis.ShapeFileReader;
import org.matsim.core.utils.io.UncheckedIOException;
import org.opengis.feature.simple.SimpleFeature;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
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.ScoringConfigGroup;
import org.matsim.core.config.groups.QSimConfigGroup;
import org.matsim.core.config.groups.QSimConfigGroup.SnapshotStyle;
import org.matsim.core.controler.Controler;
Expand Down Expand Up @@ -67,18 +67,18 @@ public static void main(String[] args) {
Config config = RunDrtOpenBerlinScenario.prepareConfig( RunDrtOpenBerlinScenario.AdditionalInformation.acceptUnknownParamsBerlinConfig,
new String[] {base + runID + "/" + runID + ".output_config_reduced.xml"} ) ;

config.network().setInputFile( config.controler().getRunId() + ".output_network.xml.gz" );
config.network().setInputFile( config.controller().getRunId() + ".output_network.xml.gz" );

config.plans().setInputFile( config.controler().getRunId() + ".output_plans.xml.gz" );
config.plans().setInputFile( config.controller().getRunId() + ".output_plans.xml.gz" );
// config.plans().setInputFile( "/Users/kainagel/git/berlin-matsim/popSel.xml.gz" );

config.transit().setTransitScheduleFile( config.controler().getRunId() + ".output_transitSchedule.xml.gz" );
config.transit().setTransitScheduleFile( config.controller().getRunId() + ".output_transitSchedule.xml.gz" );

config.global().setNumberOfThreads(6);

config.controler()
config.controller()
.setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.controler().setLastIteration(0);
config.controller().setLastIteration(0);

final OTFVisConfigGroup otfVisConfigGroup = ConfigUtils.addOrGetModule(config, OTFVisConfigGroup.class);
otfVisConfigGroup.setDrawTransitFacilityIds(false);
Expand All @@ -91,7 +91,7 @@ public static void main(String[] args) {
// drtCfg.addParameterSet(new DrtSpeedUpParams());
// }
// }
for (final PlanCalcScoreConfigGroup.ActivityParams params : config.planCalcScore().getActivityParams()) {
for (final ScoringConfigGroup.ActivityParams params : config.scoring().getActivityParams()) {
if (params.getActivityType().endsWith("interaction")) {
params.setScoringThisActivityAtAll(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public static Config prepareConfig( AdditionalInformation additionalInformation,

Config config = RunBerlinScenario.prepareConfig( additionalInformation, args, customModulesAll ) ;

DrtConfigs.adjustMultiModeDrtConfig(MultiModeDrtConfigGroup.get(config), config.planCalcScore(), config.plansCalcRoute());
DrtConfigs.adjustMultiModeDrtConfig(MultiModeDrtConfigGroup.get(config), config.scoring(), config.routing());

return config ;
}
Expand Down
Loading

0 comments on commit ab1c6ab

Please sign in to comment.