Skip to content

Commit

Permalink
update to matsim 15.0, log4j
Browse files Browse the repository at this point in the history
  • Loading branch information
vsp-gleich committed Jul 31, 2024
1 parent 9594e21 commit 24e7d47
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- release> -->
<!--<matsim.version>14.0-SNAPSHOT</matsim.version>-->
<!--weekly "release":-->
<matsim.version>14.0</matsim.version>
<matsim.version>15.0</matsim.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
package playground.gleich.analysis;

import com.google.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.PlanElement;
Expand All @@ -41,7 +42,7 @@
public final class DefaultAnalysisModeIdentifier implements AnalysisMainModeIdentifier {
private final List<String> modeHierarchy = new ArrayList<>() ;
private final List<String> drtModes;
private static final Logger log = Logger.getLogger(DefaultAnalysisModeIdentifier.class);
private static final Logger log = LogManager.getLogger(DefaultAnalysisModeIdentifier.class);
public static final String ANALYSIS_MAIN_MODE_PT_WITH_DRT_USED_FOR_ACCESS_OR_EGRESS = "pt_w_drt_used";

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package playground.gleich.analysis;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Activity;
import org.matsim.api.core.v01.population.Leg;
Expand All @@ -36,7 +37,7 @@

public class PlanFilesDifferOnlyInAttributes {

private static final Logger log = Logger.getLogger(PlanFilesDifferOnlyInAttributes.class);
private static final Logger log = LogManager.getLogger(PlanFilesDifferOnlyInAttributes.class);

public static void main(String[] args) {
String planFile1 = "/home/gregor/git/matsim/matsim/test/output/org/matsim/integration/replanning/ReRoutingIT/testReRoutingDijkstra/reference_population.xml.gz";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package playground.gleich.analysis;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.prep.PreparedGeometry;
import org.locationtech.jts.geom.prep.PreparedGeometryFactory;
Expand All @@ -25,7 +26,7 @@
public class TripsInVsOutsideArea {

private final Scenario scenario;
private static final Logger log = Logger.getLogger(TripsInVsOutsideArea.class);
private static final Logger log = LogManager.getLogger(TripsInVsOutsideArea.class);

public static void main (String[] args) throws MalformedURLException {
// String pathInclRunId = "/home/gregor/git/runs-svn/avoev/snz-gladbeck/output-snzDrt441/snzDrt441";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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.api.core.v01.Id;
import org.matsim.api.core.v01.events.ActivityEndEvent;
import org.matsim.api.core.v01.events.ActivityStartEvent;
Expand All @@ -37,7 +38,7 @@
*/
public class DrtOperationTimeEventHandler implements ActivityStartEventHandler, ActivityEndEventHandler {

private final static Logger log = Logger.getLogger(DrtOperationTimeEventHandler.class);
private final static Logger log = LogManager.getLogger(DrtOperationTimeEventHandler.class);
private Map<Id<Person>, Double> drtVehDriver2OperationTime = new HashMap<>();
private Map<Id<Person>, Double> drtVehDriver2LastStayTaskEndTime = new HashMap<>();
private Counter counter = new Counter("[" + this.getClass().getSimpleName() + "] handled ExperiencedTrip # ", "", 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

import java.util.Map;

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.population.Person;
import org.matsim.core.api.experimental.events.EventsManager;
Expand All @@ -40,7 +41,7 @@
*
*/
public class RunDrtOperationtimeCalculator {
private final static Logger log = Logger.getLogger(RunDrtOperationtimeCalculator.class);
private final static Logger log = LogManager.getLogger(RunDrtOperationtimeCalculator.class);
private final String eventsFile;

public RunDrtOperationtimeCalculator(String eventsFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import java.util.List;
import java.util.Optional;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.Point;
import org.matsim.analysis.TripsAndLegsCSVWriter;
Expand Down Expand Up @@ -69,7 +70,7 @@ public final class Events2ExperiencedTripsCSV {
private final String sep2 = ",";
private static String pathInclRunIdAndDot = "";

private static final Logger log = Logger.getLogger(Events2ExperiencedTripsCSV.class);
private static final Logger log = LogManager.getLogger(Events2ExperiencedTripsCSV.class);

public static void main(String[] args) {
pathInclRunIdAndDot = "/home/gregor/git/runs-svn/avoev/snz-vulkaneifel/output-Vu-DRT-9/Vu-DRT-9.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* *********************************************************************** */
package playground.gleich.analysis.pt;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.prep.PreparedGeometry;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
Expand Down Expand Up @@ -67,7 +68,7 @@ public class CalculatePtOperatingCostsFromEvents {
private int numVehUsed = 0;
private double pkm = 0.0;
private double totalCost = 0.0;
private final static Logger log = Logger.getLogger(CalculatePtOperatingCostsFromEvents.class);
private final static Logger log = LogManager.getLogger(CalculatePtOperatingCostsFromEvents.class);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import java.util.List;
import java.util.Map;

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.Scenario;
import org.matsim.core.api.experimental.events.EventsManager;
Expand All @@ -52,7 +53,7 @@
*/
public class PaxCountFromEvents {

private final static Logger log = Logger.getLogger(PaxCountFromEvents.class);
private final static Logger log = LogManager.getLogger(PaxCountFromEvents.class);

private final String eventsFile;
private final Scenario scenario;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
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.events.*;
import org.matsim.api.core.v01.events.handler.*;
Expand Down Expand Up @@ -69,7 +70,7 @@ public class PtStop2StopAnalysis implements TransitDriverStartsEventHandler, Veh
private final Vehicles transitVehicles; // for vehicle capacity
private final Map<Id<Vehicle>, PtVehicleData> transitVehicle2temporaryVehicleData = new HashMap<>();
private final List<Stop2StopEntry> stop2StopEntriesForEachDeparture; // the output
private static final Logger log = Logger.getLogger(PtStop2StopAnalysis.class);
private static final Logger log = LogManager.getLogger(PtStop2StopAnalysis.class);

public PtStop2StopAnalysis(Vehicles transitVehicles) {
this.transitVehicles = transitVehicles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.locationtech.jts.geom.Coordinate;
Expand Down Expand Up @@ -51,7 +52,7 @@
public class PtStop2StopAnalysis2Shp {

private static final String[] headerCsv = {"link", "transitLine", "stop", "departures", "passengers", "totalVehicleCapacity"};
private static final Logger log = Logger.getLogger(PtStop2StopAnalysis2Shp.class);
private static final Logger log = LogManager.getLogger(PtStop2StopAnalysis2Shp.class);

public static void writePtStop2StopAnalysisByTransitLine2ShpFile(
final Scenario scenario, final List<PtStop2StopAnalysis.Stop2StopEntry> stop2StopEntriesForEachDeparture, String shpFileName, String coordinateSystem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package playground.gleich.analysis.pt.stop2stop;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.Scenario;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.config.ConfigUtils;
Expand All @@ -36,7 +37,7 @@
* @author vsp-gleich
*/
public class RunPtStop2StopOffline {
private static final Logger log = Logger.getLogger(RunPtStop2StopOffline.class);
private static final Logger log = LogManager.getLogger(RunPtStop2StopOffline.class);

public static void main(String[] args) {
// String eventsFile = "/home/gregor/tmp/i364/i364.output_events.xml.gz";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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.locationtech.jts.geom.Coordinate;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
Expand All @@ -31,7 +32,7 @@

public class Links2ShapeFileRunner {

private final static Logger log = Logger.getLogger(Links2ShapeFileRunner.class);
private final static Logger log = LogManager.getLogger(Links2ShapeFileRunner.class);

public static void main(String[] args) {
String networkFile = "/home/gregor/git/capetown/output-minibus-wo-transit/lastGoodRun/output_network.xml.gz";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import java.util.Map;
import java.util.Map.Entry;

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.Scenario;
import org.matsim.contrib.minibus.PConfigGroup;
Expand All @@ -30,7 +31,7 @@
*/
public class RouteDesignScoringForAnalysis {

private final static Logger log = Logger.getLogger(RouteDesignScoringForAnalysis.class);
private final static Logger log = LogManager.getLogger(RouteDesignScoringForAnalysis.class);

public static void main(String[] args) {
String networkFile = "/home/gregor/git/capetown/output-minibus-wo-transit/lastGoodRun/output_network.xml.gz";
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/playground/gleich/network/NetworkCutOut.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package playground.gleich.network;

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

public class NetworkCutOut {

private final static Logger LOG = Logger.getLogger(NetworkCutOut.class);
private final static Logger LOG = LogManager.getLogger(NetworkCutOut.class);

public static void main(String[] args) {
// Check if args has an interpretable length
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* *********************************************************************** *
* project: org.matsim.*
* *
* *********************************************************************** *
* *
* copyright : (C) 2022 by the members listed in the COPYING, *
* LICENSE and WARRANTY file. *
* email : info at matsim dot org *
* *
* *********************************************************************** *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* See also COPYING, LICENSE and WARRANTY file *
* *
* *********************************************************************** */

package playground.gleich.plans;

import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.Plan;
import org.matsim.api.core.v01.population.PlanElement;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.population.algorithms.TripsToLegsAlgorithm;
import org.matsim.core.population.io.StreamingPopulationReader;
import org.matsim.core.population.io.StreamingPopulationWriter;
import org.matsim.core.router.RoutingModeMainModeIdentifier;
import org.matsim.core.router.TripStructureUtils;
import org.matsim.core.scenario.ScenarioUtils;

/**
* @author gleich
*
* Return a population with all agents who have activities within a certain geographic area or
* pass through this area by car (and ignore all other agents).
*
*/
public class MoveWalkTripsToWalkMainStreamReading {

public static void main(String[] args) {
String fromMode = TransportMode.walk;
String toMode = "walkMain";
double probability = 1.0;
String inputPopulationPath = "../../ilsMount/matsim-berlin/calibration-3rd/input/v6.0/berlin-v6.0-10pct.plans.xml.gz";
String outputPopulationPath = "../../ilsMount/matsim-berlin/calibration-3rd/input/v6.0/berlin-v6.0-10pct.plans_" + toMode + "_unrouted.xml.gz";
Scenario inputScenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());

TripsToLegsAlgorithm tripsToLegsAlgorithm = new TripsToLegsAlgorithm(new RoutingModeMainModeIdentifier());

System.out.println("initialize done");
StreamingPopulationWriter popWriter = new StreamingPopulationWriter();
popWriter.writeStartPlans(outputPopulationPath);

StreamingPopulationReader spr = new StreamingPopulationReader(inputScenario);
spr.addAlgorithm(person -> {

for (Plan plan: person.getPlans()) {
tripsToLegsAlgorithm.run(plan);
if (Math.random() < probability) {
for (PlanElement planElement: plan.getPlanElements()) {
if (planElement instanceof Leg) {
Leg leg = (Leg) planElement;
if (leg.getMode().equals(fromMode)) {
if (TripStructureUtils.getRoutingMode(leg).equals(fromMode)) {
leg.setMode(toMode);
TripStructureUtils.setRoutingMode(leg, toMode);
}
}
}
}
}
}
popWriter.writePerson(person);
}
);
spr.readFile(inputPopulationPath);
popWriter.writeEndPlans();
System.out.println("ExtractAgentsInArea done");
}

}
5 changes: 3 additions & 2 deletions src/main/java/playground/gleich/pt/SplitPtTripsAtStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import java.util.ListIterator;
import java.util.Set;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.Geometry;
import org.matsim.api.core.v01.Coord;
import org.matsim.api.core.v01.Scenario;
Expand Down Expand Up @@ -41,7 +42,7 @@
*/
public class SplitPtTripsAtStation {

private static final Logger log = Logger.getLogger(SplitPtTripsAtStation.class);
private static final Logger log = LogManager.getLogger(SplitPtTripsAtStation.class);
private String inputPopulationPath;
private String studyAreaShpPath;
private String studyAreaShpKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package playground.gleich.pt;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.locationtech.jts.geom.prep.PreparedGeometry;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
Expand All @@ -21,7 +22,7 @@

public class TransitLinesAreaBasedRemover {

private static final Logger log = Logger.getLogger(TransitLinesAreaBasedRemover.class);
private static final Logger log = LogManager.getLogger(TransitLinesAreaBasedRemover.class);

public static void main(String[] args) throws MalformedURLException {
final String inScheduleFile = "../../shared-svn/projects/avoev/matsim-input-files/vulkaneifel/v0/optimizedSchedule.xml.gz";
Expand Down
Loading

0 comments on commit 24e7d47

Please sign in to comment.