From e4dca0030a5344567c1f739cf4ac2f38edff3be1 Mon Sep 17 00:00:00 2001
From: Marcel Rieser
Date: Thu, 12 Oct 2023 10:46:24 +0200
Subject: [PATCH 1/2] delete contrib eventsBasedPTRouter
Closes #2838
---
.github/workflows/verify-push.yaml | 1 -
contribs/eventsBasedPTRouter/pom.xml | 11 -
.../MultiDestinationDijkstra.java | 547 ------------------
.../MultiNodeDijkstra.java | 72 ---
.../SerializableLinkTravelTimes.java | 49 --
.../TransitRouterEventsWLFactory.java | 61 --
.../TransitRouterEventsWSFactory.java | 71 ---
.../TransitRouterEventsWSVFactory.java | 63 --
...outerNetworkTravelTimeAndDisutilityWS.java | 144 -----
...uterNetworkTravelTimeAndDisutilityWSV.java | 146 -----
...outerNetworkTravelTimeAndDisutilityWW.java | 144 -----
.../TransitRouterNetworkWW.java | 479 ---------------
.../TransitRouterVariableImpl.java | 243 --------
.../controler/RunControlerWS.java | 66 ---
.../controler/RunControlerWSV.java | 77 ---
.../controler/RunControlerWW.java | 56 --
.../stopStopTimes/StopStopTime.java | 14 -
.../stopStopTimes/StopStopTimeCalculator.java | 20 -
.../StopStopTimeCalculatorImpl.java | 153 -----
.../StopStopTimeCalculatorSerializable.java | 192 ------
.../StopStopTimeCalculatorTuple.java | 134 -----
.../stopStopTimes/StopStopTimeData.java | 13 -
.../stopStopTimes/StopStopTimeDataArray.java | 49 --
.../StopStopTimePreCalcSerializable.java | 273 ---------
.../vehicleOccupancy/VehicleOccupancy.java | 13 -
.../VehicleOccupancyCalculator.java | 106 ----
.../VehicleOccupancyData.java | 9 -
.../VehicleOccupancyDataArray.java | 42 --
.../waitTimes/WaitTime.java | 41 --
.../waitTimes/WaitTimeCalculator.java | 17 -
.../waitTimes/WaitTimeCalculatorImpl.java | 181 ------
.../WaitTimeCalculatorSerializable.java | 216 -------
.../waitTimes/WaitTimeData.java | 39 --
.../waitTimes/WaitTimeDataArray.java | 67 ---
.../waitTimes/WaitTimeStuckCalculator.java | 222 -------
.../MultiNodeDijkstraTest.java | 495 ----------------
contribs/pom.xml | 1 -
37 files changed, 4527 deletions(-)
delete mode 100644 contribs/eventsBasedPTRouter/pom.xml
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWSV.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWW.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkWW.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimePreCalcSerializable.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTime.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java
delete mode 100644 contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeStuckCalculator.java
delete mode 100644 contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java
diff --git a/.github/workflows/verify-push.yaml b/.github/workflows/verify-push.yaml
index 6c98df57073..f2a5b59d8ee 100644
--- a/.github/workflows/verify-push.yaml
+++ b/.github/workflows/verify-push.yaml
@@ -58,7 +58,6 @@ jobs:
- contribs/railsim
- contribs/roadpricing
- contribs/analysis
- - contribs/eventsBasedPTRouter
- contribs/hybridsim
- contribs/informed-mode-choice
- contribs/otfvis
diff --git a/contribs/eventsBasedPTRouter/pom.xml b/contribs/eventsBasedPTRouter/pom.xml
deleted file mode 100644
index 6544fa91056..00000000000
--- a/contribs/eventsBasedPTRouter/pom.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- org.matsim
- contrib
- 16.0-SNAPSHOT
-
- 4.0.0
- org.matsim.contrib
- events-based-pt-router
- eventsBasedPTRouter
-
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java
deleted file mode 100644
index 686ce4cebab..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiDestinationDijkstra.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * Dijkstra.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2007 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.contrib.eventsBasedPTRouter;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.api.core.v01.network.Network;
-import org.matsim.api.core.v01.network.Node;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.router.util.DijkstraNodeData;
-import org.matsim.core.router.util.LeastCostPathCalculator.Path;
-import org.matsim.core.router.util.PreProcessDijkstra;
-import org.matsim.core.router.util.TravelTime;
-import org.matsim.core.utils.collections.PseudoRemovePriorityQueue;
-import org.matsim.core.utils.misc.Time;
-import org.matsim.pt.router.TransitTravelDisutility;
-
-
-/**
- * Implementation of Dijkstra's
- * shortest-path algorithm on a time-dependent network with arbitrary
- * non-negative cost functions (e.g. negative link cost are not allowed). So
- * 'shortest' in our context actually means 'least-cost'.
- *
- *
- * For every router, there exists a class which computes some preprocessing data
- * and is passed to the router class constructor in order to accelerate the
- * routing procedure. The one used for Dijkstra is
- * {@link org.matsim.core.router.util.PreProcessDijkstra}.
- *
- *
- *
- * Code example:
- *
- * PreProcessDijkstra preProcessData = new PreProcessDijkstra();
- * preProcessData.run(network);
- * TravelCost costFunction = ...
- * LeastCostPathCalculator routingAlgo = new Dijkstra(network, costFunction, preProcessData);
- * routingAlgo.calcLeastCostPath(fromNode, toNode, startTime);
- *
- *
- * If you don't want to preprocess the network, you can invoke Dijkstra as
- * follows:
- *
- *
- * LeastCostPathCalculator routingAlgo = new Dijkstra(network, costFunction);
- *
- *
- * Important note
- * This class is NOT threadsafe!
- *
- * @see org.matsim.core.router.util.PreProcessDijkstra
- * @see org.matsim.core.router.AStarEuclidean
- * @see org.matsim.core.router.AStarLandmarks
- * @author lnicolas
- * @author mrieser
- */
-public class MultiDestinationDijkstra {
-
- private final static Logger log = LogManager.getLogger(MultiDestinationDijkstra.class);
-
- /**
- * The network on which we find routes.
- */
- protected Network network;
-
- /**
- * The cost calculator. Provides the cost for each link and time step.
- */
- final TransitTravelDisutility costFunction;
-
- /**
- * The travel time calculator. Provides the travel time for each link and time step.
- */
- final TravelTime timeFunction;
-
- final Map, DijkstraNodeData> nodeData;
-
- /**
- * Provides an unique id (loop number) for each routing request, so we don't
- * have to reset all nodes at the beginning of each re-routing but can use the
- * loop number instead.
- */
- private int iterationID = Integer.MIN_VALUE + 1;
-
- /**
- * Temporary field that is only used if dead ends are being pruned during
- * routing and is updated each time a new route has to be calculated.
- */
- private Set deadEndEntryNodes = new HashSet();
-
- /**
- * Determines whether we should mark nodes in dead ends during a
- * pre-processing step so they won't be expanded during routing.
- */
- /*package*/ final boolean pruneDeadEnds;
-
- /**
- * Comparator that defines how to order the nodes in the pending nodes queue
- * during routing.
- */
-
- private final PreProcessDijkstra preProcessData;
-
-
- private String[] modeRestriction = null;
-
- private Person person = null;
-
- /**
- * Default constructor.
- *
- * @param network
- * The network on which to route.
- * @param costFunction
- * Determines the link cost defining the cheapest route.
- * @param timeFunction
- * Determines the travel time on links.
- */
- public MultiDestinationDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction) {
- this(network, costFunction, timeFunction, null);
- }
-
- /**
- * Constructor.
- *
- * @param network
- * The network on which to route.
- * @param costFunction
- * Determines the link cost defining the cheapest route.
- * @param timeFunction
- * Determines the travel time on each link.
- * @param preProcessData
- * The pre processing data used during the routing phase.
- */
- public MultiDestinationDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction,
- final PreProcessDijkstra preProcessData) {
-
- this.network = network;
- this.costFunction = costFunction;
- this.timeFunction = timeFunction;
- this.preProcessData = preProcessData;
-
- this.nodeData = new HashMap, DijkstraNodeData>((int)(network.getNodes().size() * 1.1), 0.95f);
-
- if (preProcessData != null) {
- if (preProcessData.containsData() == false) {
- this.pruneDeadEnds = false;
- log.warn("The preprocessing data provided to router class Dijkstra contains no data! Please execute its run(...) method first!");
- log.warn("Running without dead-end pruning.");
- } else {
- this.pruneDeadEnds = true;
- }
- } else {
- this.pruneDeadEnds = false;
- }
- }
-
- public void setModeRestriction(final Set modeRestriction) {
- if (modeRestriction == null) {
- this.modeRestriction = null;
- } else {
- this.modeRestriction = modeRestriction.toArray(new String[modeRestriction.size()]);
- }
- }
-
- /**
- * Calculates the cheapest route from Node 'fromNode' to Node 'toNode' at
- * starting time 'startTime'.
- *
- * @param fromNode
- * The Node at which the route should start.
- * @param toNode
- * The Node at which the route should end.
- * @param startTime
- * The time at which the route should start. Note: Using
- * {@link Time#UNDEFINED_TIME} does not imply "time is not relevant",
- * rather, {@link Path#travelTime} will return {@link Double#NaN}.
- * @see org.matsim.core.router.util.LeastCostPathCalculator#calcLeastCostPath(org.matsim.core.network.Node,
- * org.matsim.core.network.Node, double)
- */
- public Map, Path> calcLeastCostPath(final Node fromNode, final Set toNodes, final double startTime, final Person person) {
-
- Map, Double> arrivalTimes = new HashMap, Double>();
- boolean stillSearching = true;
- int finishedNodes = 0;
- augmentIterationId(); // this call makes the class not threadsafe
- this.person = person;
-
- if (this.pruneDeadEnds == true) {
- for(Node toNode:toNodes)
- deadEndEntryNodes.add(getPreProcessData(toNode).getDeadEndEntryNode());
- }
-
- PseudoRemovePriorityQueue pendingNodes = new PseudoRemovePriorityQueue(500);
- initFromNode(fromNode, startTime, pendingNodes);
-
- while (stillSearching) {
- Node outNode = pendingNodes.poll();
-
- if (outNode == null) {
- log.warn("No route was found from node " + fromNode.getId() + " to all nodes: " + finishedNodes + " of " + toNodes.size());
- stillSearching = false;
- }
- else {
- if (toNodes.contains(outNode)) {
- DijkstraNodeData outData = getData(outNode);
- arrivalTimes.put(outNode.getId(), outData.getTime());
- finishedNodes++;
- }
- relaxNode(outNode, pendingNodes);
- if(finishedNodes==toNodes.size())
- stillSearching = false;
- }
- }
-
- // now construct and return the path
- return constructPaths(fromNode, toNodes, startTime, arrivalTimes);
-
- }
-
- /**
- * Constructs the path after the algorithm has been run.
- *
- * @param fromNode
- * The node where the path starts.
- * @param toNode
- * The node where the path ends.
- * @param startTime
- * The time when the trip starts.
- * @param preProcessData
- * The time when the trip ends.
- */
- protected Map, Path> constructPaths(Node fromNode, Set toNodes, double startTime, Map, Double> arrivalTimes) {
- Map, Path> paths = new HashMap, Path>();
- for(Node toNode:toNodes) {
- Double arrivalTime = arrivalTimes.get(toNode.getId());
- Path path = null;
- if(arrivalTime != null) {
- ArrayList nodes = new ArrayList();
- ArrayList links = new ArrayList ();
-
- nodes.add(0, toNode);
- Link tmpLink = getData(toNode).getPrevLink();
- if (tmpLink != null) {
- while (tmpLink.getFromNode() != fromNode) {
- links.add(0, tmpLink);
- nodes.add(0, tmpLink.getFromNode());
- tmpLink = getData(tmpLink.getFromNode()).getPrevLink();
- }
- links.add(0, tmpLink);
- nodes.add(0, tmpLink.getFromNode());
- }
-
- DijkstraNodeData toNodeData = getData(toNode);
- path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost());
- }
- paths.put(toNode.getId(), path);
- }
- return paths;
- }
-
- /**
- * Initializes the first node of a route.
- *
- * @param fromNode
- * The Node to be initialized.
- * @param toNode
- * The Node at which the route should end.
- * @param startTime
- * The time we start routing.
- * @param pendingNodes
- * The pending nodes so far.
- */
- /*package*/ void initFromNode(final Node fromNode, final double startTime,
- final PseudoRemovePriorityQueue pendingNodes) {
- DijkstraNodeData data = getData(fromNode);
- visitNode(fromNode, data, pendingNodes, startTime, 0, null);
- }
-
- /**
- * Expands the given Node in the routing algorithm; may be overridden in
- * sub-classes.
- *
- * @param outNode
- * The Node to be expanded.
- * @param toNode
- * The target Node of the route.
- * @param pendingNodes
- * The set of pending nodes so far.
- */
- protected void relaxNode(final Node outNode, final PseudoRemovePriorityQueue pendingNodes) {
-
- DijkstraNodeData outData = getData(outNode);
- double currTime = outData.getTime();
- double currCost = outData.getCost();
- if (this.pruneDeadEnds) {
- PreProcessDijkstra.DeadEndData ddOutData = getPreProcessData(outNode);
-
- for (Link l : outNode.getOutLinks().values()) {
- relaxNodeLogic(l, pendingNodes, currTime, currCost, ddOutData);
- }
- } else { // this.pruneDeadEnds == false
- for (Link l : outNode.getOutLinks().values()) {
- relaxNodeLogic(l, pendingNodes, currTime, currCost, null);
- }
- }
- }
-
- /**
- * Logic that was previously located in the relaxNode(...) method.
- * By doing so, the FastDijkstra can overwrite relaxNode without copying the logic.
- */
- /*package*/ void relaxNodeLogic(final Link l, final PseudoRemovePriorityQueue pendingNodes,
- final double currTime, final double currCost,
- final PreProcessDijkstra.DeadEndData ddOutData) {
- if (this.pruneDeadEnds) {
- if (canPassLink(l)) {
- Node n = l.getToNode();
- PreProcessDijkstra.DeadEndData ddData = getPreProcessData(n);
- /* IF the current node n is not in a dead end
- * OR it is in the same dead end as the fromNode
- * OR it is in the same dead end as the toNode
- * THEN we add the current node to the pending nodes */
- if(ddData.getDeadEndEntryNode()==null || ddOutData.getDeadEndEntryNode()!=null)
- addToPendingNodes(l, n, pendingNodes, currTime, currCost);
- else {
- TO_NODES:
- for(Node deadEndEntryNode:deadEndEntryNodes)
- if(deadEndEntryNode != null && deadEndEntryNode.getId() == ddData.getDeadEndEntryNode().getId()) {
- addToPendingNodes(l, n, pendingNodes, currTime, currCost);
- break TO_NODES;
- }
- }
- }
- } else {
- if (canPassLink(l)) {
- addToPendingNodes(l, l.getToNode(), pendingNodes, currTime, currCost);
- }
- }
- }
-
- /**
- * Adds some parameters to the given Node then adds it to the set of pending
- * nodes.
- *
- * @param l
- * The link from which we came to this Node.
- * @param n
- * The Node to add to the pending nodes.
- * @param pendingNodes
- * The set of pending nodes.
- * @param currTime
- * The time at which we started to traverse l.
- * @param currCost
- * The cost at the time we started to traverse l.
- * @param toNode
- * The target Node of the route.
- * @return true if the node was added to the pending nodes, false otherwise
- * (e.g. when the same node already has an earlier visiting time).
- */
- protected boolean addToPendingNodes(final Link l, final Node n,
- final PseudoRemovePriorityQueue pendingNodes, final double currTime,
- final double currCost) {
-
- double travelTime = this.timeFunction.getLinkTravelTime(l, currTime, person, null);
- double travelCost = this.costFunction.getLinkTravelDisutility(l, currTime, this.person, null, null);
- DijkstraNodeData data = getData(n);
- double nCost = data.getCost();
- if (!data.isVisited(getIterationId())) {
- visitNode(n, data, pendingNodes, currTime + travelTime, currCost
- + travelCost, l);
- return true;
- }
- double totalCost = currCost + travelCost;
- if (totalCost < nCost) {
- revisitNode(n, data, pendingNodes, currTime + travelTime, totalCost, l);
- return true;
- }
-
- return false;
- }
-
- /**
- * @param link
- * @return true
if the link can be passed with respect to a possible mode restriction set
- *
- * @see #setModeRestriction(Set)
- */
- protected boolean canPassLink(final Link link) {
- if (this.modeRestriction == null) {
- return true;
- }
- for (String mode : this.modeRestriction) {
- if (link.getAllowedModes().contains(mode)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Changes the position of the given Node n in the pendingNodes queue and
- * updates its time and cost information.
- *
- * @param n
- * The Node that is revisited.
- * @param data
- * The data for n.
- * @param pendingNodes
- * The nodes visited and not processed yet.
- * @param time
- * The time of the visit of n.
- * @param cost
- * The accumulated cost at the time of the visit of n.
- * @param outLink
- * The link from which we came visiting n.
- */
- void revisitNode(final Node n, final DijkstraNodeData data,
- final PseudoRemovePriorityQueue pendingNodes, final double time, final double cost,
- final Link outLink) {
- pendingNodes.remove(n);
-
- data.visit(outLink, cost, time, getIterationId());
- pendingNodes.add(n, getPriority(data));
- }
-
- /**
- * Inserts the given Node n into the pendingNodes queue and updates its time
- * and cost information.
- *
- * @param n
- * The Node that is revisited.
- * @param data
- * The data for n.
- * @param pendingNodes
- * The nodes visited and not processed yet.
- * @param time
- * The time of the visit of n.
- * @param cost
- * The accumulated cost at the time of the visit of n.
- * @param outLink
- * The node from which we came visiting n.
- */
- protected void visitNode(final Node n, final DijkstraNodeData data,
- final PseudoRemovePriorityQueue pendingNodes, final double time, final double cost,
- final Link outLink) {
- data.visit(outLink, cost, time, getIterationId());
- pendingNodes.add(n, getPriority(data));
- }
-
- /**
- * Augments the iterationID and checks whether the visited information in
- * the nodes in the nodes have to be reset.
- */
- protected void augmentIterationId() {
- if (getIterationId() == Integer.MAX_VALUE) {
- this.iterationID = Integer.MIN_VALUE + 1;
- resetNetworkVisited();
- } else {
- this.iterationID++;
- }
- }
-
- /**
- * @return iterationID
- */
- /*package*/ int getIterationId() {
- return this.iterationID;
- }
-
- /**
- * Resets all nodes in the network as if they have not been visited yet.
- */
- private void resetNetworkVisited() {
- for (Node node : this.network.getNodes().values()) {
- DijkstraNodeData data = getData(node);
- data.resetVisited();
- }
- }
-
- /**
- * The value used to sort the pending nodes during routing.
- * This implementation compares the total effective travel cost
- * to sort the nodes in the pending nodes queue during routing.
- */
- protected double getPriority(final DijkstraNodeData data) {
- return data.getCost();
- }
-
- /**
- * Returns the data for the given node. Creates a new NodeData if none exists
- * yet.
- *
- * @param n
- * The Node for which to return the data.
- * @return The data for the given Node
- */
- protected DijkstraNodeData getData(final Node n) {
- DijkstraNodeData r = this.nodeData.get(n.getId());
- if (null == r) {
- r = new DijkstraNodeData();
- this.nodeData.put(n.getId(), r);
- }
- return r;
- }
-
- protected PreProcessDijkstra.DeadEndData getPreProcessData(final Node n) {
- return this.preProcessData.getNodeData(n);
- }
-
- protected final Person getPerson() {
- return this.person;
- }
-
- protected final void setPerson(final Person person) {
- this.person = person;
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java
deleted file mode 100644
index 457d0e68bc3..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstra.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * TransitDijkstra.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.contrib.eventsBasedPTRouter;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.matsim.api.core.v01.network.Network;
-import org.matsim.api.core.v01.network.Node;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.router.InitialNode;
-import org.matsim.core.router.util.LeastCostPathCalculator.Path;
-import org.matsim.core.router.util.TravelTime;
-import org.matsim.pt.router.TransitLeastCostPathTree;
-import org.matsim.pt.router.TransitTravelDisutility;
-
-public class MultiNodeDijkstra /*extends Dijkstra*/ {
-
- /**
- * The network on which we find routes.
- */
- protected Network network;
-
- /**
- * The cost calculator. Provides the cost for each link and time step.
- */
- private final TransitTravelDisutility costFunction;
-
- /**
- * The travel time calculator. Provides the travel time for each link and time step.
- */
- private final TravelTime timeFunction;
-
- public MultiNodeDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction) {
- this.network = network;
- this.costFunction = costFunction;
- this.timeFunction = timeFunction;
- }
-
- @SuppressWarnings("unchecked")
- public Path calcLeastCostPath(final Map fromNodes, final Map toNodes, final Person person) {
- Map swapedToNodes = swapNodes(toNodes);
- TransitLeastCostPathTree tree = new TransitLeastCostPathTree(network, costFunction, timeFunction, swapNodes(fromNodes), swapedToNodes, person);
- return tree.getPath(swapedToNodes);
- }
-
- private Map swapNodes(final Map original) {
- Map result = new HashMap<>();
- for (Map.Entry entry : original.entrySet()) {
- result.put(entry.getKey(), new InitialNode(entry.getValue().initialCost, entry.getValue().initialTime));
- }
- return result;
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java
deleted file mode 100644
index 2ca3400149b..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/SerializableLinkTravelTimes.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.router.util.TravelTime;
-import org.matsim.vehicles.Vehicle;
-
-public class SerializableLinkTravelTimes implements Serializable, TravelTime {
-
- private final double[][] times;
- private final Map indices = new HashMap<>();
- private final int travelTimeBinSize;
-
- public SerializableLinkTravelTimes(TravelTime linkTravelTimes,
- int traveltimeBinSize, double endTime,
- Collection extends Link> links) {
- this.travelTimeBinSize = traveltimeBinSize;
- endTime = endTime <= 0 ? 86400 : endTime;
- times = new double[links.size()][(int) (endTime / traveltimeBinSize)];
- Iterator extends Link> iterator = links.iterator();
- for (int i = 0; i < times.length; i++) {
- Link link = iterator.next();
- indices.put(link.getId().toString(), i);
- for (int j = 0; j < times[i].length; j++)
- times[i][j] = linkTravelTimes.getLinkTravelTime(link,
- traveltimeBinSize * j, null, null);
- }
- }
-
- @Override
- public double getLinkTravelTime(Link link, double time, Person person,
- Vehicle vehicle) {
- time = time % 86400;
- try {
- return times[indices.get(link.getId().toString())][(int) (time / travelTimeBinSize)];
- } catch (ArrayIndexOutOfBoundsException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return time;
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java
deleted file mode 100644
index f163879e763..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWLFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter;
-
-import org.matsim.api.core.v01.network.Network;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.core.controler.MatsimServices;
-import org.matsim.pt.router.PreparedTransitSchedule;
-import org.matsim.pt.router.TransitRouter;
-import org.matsim.pt.router.TransitRouterConfig;
-
-import jakarta.inject.Provider;
-import jakarta.inject.Singleton;
-
-
-/**
- * Factory for the variable transit router
- *
- * @author sergioo
- */
-@Singleton
-public class TransitRouterEventsWLFactory implements Provider {
-
- private final TransitRouterConfig config;
- private final TransitRouterNetworkWW routerNetwork;
- private final Network network;
- private MatsimServices controler;
- private final WaitTime waitTime;
-
- public TransitRouterEventsWLFactory(final MatsimServices controler, final WaitTime waitTime) {
- this.config = new TransitRouterConfig(controler.getScenario().getConfig().planCalcScore(),
- controler.getScenario().getConfig().plansCalcRoute(), controler.getScenario().getConfig().transitRouter(),
- controler.getScenario().getConfig().vspExperimental());
- this.network = controler.getScenario().getNetwork();
- this.controler = controler;
- this.waitTime = waitTime;
- routerNetwork = TransitRouterNetworkWW.createFromSchedule(network, controler.getScenario().getTransitSchedule(), this.config.getBeelineWalkConnectionDistance());
- }
- @Override
- public TransitRouter get() {
- return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWW(config, network, routerNetwork, controler.getLinkTravelTimes(), waitTime, controler.getConfig().travelTimeCalculator(), controler.getConfig().qsim(), new PreparedTransitSchedule(controler.getScenario().getTransitSchedule())), routerNetwork);
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java
deleted file mode 100644
index 51a71883525..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSFactory.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter;
-
-import com.google.inject.Inject;
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.pt.router.PreparedTransitSchedule;
-import org.matsim.pt.router.TransitRouter;
-import org.matsim.pt.router.TransitRouterConfig;
-
-import jakarta.inject.Provider;
-import jakarta.inject.Singleton;
-
-/**
- * Factory for the variable transit router
- *
- * @author sergioo
- */
-@Singleton
-public class TransitRouterEventsWSFactory implements Provider {
-
- private final TransitRouterConfig config;
- private final TransitRouterNetworkWW routerNetwork;
- private final Scenario scenario;
- private WaitTime waitTime;
-
- public void setStopStopTime(StopStopTime stopStopTime) {
- this.stopStopTime = stopStopTime;
- }
-
- public void setWaitTime(WaitTime waitTime) {
- this.waitTime = waitTime;
- }
-
- private StopStopTime stopStopTime;
-
- @Inject
- public TransitRouterEventsWSFactory(final Scenario scenario, final WaitTime waitTime, final StopStopTime stopStopTime) {
- this.config = new TransitRouterConfig(scenario.getConfig().planCalcScore(),
- scenario.getConfig().plansCalcRoute(), scenario.getConfig().transitRouter(),
- scenario.getConfig().vspExperimental());
- routerNetwork = TransitRouterNetworkWW.createFromSchedule(scenario.getNetwork(), scenario.getTransitSchedule(), this.config.getBeelineWalkConnectionDistance());
- this.scenario = scenario;
- this.waitTime = waitTime;
- this.stopStopTime = stopStopTime;
- }
- @Override
- public TransitRouter get() {
- return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWS(config, routerNetwork, waitTime, stopStopTime, scenario.getConfig().travelTimeCalculator(), scenario.getConfig().qsim(), new PreparedTransitSchedule(scenario.getTransitSchedule())), routerNetwork);
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java
deleted file mode 100644
index d3c398de718..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterEventsWSVFactory.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter;
-
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy.VehicleOccupancy;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.pt.router.PreparedTransitSchedule;
-import org.matsim.pt.router.TransitRouter;
-import org.matsim.pt.router.TransitRouterConfig;
-
-import jakarta.inject.Provider;
-import jakarta.inject.Singleton;
-
-/**
- * Factory for the variable transit router
- *
- * @author sergioo
- */
-@Singleton
-public class TransitRouterEventsWSVFactory implements Provider {
-
- private final TransitRouterConfig config;
- private final TransitRouterNetworkWW routerNetwork;
- private final Scenario scenario;
- private final WaitTime waitTime;
- private final StopStopTime stopStopTime;
- private final VehicleOccupancy vehicleOccupancy;
-
- public TransitRouterEventsWSVFactory(final Scenario scenario, final WaitTime waitTime, final StopStopTime stopStopTime, final VehicleOccupancy vehicleOccupancy) {
- this.config = new TransitRouterConfig(scenario.getConfig().planCalcScore(),
- scenario.getConfig().plansCalcRoute(), scenario.getConfig().transitRouter(),
- scenario.getConfig().vspExperimental());
- routerNetwork = TransitRouterNetworkWW.createFromSchedule(scenario.getNetwork(), scenario.getTransitSchedule(), this.config.getBeelineWalkConnectionDistance());
- this.scenario = scenario;
- this.waitTime = waitTime;
- this.stopStopTime = stopStopTime;
- this.vehicleOccupancy = vehicleOccupancy;
- }
- @Override
- public TransitRouter get() {
- return new TransitRouterVariableImpl(config, new TransitRouterNetworkTravelTimeAndDisutilityWSV(config, routerNetwork, waitTime, stopStopTime, vehicleOccupancy, scenario.getConfig().travelTimeCalculator(), scenario.getConfig().qsim(), new PreparedTransitSchedule(scenario.getTransitSchedule())), routerNetwork);
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java
deleted file mode 100644
index 2c2b68c17a7..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterNetworkTravelTimeAndDisutilityWS.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * TransitRouterNetworkTravelTimeAndDisutilityVariableWW.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.core.config.groups.QSimConfigGroup;
-import org.matsim.core.config.groups.TravelTimeCalculatorConfigGroup;
-import org.matsim.core.router.util.TravelDisutility;
-import org.matsim.pt.router.CustomDataManager;
-import org.matsim.pt.router.PreparedTransitSchedule;
-import org.matsim.pt.router.TransitRouterConfig;
-import org.matsim.pt.router.TransitRouterNetworkTravelTimeAndDisutility;
-import org.matsim.vehicles.Vehicle;
-
-import com.google.inject.Provider;
-
-/**
- * TravelTime and TravelDisutility calculator to be used with the transit network used for transit routing.
- * This version considers waiting time at stops, and takes travel time between stops from a {@link StopStopTime} object.
- *
- * @author sergioo
- */
-public class TransitRouterNetworkTravelTimeAndDisutilityWS extends TransitRouterNetworkTravelTimeAndDisutility implements TravelDisutility {
-
- private Link previousLink;
- private double previousTime;
- private double cachedLinkTime;
- private final Map, double[]> linkTravelTimes = new HashMap, double[]>();
- private final Map, double[]> linkWaitingTimes = new HashMap, double[]>();
- private final int numSlots;
- private final double timeSlot;
-
- public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, Provider waitTime, Provider stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) {
- this(config, routerNetwork, waitTime.get(), stopStopTime.get(), tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule);
- }
-
- public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) {
- this(config, routerNetwork, waitTime, stopStopTime, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule);
- }
- public TransitRouterNetworkTravelTimeAndDisutilityWS(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) {
- super(config, preparedTransitSchedule);
- timeSlot = tTConfigGroup.getTraveltimeBinSize();
- numSlots = (int) ((endTime-startTime)/timeSlot);
- for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values())
- if(link.route!=null) {
- double[] times = new double[numSlots];
- for(int slot = 0; slot, double[]> linkTravelTimes = new HashMap, double[]>();
- private final Map, double[]> linkWaitingTimes = new HashMap, double[]>();
- private final Map, double[]> linkVehicleOccupancy = new HashMap, double[]>();
- private final int numSlots;
- private final double timeSlot;
-
- public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) {
- this(config, routerNetwork, waitTime, stopStopTime, vehicleOccupancy, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule);
- }
- public TransitRouterNetworkTravelTimeAndDisutilityWSV(final TransitRouterConfig config, TransitRouterNetworkWW routerNetwork, WaitTime waitTime, StopStopTime stopStopTime, VehicleOccupancy vehicleOccupancy, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) {
- super(config, preparedTransitSchedule);
- timeSlot = tTConfigGroup.getTraveltimeBinSize();
- numSlots = (int) ((endTime-startTime)/timeSlot);
- for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values())
- if(link.route!=null) {
- double[] times = new double[numSlots];
- double[] occs = new double[numSlots];
- for(int slot = 0; slotSIT_PERCENTAGE?NO_SIT_FACTOR:1
- - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m();
- else if (wrapped.toNode.route!=null)
- // it's a wait link
- return -(cachedTravelDisutility?cachedTravelTime:linkWaitingTimes.get(wrapped.getId())[time/timeSlotSIT_PERCENTAGE?NO_SIT_FACTOR:1
- - link.getLength() * this.config.getMarginalUtilityOfTravelDistancePt_utl_m();
- else if (wrapped.toNode.route!=null)
- // it's a wait link
- return - linkWaitingTimes.get(wrapped.getId())[time/timeSlot, double[]> linkTravelTimes = new HashMap, double[]>();
- private final Map, double[]> linkWaitingTimes = new HashMap, double[]>();
- private final double timeSlot;
- private final int numSlots;
- private Link previousLink;
- private double previousTime;
- private double cachedTravelTime;
-
- public TransitRouterNetworkTravelTimeAndDisutilityWW(final TransitRouterConfig config, Network network, TransitRouterNetworkWW routerNetwork, TravelTime travelTime, WaitTime waitTime, TravelTimeCalculatorConfigGroup tTConfigGroup, QSimConfigGroup qSimConfigGroup, PreparedTransitSchedule preparedTransitSchedule) {
- this(config, network, routerNetwork, travelTime, waitTime, tTConfigGroup, qSimConfigGroup.getStartTime().seconds(), qSimConfigGroup.getEndTime().seconds(), preparedTransitSchedule);
- }
- public TransitRouterNetworkTravelTimeAndDisutilityWW(final TransitRouterConfig config, Network network, TransitRouterNetworkWW routerNetwork, TravelTime travelTime, WaitTime waitTime, TravelTimeCalculatorConfigGroup tTConfigGroup, double startTime, double endTime, PreparedTransitSchedule preparedTransitSchedule) {
- super(config, preparedTransitSchedule);
- timeSlot = tTConfigGroup.getTraveltimeBinSize();
- numSlots = (int) ((endTime-startTime)/timeSlot);
- for(TransitRouterNetworkWW.TransitRouterNetworkLink link:routerNetwork.getLinks().values())
- if(link.route!=null) {
- double[] times = new double[numSlots];
- for(int slot = 0; slot linkId:link.route.getRoute().getSubRoute(link.fromNode.stop.getStopFacility().getLinkId(), link.toNode.stop.getStopFacility().getLinkId()).getLinkIds())
- linksTime += travelTime.getLinkTravelTime(network.getLinks().get(linkId), startTime+slot*timeSlot, null, null);
- times[slot] = linksTime;
- }
- linkTravelTimes.put(link.getId(), times);
- }
- else if(link.toNode.route!=null) {
- double[] times = new double[numSlots];
- for(int slot = 0; slot, TransitRouterNetworkLink> links = new LinkedHashMap<>();
- private final Map, TransitRouterNetworkNode> nodes = new LinkedHashMap<>();
- protected QuadTree qtNodes = null;
-
- private long nextNodeId = 0;
- protected long nextLinkId = 0;
-
- public static final class TransitRouterNetworkNode implements Node {
-
- public final TransitRouteStop stop;
- public final TransitRoute route;
- public final TransitLine line;
- final Id id;
- final Map, TransitRouterNetworkLink> ingoingLinks = new LinkedHashMap<>();
- final Map, TransitRouterNetworkLink> outgoingLinks = new LinkedHashMap<>();
-
- public TransitRouterNetworkNode(final Id id, final TransitRouteStop stop, final TransitRoute route, final TransitLine line) {
- this.id = id;
- this.stop = stop;
- this.route = route;
- this.line = line;
- }
-
- @Override
- public Map, ? extends Link> getInLinks() {
- return this.ingoingLinks;
- }
-
- @Override
- public Map, ? extends Link> getOutLinks() {
- return this.outgoingLinks;
- }
-
- @Override
- public boolean addInLink(final Link link) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addOutLink(final Link link) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Coord getCoord() {
- return this.stop.getStopFacility().getCoord();
- }
-
- @Override
- public Id getId() {
- return this.id;
- }
-
- public TransitRouteStop getStop() {
- return stop;
- }
-
- public TransitRoute getRoute() {
- return route;
- }
-
- public TransitLine getLine() {
- return line;
- }
-
- @Override
- public Link removeInLink(Id linkId) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public Link removeOutLink(Id outLinkId) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public void setCoord(Coord coord) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public Attributes getAttributes() {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * Looks to me like an implementation of the Link interface, with get(Transit)Route and get(Transit)Line on top.
- * To recall: TransitLine is something like M44. But it can have more than one route, e.g. going north, going south,
- * long route, short route. That is, presumably we have one such TransitRouterNetworkLink per TransitRoute. kai/manuel, feb'12
- */
- public static final class TransitRouterNetworkLink implements Link {
-
- final TransitRouterNetworkNode fromNode;
- final TransitRouterNetworkNode toNode;
- final TransitRoute route;
- final TransitLine line;
- final Id id;
- private double length;
-
- public TransitRouterNetworkLink(final Id id, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode, final TransitRoute route, final TransitLine line, Network network) {
- this.id = id;
- this.fromNode = fromNode;
- this.toNode = toNode;
- this.route = route;
- this.line = line;
- if(route==null)
- this.length = CoordUtils.calcEuclideanDistance(this.toNode.stop.getStopFacility().getCoord(), this.fromNode.stop.getStopFacility().getCoord());
- else {
- this.length = 0;
- for(Id linkId:route.getRoute().getSubRoute(fromNode.stop.getStopFacility().getLinkId(), toNode.stop.getStopFacility().getLinkId()).getLinkIds())
- this.length += network.getLinks().get(linkId).getLength();
- this.length += network.getLinks().get(toNode.stop.getStopFacility().getLinkId()).getLength();
- }
- }
-
- @Override
- public TransitRouterNetworkNode getFromNode() {
- return this.fromNode;
- }
-
- @Override
- public TransitRouterNetworkNode getToNode() {
- return this.toNode;
- }
-
- @Override
- public double getCapacity() {
- return 9999;
- }
-
- @Override
- public double getCapacity(final double time) {
- return getCapacity();
- }
-
- @Override
- public double getFreespeed() {
- return 10;
- }
-
- @Override
- public double getFreespeed(final double time) {
- return getFreespeed();
- }
-
- @Override
- public Id getId() {
- return this.id;
- }
-
- @Override
- public double getNumberOfLanes() {
- return 1;
- }
-
- @Override
- public double getNumberOfLanes(final double time) {
- return getNumberOfLanes();
- }
-
- @Override
- public double getLength() {
- return this.length;
- }
-
- @Override
- public void setCapacity(final double capacity) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setFreespeed(final double freespeed) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean setFromNode(final Node node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setNumberOfLanes(final double lanes) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setLength(final double length) {
- this.length = length;
- }
-
- @Override
- public boolean setToNode(final Node node) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Coord getCoord() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set getAllowedModes() {
- return null;
- }
-
- @Override
- public void setAllowedModes(final Set modes) {
- throw new UnsupportedOperationException();
- }
-
- public TransitRoute getRoute() {
- return route;
- }
-
- public TransitLine getLine() {
- return line;
- }
-
- @Override
- public double getCapacityPeriod() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Attributes getAttributes() {
- throw new UnsupportedOperationException();
- }
- }
- public TransitRouterNetworkNode createNode(final TransitRouteStop stop, final TransitRoute route, final TransitLine line) {
- Id id = null;
- if(line==null && route==null)
- id = Id.createNodeId(stop.getStopFacility().getId().toString());
- else
- id = Id.createNodeId("number:"+nextNodeId++);
- final TransitRouterNetworkNode node = new TransitRouterNetworkNode(id, stop, route, line);
- if(this.nodes.get(node.getId())!=null)
- throw new RuntimeException();
- this.nodes.put(node.getId(), node);
- return node;
- }
-
- public TransitRouterNetworkLink createLink(final Network network, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode) {
- final TransitRouterNetworkLink link = new TransitRouterNetworkLink(Id.createLinkId(this.nextLinkId++), fromNode, toNode, null, null, network);
- this.links.put(link.getId(), link);
- fromNode.outgoingLinks.put(link.getId(), link);
- toNode.ingoingLinks.put(link.getId(), link);
- return link;
- }
- public TransitRouterNetworkLink createLink(final Network network, final TransitRouterNetworkNode fromNode, final TransitRouterNetworkNode toNode, final TransitRoute route, final TransitLine line) {
- final TransitRouterNetworkLink link = new TransitRouterNetworkLink(Id.createLinkId(this.nextLinkId++), fromNode, toNode, route, line, network);
- this.getLinks().put(link.getId(), link);
- fromNode.outgoingLinks.put(link.getId(), link);
- toNode.ingoingLinks.put(link.getId(), link);
- return link;
- }
- @Override
- public Map, TransitRouterNetworkNode> getNodes() {
- return this.nodes;
- }
- @Override
- public Map, TransitRouterNetworkLink> getLinks() {
- return this.links;
- }
- public void finishInit() {
- double minX = Double.POSITIVE_INFINITY;
- double minY = Double.POSITIVE_INFINITY;
- double maxX = Double.NEGATIVE_INFINITY;
- double maxY = Double.NEGATIVE_INFINITY;
- for (TransitRouterNetworkNode node : getNodes().values())
- if(node.line == null) {
- Coord c = node.stop.getStopFacility().getCoord();
- if (c.getX() < minX)
- minX = c.getX();
- if (c.getY() < minY)
- minY = c.getY();
- if (c.getX() > maxX)
- maxX = c.getX();
- if (c.getY() > maxY)
- maxY = c.getY();
- }
- QuadTree quadTree = new QuadTree(minX, minY, maxX, maxY);
- for (TransitRouterNetworkNode node : getNodes().values()) {
- if(node.line == null) {
- Coord c = node.stop.getStopFacility().getCoord();
- quadTree.put(c.getX(), c.getY(), node);
- }
- }
- this.qtNodes = quadTree;
- }
- public static TransitRouterNetworkWW createFromSchedule(final Network network, final TransitSchedule schedule, final double maxBeelineWalkConnectionDistance) {
- log.info("start creating transit network");
- final TransitRouterNetworkWW transitNetwork = new TransitRouterNetworkWW();
- final Counter linkCounter = new Counter(" link #");
- final Counter nodeCounter = new Counter(" node #");
- int numTravelLinks = 0, numWaitingLinks = 0, numInsideLinks = 0, numTransferLinks = 0;
- Map, TransitRouterNetworkNode> stops = new HashMap, TransitRouterNetworkNode>();
- TransitRouterNetworkNode nodeSR, nodeS;
- // build stop nodes
- for (TransitLine line : schedule.getTransitLines().values())
- for (TransitRoute route : line.getRoutes().values())
- for (TransitRouteStop stop : route.getStops()) {
- nodeS = stops.get(stop.getStopFacility().getId());
- if(nodeS == null) {
- nodeS = transitNetwork.createNode(stop, null, null);
- nodeCounter.incCounter();
- stops.put(stop.getStopFacility().getId(), nodeS);
- }
- }
- transitNetwork.finishInit();
- // build transfer links
- log.info("add transfer links");
- // connect all stops with walking links if they're located less than beelineWalkConnectionDistance from each other
- for (TransitRouterNetworkNode node : transitNetwork.getNodes().values())
- for (TransitRouterNetworkNode node2 : transitNetwork.getNearestNodes(node.stop.getStopFacility().getCoord(), maxBeelineWalkConnectionDistance))
- if (node!=node2) {
- transitNetwork.createLink(network, node, node2);
- linkCounter.incCounter();
- numTransferLinks++;
- }
- // build nodes and links connecting the nodes according to the transit routes
- log.info("add travel, waiting and inside links");
- for (TransitLine line : schedule.getTransitLines().values())
- for (TransitRoute route : line.getRoutes().values()) {
- TransitRouterNetworkNode prevNode = null;
- for (TransitRouteStop stop : route.getStops()) {
- nodeS = stops.get(stop.getStopFacility().getId());
- nodeSR = transitNetwork.createNode(stop, route, line);
- nodeCounter.incCounter();
- if (prevNode != null) {
- transitNetwork.createLink(network, prevNode, nodeSR, route, line);
- linkCounter.incCounter();
- numTravelLinks++;
- }
- prevNode = nodeSR;
- transitNetwork.createLink(network, nodeS, nodeSR);
- linkCounter.incCounter();
- numWaitingLinks++;
- transitNetwork.createLink(network, nodeSR, nodeS);
- linkCounter.incCounter();
- numInsideLinks++;
- }
- }
- log.info("transit router network statistics:");
- log.info(" # nodes: " + transitNetwork.getNodes().size());
- log.info(" # links total: " + transitNetwork.getLinks().size());
- log.info(" # travel links: " + numTravelLinks);
- log.info(" # waiting links: " + numWaitingLinks);
- log.info(" # inside links: " + numInsideLinks);
- log.info(" # transfer links: " + numTransferLinks);
- return transitNetwork;
- }
- public Collection getNearestNodes(final Coord coord, final double distance) {
- return this.qtNodes.getDisk(coord.getX(), coord.getY(), distance);
- }
-
- public TransitRouterNetworkNode getNearestNode(final Coord coord) {
- return this.qtNodes.getClosest(coord.getX(), coord.getY());
- }
-
- @Override
- public double getCapacityPeriod() {
- return 3600.0;
- }
-
- @Override
- public NetworkFactory getFactory() {
- return null;
- }
-
- @Override
- public double getEffectiveLaneWidth() {
- return 3;
- }
-
- @Override
- public void addNode(Node nn) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void addLink(Link ll) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Link removeLink(Id linkId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Node removeNode(Id nodeId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setCapacityPeriod(double capPeriod) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public void setEffectiveCellSize(double effectiveCellSize) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public void setEffectiveLaneWidth(double effectiveLaneWidth) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public void setName(String name) {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public String getName() {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public double getEffectiveCellSize() {
- throw new RuntimeException("not implemented") ;
- }
-
- @Override
- public Attributes getAttributes() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java
deleted file mode 100644
index 3c867f3240b..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/TransitRouterVariableImpl.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * TranitRouterVariableImpl.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.contrib.eventsBasedPTRouter;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.matsim.api.core.v01.Coord;
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.TransportMode;
-import org.matsim.api.core.v01.network.Link;
-import org.matsim.api.core.v01.network.Node;
-import org.matsim.api.core.v01.population.Leg;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.api.core.v01.population.Route;
-import org.matsim.core.population.PopulationUtils;
-import org.matsim.core.population.routes.RouteUtils;
-import org.matsim.core.router.InitialNode;
-import org.matsim.core.router.RoutingRequest;
-import org.matsim.core.router.TripStructureUtils;
-import org.matsim.core.router.util.LeastCostPathCalculator.Path;
-import org.matsim.core.router.util.PreProcessDijkstra;
-import org.matsim.core.utils.geometry.CoordUtils;
-import org.matsim.facilities.Facility;
-import org.matsim.pt.router.TransitRouter;
-import org.matsim.pt.router.TransitRouterConfig;
-import org.matsim.pt.router.TransitRouterNetworkTravelTimeAndDisutility;
-import org.matsim.pt.routes.DefaultTransitPassengerRoute;
-import org.matsim.pt.routes.TransitPassengerRoute;
-import org.matsim.pt.transitSchedule.api.TransitRouteStop;
-
-public class TransitRouterVariableImpl implements TransitRouter {
-
- private final TransitRouterNetworkWW transitNetwork;
-
- private final MultiNodeDijkstra dijkstra;
- private final MultiDestinationDijkstra mDijkstra;
- private final TransitRouterConfig config;
- private final TransitRouterNetworkTravelTimeAndDisutility ttCalculator;
-
- public TransitRouterVariableImpl(final TransitRouterConfig config, final TransitRouterNetworkTravelTimeAndDisutility ttCalculator, final TransitRouterNetworkWW routerNetwork) {
- this.config = config;
- this.transitNetwork = routerNetwork;
- this.ttCalculator = ttCalculator;
- this.dijkstra = new MultiNodeDijkstra(this.transitNetwork, this.ttCalculator, this.ttCalculator);
- PreProcessDijkstra preProcessDijkstra = new PreProcessDijkstra();
- preProcessDijkstra.run(routerNetwork);
- mDijkstra = new MultiDestinationDijkstra(routerNetwork, this.ttCalculator, this.ttCalculator, preProcessDijkstra);
- }
-
- private Map locateWrappedNearestTransitNodes(Person person, Coord coord, double departureTime){
- Collection nearestNodes = this.transitNetwork.getNearestNodes(coord, this.config.getSearchRadius());
- if (nearestNodes.size() < 2) {
- // also enlarge search area if only one stop found, maybe a second one is near the border of the search area
- TransitRouterNetworkWW.TransitRouterNetworkNode nearestNode = this.transitNetwork.getNearestNode(coord);
- double distance = CoordUtils.calcEuclideanDistance(coord, nearestNode.stop.getStopFacility().getCoord());
- nearestNodes = this.transitNetwork.getNearestNodes(coord, distance + this.config.getExtensionRadius());
- }
- Map wrappedNearestNodes = new LinkedHashMap();
- for (TransitRouterNetworkWW.TransitRouterNetworkNode node : nearestNodes) {
- Coord toCoord = node.stop.getStopFacility().getCoord();
- double initialTime = getWalkTime(person, coord, toCoord);
- double initialCost = getWalkDisutility(person, coord, toCoord);
- wrappedNearestNodes.put(node, new InitialNode(initialCost, initialTime + departureTime));
- }
- return wrappedNearestNodes;
- }
-
- private double getWalkTime(Person person, Coord coord, Coord toCoord) {
- return this.ttCalculator.getWalkTravelTime(person, coord, toCoord);
- }
-
- private double getWalkDisutility(Person person, Coord coord, Coord toCoord) {
- return this.ttCalculator.getWalkTravelDisutility(person, coord, toCoord);
- }
-
- public Map, Path> calcPathRoutes(final Id fromNodeId, final Set> toNodeIds, final double startTime, final Person person) {
- Set toNodes = new HashSet<>();
- for(Id toNode:toNodeIds)
- if(transitNetwork.getNodes().get(toNode)!=null)
- toNodes.add(transitNetwork.getNodes().get(toNode));
- Node node = transitNetwork.getNodes().get(fromNodeId);
- if(node!=null)
- return mDijkstra.calcLeastCostPath(node, toNodes, startTime, person);
- else
- return new HashMap<>();
- }
- @Override
- public List calcRoute(RoutingRequest request) {
- final Facility fromFacility = request.getFromFacility();
- final Facility toFacility = request.getToFacility();
- final double departureTime = request.getDepartureTime();
- final Person person = request.getPerson();
-
- // find possible start stops
- Map wrappedFromNodes = this.locateWrappedNearestTransitNodes(person, fromFacility.getCoord(), departureTime);
- // find possible end stops
- Map wrappedToNodes = this.locateWrappedNearestTransitNodes(person, toFacility.getCoord(), departureTime);
-
- // find routes between start and end stops
- Path p = this.dijkstra.calcLeastCostPath(wrappedFromNodes, wrappedToNodes, person);
- if (p == null) {
- return null;
- }
-
- double directWalkCost = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), toFacility.getCoord()) / this.config.getBeelineWalkSpeed() * ( 0 - this.config.getMarginalUtilityOfTravelTimeWalk_utl_s());
- double pathCost = p.travelCost + wrappedFromNodes.get(p.getFromNode()).initialCost + wrappedToNodes.get(
- p.getToNode()).initialCost;
- if (directWalkCost < pathCost) {
- List legs = new ArrayList();
- Leg leg = PopulationUtils.createLeg(TransportMode.walk); // formerly transit_walk
- TripStructureUtils.setRoutingMode(leg, TransportMode.pt);
- double walkDistance = CoordUtils.calcEuclideanDistance(fromFacility.getCoord(), toFacility.getCoord());
- Route walkRoute = RouteUtils.createGenericRouteImpl(null, null);
- walkRoute.setDistance(walkDistance);
- leg.setRoute(walkRoute);
- leg.setTravelTime(walkDistance/this.config.getBeelineWalkSpeed());
- legs.add(leg);
- return legs;
- }
-
- return convertPathToLegList( departureTime, p, fromFacility.getCoord(), toFacility.getCoord(), person ) ;
- }
-
- public Path calcPathRoute(final Coord fromCoord, final Coord toCoord, final double departureTime, final Person person) {
- // find possible start stops
- // find possible start stops
- Map wrappedFromNodes = this.locateWrappedNearestTransitNodes(person, fromCoord, departureTime);
- // find possible end stops
- Map wrappedToNodes = this.locateWrappedNearestTransitNodes(person, toCoord, departureTime);
- // find routes between start and end stops
- Path path = this.dijkstra.calcLeastCostPath(wrappedFromNodes, wrappedToNodes, person);
- if (path == null) {
- return null;
- }
- double directWalkTime = CoordUtils.calcEuclideanDistance(fromCoord, toCoord) / this.config.getBeelineWalkSpeed();
- double directWalkCost = directWalkTime * ( 0 - this.config.getMarginalUtilityOfTravelTimeWalk_utl_s());
- double pathCost = path.travelCost + wrappedFromNodes.get(path.getFromNode()).initialCost + wrappedToNodes.get(
- path.getToNode()).initialCost;
- if (directWalkCost < pathCost) {
- return new Path(new ArrayList(), new ArrayList (), directWalkTime, directWalkCost);
- }
- double pathTime = path.travelTime + wrappedFromNodes.get(path.getFromNode()).initialTime + wrappedToNodes.get(
- path.getToNode()).initialTime - 2 * departureTime;
- return new Path(path.nodes, path.links, pathTime, pathCost);
- }
-
- protected List convertPathToLegList( double departureTime, Path p, Coord fromCoord, Coord toCoord, Person person) {
- List legs = new ArrayList();
- Leg leg;
- double walkDistance, walkWaitTime, travelTime = 0;
- Route walkRoute;
- Coord coord = fromCoord;
- TransitRouteStop stop = null;
- double time = departureTime;
- for (Link link : p.links) {
- TransitRouterNetworkWW.TransitRouterNetworkLink l = (TransitRouterNetworkWW.TransitRouterNetworkLink) link;
- if(l.route!=null) {
- //in line link
- double ttime = ttCalculator.getLinkTravelTime(l, time, person, null);
- travelTime += ttime;
- time += ttime;
- }
- else if(l.fromNode.route!=null) {
- //inside link
- leg = PopulationUtils.createLeg(TransportMode.pt);
- TransitPassengerRoute ptRoute = new DefaultTransitPassengerRoute(stop.getStopFacility(), l.fromNode.line, l.fromNode.route, l.fromNode.stop.getStopFacility());
- leg.setRoute(ptRoute);
- leg.setTravelTime(travelTime);
- legs.add(leg);
- travelTime = 0;
- stop = l.fromNode.stop;
- coord = l.fromNode.stop.getStopFacility().getCoord();
- }
- else if(l.toNode.route!=null) {
- //wait link
- leg = PopulationUtils.createLeg(TransportMode.walk);
- TripStructureUtils.setRoutingMode(leg, TransportMode.pt);
- walkDistance = CoordUtils.calcEuclideanDistance(coord, l.toNode.stop.getStopFacility().getCoord());
- walkWaitTime = walkDistance/this.config.getBeelineWalkSpeed()/*+ttCalculator.getLinkTravelTime(l, time+walkDistance/this.config.getBeelineWalkSpeed(), person, null)*/;
- walkRoute = RouteUtils.createGenericRouteImpl(stop==null?null:stop.getStopFacility().getLinkId(), l.toNode.stop.getStopFacility().getLinkId());
- walkRoute.setDistance(walkDistance);
- leg.setRoute(walkRoute);
- leg.setTravelTime(walkWaitTime);
- legs.add(leg);
- stop = l.toNode.stop;
- time += walkWaitTime;
- }
-
- }
- leg = PopulationUtils.createLeg(TransportMode.walk);
- TripStructureUtils.setRoutingMode(leg, TransportMode.pt);
- walkDistance = CoordUtils.calcEuclideanDistance(coord, toCoord);
- walkWaitTime = walkDistance/this.config.getBeelineWalkSpeed();
- walkRoute = RouteUtils.createGenericRouteImpl(stop==null?null:stop.getStopFacility().getLinkId(), null);
- walkRoute.setDistance(walkDistance);
- leg.setRoute(walkRoute);
- leg.setTravelTime(walkWaitTime);
- legs.add(leg);
- return legs;
- }
-
- public TransitRouterNetworkWW getTransitRouterNetwork() {
- return this.transitNetwork;
- }
-
- protected TransitRouterNetworkWW getTransitNetwork() {
- return transitNetwork;
- }
-
- protected MultiNodeDijkstra getDijkstra() {
- return dijkstra;
- }
-
- protected TransitRouterConfig getConfig() {
- return config;
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java
deleted file mode 100644
index 56ea9525a6b..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWS.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * ControlerWW.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.controler;
-
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.controler.AbstractModule;
-import org.matsim.core.controler.Controler;
-import org.matsim.core.controler.OutputDirectoryHierarchy;
-import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.pt.router.TransitRouter;
-
-
-/**
- * A run Controler for a transit router that depends on the travel times and wait times
- *
- * @author sergioo
- */
-
-public class RunControlerWS {
-
- public static void main(String[] args) {
- Config config = ConfigUtils.createConfig();
- ConfigUtils.loadConfig(config, args[0]);
- final Controler controler = new Controler(ScenarioUtils.loadScenario(config));
- controler.getConfig().controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles);
- final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(),
- controler.getScenario().getTransitSchedule(), controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds()));
- controler.getEvents().addHandler(waitTimeCalculator);
- final StopStopTimeCalculatorImpl stopStopTimeCalculator = new StopStopTimeCalculatorImpl(controler.getScenario().getTransitSchedule(),
- controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds()));
- controler.getEvents().addHandler(stopStopTimeCalculator);
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(), waitTimeCalculator.get(),
- stopStopTimeCalculator.get()));
- }
- });
- controler.run();
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java
deleted file mode 100644
index a40e1bdf88f..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWSV.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * ControlerWW.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.controler;
-
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSVFactory;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl;
-import org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy.VehicleOccupancyCalculator;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.controler.AbstractModule;
-import org.matsim.core.controler.Controler;
-import org.matsim.core.scenario.MutableScenario;
-import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.pt.router.TransitRouter;
-
-
-/**
- * A run Controler for a transit router that depends on the travel times and wait times
- *
- * @author sergioo
- */
-
-public class RunControlerWSV {
-
- public static void main(String[] args) {
- Config config = ConfigUtils.createConfig();
- ConfigUtils.loadConfig(config, args[0]);
- final Controler controler = new Controler(ScenarioUtils.loadScenario(config));
- final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(),
- controler.getScenario().getTransitSchedule(), controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds()));
- controler.getEvents().addHandler(waitTimeCalculator);
- final StopStopTimeCalculatorImpl stopStopTimeCalculator = new StopStopTimeCalculatorImpl(controler.getScenario().getTransitSchedule(),
- controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds()));
- controler.getEvents().addHandler(stopStopTimeCalculator);
- final VehicleOccupancyCalculator vehicleOccupancyCalculator = new VehicleOccupancyCalculator(controler.getScenario().getTransitSchedule(),
- ((MutableScenario)controler.getScenario()).getTransitVehicles(),
- controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds()-controler.getConfig().qsim().getStartTime().seconds()));
- controler.getEvents().addHandler(vehicleOccupancyCalculator);
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- bind(TransitRouter.class).toProvider(new TransitRouterEventsWSVFactory(controler.getScenario(), waitTimeCalculator.get(),
- stopStopTimeCalculator.get(), vehicleOccupancyCalculator.getVehicleOccupancy()));
- }
- });
-
- // yyyyyy note that in the above script only the router is modified, but not the scoring. With standard matsim, a slower bu
- // less crowded pt route will only be accepted by the agent when the faster but more crowded option was never presented
- // to the agent. (Alternatively, e.g. with the Singapore scenario, there may be boarding denials, in which case
- // routes that avoid crowded sections may also be beneficial.) kai, jul'15
-
- controler.run();
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java
deleted file mode 100644
index 27c713ed684..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/controler/RunControlerWW.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * ControlerWW.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.controler;
-
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWLFactory;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.controler.AbstractModule;
-import org.matsim.core.controler.Controler;
-import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
-import org.matsim.pt.router.TransitRouter;
-
-
-/**
- * A run Controler for a transit router that depends on the travel times and wait times
- *
- * @author sergioo
- */
-
-public class RunControlerWW {
-
- public static void main(String[] args) {
- Config config = ConfigUtils.createConfig();
- ConfigUtils.loadConfig(config, args[0]);
- final Controler controler = new Controler(ScenarioUtils.loadScenario(config));
- final WaitTimeStuckCalculator waitTimeCalculator = new WaitTimeStuckCalculator(controler.getScenario().getPopulation(), controler.getScenario().getTransitSchedule(), controler.getConfig(), controler.getEvents());
- controler.getEvents().addHandler(waitTimeCalculator);
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- bind(TransitRouter.class).toProvider(new TransitRouterEventsWLFactory(controler, waitTimeCalculator.get()));
- }
- });
- controler.run();
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java
deleted file mode 100644
index 0b5fa9056f5..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTime.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-import java.io.Serializable;
-
-public interface StopStopTime extends Serializable {
-
- //Methods
- public double getStopStopTime(Id stopOId, Id stopDId, double time);
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time);
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java
deleted file mode 100644
index a27652742bd..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import com.google.inject.Provider;
-import com.google.inject.Provides;
-import org.matsim.api.core.v01.Id;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-
-
-public interface StopStopTimeCalculator extends Provider {
-
- //Methods
- double getStopStopTime(Id stopOId, Id stopDId, double time);
-
- double getStopStopTimeVariance(Id stopOId, Id stopDId, double time);
-
- @Override
- @Provides
- StopStopTime get();
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java
deleted file mode 100644
index c2ffef28c35..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorImpl.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.core.api.experimental.events.EventsManager;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.vehicles.Vehicle;
-
-import com.google.inject.Inject;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-@Singleton
-public class StopStopTimeCalculatorImpl implements VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler, StopStopTimeCalculator {
-
- private final Map, Map, StopStopTimeData>> stopStopTimes = new HashMap, Map, StopStopTimeData>>(5000);
- private final Map, Map, Double>> scheduledStopStopTimes = new HashMap, Map, Double>>(5000);
- private final Map, Tuple, Double>> inTransitVehicles = new HashMap, Tuple, Double>>(1000);
- private final Set> vehicleIds = new HashSet>();
- private final double timeSlot;
- private final int totalTime;
- private boolean useVehicleIds = true;
-
- //Constructors
- @Inject
- public StopStopTimeCalculatorImpl(final TransitSchedule transitSchedule, final Config config, EventsManager eventsManager) {
- this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- eventsManager.addHandler(this);
- }
- public StopStopTimeCalculatorImpl(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- Map, Map, Integer>> numObservations = new HashMap, Map, Integer>>();
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- for(int s=0; s, StopStopTimeData> map = stopStopTimes.computeIfAbsent(
- route.getStops().get(s).getStopFacility().getId(),
- k -> new HashMap<>(2));
- map.put(route.getStops().get(s+1).getStopFacility().getId(), new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot)));
- Map, Double> map2 = scheduledStopStopTimes.get(route.getStops().get(s).getStopFacility().getId());
- Map, Integer> map3 = numObservations.get(route.getStops().get(s).getStopFacility().getId());
- Double stopStopTime;
- Integer num;
- if(map2==null) {
- map2 = new HashMap, Double>(2);
- scheduledStopStopTimes.put(route.getStops().get(s).getStopFacility().getId(), map2);
- map3 = new HashMap, Integer>(2);
- numObservations.put(route.getStops().get(s).getStopFacility().getId(), map3);
- stopStopTime = 0.0;
- num = 0;
- }
- else {
- stopStopTime = map2.get(route.getStops().get(s+1).getStopFacility().getId());
- num = map3.get(route.getStops().get(s+1).getStopFacility().getId());
- if(stopStopTime==null) {
- stopStopTime = 0.0;
- num = 0;
- }
- }
- map2.put(route.getStops().get(s+1).getStopFacility().getId(),
- stopStopTime+route.getStops().get(s+1).getArrivalOffset().seconds()-route.getStops().get(s).getDepartureOffset().seconds());
- map3.put(route.getStops().get(s+1).getStopFacility().getId(), ++num);
- }
- for(Departure departure:route.getDepartures().values())
- vehicleIds.add(departure.getVehicleId());
- }
- for(Entry, Map, Double>> entry:scheduledStopStopTimes.entrySet())
- for(Entry, Double> entry2:entry.getValue().entrySet())
- entry.getValue().put(entry2.getKey(), entry2.getValue()/numObservations.get(entry.getKey()).get(entry2.getKey()));
- }
-
- //Methods
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId).get(stopDId);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0)
- return scheduledStopStopTimes.get(stopOId).get(stopDId);
- else
- return stopStopTimeData.getStopStopTime(timeBinIndex);
- }
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId).get(stopDId);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0)
- return 0;
- else
- return stopStopTimeData.getStopStopTimeVariance(timeBinIndex);
- }
- @Override
- public void reset(int iteration) {
- for(Map, StopStopTimeData> map:stopStopTimes.values())
- for(StopStopTimeData stopStopTimeData:map.values())
- stopStopTimeData.resetStopStopTimes();
- inTransitVehicles.clear();
- }
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if(!useVehicleIds || vehicleIds.contains(event.getVehicleId())) {
- Tuple, Double> route = inTransitVehicles.remove(event.getVehicleId());
- if(route!=null)
- stopStopTimes.get(route.getFirst()).get(event.getFacilityId()).addStopStopTime(
- TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)),
- event.getTime()-route.getSecond());
- inTransitVehicles.put(event.getVehicleId(), new Tuple, Double>(event.getFacilityId(), event.getTime()));
- }
- }
- @Override
- public void handleEvent(PersonLeavesVehicleEvent event) {
- if((!useVehicleIds || vehicleIds.contains(event.getVehicleId())) && event.getPersonId().toString().startsWith("pt_")
- && event.getPersonId().toString().contains(event.getVehicleId().toString()))
- inTransitVehicles.remove(event.getVehicleId());
- }
- public void setUseVehicleIds(boolean useVehicleIds) {
- this.useVehicleIds = useVehicleIds;
- }
-
- @Override
- @Provides
- public StopStopTime get() {
- return new StopStopTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorImpl.this.getStopStopTime(stopOId, stopDId, time);
- }
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorImpl.this.getStopStopTimeVariance(stopOId, stopDId, time);
- }
- };
- }
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java
deleted file mode 100644
index d03b9ed5f2b..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorSerializable.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-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.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-import com.google.inject.Provider;
-import com.google.inject.Provides;
-
-public class StopStopTimeCalculatorSerializable implements StopStopTimeCalculator, VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler, Serializable, Provider {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final Map> stopStopTimes = new HashMap>(5000);
- private final Map> scheduledStopStopTimes = new HashMap>(5000);
- private final Map> inTransitVehicles = new HashMap>(1000);
- private final Set vehicleIds = new HashSet();
- private final double timeSlot;
- private final int totalTime;
- private boolean useVehicleIds = true;
- private static int scheduleCalls = 0;
- private static int totalCalls = 0;
- private static double stopTimesInflation = 0;
-
- //Constructors
- public StopStopTimeCalculatorSerializable(final TransitSchedule transitSchedule, final Config config) {
- this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- }
- public static void printCallStatisticsAndReset(){
- Logger logger = LogManager.getLogger(StopStopTimeCalculatorSerializable.class);
- logger.warn("stop times read from schedule vs total (S:T) = " + scheduleCalls + " : " + totalCalls);
- logger.warn("inflation of recorded times called vs their scheduled time:" +stopTimesInflation/(double)(totalCalls -scheduleCalls));
- scheduleCalls = 0;
- totalCalls = 0;
- stopTimesInflation=0;
- }
- public StopStopTimeCalculatorSerializable(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- Map> numObservations = new HashMap>();
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- for(int s=0; s map = stopStopTimes.get(route.getStops().get(s).getStopFacility().getId().toString());
- if(map==null) {
- map = new HashMap(2);
- stopStopTimes.put(route.getStops().get(s).getStopFacility().getId().toString(), map);
- }
- map.put(route.getStops().get(s+1).getStopFacility().getId().toString(),
- new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot)));
- Map map2 = scheduledStopStopTimes.get(route.getStops().get(s).getStopFacility().getId().toString());
- Map map3 = numObservations.get(route.getStops().get(s).getStopFacility().getId().toString());
- Double stopStopTime;
- Integer num;
- if(map2==null) {
- map2 = new HashMap(2);
- scheduledStopStopTimes.put(route.getStops().get(s).getStopFacility().getId().toString(), map2);
- map3 = new HashMap(2);
- numObservations.put(route.getStops().get(s).getStopFacility().getId().toString(), map3);
- stopStopTime = 0.0;
- num = 0;
- }
- else {
- stopStopTime = map2.get(route.getStops().get(s+1).getStopFacility().getId().toString());
- num = map3.get(route.getStops().get(s+1).getStopFacility().getId().toString());
- if(stopStopTime==null) {
- stopStopTime = 0.0;
- num = 0;
- }
- }
- map2.put(route.getStops().get(s+1).getStopFacility().getId().toString(),
- stopStopTime+route.getStops().get(s+1).getArrivalOffset().seconds()
- - route.getStops().get(s).getDepartureOffset().seconds());
- map3.put(route.getStops().get(s+1).getStopFacility().getId().toString(), ++num);
- }
- for(Departure departure:route.getDepartures().values())
- vehicleIds.add(departure.getVehicleId().toString());
- }
- for(Entry> entry:scheduledStopStopTimes.entrySet())
- for(Entry entry2:entry.getValue().entrySet())
- entry.getValue().put(entry2.getKey(), entry2.getValue()/numObservations.get(entry.getKey()).get(entry2.getKey()));
- }
-
- //Methods
- public StopStopTime getStopStopTimes() {
- return new StopStopTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorSerializable.this.getStopStopTime(stopOId, stopDId, time);
- }
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorSerializable.this.getStopStopTimeVariance(stopOId, stopDId, time);
- }
- };
- }
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId.toString()).get(stopDId.toString());
- totalCalls++;
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0) {
- scheduleCalls++;
- return scheduledStopStopTimes.get(stopOId.toString()).get(stopDId.toString());
- }
- else {
- stopTimesInflation += stopStopTimeData.getStopStopTime(timeBinIndex)/scheduledStopStopTimes.get(stopOId.toString()).get(stopDId.toString());
- return stopStopTimeData.getStopStopTime(timeBinIndex);
- }
- }
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- StopStopTimeData stopStopTimeData = stopStopTimes.get(stopOId.toString()).get(stopDId.toString());
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0)
- return 0;
- else
- return stopStopTimeData.getStopStopTimeVariance(timeBinIndex);
- }
-
- @Provides
- public StopStopTime get() {
- return new StopStopTime() {
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorSerializable.this.getStopStopTime(stopOId,stopDId,time);
- }
-
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorSerializable.this.getStopStopTimeVariance(stopOId,stopDId,time);
- }
- };
- }
-
- @Override
- public void reset(int iteration) {
- for(Map map:stopStopTimes.values())
- for(StopStopTimeData stopStopTimeData:map.values())
- stopStopTimeData.resetStopStopTimes();
- inTransitVehicles.clear();
- }
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if(!useVehicleIds || vehicleIds.contains(event.getVehicleId().toString())) {
- Tuple route = inTransitVehicles.remove(event.getVehicleId().toString());
- if(route!=null)
- try {
- stopStopTimes.get(route.getFirst()).get(event.getFacilityId().toString()).addStopStopTime(
- TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)),
- event.getTime()-route.getSecond());
- } catch(Exception e) {
- //System.out.println("No: "+route.getFirst()+"-->"+event.getFacilityId());
- }
- inTransitVehicles.put(event.getVehicleId().toString(), new Tuple(event.getFacilityId().toString(), event.getTime()));
- }
- }
- @Override
- public void handleEvent(PersonLeavesVehicleEvent event) {
- if((!useVehicleIds || vehicleIds.contains(event.getVehicleId().toString())) && event.getPersonId().toString().startsWith("pt_")
- && event.getPersonId().toString().contains(event.getVehicleId().toString()))
- inTransitVehicles.remove(event.getVehicleId().toString());
- }
- public void setUseVehicleIds(boolean useVehicleIds) {
- this.useVehicleIds = useVehicleIds;
- }
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java
deleted file mode 100644
index 1d6a522694e..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeCalculatorTuple.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.Scenario;
-import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.config.ConfigUtils;
-import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.core.utils.misc.Time;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitScheduleReader;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.vehicles.Vehicle;
-
-public class StopStopTimeCalculatorTuple implements VehicleArrivesAtFacilityEventHandler, PersonLeavesVehicleEventHandler {
-
- private final Map, Id>, StopStopTimeData> stopStopTimes = new HashMap, Id>, StopStopTimeData>();
- private final Map, Id>, Double> scheduledStopStopTimes = new HashMap, Id>, Double>();
- private final Map, Tuple, Double>> inTransitVehicles = new HashMap, Tuple, Double>>(1000);
- private final Set> vehicleIds = new HashSet>();
- private final double timeSlot;
- private final int totalTime;
-
- //Constructors
- public StopStopTimeCalculatorTuple(final TransitSchedule transitSchedule, final Config config) {
- this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- }
- public StopStopTimeCalculatorTuple(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- Map, Id>, Integer> numObservations = new HashMap, Id>, Integer>();
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- for(int s=0; s, Id> key = new Tuple, Id>(route.getStops().get(s).getStopFacility().getId(),
- route.getStops().get(s+1).getStopFacility().getId());
- StopStopTimeData data = stopStopTimes.get(key);
- if(data==null)
- stopStopTimes.put(key, new StopStopTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot)));
- Double sTime = scheduledStopStopTimes.get(key);
- Integer num = numObservations.get(key);
- if(sTime==null) {
- sTime = 0.0;
- scheduledStopStopTimes.put(key, sTime);
- num = 0;
- numObservations.put(key, num);
- }
- scheduledStopStopTimes.put(key, (num*sTime+route.getStops().get(s+1).getArrivalOffset().seconds()
- - route.getStops().get(s).getDepartureOffset().seconds())/++num);
- numObservations.put(key, num);
- }
- for(Departure departure:route.getDepartures().values())
- vehicleIds.add(departure.getVehicleId());
- }
- System.out.println(stopStopTimes.size());
- }
- public static void main(String[] args) {
- Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
- scenario.getConfig().transit().setUseTransit(true);
- new TransitScheduleReader(scenario).readFile(args[0]);
- new StopStopTimeCalculatorTuple(scenario.getTransitSchedule(), 900, 30*3600);
- }
- //Methods
- public StopStopTime getStopStopTimes() {
- return new StopStopTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorTuple.this.getStopStopTime(stopOId, stopDId, time);
- }
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- return StopStopTimeCalculatorTuple.this.getStopStopTimeVariance(stopOId, stopDId, time);
- }
- };
- }
- private double getStopStopTime(Id stopOId, Id stopDId, double time) {
- Tuple, Id> key = new Tuple, Id>(stopOId, stopDId);
- StopStopTimeData stopStopTimeData = stopStopTimes.get(key);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0)
- return scheduledStopStopTimes.get(key);
- else
- return stopStopTimeData.getStopStopTime(timeBinIndex);
- }
- private double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- Tuple, Id> key = new Tuple, Id>(stopOId, stopDId);
- StopStopTimeData stopStopTimeData = stopStopTimes.get(key);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(stopStopTimeData.getNumData(timeBinIndex)==0)
- return 0;
- else
- return stopStopTimeData.getStopStopTimeVariance(timeBinIndex);
- }
- @Override
- public void reset(int iteration) {
- for(StopStopTimeData stopStopTimeData:stopStopTimes.values())
- stopStopTimeData.resetStopStopTimes();
- inTransitVehicles.clear();
- }
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if(vehicleIds.contains(event.getVehicleId())) {
- Tuple, Double> route = inTransitVehicles.remove(event.getVehicleId());
- if(route!=null)
- stopStopTimes.get(new Tuple, Id>(route.getFirst(),
- event.getFacilityId())).addStopStopTime(
- TimeBinUtils.getTimeBinIndex(route.getSecond(), timeSlot,
- TimeBinUtils.getTimeBinCount(totalTime, timeSlot)), event.getTime()-route.getSecond());
- inTransitVehicles.put(event.getVehicleId(), new Tuple, Double>(event.getFacilityId(), event.getTime()));
- }
- }
- @Override
- public void handleEvent(PersonLeavesVehicleEvent event) {
- if(vehicleIds.contains(event.getVehicleId()) && event.getPersonId().toString().startsWith("pt_"+event.getVehicleId()+"_"))
- inTransitVehicles.remove(event.getVehicleId());
- }
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java
deleted file mode 100644
index 9f3de496a90..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeData.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-import java.io.Serializable;
-
-public interface StopStopTimeData extends Serializable {
-
- int getNumData(int i);
- double getStopStopTime(int i);
- void addStopStopTime(final int timeSlot, final double stopStopTime);
- void resetStopStopTimes();
- double getStopStopTimeVariance(int timeSlot);
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java
deleted file mode 100644
index b1ac8626324..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/stopStopTimes/StopStopTimeDataArray.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.stopStopTimes;
-
-public class StopStopTimeDataArray implements StopStopTimeData {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- //Attributes
- private double[] stopStopTimeMeans;
- private double[] stopStopTimeSquares;
- private int[] numTimes;
-
- //Constructors
- public StopStopTimeDataArray(int numSlots) {
- stopStopTimeSquares = new double[numSlots];
- stopStopTimeMeans = new double[numSlots];
- numTimes = new int[numSlots];
- resetStopStopTimes();
- }
-
- //Methods
- @Override
- public int getNumData(int timeSlot) {
- return numTimes[timeSlotWhen StopStopTimes are generated externally, e.g. by a regression.
- *
- * See constructor for input format.
- *
- */
-public class StopStopTimePreCalcSerializable implements StopStopTime, Serializable {
-
- private final Map>>> stopStopTimes = new HashMap<>(5000);
- private final Scenario scenario;
-
- public boolean isLogarithmic() {
- return logarithmic;
- }
-
- private final boolean logarithmic;
- private int nfeCounter = 0;
- private int aiobCounter = 0;
- private int errorCounter = 0;
-
- //Constructors
-
-
- /**
- * Populates a StopStopTime object with stop to stop travel times and their variances
- * recorded at particular times.
- * Needs at minimum one record per stop-to-stop combination.
- * Times at which records are recorded needn't be regular intervals, because a TreeMap is used.
- *
- * @param inputFile path to the tab-separated file.Format is fromStopId (String), toStopId (String), time of record (seconds, double),
- * travelTime (seconds, double), travelTimeVariance (seconds**2, double). No headings or row numbers.
- * @param logarithmic if times are recorded as logarithms (normally distributed residuals)
- */
- public StopStopTimePreCalcSerializable(String inputFile, Scenario scenario, boolean logarithmic) {
- this.logarithmic = logarithmic;
- this.scenario = scenario;
- BufferedReader reader = IOUtils.getBufferedReader(inputFile);
- String txt = "";
- while (true) {
- try {
- txt = reader.readLine();
- if (txt == null)
- break;
- String[] split = txt.split("\t");
-// get the map from this stop id
- Map>> toMap = stopStopTimes.get(split[0]);
- if (toMap == null) {
- toMap = new HashMap<>();
- stopStopTimes.put(split[0], toMap);
- }
-
- Map> timeData = toMap.get(split[1]);
- if (timeData == null) {
- timeData = new TreeMap<>();
- toMap.put(split[1], timeData);
- }
-
- timeData.put(Integer.parseInt(split[2]), new Tuple<>(Double.parseDouble(split[3]), Double.parseDouble(split[4])));
-
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ArrayIndexOutOfBoundsException e) {
- if (aiobCounter < 10) {
- System.err.println("Seems one of the lines in the StopStopTime input file is missing a value. Skipping it.");
- } else {
- System.err.println("Seems one of the lines in the StopStopTime input file is missing a value. Skipping further warnings...");
-
- }
- aiobCounter++;
- } catch (NumberFormatException e) {
- if (nfeCounter < 10) {
- System.err.println("Some values in the StopStopTime input file are of the wrong type. Skipping it.");
- } else {
- System.err.println("Some values in the StopStopTime input file are of the wrong type. Skipping further warnings...");
- }
- nfeCounter++;
- }
- }
- System.out.println("\n\n*************************************************************************\n\n");
- System.out.println("STOPSTOPTIMES LOADED, filling in the blanks from the schedule and network");
- System.out.println("\n\n*************************************************************************\n\n");
-
- for (TransitLine transitLine : scenario.getTransitSchedule().getTransitLines().values()) {
- for (TransitRoute route : transitLine.getRoutes().values()) {
- TRANSITSTOPS:
- for (int s = 0; s < route.getStops().size() - 1; s++) {
- String origin = route.getStops().get(s).getStopFacility().getId().toString();
- String destination = route.getStops().get(s + 1).getStopFacility().getId().toString();
- Map>> toMap = stopStopTimes.get(origin);
- if (toMap == null) {
- toMap = new HashMap<>();
- stopStopTimes.put(origin, toMap);
- }
-
- Map> timeData = toMap.get(destination);
- if (timeData == null) {
- timeData = new TreeMap<>();
- toMap.put(destination, timeData);
-
- try {
- List stops;
- stops = scenario.getTransitSchedule().getTransitLines().get(transitLine.getId()).getRoutes().get(route.getId()).getStops();
- if (stops == null)
- throw new NullPointerException();
- Link fromLink = null;
- Link toLink = null;
- for (TransitRouteStop tss : stops) {
- if (tss.getStopFacility().getId().toString().equals(origin)) {
- fromLink = scenario.getNetwork().getLinks().get(tss.getStopFacility().getLinkId());
- }
- if (tss.getStopFacility().getId().toString().equals(destination)) {
- toLink = scenario.getNetwork().getLinks().get(tss.getStopFacility().getLinkId());
- }
- }
- if (fromLink == null || toLink == null)
- throw new NullPointerException();
- NetworkRoute networkRoute = scenario.getTransitSchedule().getTransitLines().get(transitLine.getId())
- .getRoutes().get(route.getId()).getRoute();
- NetworkRoute subRoute = networkRoute.getSubRoute(fromLink.getId(), toLink.getId());
- List> linkIds = new ArrayList<>();
- linkIds.addAll(subRoute.getLinkIds());
- linkIds.add(toLink.getId());
- double freeSpeedTravelTime = 0;
- for (Id id : linkIds) {
- Link link = scenario.getNetwork().getLinks().get(id);
- freeSpeedTravelTime += link.getLength() / link.getFreespeed();
- }
- if (logarithmic)
- timeData.put(0, new Tuple(Math.log(freeSpeedTravelTime), 0.005));
- else
- timeData.put(0, new Tuple(freeSpeedTravelTime, 0.0));
-
- } catch (NullPointerException ne) {
- System.err.printf("Couldnt create STOP-STOP entry for for from: %s, to: %s, route: %s, line: %s\n",
- origin, destination, route.getId().toString(), transitLine.getId().toString());
- continue TRANSITSTOPS;
- }
-
- } else {
- //value already exists (assuming singular stop-stop network routes)
- continue TRANSITSTOPS;
- }
-
- }
- }
- }
- }
-
-
- /**
- * Retrieves the interpolated travel time for a combination of stops at a particular time, or the first/last variance observation if one cannot be interpolated.
- *
- * Returns the error value of infinity for a compbination that doesn't appear in the map
- *
- * @param stopOId
- * @param stopDId
- * @param time
- * @return the travel time, or Double.POSITIVE_INFINITY
- */
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- Map>> toMap = stopStopTimes.get(stopOId.toString());
-
- if (toMap == null) {
- return errorValue(stopOId, stopDId);
- }
-
- TreeMap> timedObservations = (TreeMap>) toMap.get(stopDId.toString());
-
- if (timedObservations == null) {
- return errorValue(stopOId, stopDId);
- }
-
- Map.Entry> ceilingEntry = timedObservations.ceilingEntry((int) time);
- Map.Entry> floorEntry = timedObservations.floorEntry((int) time);
- if (ceilingEntry == null) {
- if (floorEntry == null) {
- return errorValue(stopOId, stopDId);
- } else {
- return floorEntry.getValue().getFirst();
- }
- } else {
- if (floorEntry == null) {
- return ceilingEntry.getValue().getFirst();
- } else {
- // I have both, so can interpolate a travel time
- double x1 = floorEntry.getKey();
- double x2 = ceilingEntry.getKey();
- double y1 = floorEntry.getValue().getFirst();
- double y2 = ceilingEntry.getValue().getFirst();
- double m = (y2 - y1) / (x2 - x1);
- double x = time - x1;
- return y1 + m * x;
- }
- }
- }
-
- private double errorValue(Id stopOId, Id stopDId) {
- if (errorCounter < 10) {
- System.err.println("No StopStop data for origin stop " + stopOId.toString() + ", destination stop " + stopDId.toString() + ". Returning estimation...");
- } else if (errorCounter == 10) {
- System.err.println("No StopStop data for origin stop " + stopOId.toString() + ". Skipping further warnings...");
- }
- errorCounter++;
-
- return Double.POSITIVE_INFINITY;
- }
-
- /**
- * Retrieves the interpolated travel time variance for a combination of stops at a particular time, or the first/last variance observation if one cannot be interpolated.
- *
- * Returns the error value of infinity for a compbination that doesn't appear in the map
- *
- * @param stopOId
- * @param stopDId
- * @param time seconds till the start of the sim
- * @return the travel time, or Double.POSITIVE_INFINITY
- */
- public double getStopStopTimeVariance(Id stopOId, Id stopDId, double time) {
- Map>> toMap = stopStopTimes.get(stopOId.toString());
-
- if (toMap == null) {
- return errorValue(stopOId, stopDId);
- }
-
- TreeMap> timedObservations = (TreeMap>) toMap.get(stopDId.toString());
-
- if (timedObservations == null) {
- return errorValue(stopOId, stopDId);
- }
-
- Map.Entry> ceilingEntry = timedObservations.ceilingEntry((int) time);
- Map.Entry> floorEntry = timedObservations.floorEntry((int) time);
- if (ceilingEntry == null) {
- if (floorEntry == null) {
- return 0;
- } else {
- return floorEntry.getValue().getSecond();
- }
- } else {
- if (floorEntry == null) {
- return ceilingEntry.getValue().getSecond();
- } else {
- // I have both, so can interpolate a travel time
- double x1 = floorEntry.getKey();
- double x2 = ceilingEntry.getKey();
- double y1 = floorEntry.getValue().getSecond();
- double y2 = ceilingEntry.getValue().getSecond();
- double m = (y2 - y1) / (x2 - x1);
- double x = time - x1;
- return y1 + m * x;
- }
- }
- }
-
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java
deleted file mode 100644
index 22168b8ce75..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancy.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-public interface VehicleOccupancy {
-
- //Methods
- public double getVehicleOccupancy(Id stopOId, Id lineId, Id routeId, double time);
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java
deleted file mode 100644
index 9cae7720b1b..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyCalculator.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.api.core.v01.events.PersonLeavesVehicleEvent;
-import org.matsim.api.core.v01.events.TransitDriverStartsEvent;
-import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.PersonLeavesVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler;
-import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleDepartsAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.vehicles.Vehicle;
-import org.matsim.vehicles.VehicleCapacity;
-import org.matsim.vehicles.Vehicles;
-
-public class VehicleOccupancyCalculator implements VehicleDepartsAtFacilityEventHandler, PersonEntersVehicleEventHandler, PersonLeavesVehicleEventHandler, TransitDriverStartsEventHandler {
-
- private final Map, Id>, Map, VehicleOccupancyData>> vehicleOccupancy = new HashMap, Id>, Map, VehicleOccupancyData>>(1000);
- private double timeSlot;
- private int totalTime;
- private Map, Integer> ptVehicles = new HashMap, Integer>();
- private Map, Integer> capacities = new HashMap, Integer>();
- private Map, Tuple, Id>> linesRoutesOfVehicle = new HashMap, Tuple, Id>>();
- private final Vehicles vehicles;
-
- //Constructors
- public VehicleOccupancyCalculator(final TransitSchedule transitSchedule, final Vehicles vehicles, final Config config) {
- this(transitSchedule, vehicles, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- }
- public VehicleOccupancyCalculator(final TransitSchedule transitSchedule, final Vehicles vehicles, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- Map, VehicleOccupancyData> routeMap = new HashMap, VehicleOccupancyData>(100);
- vehicleOccupancy.put(new Tuple, Id>(line.getId(), route.getId()), routeMap);
- for(int s=0; s stopOId, Id lineId, Id routeId, double time) {
- return VehicleOccupancyCalculator.this.getVehicleOccupancy(stopOId, lineId, routeId, time);
- }
- };
- }
- private double getVehicleOccupancy(Id stopOId, Id lineId, Id routeId, double time) {
- return vehicleOccupancy.get(new Tuple, Id>(lineId, routeId)).get(stopOId).getVehicleOccupancy(TimeBinUtils.getTimeBinIndex(time, timeSlot, totalTime));
- }
- @Override
- public void reset(int iteration) {
- for(Map, VehicleOccupancyData> map:vehicleOccupancy.values())
- for(VehicleOccupancyData vehicleOcupancyData:map.values())
- vehicleOcupancyData.resetVehicleOccupancies();
- this.ptVehicles.clear();
- }
- @Override
- public void handleEvent(VehicleDepartsAtFacilityEvent event) {
- Integer num = ptVehicles.get(event.getVehicleId());
- if(num!=null) {
- VehicleOccupancyData vehicleOccupancyData = vehicleOccupancy.get(linesRoutesOfVehicle.get(event.getVehicleId())).get(event.getFacilityId());
- if(vehicleOccupancyData!=null)
- vehicleOccupancyData.addVehicleOccupancy(
- TimeBinUtils.getTimeBinIndex(event.getTime(), timeSlot,
- TimeBinUtils.getTimeBinCount(totalTime, timeSlot)),
- num/(double)capacities.get(event.getVehicleId()));
- }
- }
- @Override
- public void handleEvent(PersonLeavesVehicleEvent event) {
- Integer num = this.ptVehicles.get(event.getVehicleId());
- if(num!=null)
- this.ptVehicles.put(event.getVehicleId(), num-1);
- }
- @Override
- public void handleEvent(PersonEntersVehicleEvent event) {
- Integer num = this.ptVehicles.get(event.getVehicleId());
- if(num!=null)
- this.ptVehicles.put(event.getVehicleId(), num+1);
- }
- @Override
- public void handleEvent(TransitDriverStartsEvent event) {
- this.ptVehicles.put(event.getVehicleId(), 0);
- VehicleCapacity vehicleCapacity = vehicles.getVehicles().get(event.getVehicleId()).getType().getCapacity();
- this.capacities.put(event.getVehicleId(), vehicleCapacity.getSeats()+vehicleCapacity.getStandingRoom());
- linesRoutesOfVehicle.put(event.getVehicleId(), new Tuple, Id>(event.getTransitLineId(), event.getTransitRouteId()));
- }
-
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java
deleted file mode 100644
index 59e155a79e9..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyData.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy;
-
-public interface VehicleOccupancyData {
-
- double getVehicleOccupancy(int i);
- void addVehicleOccupancy(final int timeSlot, final double vehicleOccupancy);
- void resetVehicleOccupancies();
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java
deleted file mode 100644
index 29c405c1772..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/vehicleOccupancy/VehicleOccupancyDataArray.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.vehicleOccupancy;
-
-public class VehicleOccupancyDataArray implements VehicleOccupancyData {
-
- //Attributes
- private double[] vehicleOccupancies;
- private int[] numTimes;
- private int lastPosition;
-
- //Constructors
- public VehicleOccupancyDataArray(int numSlots) {
- vehicleOccupancies = new double[numSlots];
- numTimes = new int[numSlots];
- resetVehicleOccupancies();
- }
-
- //Methods
- @Override
- public double getVehicleOccupancy(int timeSlot) {
- if(timeSlot>lastPosition)
- return 1;
- else
- while(vehicleOccupancies[timeSlot]==-1)
- timeSlot++;
- return vehicleOccupancies[timeSlot];
- }
- @Override
- public synchronized void addVehicleOccupancy(int timeSlot, double vehicleOccupancy) {
- if(lastPosition lineId, Id routeId, Id stopId, double time);
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java
deleted file mode 100644
index 3cec2e82f67..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculator.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.matsim.contrib.eventsBasedPTRouter.waitTimes;
-
-import com.google.inject.Provider;
-import com.google.inject.Provides;
-import org.matsim.api.core.v01.Id;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-
-public interface WaitTimeCalculator extends Provider {
- double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time);
-
- @Override
- @Provides
- WaitTime get();
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java
deleted file mode 100644
index ed80d814c81..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorImpl.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * WaitTimeCalculator.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.waitTimes;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.events.PersonDepartureEvent;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.api.core.v01.events.TransitDriverStartsEvent;
-import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler;
-import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.api.experimental.events.EventsManager;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitRouteStop;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.vehicles.Vehicle;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-
-/**
- * Save waiting times of agents while mobsim is running
- *
- * @author sergioo
- */
-
-@Singleton
-public class WaitTimeCalculatorImpl implements WaitTimeCalculator, PersonDepartureEventHandler, PersonEntersVehicleEventHandler, TransitDriverStartsEventHandler, VehicleArrivesAtFacilityEventHandler, Provider {
-
- //Attributes
- private final double timeSlot;
- private final int totalTime;
- private final Map, Id>, Map, WaitTimeData>> waitTimes = new HashMap, Id>, Map, WaitTimeData>>(1000);
- private final Map, Id>, Map, double[]>> scheduledWaitTimes = new HashMap, Id>, Map, double[]>>(1000);
- private final Map, Double> agentsWaitingData = new HashMap, Double>();
- private Map, Tuple, Id>> linesRoutesOfVehicle = new HashMap, Tuple, Id>>();
- private Map, Id> stopOfVehicle = new HashMap, Id>();
-
- //Constructors
- @Inject
- public WaitTimeCalculatorImpl(final TransitSchedule transitSchedule, final Config config, EventsManager eventsManager) {
- this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- eventsManager.addHandler(this);
- }
- public WaitTimeCalculatorImpl(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- double[] sortedDepartures = new double[route.getDepartures().size()];
- int d=0;
- for(Departure departure:route.getDepartures().values())
- sortedDepartures[d++] = departure.getDepartureTime();
- Arrays.sort(sortedDepartures);
- Map, WaitTimeData> stopsMap = new HashMap, WaitTimeData>(100);
- Map, double[]> stopsScheduledMap = new HashMap, double[]>(100);
- for(TransitRouteStop stop:route.getStops()) {
- stopsMap.put(stop.getStopFacility().getId(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot)));
- double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime, timeSlot)];
- for(int i=0; i24*3600)
- endTime-=24*3600;
- cacheWaitTimes[i] = Double.NaN;
- SORTED_DEPARTURES:
- for(double departure:sortedDepartures) {
- double arrivalTime = departure+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds();
- if(arrivalTime>=endTime) {
- cacheWaitTimes[i] = arrivalTime-endTime;
- break SORTED_DEPARTURES;
- }
- }
- if(Double.isNaN(cacheWaitTimes[i]))
- cacheWaitTimes[i] = sortedDepartures[0]+24*3600+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds()-endTime;
- }
- stopsScheduledMap.put(stop.getStopFacility().getId(), cacheWaitTimes);
- }
- Tuple, Id> key = new Tuple, Id>(line.getId(), route.getId());
- waitTimes.put(key, stopsMap);
- scheduledWaitTimes.put(key, stopsScheduledMap);
- }
- }
-
- //Methods
- @Override
- public WaitTime get() {
- return new WaitTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- return WaitTimeCalculatorImpl.this.getRouteStopWaitTime(lineId, routeId, stopId, time);
- }
- };
- }
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- Tuple, Id> key = new Tuple, Id>(lineId, routeId);
- WaitTimeData waitTimeData = waitTimes.get(key).get(stopId);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(waitTimeData.getNumData(timeBinIndex)==0) {
- double[] waitTimes = scheduledWaitTimes.get(key).get(stopId);
- return waitTimes[timeBinIndex, WaitTimeData> routeData:waitTimes.values())
- for(WaitTimeData waitTimeData:routeData.values())
- waitTimeData.resetWaitTimes();
- agentsWaitingData.clear();
- linesRoutesOfVehicle.clear();
- stopOfVehicle.clear();
- }
- @Override
- public void handleEvent(PersonDepartureEvent event) {
- if(event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId())==null)
- agentsWaitingData.put(event.getPersonId(), event.getTime());
- else if(agentsWaitingData.get(event.getPersonId())!=null)
- new RuntimeException("Departing with old data");
- }
- @Override
- public void handleEvent(PersonEntersVehicleEvent event) {
- Double startWaitingTime = agentsWaitingData.get(event.getPersonId());
- if(startWaitingTime!=null) {
- Tuple, Id> lineRoute = linesRoutesOfVehicle.get(event.getVehicleId());
- WaitTimeData data = waitTimes.get(lineRoute).get(stopOfVehicle.get(event.getVehicleId()));
- data.addWaitTime((int) (startWaitingTime/timeSlot), event.getTime()-startWaitingTime);
- agentsWaitingData.remove(event.getPersonId());
- }
- }
-
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if(linesRoutesOfVehicle.get(event.getVehicleId())!=null)
- stopOfVehicle.put(event.getVehicleId(), event.getFacilityId());
- }
-
- @Override
- public void handleEvent(TransitDriverStartsEvent event) {
- linesRoutesOfVehicle.put(event.getVehicleId(), new Tuple, Id>(event.getTransitLineId(), event.getTransitRouteId()));
- }
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java
deleted file mode 100644
index 17a93bd0410..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeCalculatorSerializable.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * WaitTimeCalculator.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.waitTimes;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-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.PersonDepartureEvent;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.api.core.v01.events.TransitDriverStartsEvent;
-import org.matsim.api.core.v01.events.handler.PersonDepartureEventHandler;
-import org.matsim.api.core.v01.events.handler.PersonEntersVehicleEventHandler;
-import org.matsim.api.core.v01.events.handler.TransitDriverStartsEventHandler;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.api.experimental.events.handler.VehicleArrivesAtFacilityEventHandler;
-import org.matsim.core.config.Config;
-import org.matsim.core.trafficmonitoring.TimeBinUtils;
-import org.matsim.core.utils.collections.Tuple;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitRouteStop;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-import com.google.inject.Provider;
-import com.google.inject.Provides;
-
-/**
- * Save waiting times of agents while mobsim is running
- *
- * @author sergioo
- */
-
-public class WaitTimeCalculatorSerializable implements
- WaitTimeCalculator, PersonDepartureEventHandler,
- PersonEntersVehicleEventHandler, TransitDriverStartsEventHandler,
- VehicleArrivesAtFacilityEventHandler, Serializable,
- Provider {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static int scheduleCalls;
- private static int waitTimeCalls;
- //Attributes
- private final double timeSlot;
- private final int totalTime;
- private final Map, Map> waitTimes = new HashMap, Map>(1000);
- private final Map, Map> scheduledWaitTimes = new HashMap, Map>(1000);
- private final Map agentsWaitingData = new HashMap();
- private Map> linesRoutesOfVehicle = new HashMap>();
- private Map stopOfVehicle = new HashMap();
-
- public static void printCallStatisticsAndReset() {
- Logger logger = LogManager.getLogger(WaitTimeCalculatorSerializable.class);
- logger.warn("scheduled wait time calls vs unscheduled: " + scheduleCalls + " : " + waitTimeCalls);
- scheduleCalls = 0;
- waitTimeCalls = 0;
- }
-
- //Constructors
- public WaitTimeCalculatorSerializable(final TransitSchedule transitSchedule, final Config config) {
- this(transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds()));
- }
-
- public WaitTimeCalculatorSerializable(final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- for (TransitLine line : transitSchedule.getTransitLines().values())
- for (TransitRoute route : line.getRoutes().values()) {
- double[] sortedDepartures = new double[route.getDepartures().size()];
- int d = 0;
- for (Departure departure : route.getDepartures().values())
- sortedDepartures[d++] = departure.getDepartureTime();
- Arrays.sort(sortedDepartures);
- Map stopsMap = new HashMap(100);
- Map stopsScheduledMap = new HashMap(100);
- for (TransitRouteStop stop : route.getStops()) {
- stopsMap.put(stop.getStopFacility().getId().toString(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime , timeSlot)));
- double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime , timeSlot)];
- for (int i = 0; i < cacheWaitTimes.length; i++) {
- double endTime = timeSlot * (i + 1);
- if (endTime > 24 * 3600)
- endTime -= 24 * 3600;
- cacheWaitTimes[i] = Double.NaN;
- SORTED_DEPARTURES:
- for (double departure : sortedDepartures) {
- double arrivalTime = departure + stop.getArrivalOffset().or(stop::getDepartureOffset).seconds();
- if (arrivalTime >= endTime) {
- cacheWaitTimes[i] = arrivalTime - endTime;
- break SORTED_DEPARTURES;
- }
- }
- if (Double.isNaN(cacheWaitTimes[i]))
- cacheWaitTimes[i] = sortedDepartures[0] + 24 * 3600 + stop.getArrivalOffset().or(stop::getDepartureOffset).seconds() - endTime;
- }
- stopsScheduledMap.put(stop.getStopFacility().getId().toString(), cacheWaitTimes);
- }
- Tuple key = new Tuple(line.getId().toString(), route.getId().toString());
- waitTimes.put(key, stopsMap);
- scheduledWaitTimes.put(key, stopsScheduledMap);
- }
- }
-
- //Methods
- public WaitTime getWaitTimes() {
- return new WaitTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- return WaitTimeCalculatorSerializable.this.getRouteStopWaitTime(lineId, routeId, stopId, time);
- }
- };
- }
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- Tuple key = new Tuple(lineId.toString(), routeId.toString());
- waitTimeCalls++;
- WaitTimeData waitTimeData = waitTimes.get(key).get(stopId.toString());
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if (waitTimeData.getNumData(timeBinIndex) == 0) {
- scheduleCalls++;
- double[] waitTimes = scheduledWaitTimes.get(key).get(stopId.toString());
- return waitTimes[timeBinIndex < waitTimes.length ? timeBinIndex : (waitTimes.length - 1)];
- } else {
- return waitTimeData.getWaitTime(timeBinIndex);
- }
- }
-
- @Override
- public void reset(int iteration) {
- for (Map routeData : waitTimes.values())
- for (WaitTimeData waitTimeData : routeData.values())
- waitTimeData.resetWaitTimes();
- agentsWaitingData.clear();
- linesRoutesOfVehicle.clear();
- stopOfVehicle.clear();
- }
-
- @Override
- public void handleEvent(PersonDepartureEvent event) {
- if (event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId().toString()) == null)
- agentsWaitingData.put(event.getPersonId().toString(), event.getTime());
- else if (agentsWaitingData.get(event.getPersonId().toString()) != null)
- new RuntimeException("Departing with old data");
- }
-
- @Override
- public void handleEvent(PersonEntersVehicleEvent event) {
- Double startWaitingTime = agentsWaitingData.get(event.getPersonId().toString());
- if (startWaitingTime != null) {
- Tuple lineRoute = linesRoutesOfVehicle.get(event.getVehicleId().toString());
- WaitTimeData data = waitTimes.get(lineRoute).get(stopOfVehicle.get(event.getVehicleId().toString()));
- data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot)),
- event.getTime() - startWaitingTime);
- agentsWaitingData.remove(event.getPersonId().toString());
- }
- }
-
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if (linesRoutesOfVehicle.get(event.getVehicleId().toString()) != null)
- stopOfVehicle.put(event.getVehicleId().toString(), event.getFacilityId().toString());
- }
-
- @Override
- public void handleEvent(TransitDriverStartsEvent event) {
- linesRoutesOfVehicle.put(event.getVehicleId().toString(), new Tuple(event.getTransitLineId().toString(), event.getTransitRouteId().toString()));
- }
-
- @Override
- @Provides
- public WaitTime get() {
- return new WaitTime() {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- return WaitTimeCalculatorSerializable.this.getRouteStopWaitTime(lineId, routeId, stopId, time);
- }
- };
- }
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java
deleted file mode 100644
index 645a1a39efd..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeData.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * WaitTimeCalculator.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.waitTimes;
-
-import java.io.Serializable;
-
-/**
- * Structure for saving waiting times
- *
- * @author sergioo
- */
-
-public interface WaitTimeData extends Serializable {
-
- //Methods
- void resetWaitTimes();
- void addWaitTime(final int timeSlot, final double waitTime);
- double getWaitTime(final int timeSlot);
- int getNumData(final int timeSlot);
-
-}
diff --git a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java b/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java
deleted file mode 100644
index 43064e2f913..00000000000
--- a/contribs/eventsBasedPTRouter/src/main/java/org/matsim/contrib/eventsBasedPTRouter/waitTimes/WaitTimeDataArray.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * WaitTimeCalculator.java
- * *
- * *********************************************************************** *
- * *
- * copyright : (C) 2012 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.contrib.eventsBasedPTRouter.waitTimes;
-
-/**
- * Array implementation of the structure for saving wait times
- *
- * @author sergioo
- */
-
-public class WaitTimeDataArray implements WaitTimeData {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- //Attributes
- private double[] waitTimes;
- private int[] numTimes;
-
- //Constructors
- public WaitTimeDataArray(int numSlots) {
- waitTimes = new double[numSlots];
- numTimes = new int[numSlots];
- resetWaitTimes();
- }
-
- //Methods
- @Override
- public void resetWaitTimes() {
- for(int i=0; i, Id>, Map, WaitTimeData>> waitTimes = new HashMap, Id>, Map, WaitTimeData>>(1000);
- private final Map, Id>, Map, double[]>> scheduledWaitTimes = new HashMap, Id>, Map, double[]>>(1000);
- private final Map, Double> agentsWaitingData = new HashMap, Double>();
- private final Map, Integer> agentsCurrentLeg = new HashMap, Integer>();
- private final Population population;
-
- //Constructors
- @Inject
- public WaitTimeStuckCalculator(final Population population, final TransitSchedule transitSchedule, final Config config, final EventsManager eventsManager) {
- this(population, transitSchedule, config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config.qsim().getEndTime().seconds()-config.qsim().getStartTime().seconds()));
- eventsManager.addHandler(this);
- }
- public WaitTimeStuckCalculator(final Population population, final TransitSchedule transitSchedule, final double timeSlot, final int totalTime) {
- this.population = population;
- this.timeSlot = timeSlot;
- this.totalTime = totalTime;
- for(TransitLine line:transitSchedule.getTransitLines().values())
- for(TransitRoute route:line.getRoutes().values()) {
- double[] sortedDepartures = new double[route.getDepartures().size()];
- int d=0;
- for(Departure departure:route.getDepartures().values())
- sortedDepartures[d++] = departure.getDepartureTime();
- Arrays.sort(sortedDepartures);
- Map, WaitTimeData> stopsMap = new HashMap, WaitTimeData>(100);
- Map, double[]> stopsScheduledMap = new HashMap, double[]>(100);
- for(TransitRouteStop stop:route.getStops()) {
- stopsMap.put(stop.getStopFacility().getId(), new WaitTimeDataArray(TimeBinUtils.getTimeBinCount(totalTime, timeSlot)));
- double[] cacheWaitTimes = new double[TimeBinUtils.getTimeBinCount(totalTime, timeSlot)];
- for(int i=0; i24*3600)
- endTime-=24*3600;
- cacheWaitTimes[i] = Double.NaN;
- SORTED_DEPARTURES:
- for(double departure:sortedDepartures) {
- double arrivalTime = departure+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds();
- if(arrivalTime>=endTime) {
- cacheWaitTimes[i] = arrivalTime-endTime;
- break SORTED_DEPARTURES;
- }
- }
- if(Double.isNaN(cacheWaitTimes[i]))
- cacheWaitTimes[i] = sortedDepartures[0]+24*3600+stop.getArrivalOffset().or(stop::getDepartureOffset).seconds()-endTime;
- }
- stopsScheduledMap.put(stop.getStopFacility().getId(), cacheWaitTimes);
- }
- Tuple, Id> key = new Tuple, Id>(line.getId(), route.getId());
- waitTimes.put(key, stopsMap);
- scheduledWaitTimes.put(key, stopsScheduledMap);
- }
- }
-
- //Methods
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- Tuple, Id> key = new Tuple, Id>(lineId, routeId);
- WaitTimeData waitTimeData = waitTimes.get(key).get(stopId);
- int timeBinIndex = TimeBinUtils.getTimeBinIndex(time, timeSlot, TimeBinUtils.getTimeBinCount(totalTime, timeSlot));
- if(waitTimeData.getNumData(timeBinIndex)==0) {
- double[] waitTimes = scheduledWaitTimes.get(key).get(stopId);
- return waitTimes[timeBinIndex, WaitTimeData> routeData:waitTimes.values())
- for(WaitTimeData waitTimeData:routeData.values())
- waitTimeData.resetWaitTimes();
- agentsWaitingData.clear();
- agentsCurrentLeg.clear();
- }
- @Override
- public void handleEvent(PersonDepartureEvent event) {
- Integer currentLeg = agentsCurrentLeg.get(event.getPersonId());
- if(currentLeg == null)
- currentLeg = 0;
- else
- currentLeg++;
- agentsCurrentLeg.put(event.getPersonId(), currentLeg);
- if(event.getLegMode().equals("pt") && agentsWaitingData.get(event.getPersonId())==null)
- agentsWaitingData.put(event.getPersonId(), event.getTime());
- else if(agentsWaitingData.get(event.getPersonId())!=null)
- new RuntimeException("Departing with old data");
- }
- @Override
- public void handleEvent(PersonEntersVehicleEvent event) {
- Double startWaitingTime = agentsWaitingData.get(event.getPersonId());
- if(startWaitingTime!=null) {
- int legs = 0, currentLeg = agentsCurrentLeg.get(event.getPersonId());
- PLAN_ELEMENTS:
- for(PlanElement planElement:population.getPersons().get(event.getPersonId()).getSelectedPlan().getPlanElements())
- if(planElement instanceof Leg) {
- if(currentLeg==legs) {
- Route route = (((Leg)planElement).getRoute());
- TransitPassengerRoute eRoute = (TransitPassengerRoute) new DefaultTransitPassengerRouteFactory().
- createRoute(route.getStartLinkId(), route.getEndLinkId());
- eRoute.setStartLinkId(route.getStartLinkId());
- eRoute.setEndLinkId(route.getEndLinkId());
- eRoute.setRouteDescription(route.getRouteDescription());
- WaitTimeData data = waitTimes.get(new Tuple, Id>(eRoute.getLineId(),
- eRoute.getRouteId())).get(eRoute.getAccessStopId());
- data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, totalTime), event.getTime()-startWaitingTime);
- agentsWaitingData.remove(event.getPersonId());
- break PLAN_ELEMENTS;
- }
- else
- legs++;
- }
- }
- }
-
- @Override
- public void handleEvent(PersonStuckEvent event) {
- Double startWaitingTime = agentsWaitingData.get(event.getPersonId());
- if(startWaitingTime!=null) {
- int legs = 0, currentLeg = agentsCurrentLeg.get(event.getPersonId());
- PLAN_ELEMENTS:
- for(PlanElement planElement:population.getPersons().get(event.getPersonId()).getSelectedPlan().getPlanElements())
- if(planElement instanceof Leg) {
- if(currentLeg==legs) {
- Route route = ((Leg)planElement).getRoute();
- TransitPassengerRoute eRoute = (TransitPassengerRoute) new DefaultTransitPassengerRouteFactory().
- createRoute(route.getStartLinkId(), route.getEndLinkId());
- eRoute.setStartLinkId(route.getStartLinkId());
- eRoute.setEndLinkId(route.getEndLinkId());
- eRoute.setRouteDescription(route.getRouteDescription());
- WaitTimeData data = waitTimes.get(new Tuple, Id>(eRoute.getLineId(),
- eRoute.getRouteId())).get(eRoute.getAccessStopId());
- if(data!=null)
- data.addWaitTime(TimeBinUtils.getTimeBinIndex(startWaitingTime, timeSlot, totalTime), event.getTime()-startWaitingTime);
- agentsWaitingData.remove(event.getPersonId());
- break PLAN_ELEMENTS;
- }
- else
- legs++;
- }
- }
- }
-
- @Override
- public WaitTime get() {
- return new WaitTime() {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId, double time) {
- return WaitTimeStuckCalculator.this.getRouteStopWaitTime(lineId, routeId, stopId, time);
- }
-
- };
- }
-}
-
diff --git a/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java b/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java
deleted file mode 100644
index 96574ed0d84..00000000000
--- a/contribs/eventsBasedPTRouter/src/test/java/org/matsim/contrib/eventsBasedPTRouter/MultiNodeDijkstraTest.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/* *********************************************************************** *
- * project: org.matsim.*
- * TransitDijkstraTest.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.contrib.eventsBasedPTRouter;
-
-import static org.junit.Assert.*;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-import org.matsim.api.core.v01.Coord;
-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.api.core.v01.network.Node;
-import org.matsim.api.core.v01.population.Person;
-import org.matsim.core.network.NetworkUtils;
-import org.matsim.core.router.InitialNode;
-import org.matsim.core.router.util.LeastCostPathCalculator.Path;
-import org.matsim.core.router.util.TravelTime;
-import org.matsim.pt.router.CustomDataManager;
-import org.matsim.pt.router.TransitTravelDisutility;
-import org.matsim.vehicles.Vehicle;
-
-/**
- * @author mrieser
- */
-public class MultiNodeDijkstraTest {
-
- @Test public void testMultipleStarts() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0));
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0));
- fromNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(2.0, 2.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(0.0, 0.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("1", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
-
- // change costs
- tc.setData(Id.create(1, Link.class), 2.0, 5.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
-
- // change costs again
- tc.setData(Id.create(1, Link.class), 2.0, 1.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("1", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
- }
-
- @Test public void testMultipleEnds() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 4.0, 4.0);
- tc.setData(Id.create(5, Link.class), 3.0, 3.0);
- tc.setData(Id.create(6, Link.class), 7.0, 7.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(0.0, 0.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(5.0, 5.0));
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(4.0, 4.0));
- toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(1.0, 1.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
-
- // change costs
- tc.setData(Id.create(4, Link.class), 3.0, 1.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("4", p.links.get(2).getId().toString());
-
- // change costs again
- tc.setData(Id.create(6, Link.class), 7.0, 3.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("6", p.links.get(2).getId().toString());
- }
-
- @Test public void testMultipleStartsAndEnds() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 4.0, 4.0);
- tc.setData(Id.create(5, Link.class), 3.0, 3.0);
- tc.setData(Id.create(6, Link.class), 7.0, 7.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(4.0, 4.0));
- fromNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(3.0, 3.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(5.0, 5.0));
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(4.0, 4.0));
- toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(1.0, 1.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
-
- // change costs
- tc.setData(Id.create(3, Link.class), 3.0, 1.0);
- tc.setData(Id.create(4, Link.class), 3.0, 1.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("3", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("4", p.links.get(2).getId().toString());
-
- // change costs again
- tc.setData(Id.create(3, Link.class), 3.0, 4.0);
- tc.setData(Id.create(6, Link.class), 7.0, 3.0);
-
- p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("6", p.links.get(2).getId().toString());
- }
-
- /**
- * Both nodes 1 and 4 are part of the start set. Even if the path from 1 to the
- * target leads over node 4, it may be faster, due to the intial cost values.
- * Test that the route does not cut at node 4 as the first node backwards from
- * the start set.
- */
- @Test public void testStartViaFaster() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0));
- fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(4.0, 4.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(0.0, 0.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("1", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
- }
-
- @Test public void testEndViaFaster() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(1.0, 1.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(8, Node.class)), new InitialNode(3.0, 3.0));
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
- }
-
- @Test public void testOnlyFromToSameNode() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(1.0, 1.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(0, p.links.size());
- assertEquals(1, p.nodes.size());
- assertEquals("2", p.nodes.get(0).getId().toString());
- }
-
- /**
- * Tests that a path is found if some links are in the set of start
- * as well as in the set of end nodes and the path only containing
- * of this node is the cheapest.
- */
- @Test public void testSameNodeInFromToSetCheapest() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0));
- fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(1.0, 1.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(1.0, 1.0));
- toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(0, p.links.size());
- assertEquals(1, p.nodes.size());
- assertEquals("4", p.nodes.get(0).getId().toString());
- }
-
- /**
- * Tests that a path is found if some links are in the set of start
- * as well as in the set of end nodes, but the path only containing
- * of this node is the not the cheapest.
- */
- @Test public void testSameNodeInFromToSetNotCheapest() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0));
- fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(10.0, 10.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(8.0, 8.0));
- toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("6", p.links.get(2).getId().toString());
- }
-
- /**
- * Tests that a route is found even if not all given end nodes are reachable
- */
- @Test public void testSomeEndNodesNotReachable() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0));
- fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(3.0, 3.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0));
- toNodes.put(f.network.getNodes().get(Id.create(3, Node.class)), new InitialNode(3.0, 3.0)); // cannot be reached!
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
- }
-
- /**
- * Tests that a route is found even if not all given start nodes lead to an end node
- */
- @Test public void testSomeStartNodesNotUseable() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(2.0, 2.0));
- fromNodes.put(f.network.getNodes().get(Id.create(4, Node.class)), new InitialNode(3.0, 3.0)); // cannot lead to 5 or 6
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(5, Node.class)), new InitialNode(1.0, 1.0));
- toNodes.put(f.network.getNodes().get(Id.create(6, Node.class)), new InitialNode(3.0, 3.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNotNull("no path found!", p);
- assertEquals(3, p.links.size());
- assertEquals("2", p.links.get(0).getId().toString());
- assertEquals("7", p.links.get(1).getId().toString());
- assertEquals("5", p.links.get(2).getId().toString());
- }
-
- @Test public void testImpossibleRoute() {
- Fixture f = new Fixture();
- TestTimeCost tc = new TestTimeCost();
- tc.setData(Id.create(1, Link.class), 2.0, 2.0);
- tc.setData(Id.create(2, Link.class), 1.0, 1.0);
- tc.setData(Id.create(3, Link.class), 3.0, 3.0);
- tc.setData(Id.create(4, Link.class), 2.0, 2.0);
- tc.setData(Id.create(5, Link.class), 1.0, 1.0);
- tc.setData(Id.create(6, Link.class), 3.0, 3.0);
- tc.setData(Id.create(7, Link.class), 4.0, 4.0);
- MultiNodeDijkstra dijkstra = new MultiNodeDijkstra(f.network, tc, tc);
- Map fromNodes = new HashMap();
- fromNodes.put(f.network.getNodes().get(Id.create(1, Node.class)), new InitialNode(1.0, 1.0));
- Map toNodes = new HashMap();
- toNodes.put(f.network.getNodes().get(Id.create(2, Node.class)), new InitialNode(3.0, 3.0));
-
- Path p = dijkstra.calcLeastCostPath(fromNodes, toNodes, null);
- assertNull("wow, impossible path found!", p);
- }
-
- /**
- * Creates a simple network to be used in tests.
- *
- *
- * (1) (4)
- * \ /
- * \_1 4_/
- * \ /
- * (2)-2-(7)-----7-----(8)-5-(5)
- * / \
- * /_3 6_\
- * / \
- * (3) (6)
- *
- *
- * @author mrieser
- */
- /*package*/ static class Fixture {
- /*package*/ Network network;
-
- public Fixture() {
- this.network = NetworkUtils.createNetwork();
- Node node1 = NetworkUtils.createAndAddNode(this.network, Id.create(1, Node.class), new Coord((double) 1000, (double) 0));
- Node node2 = NetworkUtils.createAndAddNode(this.network, Id.create(2, Node.class), new Coord((double) 500, (double) 0));
- Node node3 = NetworkUtils.createAndAddNode(this.network, Id.create(3, Node.class), new Coord((double) 0, (double) 0));
- Node node4 = NetworkUtils.createAndAddNode(this.network, Id.create(4, Node.class), new Coord((double) 1000, (double) 2000));
- Node node5 = NetworkUtils.createAndAddNode(this.network, Id.create(5, Node.class), new Coord((double) 500, (double) 2000));
- Node node6 = NetworkUtils.createAndAddNode(this.network, Id.create(6, Node.class), new Coord((double) 0, (double) 2000));
- Node node7 = NetworkUtils.createAndAddNode(this.network, Id.create(7, Node.class), new Coord((double) 500, (double) 500));
- Node node8 = NetworkUtils.createAndAddNode(this.network, Id.create(8, Node.class), new Coord((double) 500, (double) 1500));
- final Node fromNode = node1;
- final Node toNode = node7;
- NetworkUtils.createAndAddLink(this.network,Id.create(1, Link.class), fromNode, toNode, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode1 = node2;
- final Node toNode1 = node7;
- NetworkUtils.createAndAddLink(this.network,Id.create(2, Link.class), fromNode1, toNode1, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode2 = node3;
- final Node toNode2 = node7;
- NetworkUtils.createAndAddLink(this.network,Id.create(3, Link.class), fromNode2, toNode2, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode3 = node8;
- final Node toNode3 = node4;
- NetworkUtils.createAndAddLink(this.network,Id.create(4, Link.class), fromNode3, toNode3, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode4 = node8;
- final Node toNode4 = node5;
- NetworkUtils.createAndAddLink(this.network,Id.create(5, Link.class), fromNode4, toNode4, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode5 = node8;
- final Node toNode5 = node6;
- NetworkUtils.createAndAddLink(this.network,Id.create(6, Link.class), fromNode5, toNode5, 1000.0, 10.0, 2000.0, (double) 1 );
- final Node fromNode6 = node7;
- final Node toNode6 = node8;
- NetworkUtils.createAndAddLink(this.network,Id.create(7, Link.class), fromNode6, toNode6, 1000.0, 10.0, 2000.0, (double) 1 );
- }
- }
-
- /*package*/ static class TestTimeCost implements TravelTime, TransitTravelDisutility {
-
- private final Map, Double> travelTimes = new HashMap<>();
- private final Map, Double> travelCosts = new HashMap<>();
-
- public void setData(final Id id, final double travelTime, final double travelCost) {
- this.travelTimes.put(id, Double.valueOf(travelTime));
- this.travelCosts.put(id, Double.valueOf(travelCost));
- }
-
- @Override
- public double getLinkTravelTime(final Link link, final double time, Person person, Vehicle vehicle) {
- return this.travelTimes.get(link.getId()).doubleValue();
- }
-
- @Override
- public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle, final CustomDataManager dataManager) {
- return this.travelCosts.get(link.getId()).doubleValue();
- }
-
- @Override
- public double getWalkTravelTime(Person person, Coord coord, Coord toCoord) {
- return 0;
- }
-
- @Override
- public double getWalkTravelDisutility(Person person, Coord coord, Coord toCoord) {
- return 0;
- }
-
-
-
- }
-
-}
diff --git a/contribs/pom.xml b/contribs/pom.xml
index 90f504be8fa..9ffc2dec10e 100644
--- a/contribs/pom.xml
+++ b/contribs/pom.xml
@@ -74,7 +74,6 @@
dvrp
ev
emissions
- eventsBasedPTRouter
freight
freightreceiver
hybridsim
From 11c62dec93120da9076b79e1fa5ca6dd7902d85e Mon Sep 17 00:00:00 2001
From: Marcel Rieser
Date: Thu, 12 Oct 2023 11:19:34 +0200
Subject: [PATCH 2/2] pseudosim no longer depends on eventsbasedPtRouter
---
contribs/pseudosimulation/pom.xml | 5 --
.../ChoiceGenerationControler.java | 52 ++++++------
.../pseudosimulation/PSimDataProvider.java | 8 +-
.../contrib/pseudosimulation/RunPSim.java | 23 +++--
.../distributed/MasterControler.java | 24 +++---
.../distributed/SlaveControler.java | 39 +++------
.../pseudosimulation/mobsim/PSimProvider.java | 26 +++---
...ormanceFromEventBasedRouterInterfaces.java | 22 ++---
.../PSimStopStopTimeCalculator.java | 49 -----------
.../trafficinfo/PSimWaitTimeCalculator.java | 57 -------------
.../DeterministicStopStopTimeCalculator.java | 66 ---------------
.../DeterministicWaitTimeCalculator.java | 84 -------------------
.../contrib/pseudosimulation/RunPSimTest.java | 2 +-
13 files changed, 86 insertions(+), 371 deletions(-)
delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java
delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java
delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java
delete mode 100644 contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java
diff --git a/contribs/pseudosimulation/pom.xml b/contribs/pseudosimulation/pom.xml
index 3c8e45cc647..56b3b3b9bfc 100644
--- a/contribs/pseudosimulation/pom.xml
+++ b/contribs/pseudosimulation/pom.xml
@@ -15,11 +15,6 @@
common
16.0-SNAPSHOT
-
- org.matsim.contrib
- events-based-pt-router
- 16.0-SNAPSHOT
-
commons-cli
commons-cli
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java
index 00fc950cbcc..f3acb572ce8 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/ChoiceGenerationControler.java
@@ -6,9 +6,9 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Person;
import org.matsim.api.core.v01.population.Plan;
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
+//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
+//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorImpl;
+//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
@@ -34,8 +34,8 @@
*/
public class ChoiceGenerationControler implements BeforeMobsimListener{
- final WaitTimeStuckCalculator waitTimeCalculator;
- final StopStopTimeCalculatorImpl stopStopTimeCalculator;
+// final WaitTimeStuckCalculator waitTimeCalculator;
+// final StopStopTimeCalculatorImpl stopStopTimeCalculator;
final TravelTimeCalculator travelTimeCalculator;
private PSimProvider pSimProvider;
Config config;
@@ -49,23 +49,23 @@ public ChoiceGenerationControler(String[] args) {
scenario = ScenarioUtils.loadScenario(config);
controler = new Controler(scenario);
- waitTimeCalculator = new WaitTimeStuckCalculator(
- controler.getScenario().getPopulation(),
- controler.getScenario().getTransitSchedule(),
- controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds()));
- stopStopTimeCalculator = new StopStopTimeCalculatorImpl(
- controler.getScenario().getTransitSchedule(),
- controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
- (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds()));
- controler.addOverridingModule(new AbstractModule() {
- @Override
- public void install() {
- bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(),
- waitTimeCalculator.get(),
- stopStopTimeCalculator.get()));
- }
- });
+// waitTimeCalculator = new WaitTimeStuckCalculator(
+// controler.getScenario().getPopulation(),
+// controler.getScenario().getTransitSchedule(),
+// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
+// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds()));
+// stopStopTimeCalculator = new StopStopTimeCalculatorImpl(
+// controler.getScenario().getTransitSchedule(),
+// controler.getConfig().travelTimeCalculator().getTraveltimeBinSize(),
+// (int) (controler.getConfig().qsim().getEndTime().seconds() - controler.getConfig().qsim().getStartTime().seconds()));
+// controler.addOverridingModule(new AbstractModule() {
+// @Override
+// public void install() {
+// bind(TransitRouter.class).toProvider(new TransitRouterEventsWSFactory(controler.getScenario(),
+// waitTimeCalculator.get(),
+// stopStopTimeCalculator.get()));
+// }
+// });
// controler.setScoringFunctionFactory(
// new CharyparNagelOpenTimesScoringFunctionFactory(controler.getConfig().planCalcScore(),
// controler.getScenario()));
@@ -73,8 +73,8 @@ public void install() {
EventsManagerImpl eventsManager = new EventsManagerImpl();
EventsReaderXMLv1 reader = new EventsReaderXMLv1(eventsManager);
- eventsManager.addHandler(waitTimeCalculator);
- eventsManager.addHandler(stopStopTimeCalculator);
+// eventsManager.addHandler(waitTimeCalculator);
+// eventsManager.addHandler(stopStopTimeCalculator);
eventsManager.addHandler(travelTimeCalculator);
reader.readFile(args[1]);
@@ -106,8 +106,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) {
for(Person person:controler.getScenario().getPopulation().getPersons().values()){
plans.add(person.getSelectedPlan());
}
- pSimProvider.setWaitTime(waitTimeCalculator.get());
+// pSimProvider.setWaitTime(waitTimeCalculator.get());
pSimProvider.setTravelTime(travelTimeCalculator.getLinkTravelTimes());
- pSimProvider.setStopStopTime(stopStopTimeCalculator.get());
+// pSimProvider.setStopStopTime(stopStopTimeCalculator.get());
}
}
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java
index 7c6368c7528..461999c0120 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/PSimDataProvider.java
@@ -1,7 +1,7 @@
package org.matsim.contrib.pseudosimulation;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
+//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
+//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance;
import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher;
import org.matsim.core.router.util.TravelTime;
@@ -10,8 +10,8 @@
* Created by fouriep on 4/21/15.
*/
public interface PSimDataProvider {
- public StopStopTime getStopStopTime();
- public WaitTime getWaitTime();
+// public StopStopTime getStopStopTime();
+// public WaitTime getWaitTime();
public TransitPerformance getTransitPerformance();
public PlanCatcher getPlanCatcher();
public TravelTime getTravelTime();
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java
index 3df6ab05ecf..fde2b4a010c 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/RunPSim.java
@@ -23,18 +23,16 @@
import com.google.inject.Singleton;
import org.matsim.api.core.v01.Scenario;
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator;
+//import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
+//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
+//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator;
+//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
+//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator;
//import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformanceRecorder;
import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider;
import org.matsim.contrib.pseudosimulation.mobsim.SwitchingMobsimProvider;
import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher;
-import org.matsim.contrib.pseudosimulation.trafficinfo.PSimStopStopTimeCalculator;
import org.matsim.contrib.pseudosimulation.trafficinfo.PSimTravelTimeCalculator;
-import org.matsim.contrib.pseudosimulation.trafficinfo.PSimWaitTimeCalculator;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.AbstractModule;
@@ -43,7 +41,6 @@
import org.matsim.core.mobsim.qsim.QSimProvider;
import org.matsim.core.router.util.TravelTime;
import org.matsim.core.scenario.ScenarioUtils;
-import org.matsim.pt.router.TransitRouter;
/**
* @author pieterfourie
@@ -74,10 +71,10 @@ public RunPSim(Config config, PSimConfigGroup pSimConfigGroup) {
public void install() {
bind(MobSimSwitcher.class).toInstance(mobSimSwitcher);
bindMobsim().toProvider(SwitchingMobsimProvider.class);
- bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class);
- bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class);
- bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class);
- bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class);
+// bind(WaitTimeCalculator.class).to(PSimWaitTimeCalculator.class);
+// bind(WaitTime.class).toProvider(PSimWaitTimeCalculator.class);
+// bind(StopStopTimeCalculator.class).to(PSimStopStopTimeCalculator.class);
+// bind(StopStopTime.class).toProvider(PSimStopStopTimeCalculator.class);
// bind(TravelTimeCalculator.class).to(PSimTravelTimeCalculator.class);
// I made TravelTimeCalculator final, so PSimTravelTimeCalculator can no longer inherit from it. The following statement binds PSimTravelTimeCalculator
@@ -85,7 +82,7 @@ public void install() {
bind(PSimTravelTimeCalculator.class).in( Singleton.class ) ;
bind(TravelTime.class).toProvider(PSimTravelTimeCalculator.class);
- bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class);
+// bind(TransitRouter.class).toProvider(TransitRouterEventsWSFactory.class);
bind(PlanCatcher.class).toInstance(new PlanCatcher());
bind(PSimProvider.class).toInstance(new PSimProvider(scenario,matsimControler.getEvents()));
bind(QSimProvider.class);
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java
index 9e1e85a8450..acd92e861e5 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/MasterControler.java
@@ -23,8 +23,6 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.population.Person;
import org.matsim.api.core.v01.population.Plan;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable;
import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStats;
import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.GenomeAnalysis;
import org.matsim.contrib.pseudosimulation.distributed.listeners.controler.SlaveScoreWriter;
@@ -73,8 +71,8 @@ public class MasterControler implements AfterMobsimListener, ShutdownListener, S
private Config config;
private Controler matsimControler;
private TreeMap slaveHandlerTreeMap;
- private WaitTimeCalculatorSerializable waitTimeCalculator;
- private StopStopTimeCalculatorSerializable stopStopTimeCalculator;
+// private WaitTimeCalculatorSerializable waitTimeCalculator;
+// private StopStopTimeCalculatorSerializable stopStopTimeCalculator;
private TransitPerformanceRecorder transitPerformanceRecorder;
private SerializableLinkTravelTimes linkTravelTimes;
private AtomicInteger numThreads = new AtomicInteger(0);
@@ -180,13 +178,13 @@ public MasterControler(String configFile) throws NumberFormatException, IOExcept
if (this.config.transit().isUseTransit()) {
- waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(),
- (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds()));
- matsimControler.getEvents().addHandler(waitTimeCalculator);
- stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(),
- this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim()
- .getEndTime().seconds() - this.config.qsim().getStartTime().seconds()));
- matsimControler.getEvents().addHandler(stopStopTimeCalculator);
+// waitTimeCalculator = new WaitTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(), this.config.travelTimeCalculator().getTraveltimeBinSize(),
+// (int) (this.config.qsim().getEndTime().seconds() - this.config.qsim().getStartTime().seconds()));
+// matsimControler.getEvents().addHandler(waitTimeCalculator);
+// stopStopTimeCalculator = new StopStopTimeCalculatorSerializable(matsimControler.getScenario().getTransitSchedule(),
+// this.config.travelTimeCalculator().getTraveltimeBinSize(), (int) (this.config.qsim()
+// .getEndTime().seconds() - this.config.qsim().getStartTime().seconds()));
+// matsimControler.getEvents().addHandler(stopStopTimeCalculator);
//tell PlanSerializable to record transit routes
PlanSerializable.isUseTransit = true;
if (fullTransitPerformanceTransmission) {
@@ -778,8 +776,8 @@ public void transmitTravelTimes() throws IOException {
writer.writeInt(currentIteration);
writer.writeObject(linkTravelTimes);
if (config.transit().isUseTransit()) {
- writer.writeObject(stopStopTimeCalculator.getStopStopTimes());
- writer.writeObject(waitTimeCalculator.getWaitTimes());
+// writer.writeObject(stopStopTimeCalculator.getStopStopTimes());
+// writer.writeObject(waitTimeCalculator.getWaitTimes());
if (fullTransitPerformanceTransmission)
writer.writeObject(transitPerformanceRecorder.getTransitPerformance());
}
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java
index a45f80ba4d6..5ec460d62d9 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/distributed/SlaveControler.java
@@ -28,11 +28,6 @@
import org.matsim.api.core.v01.population.Person;
import org.matsim.api.core.v01.population.Plan;
import org.matsim.contrib.common.diversitygeneration.planselectors.DiversityGeneratingPlansRemover;
-import org.matsim.contrib.eventsBasedPTRouter.TransitRouterEventsWSFactory;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable;
import org.matsim.contrib.pseudosimulation.distributed.instrumentation.scorestats.SlaveScoreStatsCalculator;
import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance;
import org.matsim.contrib.pseudosimulation.mobsim.PSimProvider;
@@ -86,8 +81,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener,
private double totalIterationTime;
private Controler matsimControler;
private TravelTime linkTravelTimes;
- private WaitTime waitTimes;
- private StopStopTime stopStopTimes;
private ObjectInputStream reader;
private ObjectOutputStream writer;
private PSimProvider pSimProvider;
@@ -97,7 +90,6 @@ public class SlaveControler implements IterationStartsListener, StartupListener,
private boolean isOkForNextIter = true;
private Map, Double> selectedPlanScoreMemory;
private TransitPerformance transitPerformance;
- private TransitRouterEventsWSFactory transitRouterEventsWSFactory;
private void printHelp(Options options) {
String header = "The MasterControler takes the following options:\n\n";
@@ -268,15 +260,6 @@ public void install() {
});
if (config.transit().isUseTransit()) {
-
- stopStopTimes = new StopStopTimeCalculatorSerializable(scenario.getTransitSchedule(),
- config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config
- .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getStopStopTimes();
-
- waitTimes = new WaitTimeCalculatorSerializable(scenario.getTransitSchedule(),
- config.travelTimeCalculator().getTraveltimeBinSize(), (int) (config
- .qsim().getEndTime().seconds() - config.qsim().getStartTime().seconds())).getWaitTimes();
-
// tell PlanSerializable to record transit routes
PlanSerializable.isUseTransit = true;
@@ -285,11 +268,11 @@ public void install() {
matsimControler.addOverridingModule(new AbstractModule() {
@Override
public void install() {
- System.out.println("init routers");
+// System.out.println("init routers");
// transitRouterEventsWSFactory = new TransitRouterEventsWSFactory(scenario,
// waitTimes,
// stopStopTimes);
- bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory);
+// bind(TransitRouter.class).toProvider(transitRouterEventsWSFactory);
}
});
@@ -387,13 +370,13 @@ public void notifyIterationStarts(IterationStartsEvent event) {
travelTime.setTravelTime(linkTravelTimes);
pSimProvider.setTravelTime(linkTravelTimes);
if (config.transit().isUseTransit()) {
- pSimProvider.setStopStopTime(stopStopTimes);
- pSimProvider.setWaitTime(waitTimes);
- pSimProvider.setTransitPerformance(transitPerformance);
- if (transitRouterEventsWSFactory != null) {
+// pSimProvider.setStopStopTime(stopStopTimes);
+// pSimProvider.setWaitTime(waitTimes);
+// pSimProvider.setTransitPerformance(transitPerformance);
+// if (transitRouterEventsWSFactory != null) {
// transitRouterEventsWSFactory.setStopStopTimeCalculator(stopStopTimes);
// transitRouterEventsWSFactory.setWaitTimeCalculator(waitTimes);
- }
+// }
}
plancatcher.init();
numberOfIterations++;
@@ -449,8 +432,8 @@ public void transmitTravelTimes() throws IOException, ClassNotFoundException {
masterCurrentIteration = reader.readInt();
linkTravelTimes = (SerializableLinkTravelTimes) reader.readObject();
if (config.transit().isUseTransit()) {
- stopStopTimes = (StopStopTime) reader.readObject();
- waitTimes = (WaitTime) reader.readObject();
+// stopStopTimes = (StopStopTime) reader.readObject();
+// waitTimes = (WaitTime) reader.readObject();
if (fullTransitPerformanceTransmission) {
Object o = reader.readObject();
transitPerformance = (TransitPerformance) o;
@@ -619,8 +602,8 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) {
@Override
public void notifyIterationEnds(IterationEndsEvent event) {
Iterator, Double>> iterator = selectedPlanScoreMemory.entrySet().iterator();
- StopStopTimeCalculatorSerializable.printCallStatisticsAndReset();
- WaitTimeCalculatorSerializable.printCallStatisticsAndReset();
+// StopStopTimeCalculatorSerializable.printCallStatisticsAndReset();
+// WaitTimeCalculatorSerializable.printCallStatisticsAndReset();
while (iterator.hasNext()) {
Map.Entry, Double> entry = iterator.next();
scenario.getPopulation().getPersons().get(entry.getKey()).getSelectedPlan().setScore(entry.getValue());
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java
index 2759e9c38be..baa9619edc4 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/PSimProvider.java
@@ -4,8 +4,6 @@
package org.matsim.contrib.pseudosimulation.mobsim;
import org.matsim.api.core.v01.Scenario;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
import org.matsim.contrib.pseudosimulation.distributed.listeners.events.transit.TransitPerformance;
import org.matsim.contrib.pseudosimulation.mobsim.transitperformance.TransitEmulator;
import org.matsim.contrib.pseudosimulation.replanning.PlanCatcher;
@@ -42,25 +40,25 @@ public void setTravelTime(TravelTime travelTime) {
this.travelTime = travelTime;
}
- @Deprecated
- public void setWaitTime(WaitTime waitTime) {
- throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
- }
+// @Deprecated
+// public void setWaitTime(WaitTime waitTime) {
+// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
+// }
- @Deprecated
- public void setStopStopTime(StopStopTime stopStopTime) {
- throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
- }
+// @Deprecated
+// public void setStopStopTime(StopStopTime stopStopTime) {
+// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
+// }
@Deprecated
public void setTransitPerformance(TransitPerformance transitPerformance) {
throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
}
- @Deprecated
- public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) {
- throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
- }
+// @Deprecated
+// public void setTimes(TravelTime travelTime, WaitTime waitTime, StopStopTime stopStopTime) {
+// throw new RuntimeException("Use an instance of " + TransitEmulator.class.getSimpleName() + " instead.");
+// }
@Deprecated
//will replace where necessary
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java
index 13f2536ddf9..e767a863b02 100644
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java
+++ b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/mobsim/transitperformance/TransitPerformanceFromEventBasedRouterInterfaces.java
@@ -1,6 +1,6 @@
/*
* Copyright 2018 Gunnar Flötteröd
- *
+ *
* 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 3 of the License, or
@@ -23,8 +23,8 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.population.Leg;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
+//import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
+//import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
import org.matsim.pt.routes.TransitPassengerRoute;
import org.matsim.pt.transitSchedule.TransitRouteImpl;
import org.matsim.pt.transitSchedule.api.TransitLine;
@@ -44,16 +44,16 @@
*/
public class TransitPerformanceFromEventBasedRouterInterfaces implements TransitEmulator {
- private WaitTime waitTimes;
- private StopStopTime stopStopTimes;
+// private WaitTime waitTimes;
+// private StopStopTime stopStopTimes;
private Map, TransitLine> transitLines;
private Map, TransitStopFacility> stopFacilities;
@Inject
- public TransitPerformanceFromEventBasedRouterInterfaces(WaitTime waitTimes, StopStopTime stopStopTimes,
+ public TransitPerformanceFromEventBasedRouterInterfaces(/*WaitTime waitTimes, StopStopTime stopStopTimes,*/
TransitSchedule transitSchedule) {
- this.waitTimes = waitTimes;
- this.stopStopTimes = stopStopTimes;
+// this.waitTimes = waitTimes;
+// this.stopStopTimes = stopStopTimes;
this.transitLines = transitSchedule.getTransitLines();
this.stopFacilities = transitSchedule.getFacilities();
}
@@ -65,8 +65,8 @@ public Trip findTrip(Leg prevLeg, double earliestDepartureTime_s) {
TransitLine line = this.transitLines.get(route.getLineId());
TransitRoute transitRoute = line.getRoutes().get(route.getRouteId());
- final double accessTime_s = earliestDepartureTime_s + this.waitTimes.getRouteStopWaitTime(route.getLineId(),
- transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s);
+ final double accessTime_s = earliestDepartureTime_s /*+ this.waitTimes.getRouteStopWaitTime(route.getLineId(),
+ transitRoute.getId(), route.getAccessStopId(), earliestDepartureTime_s)*/;
final double egressTime_s = accessTime_s + this.findTransitTravelTime(route, accessTime_s);
return new Trip(null, accessTime_s, egressTime_s);
}
@@ -99,7 +99,7 @@ private double findTransitTravelTime(TransitPassengerRoute route, double prevEnd
Id fromId = transitRoute.getStops().get(i).getStopFacility().getId();
TransitRouteStop toStop = transitRoute.getStops().get(i + 1);
Id toId = toStop.getStopFacility().getId();
- travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime);
+// travelTime += stopStopTimes.getStopStopTime(fromId, toId, prevStopTime);
prevStopTime += travelTime;
if (toStop.getStopFacility().getId().equals(dest)) {
destinationFound = true;
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java
deleted file mode 100644
index 4b1a0e49a21..00000000000
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimStopStopTimeCalculator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.matsim.contrib.pseudosimulation.trafficinfo;
-
-import com.google.inject.Singleton;
-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.events.PersonLeavesVehicleEvent;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculatorSerializable;
-import org.matsim.contrib.pseudosimulation.MobSimSwitcher;
-import org.matsim.core.api.experimental.events.EventsManager;
-import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent;
-import org.matsim.core.config.Config;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-
-import jakarta.inject.Inject;
-
-@Singleton
-public class PSimStopStopTimeCalculator extends StopStopTimeCalculatorSerializable {
- private final MobSimSwitcher switcher;
-
- @Inject
- PSimStopStopTimeCalculator(Scenario scenario, MobSimSwitcher switcher, EventsManager eventsManager) {
- super(scenario.getTransitSchedule(),scenario.getConfig() );
- this.switcher = switcher;
- eventsManager.addHandler(this);
- }
-
- @Override
- public void reset(int iteration) {
- if (switcher.isQSimIteration()) {
- LogManager.getLogger(this.getClass()).error(
- "Calling reset on traveltimecalc");
- super.reset(iteration);
- }
- }
-
- @Override
- public void handleEvent(VehicleArrivesAtFacilityEvent event) {
- if (switcher.isQSimIteration())
- super.handleEvent(event);
- }
-
- @Override
- public void handleEvent(PersonLeavesVehicleEvent event) {
- if (switcher.isQSimIteration())
- super.handleEvent(event);
- }
-
-}
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java
deleted file mode 100644
index f618a5c8a45..00000000000
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/PSimWaitTimeCalculator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.matsim.contrib.pseudosimulation.trafficinfo;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-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.events.PersonDepartureEvent;
-import org.matsim.api.core.v01.events.PersonEntersVehicleEvent;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculatorSerializable;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeStuckCalculator;
-import org.matsim.contrib.pseudosimulation.MobSimSwitcher;
-import org.matsim.core.api.experimental.events.EventsManager;
-
-
-/**
- * @author fouriep
- *
- * Extends Ordonez's {@link WaitTimeStuckCalculator} to only handle
- * events during QSim iterations.
- */
-@Singleton
-public class PSimWaitTimeCalculator extends WaitTimeCalculatorSerializable {
- private final MobSimSwitcher switcher;
-
- @Inject
- public PSimWaitTimeCalculator(Scenario scenario,
- MobSimSwitcher switcher, EventsManager eventsManager) {
- super(scenario.getTransitSchedule(),scenario.getConfig());
- this.switcher = switcher;
- eventsManager.addHandler(this);
- }
-
- @Override
- public void reset(int iteration) {
- if (switcher.isQSimIteration()) {
- LogManager.getLogger(this.getClass()).error(
- "Calling reset on traveltimecalc");
- super.reset(iteration);
- }
- }
-
- @Override
- public void handleEvent(PersonDepartureEvent event) {
- if (switcher.isQSimIteration())
- super.handleEvent(event);
- }
-
- @Override
- public void handleEvent(PersonEntersVehicleEvent event) {
- if (switcher.isQSimIteration())
- super.handleEvent(event);
- }
-
-
-
-}
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java
deleted file mode 100644
index 567187f053d..00000000000
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicStopStopTimeCalculator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic;
-
-import java.util.List;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.api.core.v01.population.Leg;
-import org.matsim.api.core.v01.population.PlanElement;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTime;
-import org.matsim.contrib.eventsBasedPTRouter.stopStopTimes.StopStopTimeCalculator;
-import org.matsim.core.router.DefaultRoutingRequest;
-import org.matsim.pt.router.TransitRouter;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-import org.matsim.utils.objectattributes.attributable.Attributes;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-public class DeterministicStopStopTimeCalculator implements StopStopTimeCalculator {
- private final TransitRouter transitRouter;
- private final TransitSchedule schedule;
-
- @Inject
- public DeterministicStopStopTimeCalculator(TransitRouter transitRouter, TransitSchedule schedule) {
- this.transitRouter = transitRouter;
- this.schedule = schedule;
- }
-
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId, double time) {
- // ATTENTION! This could be optimized. Basically, we probably don't need to
- // route here. However, finding the travel time even on one route is not a
- // computationally efficient task, because the same transit stop id may occur
- // multiple times on the same route.
-
- TransitStopFacility originFacility = schedule.getFacilities().get(stopOId);
- TransitStopFacility destinationFacility = schedule.getFacilities().get(stopDId);
-
- List extends PlanElement> legs = transitRouter.calcRoute(DefaultRoutingRequest.withoutAttributes(originFacility, destinationFacility, time, null));
- return legs.stream().mapToDouble(l -> ((Leg)l).getTravelTime().seconds()).sum();
- }
-
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId,
- double time) {
- return 0.0;
- }
-
- @Override
- public StopStopTime get() {
- return new StopStopTime() {
- @Override
- public double getStopStopTimeVariance(Id stopOId, Id stopDId,
- double time) {
- return 0.0;
- }
-
- @Override
- public double getStopStopTime(Id stopOId, Id stopDId,
- double time) {
- return DeterministicStopStopTimeCalculator.this.getStopStopTime(stopOId, stopDId, time);
- }
- };
- }
-}
diff --git a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java b/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java
deleted file mode 100644
index d1aa43ce61b..00000000000
--- a/contribs/pseudosimulation/src/main/java/org/matsim/contrib/pseudosimulation/trafficinfo/deterministic/DeterministicWaitTimeCalculator.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.matsim.contrib.pseudosimulation.trafficinfo.deterministic;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.matsim.api.core.v01.Id;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTime;
-import org.matsim.contrib.eventsBasedPTRouter.waitTimes.WaitTimeCalculator;
-import org.matsim.pt.transitSchedule.api.Departure;
-import org.matsim.pt.transitSchedule.api.TransitLine;
-import org.matsim.pt.transitSchedule.api.TransitRoute;
-import org.matsim.pt.transitSchedule.api.TransitRouteStop;
-import org.matsim.pt.transitSchedule.api.TransitSchedule;
-import org.matsim.pt.transitSchedule.api.TransitStopFacility;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-public class DeterministicWaitTimeCalculator implements WaitTimeCalculator {
- private final TransitSchedule schedule;
-
- @Inject
- public DeterministicWaitTimeCalculator(TransitSchedule schedule) {
- this.schedule = schedule;
- }
-
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId, Id stopId,
- double time) {
- TransitRoute route = schedule.getTransitLines().get(lineId).getRoutes().get(routeId);
-
- // First collect all the offsets on the route for a specific transit stop id.
- // Note that a single transit facility may be contained multiple times on a
- // route!
- List facilityOffsets = new LinkedList<>();
-
- for (TransitRouteStop stop : route.getStops()) {
- if (stop.getStopFacility().getId().equals(stopId)) {
- facilityOffsets.add(stop.getDepartureOffset().seconds());
- }
- }
-
- if (facilityOffsets.size() == 0) {
- // The facility is not contained on this route
- throw new IllegalStateException();
- }
-
- // Now loop through all the departures and routes and find the actual stop
- // departure that is right after the given time.
-
- double minimumWaitTime = Double.POSITIVE_INFINITY;
-
- for (double offset : facilityOffsets) {
- for (Departure departure : route.getDepartures().values()) {
- double stopDepartureTime = departure.getDepartureTime() + offset;
-
- while (stopDepartureTime < time) {
- // Consistent with TransitRouterNetworkTravelTimeAndDisutility.MIDNIGHT
- stopDepartureTime += 24.0 * 3600;
- }
-
- double waitTime = time - stopDepartureTime;
-
- if (waitTime < minimumWaitTime) {
- minimumWaitTime = waitTime;
- }
- }
- }
-
- return minimumWaitTime;
- }
-
- @Override
- public WaitTime get() {
- return new WaitTime() {
- @Override
- public double getRouteStopWaitTime(Id lineId, Id routeId,
- Id