Only refine individual solutions when error > TOLERANCE

This commit is contained in:
Rafa de la Torre
2016-07-05 18:36:28 +02:00
parent 2d95601c5a
commit 77cdc3d8ff

View File

@@ -56,11 +56,13 @@ class MapzenIsolines:
# let's refine the solution, binary search
for j in xrange(0, self.NUMBER_OF_ANGLES):
if errors[j] > 0:
rmax[j] = (rmax[j] + rmin[j]) / 2.0
else:
rmin[j] = (rmax[j] + rmin[j]) / 2.0
location_estimates[j] = self._calculate_dest_location(origin, angles[j], (rmax[j]+rmin[j])/2.0)
if abs(errors[j]) > self.TOLERANCE:
if errors[j] > 0:
rmax[j] = (rmax[j] + rmin[j]) / 2.0
else:
rmin[j] = (rmax[j] + rmin[j]) / 2.0
location_estimates[j] = self._calculate_dest_location(origin, angles[j], (rmax[j]+rmin[j])/2.0)
# and check "actual" costs again
resp = self._matrix_client.one_to_many([origin] + location_estimates, 'pedestrian')