public TransitLeastCostPathTree(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction, final Map<Node, InitialNode> fromNodes, final Map<Node, InitialNode> toNodes, final Person person) { this.network = network; this.costFunction = costFunction; this.timeFunction = timeFunction; this.nodeData = new HashMap<>((int)(network.getNodes().size() * 1.1), 0.95f); //create tree this.resetNetworkVisited(); this.person = person; this.customDataManager.reset(); this.fromNodes = fromNodes; pendingNodes = (RouterPriorityQueue<Node>) createRouterPriorityQueue(); for (Map.Entry<Node, InitialNode> entry : fromNodes.entrySet()) { DijkstraNodeData data = getData(entry.getKey()); visitNode(entry.getKey(), data, pendingNodes, entry.getValue().initialTime, entry.getValue().initialCost, null); } expandNodeData(toNodes); }
final double currCost) { this.customDataManager.initForLink(l); double travelTime = this.timeFunction.getLinkTravelTime(l, currTime, this.person, this.vehicle); double travelCost = this.costFunction.getLinkTravelDisutility(l, currTime, this.person, this.vehicle, this.customDataManager); if (!data.isVisited(getIterationId())) { visitNode(n, data, pendingNodes, currTime + travelTime, currCost + travelCost, l); this.customDataManager.storeTmpData(); return true; if (totalCost < nCost) { revisitNode(n, data, pendingNodes, currTime + travelTime, totalCost, l); this.customDataManager.storeTmpData(); return true;
@Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle, CustomDataManager dataManager) { double val = this.routerDisutility.getLinkTravelDisutility(link, time, person, vehicle, dataManager); System.out.print("handling link " + ((TransitRouterNetworkNode) link.getFromNode()).getStop().getStopFacility().getId() + ">" + ((TransitRouterNetworkNode) link.getToNode()).getStop().getStopFacility().getId()); ArrayList<LoggerData> links = new ArrayList<LoggerData>(); Object o = dataManager.getFromNodeCustomData(); if (o instanceof ArrayList) { links.addAll((Collection<? extends LoggerData>) o); } links.add(new LoggerData(link, time)); String newState = Arrays.toString(links.toArray(new LoggerData[links.size()])); System.out.println(" : " + newState); this.states.add(newState); dataManager.setToNodeCustomData(links); return val; }
public TransitLeastCostPathTree(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction, final Map<Node, InitialNode> fromNodes, final Person person) { this.network = network; this.costFunction = costFunction; this.timeFunction = timeFunction; this.nodeData = new HashMap<>((int)(network.getNodes().size() * 1.1), 0.95f); //create tree this.resetNetworkVisited(); this.person = person; this.customDataManager.reset(); this.fromNodes = fromNodes; pendingNodes = (RouterPriorityQueue<Node>) createRouterPriorityQueue(); for (Map.Entry<Node, InitialNode> entry : fromNodes.entrySet()) { DijkstraNodeData data = getData(entry.getKey()); visitNode(entry.getKey(), data, pendingNodes, entry.getValue().initialTime, entry.getValue().initialCost, null); } // do the real work while (pendingNodes.size() > 0) { Node outNode = pendingNodes.poll(); relaxNode(outNode, pendingNodes); } }