From e63a9196463dfe5e52eb7a6a952fee57ab797f59 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 10:08:23 +0200 Subject: [PATCH 1/4] remove unused imports --- .../contrib/noise/ProcessNoiseImmissions.java | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/ProcessNoiseImmissions.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/ProcessNoiseImmissions.java index 25ad915d084..7010df609cf 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/ProcessNoiseImmissions.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/ProcessNoiseImmissions.java @@ -18,7 +18,7 @@ * *********************************************************************** */ /** - * + * */ package org.matsim.contrib.noise; @@ -31,11 +31,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.locationtech.jts.geom.Envelope; -import org.matsim.analysis.XYTRecord; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.contrib.analysis.vsp.qgis.*; -import org.matsim.core.router.priorityqueue.BinaryMinHeap; import org.matsim.core.utils.geometry.transformations.TransformationFactory; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.misc.Time; @@ -45,7 +43,7 @@ * */ public final class ProcessNoiseImmissions { - + private static final Logger log = LogManager.getLogger(ProcessNoiseImmissions.class); private final double receiverPointGap; @@ -71,12 +69,12 @@ public static void main(String[] args) { ProcessNoiseImmissions readNoiseFile = new ProcessNoiseImmissions(workingDirectory, receiverPointsFile, 100); readNoiseFile.run(); } - + public void run() { String label = "immission"; String outputFile = outputPath + label + "_processed.csv"; - + try { double startTime = 3600.; @@ -84,12 +82,12 @@ public void run() { double endTime = 24. * 3600.; String separator = ";"; for ( double time = startTime ; time <= endTime ; time = time + timeBinSize ) { - + log.info("Reading time bin: " + time); String fileName = workingDirectory + label + "_" + time + ".csv"; BufferedReader br = IOUtils.getBufferedReader(fileName); - + String line = null; line = br.readLine(); @@ -97,11 +95,11 @@ public void run() { int lineCounter = 0; log.info("Reading lines "); while ((line = br.readLine()) != null) { - + if (lineCounter % 10000 == 0.) { log.info("# " + lineCounter); } - + String[] columns = line.split( separator ); Id rp = null; Double value = null; @@ -109,41 +107,41 @@ public void run() { if (column == 0) { rp = Id.create(columns[column], ReceiverPoint.class); } else if (column == 1) { - value = Double.valueOf(columns[column]); + value = Double.valueOf(columns[column]); } else { // throw new RuntimeException("More than two columns. Aborting..."); } rp2value.put(rp, value); - + } lineCounter++; time2rp2value.put(time, rp2value); } } - + BufferedReader br = IOUtils.getBufferedReader(this.receiverPointsFile); String line = br.readLine(); - + Map, Coord> rp2Coord = new HashMap, Coord>(); int lineCounter = 0; - + log.info("Reading receiver points file"); - + while( (line = br.readLine()) != null){ - + if (lineCounter % 10000 == 0.) { log.info("# " + lineCounter); } - + String[] columns = line.split( separator ); Id rpId = null; double x = 0; double y = 0; - + for(int i = 0; i < columns.length; i++){ - + switch(i){ - + case 0: rpId = Id.create(columns[i], ReceiverPoint.class); break; case 1: x = Double.valueOf(columns[i]); @@ -151,25 +149,25 @@ public void run() { case 2: y = Double.valueOf(columns[i]); break; default: throw new RuntimeException("More than three columns. Aborting..."); - + } - + } - + lineCounter++; rp2Coord.put(rpId, new Coord(x, y)); - + } BufferedWriter bw = new BufferedWriter( new FileWriter( outputFile ) ); - + // write headers bw.write("Receiver Point Id;x;y" ); - + for ( double time = startTime ; time <= endTime ; time = time + timeBinSize ) { bw.write(";" + label + "_" + Time.writeTime(time, Time.TIMEFORMAT_HHMMSS ) ); } - + bw.write(";Lden;L_6-9;L_16-19" ); bw.newLine(); @@ -177,19 +175,19 @@ public void run() { // fill table for (Id rp : time2rp2value.get( endTime ).keySet()) { bw.write(rp.toString() + ";" + rp2Coord.get(rp ).getX() + ";" + rp2Coord.get(rp ).getY() ); - + for ( double time = startTime ; time <= endTime ; time = time + timeBinSize ) { bw.write(";" + time2rp2value.get(time ).get(rp ) ); } - + // aggregate time intervals - + double termDay = 0.; // day: 7-19 for (double time = 8 * 3600.; time <= 19 * 3600.; time = time + timeBinSize ) { termDay = termDay + Math.pow(10, time2rp2value.get(time).get(rp) / 10); } - + double termEvening = 0.; // evening: 19-23 for (double time = 20 * 3600.; time <= 23 * 3600.; time = time + timeBinSize ) { @@ -198,7 +196,7 @@ public void run() { double termNight = 0.; // night: 23-7 - + // nightA: 23-24 for (double time = 24 * 3600.; time <= 24 * 3600.; time = time + timeBinSize ) { termNight = termNight + Math.pow(10, (time2rp2value.get(time).get(rp) + 10) / 10); @@ -207,24 +205,24 @@ public void run() { for (double time = 1 * 3600.; time <= 7 * 3600.; time = time + timeBinSize ) { termNight = termNight + Math.pow(10, (time2rp2value.get(time).get(rp) + 10) / 10); } - + double Lden = 10 * Math.log10(1./24. * (termDay + termEvening + termNight)); bw.write(";" + Lden ); - + double term69 = 0.; for (double time = 7 * 3600.; time <= 9 * 3600.; time = time + timeBinSize ) { term69 = term69 + Math.pow(10, (time2rp2value.get(time).get(rp)) / 10); } double L_69 = 10 * Math.log10(1./3. * term69); bw.write(";" + L_69 ); - + double term1619 = 0.; for (double time = 17 * 3600.; time <= 19 * 3600.; time = time + timeBinSize ) { term1619 = term1619 + Math.pow(10, (time2rp2value.get(time).get(rp)) / 10); } double L_1619 = 10 * Math.log10(1./3. * term1619); bw.write(";" + L_1619 ); - + bw.newLine(); // TODO // for( NoiseModule.NoiseListener listener : listeners ){ @@ -235,24 +233,24 @@ public void run() { // listener.newRecord( record ); // } - } - + } + bw.close(); log.info("Output written to " + outputFile); } - + catch (IOException e1) { e1.printStackTrace(); } String qGisProjectFile = "immission.qgs"; - + QGisWriter writer = new QGisWriter(TransformationFactory.DHDN_GK4, workingDirectory); - + // ################################################################################################################################################ Envelope envelope = new Envelope(4568808,5803042,4622772,5844280); writer.setEnvelope(envelope); - + VectorLayer noiseLayer = new VectorLayer("noise", outputFile, QGisConstants.geometryType.Point, true); noiseLayer.setDelimiter(";"); noiseLayer.setXField("x"); @@ -260,13 +258,13 @@ public void run() { GraduatedSymbolRenderer renderer = RendererFactory.createNoiseRenderer(noiseLayer, this.receiverPointGap ); renderer.setRenderingAttribute("Lden"); - + writer.addLayer(noiseLayer); - + // ################################################################################################################################################ - + writer.write(qGisProjectFile); - + } public void addListener( NoiseModule.NoiseListener noiseListener ){ From 5e0214982f539220bd11f30b8ef6031529806fa6 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Wed, 11 Oct 2023 10:25:16 +0200 Subject: [PATCH 2/4] get rid of DataContainerProvider There were a Map-based and an Array-based implementation of DataContainerProvider. Since we have Indices in Ids and use an IdMap, the Map-based lookup is essentially also an array-based lookup. --- .../ArrayBasedDataContainerProvider.java | 82 ------------------- .../DataContainerProvider.java | 37 --------- .../MapBasedDataContainerProvider.java | 53 ------------ .../TravelTimeCalculator.java | 77 ++++------------- 4 files changed, 18 insertions(+), 231 deletions(-) delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/ArrayBasedDataContainerProvider.java delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/DataContainerProvider.java delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/MapBasedDataContainerProvider.java diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/ArrayBasedDataContainerProvider.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/ArrayBasedDataContainerProvider.java deleted file mode 100644 index 870e47c41c0..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/ArrayBasedDataContainerProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * ArrayBasedDataContainerProvider.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2013 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; -import org.matsim.core.router.priorityqueue.HasIndex; - -import java.util.Map; - -/** - * Uses an array to store DataContainer object for the TravelTimeCalculator. - * It is tried to get a DataContainer's position in the array is taken from the - * the Link, which is possible if routing networks are used (there, link implement - * the HasIndex interface). - * - * If regular network are used, calls are forwarded to a MapBasedDataContainerProvider, - * which represents the lookup approach used so far. - * - * @author cdobler - */ -class ArrayBasedDataContainerProvider implements DataContainerProvider { - - private final TravelTimeData[] arrayLinkData; - private final DataContainerProvider delegate; - - public ArrayBasedDataContainerProvider(Map, TravelTimeData> linkData, TravelTimeDataFactory ttDataFactory, - Network network) { - this.arrayLinkData = new TravelTimeData[network.getLinks().size()]; - this.delegate = new MapBasedDataContainerProvider(linkData, ttDataFactory); - } - - /* - * This method is called from the EventHandler part of the TravelTimeCalculator. - * There, only link ids are available. We cannot optimize this. - */ - @Override - public TravelTimeData getTravelTimeData(final Id linkId, final boolean createIfMissing) { - return this.delegate.getTravelTimeData(linkId, createIfMissing); - } - - /* - * This method is called from the TravelTime part of the TravelTimeCalculator. - * There, links are available. we can optimize this by using an array instead of a map. - * - * Probably pre-initialize all DataContainers to avoid the null-check? - */ - @Override - public TravelTimeData getTravelTimeData(Link link, boolean createIfMissing) { - if (link instanceof HasIndex) { - int index = ((HasIndex) link).getArrayIndex(); - TravelTimeData data = this.arrayLinkData[index]; - if (data == null) { - data = this.delegate.getTravelTimeData(link, createIfMissing); - this.arrayLinkData[index] = data; - } - return data; - } else { - return this.delegate.getTravelTimeData(link, createIfMissing); - } - } - -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/DataContainerProvider.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/DataContainerProvider.java deleted file mode 100644 index f308d815669..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/DataContainerProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * DataContainerProvider.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2013 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; - -interface DataContainerProvider { - - /* - * This method is called from the EventHandler part of the TravelTimeCalculator. - */ - /*package*/ TravelTimeData getTravelTimeData(final Id linkId, final boolean createIfMissing); - - /* - * This method is called from the TravelTime part of the TravelTimeCalculator. - */ - /*package*/ TravelTimeData getTravelTimeData(final Link link, final boolean createIfMissing); -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/MapBasedDataContainerProvider.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/MapBasedDataContainerProvider.java deleted file mode 100644 index 391c7cd60c4..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/MapBasedDataContainerProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * MapBasedDataContainerProvider.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2013 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; - -import java.util.Map; - -class MapBasedDataContainerProvider implements DataContainerProvider { - - private final Map, TravelTimeData> linkData; - private final TravelTimeDataFactory ttDataFactory; - - public MapBasedDataContainerProvider(Map, TravelTimeData> linkData, TravelTimeDataFactory ttDataFactory) { - this.linkData = linkData; - this.ttDataFactory = ttDataFactory; - } - - @Override - public TravelTimeData getTravelTimeData(final Id linkId, final boolean createIfMissing) { - TravelTimeData data = this.linkData.get(linkId); - if ((null == data) && createIfMissing) { - data = this.ttDataFactory.createTravelTimeData(linkId) ; - this.linkData.put(linkId, data); - } - return data; - } - - @Override - public TravelTimeData getTravelTimeData(Link link, boolean createIfMissing) { - return this.getTravelTimeData(link.getId(), createIfMissing); - } - -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java index 9c243c87116..68e60af776e 100644 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java +++ b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java @@ -82,13 +82,10 @@ public final class TravelTimeCalculator implements LinkEnterEventHandler, LinkLe private final int numSlots; TimeSlotComputation aggregator; - private IdMap linkData; private Map, Id>, TravelTimeData> linkToLinkData; - private final DataContainerProvider dataContainerProvider; - private final Map, LinkEnterEvent> linkEnterEvents; private final Set> vehiclesToIgnore; @@ -105,7 +102,7 @@ public final class TravelTimeCalculator implements LinkEnterEventHandler, LinkLe @Inject private QSimConfigGroup qsimConfig ; TravelTimeGetter travelTimeGetter ; - @Deprecated // user builder instead. kai, feb'19 + @Deprecated // use builder instead. kai, feb'19 public static TravelTimeCalculator create(Network network, TravelTimeCalculatorConfigGroup group) { TravelTimeCalculator calculator = new TravelTimeCalculator(network, group); configure(calculator, group, network); @@ -237,22 +234,9 @@ private TravelTimeCalculator(final Network network, final double timeslice, fina this.aggregator = new TimeSlotComputation(this.numSlots, this.timeSlice); this.travelTimeGetter = new AveragingTravelTimeGetter( this.aggregator ) ; this.ttDataFactory = new TravelTimeDataArrayFactory(network, this.numSlots); - if (this.calculateLinkTravelTimes){ + if (this.calculateLinkTravelTimes) { this.linkData = new IdMap<>(Link.class); - - /* - * So far, link data objects were stored in a HashMap. This lookup strategy is used - * by a MapBasedDataContainerProvider. - * When ArrayRoutingNetworks are used (as the FastRouter implementations do), the - * getArrayIndex() methods from the RoutingLinks can be used to lookup the link - * data objects in an array. This approach is implemented by the ArrayBasedDataContainerProvider. - * Using a ArrayBasedDataContainerProvider instead of a MapBasedDataContainerProvider - * increases the routing performance by 20-30%. - * cdobler, oct'13 - */ - // this.dataContainerProvider = new MapBasedDataContainerProvider(linkData, ttDataFactory); - this.dataContainerProvider = new ArrayBasedDataContainerProvider(linkData, ttDataFactory, network); - } else this.dataContainerProvider = null; + } if (this.calculateLinkToLinkTravelTimes){ // assume that every link has 2 outgoing links as default this.linkToLinkData = new ConcurrentHashMap<>((int) (network.getLinks().size() * 1.4 * 2)); @@ -289,7 +273,7 @@ public void handleEvent(final LinkLeaveEvent e) { if (this.calculateLinkTravelTimes) { LinkEnterEvent oldEvent = this.linkEnterEvents.get(e.getVehicleId()); if (oldEvent != null) { - TravelTimeData data = this.dataContainerProvider.getTravelTimeData(e.getLinkId(), true); + TravelTimeData data = this.getTravelTimeData(e.getLinkId(), true); double enterTime = oldEvent.getTime(); final int timeSlot = this.aggregator.getTimeSlotIndex(enterTime ); @@ -332,7 +316,7 @@ public void handleEvent(VehicleArrivesAtFacilityEvent event) { public void handleEvent(VehicleAbortsEvent event) { LinkEnterEvent e = this.linkEnterEvents.remove(event.getVehicleId()); if (e != null) { - TravelTimeData data = this.dataContainerProvider.getTravelTimeData(e.getLinkId(), true); + TravelTimeData data = this.getTravelTimeData(e.getLinkId(), true); data.setNeedsConsolidation( true ); // this.aggregator.addStuckEventTravelTime(data, e.getTime(), event.getTime()); @@ -351,6 +335,15 @@ public void handleEvent(VehicleAbortsEvent event) { if (filterAnalyzedModes) this.vehiclesToIgnore.remove(event.getVehicleId()); } + private TravelTimeData getTravelTimeData(final Id linkId, final boolean createIfMissing) { + TravelTimeData data = this.linkData.get(linkId); + if ((null == data) && createIfMissing) { + data = this.ttDataFactory.createTravelTimeData(linkId); + this.linkData.put(linkId, data); + } + return data; + } + private TravelTimeData getLinkToLinkTravelTimeData( Tuple, Id> fromLinkToLink ) { TravelTimeData data = this.linkToLinkData.get(fromLinkToLink); if ( null == data ) { @@ -360,48 +353,14 @@ private TravelTimeData getLinkToLinkTravelTimeData( Tuple, Id> fr return data; } - /* - * Use the link as argument here! In case the DataContainer is array-based and the link is from a routing network, - * the DataContainer uses the link's index to access its data structures instead of performing a map lookup, which - * increases the router performance by 20-30%! - * cdobler, aug'17 - */ - private double getLinkTravelTime(final Link link, final double time) { + private double getLinkTravelTime(final Id linkId, final double time) { if (this.calculateLinkTravelTimes) { - TravelTimeData data = this.dataContainerProvider.getTravelTimeData(link, true); + TravelTimeData data = this.getTravelTimeData(linkId, true); if ( data.isNeedingConsolidation() ) { consolidateData(data); } return this.travelTimeGetter.getTravelTime( data, time ); - - /* - * Workaround for jumps in returned travel times due to time bin approach? - * Should not be necessary when using linear interpolated travel times. - */ - // DataContainer data = this.dataContainerProvider.getTravelTimeInfo(link, true); - // if (data.needsConsolidation) { - // consolidateData(data); - // } - // double travelTime = this.aggregator.getTravelTime(data, time); - // - // // in case there is no previous time bin - // if (time <= this.timeSlice) return travelTime; - // - // int index = this.aggregator.getTimeSlotIndex(time); - // double previousBinEndTime = index * this.timeSlice; - // - // // calculate travel time when starting at the last second of the previous time slot - // double previousTravelTime = this.aggregator.getTravelTime(data, time - this.timeSlice); - // - // double prev = previousBinEndTime + previousTravelTime; - // double now = time + travelTime; - // if (now >= prev) { - // return travelTime; - // } - // else { - // return prev - time; // ensure travel time not shorter than travel time from the previous bin - // } } throw new IllegalStateException("No link travel time is available " + "if calculation is switched off by config option!"); @@ -511,7 +470,7 @@ public double getLinkTravelTime(Link link, double time, Person person, Vehicle v linkTtimeFromVehicle = link.getLength() / vehicleType.getMaximumVelocity(); } } - double linkTTimeFromObservation = TravelTimeCalculator.this.getLinkTravelTime(link, time); + double linkTTimeFromObservation = TravelTimeCalculator.this.getLinkTravelTime(link.getId(), time); return Math.max( linkTtimeFromVehicle, linkTTimeFromObservation) ; // yyyyyy should this not be min? kai/janek, may'19 // No, it is correct. It is preventing the router to route with an empirical speed from @@ -549,7 +508,7 @@ public double getLinkToLinkTravelTime(Link fromLink, Link toLink, double time, P } @Deprecated // use builder.configure(config) instead. kai, feb'19 - public void setTtDataFactory( TravelTimeDataFactory ttDataFactory ){ + void setTtDataFactory( TravelTimeDataFactory ttDataFactory ){ // yyyyyy this is currently here for a test, but should be removed. kai, feb'19 this.ttDataFactory = ttDataFactory; } From 1d9c3794309752376c5324bcc4980566824097c6 Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 15:48:00 +0200 Subject: [PATCH 3/4] remove TravelTimeDataHashMap from TravelTimeCalculator The suggested memory-savings only occur in scenarios with very very little traffic. Each timebin-data in TravelTimeDataHashMap uses 72 bytes (64-bit JVM), while it uses only 8 bytes in TravelTimeDataArray. Thus, only if at most every 9th timebin has traffic, it would bring memory savings. In all other cases it will actually use more memory and be slower (accessing nested objects in a hashmap instead of a simple array access). --- .../withinDayEvacuationConf.xml | 7 +- .../TravelTimeCalculatorConfigGroup.java | 15 --- .../TravelTimeCalculator.java | 66 +++++-------- .../TravelTimeDataArrayFactory.java | 42 -------- .../TravelTimeDataFactory.java | 31 ------ .../TravelTimeDataHashMap.java | 97 ------------------- .../TravelTimeDataHashMapFactory.java | 40 -------- .../TravelTimeCalculatorTest.java | 80 +-------------- 8 files changed, 31 insertions(+), 347 deletions(-) delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayFactory.java delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataFactory.java delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMap.java delete mode 100644 matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMapFactory.java diff --git a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml index 5e7845adf1b..b57a29d5fec 100644 --- a/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml +++ b/examples/scenarios/evacuation-tutorial/withinDayEvacuationConf.xml @@ -17,17 +17,16 @@ - - + - + @@ -40,7 +39,7 @@ - + diff --git a/matsim/src/main/java/org/matsim/core/config/groups/TravelTimeCalculatorConfigGroup.java b/matsim/src/main/java/org/matsim/core/config/groups/TravelTimeCalculatorConfigGroup.java index 8ca06b3fc1f..c0302d24095 100644 --- a/matsim/src/main/java/org/matsim/core/config/groups/TravelTimeCalculatorConfigGroup.java +++ b/matsim/src/main/java/org/matsim/core/config/groups/TravelTimeCalculatorConfigGroup.java @@ -41,9 +41,6 @@ public final class TravelTimeCalculatorConfigGroup extends ReflectiveConfigGroup public static final String GROUPNAME = "travelTimeCalculator"; - public enum TravelTimeCalculatorType {TravelTimeCalculatorArray,TravelTimeCalculatorHashMap} - - private static final String TRAVEL_TIME_CALCULATOR = "travelTimeCalculator"; private static final String TRAVEL_TIME_BIN_SIZE = "travelTimeBinSize"; private static final String TRAVEL_TIME_AGGREGATOR = "travelTimeAggregator"; private static final String TRAVEL_TIME_GETTER = "travelTimeGetter"; @@ -56,7 +53,6 @@ public enum TravelTimeCalculatorType {TravelTimeCalculatorArray,TravelTimeCalcul private static final String FILTERMODES = "filterModes"; private static final String SEPARATEMODES = "separateModes"; - private TravelTimeCalculatorType travelTimeCalculator = TravelTimeCalculatorType.TravelTimeCalculatorArray; private String travelTimeAggregator = "optimistic"; private String travelTimeGetter = "average"; private double traveltimeBinSize = 15 * 60; // use a default of 15min time-bins for analyzing the travel times @@ -89,22 +85,11 @@ public final Map getComments() { "respected by the travel time collector. 'car' is default which includes also buses from the pt simulation module."); map.put(FILTERMODES, "(only for backwards compatiblity; only used if " + SEPARATEMODES + "==false) Only modes included in analyzedModes are included." ) ; map.put(SEPARATEMODES, "(only for backwards compatibility) If false, link travel times are measured and aggregated over all vehicles using the link." ) ; - map.put( TRAVEL_TIME_CALCULATOR, "possible values: " + Arrays.stream( TravelTimeCalculatorType.values() ).map( type -> type.toString() + ' ' ).collect( Collectors.joining() ) ); return map; } enum DifferentModesHandling { separateAccordingToAnalyzedModes, jointButRestrictedToAnalyzedModes, jointAndUsingAllModes } - // --- - @StringSetter( TRAVEL_TIME_CALCULATOR ) - public void setTravelTimeCalculatorType(final String travelTimeCalculator){ - // leaving this as setter from string for backwards compatibility; enum.name() is not that terrible. kai, feb'18 - this.travelTimeCalculator = TravelTimeCalculatorType.valueOf( travelTimeCalculator ) ; - } - @StringGetter( TRAVEL_TIME_CALCULATOR ) - public TravelTimeCalculatorType getTravelTimeCalculatorType(){ - return this.travelTimeCalculator; - } // --- @StringSetter( TRAVEL_TIME_AGGREGATOR ) public void setTravelTimeAggregatorType(final String travelTimeAggregator){ diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java index 68e60af776e..1c28d9a0b19 100644 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java +++ b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeCalculator.java @@ -61,11 +61,7 @@ * at a node may take a different amount of time. *
* Travel times on links are collected and averaged in bins/slots with a specified size - * (binSize, in seconds, default 900 seconds = 15 minutes). The data for the travel times per link - * is stored in {@link TravelTimeData}-objects. If a short binSize is used, it is useful to - * use {@link TravelTimeDataHashMap},} - * as that one does not use any memory to time bins where no traffic occurred. By default, - * {@link TravelTimeDataArray} is used. + * (binSize, in seconds, default 900 seconds = 15 minutes). * * @author dgrether * @author mrieser @@ -82,9 +78,10 @@ public final class TravelTimeCalculator implements LinkEnterEventHandler, LinkLe private final int numSlots; TimeSlotComputation aggregator; - private IdMap linkData; + private final Network network; + private IdMap linkData; - private Map, Id>, TravelTimeData> linkToLinkData; + private Map, Id>, TravelTimeDataArray> linkToLinkData; private final Map, LinkEnterEvent> linkEnterEvents; @@ -97,8 +94,6 @@ public final class TravelTimeCalculator implements LinkEnterEventHandler, LinkLe private final boolean calculateLinkToLinkTravelTimes; - private TravelTimeDataFactory ttDataFactory = null; - @Inject private QSimConfigGroup qsimConfig ; TravelTimeGetter travelTimeGetter ; @@ -112,29 +107,15 @@ public static TravelTimeCalculator create(Network network, TravelTimeCalculatorC private static TravelTimeCalculator configure(TravelTimeCalculator calculator, TravelTimeCalculatorConfigGroup config, Network network) { // This should be replaced by a builder if we need the functionality. kai/mads, feb'19 - - // Customize micro-behavior of the TravelTimeCalculator based on config. Should not be necessary for most use cases. - switch ( config.getTravelTimeCalculatorType() ) { - case TravelTimeCalculatorArray: - calculator.ttDataFactory = new TravelTimeDataArrayFactory(network, calculator.numSlots); + switch( config.getTravelTimeGetterType() ){ + case "average": + calculator.travelTimeGetter = new AveragingTravelTimeGetter( calculator.aggregator ); break; - case TravelTimeCalculatorHashMap: - calculator.ttDataFactory = new TravelTimeDataHashMapFactory(network); + case "linearinterpolation": + calculator.travelTimeGetter = new LinearInterpolatingTravelTimeGetter( calculator.numSlots, calculator.timeSlice, calculator.aggregator ); break; default: - throw new RuntimeException(config.getTravelTimeCalculatorType() + " is unknown!"); - } - { - switch( config.getTravelTimeGetterType() ){ - case "average": - calculator.travelTimeGetter = new AveragingTravelTimeGetter( calculator.aggregator ); - break; - case "linearinterpolation": - calculator.travelTimeGetter = new LinearInterpolatingTravelTimeGetter( calculator.numSlots, calculator.timeSlice, calculator.aggregator ); - break; - default: - throw new RuntimeException( config.getTravelTimeGetterType() + " is unknown!" ); - } + throw new RuntimeException( config.getTravelTimeGetterType() + " is unknown!" ); } return calculator; } @@ -229,11 +210,11 @@ private TravelTimeCalculator(final Network network, final double timeslice, fina this.calculateLinkToLinkTravelTimes = calculateLinkToLinkTravelTimes; this.filterAnalyzedModes = filterModes; this.analyzedModes = analyzedModes; + this.network = network; this.timeSlice = timeslice; this.numSlots = TimeBinUtils.getTimeBinCount(maxTime, timeslice); this.aggregator = new TimeSlotComputation(this.numSlots, this.timeSlice); this.travelTimeGetter = new AveragingTravelTimeGetter( this.aggregator ) ; - this.ttDataFactory = new TravelTimeDataArrayFactory(network, this.numSlots); if (this.calculateLinkTravelTimes) { this.linkData = new IdMap<>(Link.class); } @@ -296,7 +277,7 @@ public void handleEvent(VehicleEntersTrafficEvent event) { @Override public void handleEvent(final VehicleLeavesTrafficEvent event) { /* remove EnterEvents from list when a vehicle arrives. - * otherwise, the activity duration would counted as travel time, when the + * otherwise, the activity duration would be counted as travel time, when the * vehicle departs again and leaves the link! */ this.linkEnterEvents.remove(event.getVehicleId()); @@ -307,7 +288,7 @@ public void handleEvent(final VehicleLeavesTrafficEvent event) { @Override public void handleEvent(VehicleArrivesAtFacilityEvent event) { /* remove EnterEvents from list when a bus stops on a link. - * otherwise, the stop time would counted as travel time, when the + * otherwise, the stop time would be counted as travel time, when the * bus departs again and leaves the link! */ this.linkEnterEvents.remove(event.getVehicleId()); } @@ -335,24 +316,28 @@ public void handleEvent(VehicleAbortsEvent event) { if (filterAnalyzedModes) this.vehiclesToIgnore.remove(event.getVehicleId()); } - private TravelTimeData getTravelTimeData(final Id linkId, final boolean createIfMissing) { - TravelTimeData data = this.linkData.get(linkId); + private TravelTimeDataArray getTravelTimeData(final Id linkId, final boolean createIfMissing) { + TravelTimeDataArray data = this.linkData.get(linkId); if ((null == data) && createIfMissing) { - data = this.ttDataFactory.createTravelTimeData(linkId); + data = this.createTravelTimeData(linkId); this.linkData.put(linkId, data); } return data; } - private TravelTimeData getLinkToLinkTravelTimeData( Tuple, Id> fromLinkToLink ) { - TravelTimeData data = this.linkToLinkData.get(fromLinkToLink); + private TravelTimeDataArray getLinkToLinkTravelTimeData( Tuple, Id> fromLinkToLink ) { + TravelTimeDataArray data = this.linkToLinkData.get(fromLinkToLink); if ( null == data ) { - data = this.ttDataFactory.createTravelTimeData(fromLinkToLink.getFirst()) ; + data = this.createTravelTimeData(fromLinkToLink.getFirst()) ; this.linkToLinkData.put(fromLinkToLink, data); } return data; } + private TravelTimeDataArray createTravelTimeData(Id linkId) { + return new TravelTimeDataArray(this.network.getLinks().get(linkId), this.numSlots); + } + private double getLinkTravelTime(final Id linkId, final double time) { if (this.calculateLinkTravelTimes) { @@ -507,9 +492,4 @@ public double getLinkToLinkTravelTime(Link fromLink, Link toLink, double time, P }; } - @Deprecated // use builder.configure(config) instead. kai, feb'19 - void setTtDataFactory( TravelTimeDataFactory ttDataFactory ){ - // yyyyyy this is currently here for a test, but should be removed. kai, feb'19 - this.ttDataFactory = ttDataFactory; - } } diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayFactory.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayFactory.java deleted file mode 100644 index db9b07a578c..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataArrayFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TravelTimeDataArrayFactory.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; - -class TravelTimeDataArrayFactory implements TravelTimeDataFactory { - - private final Network network; - private final int numSlots; - - public TravelTimeDataArrayFactory(final Network network, final int numSlots) { - this.network = network; - this.numSlots = numSlots; - } - - @Override - public TravelTimeData createTravelTimeData(Id linkId) { - return new TravelTimeDataArray(this.network.getLinks().get(linkId), this.numSlots); - } - -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataFactory.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataFactory.java deleted file mode 100644 index fbe4aa0d726..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TravelTimeDataFactory.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.core.api.internal.MatsimFactory; - -interface TravelTimeDataFactory extends MatsimFactory { - - public TravelTimeData createTravelTimeData(final Id linkId); - -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMap.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMap.java deleted file mode 100644 index 64775e96edb..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMap.java +++ /dev/null @@ -1,97 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TravelTimeRoleHashMap.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2008 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 org.matsim.core.trafficmonitoring; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.matsim.api.core.v01.network.Link; -import org.matsim.core.network.NetworkUtils; -import org.matsim.core.utils.misc.IntegerCache; - -/** - * Implementation of {@link TravelTimeData} that stores the travel time data in - * a HashMap. This has the advantage that no memory is used if no vehicle travels - * over a link, and thus no data is available to be stored. Especially useful with - * short time bins as there the probability to have empty time bins is higher. - * - * @author mrieser - * @author glaemmel - */ -class TravelTimeDataHashMap extends TravelTimeData { - private final Map travelTimes; - - protected final Link link; - - public TravelTimeDataHashMap(final Link link) { - this.travelTimes = new ConcurrentHashMap<>(); - this.link = link; -// resetTravelTimes(); - } - - @Override - public void resetTravelTimes() { - this.travelTimes.clear(); - } - - @Override - public void setTravelTime( final int timeSlice, final double traveltime ) { - TimeStruct curr = this.travelTimes.get(IntegerCache.getInteger(timeSlice)); - if (curr != null) { - curr.cnt = 1; - curr.timeSum = traveltime; - } else { - this.travelTimes.put(IntegerCache.getInteger(timeSlice), new TimeStruct(traveltime,1)); - } - } - - @Override - public void addTravelTime(final int timeSlice, final double traveltime) { - TimeStruct curr = this.travelTimes.get(IntegerCache.getInteger(timeSlice)); - if (curr != null) { - curr.cnt += 1; - curr.timeSum += traveltime; - } else { - this.travelTimes.put(IntegerCache.getInteger(timeSlice), new TimeStruct(traveltime,1)); - } - } - - @Override - public double getTravelTime(final int timeSlice, final double now) { - - TimeStruct ts = this.travelTimes.get(IntegerCache.getInteger(timeSlice)); - if (ts == null) { - Link r = ((Link)this.link); - return NetworkUtils.getFreespeedTravelTime(r, now) ; - } - return ts.timeSum / ts.cnt; - } - - private static class TimeStruct { - public double timeSum; - public int cnt; - public TimeStruct(final double timeSum, final int cnt) { - this.cnt = cnt; - this.timeSum = timeSum; - } - } - -} diff --git a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMapFactory.java b/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMapFactory.java deleted file mode 100644 index a8689615970..00000000000 --- a/matsim/src/main/java/org/matsim/core/trafficmonitoring/TravelTimeDataHashMapFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * TravelTimeDataHashMapFactory.java - * * - * *********************************************************************** * - * * - * copyright : (C) 2009 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 org.matsim.core.trafficmonitoring; - -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; - -class TravelTimeDataHashMapFactory implements TravelTimeDataFactory { - - private final Network network; - - public TravelTimeDataHashMapFactory(final Network network) { - this.network = network; - } - - @Override - public TravelTimeData createTravelTimeData(Id linkId) { - return new TravelTimeDataHashMap(this.network.getLinks().get(linkId)); - } - -} diff --git a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java index 17ec9fd0902..a7bc3c003af 100644 --- a/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java +++ b/matsim/src/test/java/org/matsim/core/trafficmonitoring/TravelTimeCalculatorTest.java @@ -87,7 +87,7 @@ public class TravelTimeCalculatorTest { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario( ConfigUtils.createConfig() ); TimeSlotComputation travelTimeAggregator = new TimeSlotComputation( numSlots, binSize ); TravelTimeGetter travelTimeGetter = new AveragingTravelTimeGetter( travelTimeAggregator ) ; - doTravelTimeCalculatorTest(scenario, new TravelTimeDataArrayFactory(scenario.getNetwork(), numSlots), + doTravelTimeCalculatorTest(scenario, travelTimeAggregator, binSize, endTime, compareFile, false, utils.getClassInputDirectory(), travelTimeGetter ); } @@ -102,80 +102,11 @@ public class TravelTimeCalculatorTest { MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario( ConfigUtils.createConfig() ); TimeSlotComputation aggregator = new TimeSlotComputation( numSlots, binSize ); TravelTimeGetter travelTimeGetter = new LinearInterpolatingTravelTimeGetter( numSlots, binSize, aggregator ); - doTravelTimeCalculatorTest(scenario, new TravelTimeDataArrayFactory(scenario.getNetwork(), numSlots), + doTravelTimeCalculatorTest(scenario, aggregator, binSize, endTime, compareFile, false, utils.getClassInputDirectory(), travelTimeGetter ); } - @Test public final void testTravelTimeCalculator_HashMap_Optimistic() throws IOException { - - int endTime = 30*3600; - int binSize = 15*60; - int numSlots = (endTime / binSize) + 1; - - // by default: averaging travel times - String compareFile = utils.getClassInputDirectory() + "link10_ttimes.txt"; - MutableScenario scenario = (MutableScenario) ScenarioUtils.createScenario( ConfigUtils.createConfig() ); - TimeSlotComputation travelTimeAggregator = new TimeSlotComputation( numSlots, binSize ); - TravelTimeGetter travelTimeGetter = new AveragingTravelTimeGetter( travelTimeAggregator ) ; - doTravelTimeCalculatorTest(scenario, new TravelTimeDataHashMapFactory(scenario.getNetwork()), - travelTimeAggregator, binSize, endTime, compareFile, false, utils.getClassInputDirectory(), travelTimeGetter ); - } - - @Test public final void testTravelTimeCalculator_HashMap_Optimistic_LinearInterpolation() throws IOException { - String compareFile; - MutableScenario scenario; - TimeSlotComputation aggregator; - - int endTime = 30*3600; - int binSize = 15*60; - int numSlots = (endTime / binSize) + 1; - - // use linear interpolation - compareFile = utils.getClassInputDirectory() + "link10_ttimes_linearinterpolation.txt"; - scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); - aggregator = new TimeSlotComputation(numSlots, binSize); - TravelTimeGetter travelTimeGetter = new LinearInterpolatingTravelTimeGetter( numSlots, binSize, aggregator ); - doTravelTimeCalculatorTest(scenario, new TravelTimeDataHashMapFactory(scenario.getNetwork()), - aggregator, binSize, endTime, compareFile, false, utils.getClassInputDirectory(), travelTimeGetter ); - } - -// @Test public final void testTravelTimeCalculator_HashMap_Pessimistic() throws IOException { -// String compareFile; -// MutableScenario scenario; -// TravelTimeAggregator aggregator; -// -// int endTime = 12*3600; -// int binSize = 1*60; -// int numSlots = (endTime / binSize) + 1; -// -// // by default: averaging travel times -// compareFile = getClassInputDirectory() + "link10_ttimes_pessimistic.txt"; -// scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); -// aggregator = new PessimisticTravelTimeAggregator(binSize, numSlots); -// assertEquals(AveragingTravelTimeGetter.class, aggregator.getTravelTimeGetter().getClass()); -// doTravelTimeCalculatorTest(scenario, new TravelTimeDataHashMapFactory(scenario.getNetwork()), -// aggregator, binSize, endTime, compareFile, false); -// } -// -// @Test public final void testTravelTimeCalculator_HashMap_Pessimistic_LinearInterpolation() throws IOException { -// String compareFile; -// MutableScenario scenario; -// TravelTimeAggregator aggregator; -// -// int endTime = 12*3600; -// int binSize = 1*60; -// int numSlots = (endTime / binSize) + 1; -// -// // use linear interpolation -// compareFile = getClassInputDirectory() + "link10_ttimes_pessimistic_linearinterpolation.txt"; -// scenario = (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig()); -// aggregator = new PessimisticTravelTimeAggregator(binSize, numSlots); -// aggregator.connectTravelTimeGetter(new LinearInterpolatingTravelTimeGetter(numSlots, binSize)); -// doTravelTimeCalculatorTest(scenario, new TravelTimeDataHashMapFactory(scenario.getNetwork()), -// aggregator, binSize, endTime, compareFile, false); -// } - - private static void doTravelTimeCalculatorTest( final MutableScenario scenario, final TravelTimeDataFactory ttDataFactory, + private static void doTravelTimeCalculatorTest( final MutableScenario scenario, final TimeSlotComputation aggregator, final int timeBinSize, final int endTime, final String compareFile, final boolean generateNewData, String inputDirectory, TravelTimeGetter travelTimeGetter ) throws IOException { @@ -195,9 +126,8 @@ private static void doTravelTimeCalculatorTest( final MutableScenario scenario, EventsManager events2 = EventsUtils.createEventsManager(); TravelTimeCalculator ttcalc = new TravelTimeCalculator(network, timeBinSize, endTime, scenario.getConfig().travelTimeCalculator()); - ttcalc.travelTimeGetter = travelTimeGetter ; - ttcalc.aggregator = aggregator ; - ttcalc.setTtDataFactory( ttDataFactory ); + ttcalc.travelTimeGetter = travelTimeGetter; + ttcalc.aggregator = aggregator; events2.addHandler(ttcalc); events2.initProcessing(); for (Event e : collector.getEvents()) { From d451e75569c777a8e16e53a51d7a98426eb1f64c Mon Sep 17 00:00:00 2001 From: Marcel Rieser Date: Thu, 12 Oct 2023 17:04:24 +0200 Subject: [PATCH 4/4] remove no-longer supported config-parameter "travelTimeCalculator" from configs --- .../config_demand.xml | 2 -- .../runExample/RunCarsharingIT/config.xml | 10 ++++------ .../scenarios/grid/jointDemand_config.xml | 2 -- .../matsim/contrib/locationchoice/config2.xml | 1 - .../locationchoice/facilityload/config.xml | 17 ++++++++--------- .../locationchoice/timegeography/config.xml | 13 ++++++------- ...fig-in-original-coords-minibus-w-transit.xml | 3 --- .../useSignalInput/withLanes/config.xml | 3 --- .../useSignalInput/woLanes/config.xml | 3 --- 9 files changed, 18 insertions(+), 36 deletions(-) diff --git a/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml b/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml index 67f61c5ca74..45f4d748e04 100644 --- a/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml +++ b/contribs/application/test/input/org/matsim/smallScaleCommercialTrafficGeneration/config_demand.xml @@ -551,8 +551,6 @@ - - diff --git a/contribs/carsharing/test/input/org/matsim/contrib/carsharing/runExample/RunCarsharingIT/config.xml b/contribs/carsharing/test/input/org/matsim/contrib/carsharing/runExample/RunCarsharingIT/config.xml index 0be55d6d96c..adb6c05c1a0 100644 --- a/contribs/carsharing/test/input/org/matsim/contrib/carsharing/runExample/RunCarsharingIT/config.xml +++ b/contribs/carsharing/test/input/org/matsim/contrib/carsharing/runExample/RunCarsharingIT/config.xml @@ -23,8 +23,6 @@ - - @@ -45,11 +43,11 @@ - - + + - + @@ -254,7 +252,7 @@ - + diff --git a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml index 8dcb998aa8d..35223afa37d 100644 --- a/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml +++ b/contribs/commercialTrafficApplications/scenarios/grid/jointDemand_config.xml @@ -535,8 +535,6 @@ - - diff --git a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/config2.xml b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/config2.xml index 697dacbe945..63d03a5ccfa 100644 --- a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/config2.xml +++ b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/config2.xml @@ -10,7 +10,6 @@ - diff --git a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/facilityload/config.xml b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/facilityload/config.xml index 7a137c6a982..bfa8a03c984 100644 --- a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/facilityload/config.xml +++ b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/facilityload/config.xml @@ -7,13 +7,12 @@ - + - - - + + @@ -21,7 +20,7 @@ - + @@ -31,12 +30,12 @@ - + - - + + @@ -63,5 +62,5 @@ - + diff --git a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/timegeography/config.xml b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/timegeography/config.xml index 3c2fbac487d..e75b74bf2bf 100644 --- a/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/timegeography/config.xml +++ b/contribs/locationchoice/test/input/org/matsim/contrib/locationchoice/timegeography/config.xml @@ -10,10 +10,9 @@ - - + @@ -21,7 +20,7 @@ - + @@ -32,12 +31,12 @@ - + - - + + @@ -94,5 +93,5 @@ - + diff --git a/contribs/minibus/test/input/org/matsim/contrib/minibus/raptor/TransferAtAccessStopRaptorTest/NPETest/config-in-original-coords-minibus-w-transit.xml b/contribs/minibus/test/input/org/matsim/contrib/minibus/raptor/TransferAtAccessStopRaptorTest/NPETest/config-in-original-coords-minibus-w-transit.xml index f754fa8d91d..794e81bbbe5 100644 --- a/contribs/minibus/test/input/org/matsim/contrib/minibus/raptor/TransferAtAccessStopRaptorTest/NPETest/config-in-original-coords-minibus-w-transit.xml +++ b/contribs/minibus/test/input/org/matsim/contrib/minibus/raptor/TransferAtAccessStopRaptorTest/NPETest/config-in-original-coords-minibus-w-transit.xml @@ -506,9 +506,6 @@ - - - diff --git a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml index dcbc59dfac2..9b05913abe9 100644 --- a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml +++ b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/withLanes/config.xml @@ -748,9 +748,6 @@ - - - diff --git a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml index 4dcd49397ff..ad0c31d9465 100644 --- a/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml +++ b/contribs/signals/examples/tutorial/example90TrafficLights/useSignalInput/woLanes/config.xml @@ -722,9 +722,6 @@ - - -