/** * 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(); }
/** * 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(); }
/** * 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. */ private double getPriority(final DijkstraNodeData data) { return data.getCost(); }
public double getCost(Node toNode) { return getData(toNode).getCost(); } }
private void expandNodeData(final Map<Node, InitialNode> toNodes) { Set<Node> endNodes = new HashSet<>(toNodes.keySet()); double minCost = Double.POSITIVE_INFINITY; // do the real work while (endNodes.size() > 0) { Node outNode = pendingNodes.poll(); if (outNode == null) { // seems we have no more nodes left, but not yet reached all endNodes... endNodes.clear(); } else { DijkstraNodeData data = getData(outNode); boolean isEndNode = endNodes.remove(outNode); if (isEndNode) { InitialNode initData = toNodes.get(outNode); double cost = data.getCost() + initData.initialCost; if (cost < minCost) { minCost = cost; } } if (data.getCost() > minCost) { endNodes.clear(); // we can't get any better now } else { relaxNode(outNode, pendingNodes); } } } }
@Override protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { ArrayList<Node> nodes = new ArrayList<Node>(); ArrayList<Link> links = new ArrayList<Link>(); nodes.add(0, toNode); Link tmpLink = getData(toNode).getPrevLink(); // Only this part has been adapted. Could probably also be changed in the super class. while (tmpLink != null) { links.add(0, tmpLink); nodes.add(0, tmpLink.getFromNode()); tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); } // Ignore the initial time and cost of the start node! DijkstraNodeData startNodeData = getData(nodes.get(0)); DijkstraNodeData toNodeData = getData(toNode); Path path = new Path(nodes, links, toNodeData.getTime() - startNodeData.getTime(), toNodeData.getCost() - startNodeData.getCost()); // double travelTime = arrivalTime - startTime; // Path path = new Path(nodes, links, travelTime, toNodeData.getCost()); return path; }
/** * Expands the given Node in the routing algorithm; may be overridden in * sub-classes. * * @param outNode * The Node to be expanded. * @param pendingNodes * The set of pending nodes so far. */ protected void relaxNode(final Node outNode, final RouterPriorityQueue<Node> pendingNodes) { DijkstraNodeData outData = getData(outNode); double currTime = outData.getTime(); double currCost = outData.getCost(); for (Link l : outNode.getOutLinks().values()) { relaxNodeLogic(l, pendingNodes, currTime, currCost); } }
@Override protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { LinkedList<Link> links = new LinkedList<>(); Link tmpLink = getData(toNode).getPrevLink(); if (tmpLink != null) { while (tmpLink.getFromNode() != fromNode) { links.add(tmpLink); tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); } links.add(tmpLink); } return new Path(null, ImmutableList.copyOf(links.descendingIterator()), arrivalTime - startTime, getData(toNode).getCost()); } }
/** * 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. */ protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { List<Node> nodes = new ArrayList<>(); List<Link> 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 path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost()); return path; }
@Override public Path calcLeastCostPath(final Node fromNode, final Node toNode, final double startTime, final Person person, final Vehicle vehicle) { // yyyyyy could you please explain why this needs to be re-implemented? I would feel better if this would just use the method of // the original class. kai, jan'13 // now construct the path ArrayList<Node> nodes = new ArrayList<Node>(); ArrayList<Link> links = new ArrayList<Link>(); 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()); } // arrival time was not ok in earlier versions! DijkstraNodeData toNodeData = getData(toNode); double arrivalTime = toNodeData.getTime(); Path path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost()); return path; }
path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost());
/** * 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 Node toNode, final RouterPriorityQueue<Node> 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, toNode, ddOutData); } } else { // this.pruneDeadEnds == false for (Link l : outNode.getOutLinks().values()) { relaxNodeLogic(l, pendingNodes, currTime, currCost, toNode, 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<Node> 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); } } }
Path path = new Path(nodes, links, travelTime, toNodeData.getCost());
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
double currCost = outData.getCost(); if (this.pruneDeadEnds) { PreProcessDijkstra.DeadEndData ddOutData = getPreProcessData(outNode);
double nCost = data.getCost(); if (!data.isVisited(this.iterationID)) { visitNode(n, data, pendingNodes, currTime + travelTime, currCost
double travelCost = this.costFunction.getLinkTravelDisutility(l, currTime, this.person, this.vehicle, this.customDataManager); DijkstraNodeData data = getData(n); double nCost = data.getCost(); if (!data.isVisited(getIterationId())) { visitNode(n, data, pendingNodes, currTime + travelTime, currCost + travelCost, l);
double nCost = data.getCost(); if (!data.isVisited(getIterationId())) { visitNode(n, data, pendingNodes, currTime + travelTime, currCost + travelCost, l);
final double nCost = data.getCost(); final double totalCost = currCost + travelCost; if (totalCost < nCost) {