All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.graphhopper.routing.util.ConsistentWeightApproximator Maven / Gradle / Ivy

Go to download

GraphHopper is a fast and memory efficient Java road routing engine working seamlessly with OpenStreetMap data.

There is a newer version: 0.7.0
Show newest version
package com.graphhopper.routing.util;

/**
 * Turns an unidirectional weight Approximation into a bidirectional consistent one.
 * 

* Ikeda, T., Hsu, M.-Y., Imai, H., Nishimura, S., Shimoura, H., Hashimoto, T., Tenmoku, K., and * Mitoh, K. (1994). A fast algorithm for finding better routes by ai search techniques. In VNIS, * pages 291–296. *

* @author jansoe */ public class ConsistentWeightApproximator { private final WeightApproximator uniDirApproximatorForward, uniDirApproximatorReverse; public ConsistentWeightApproximator( WeightApproximator weightApprox ) { uniDirApproximatorForward = weightApprox; uniDirApproximatorReverse = weightApprox.duplicate(); } public void setSourceNode( int sourceNode ) { uniDirApproximatorReverse.setGoalNode(sourceNode); } public void setGoalNode( int goalNode ) { uniDirApproximatorForward.setGoalNode(goalNode); } public double approximate( int fromNode, boolean reverse ) { double weightApproximation = 0.5 * (uniDirApproximatorForward.approximate(fromNode) - uniDirApproximatorReverse.approximate(fromNode)); if (reverse) return -weightApproximation; return weightApproximation; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy