def test_ChunkedTravelingSalesman(): n = 500 x = np.random.rand(n) * 4e3 y = np.random.rand(n) * 4e3 points = tabular.DictSource({'x_um': x, 'y_um': y}) recipe = base.ModuleCollection() recipe.add_module( measurement.ChunkedTravelingSalesperson(output='output', epsilon=0.001, points_per_chunk=50)) recipe.namespace['input'] = points ordered = recipe.execute() assert ordered.mdh['TravelingSalesperson.Distance'] < ordered.mdh[ 'TravelingSalesperson.OriginalDistance']
epsilon=0.001, points_per_chunk=50)) recipe.namespace['input'] = points ordered = recipe.execute() assert ordered.mdh['TravelingSalesperson.Distance'] < ordered.mdh[ 'TravelingSalesperson.OriginalDistance'] if __name__ == '__main__': import time n = 10000 x = np.random.rand(n) * 4e3 y = np.random.rand(n) * 4e3 points = tabular.DictSource({'x_um': x, 'y_um': y}) recipe = base.ModuleCollection() recipe.add_module( measurement.ChunkedTravelingSalesperson(output='output', epsilon=0.001, points_per_chunk=500)) recipe.namespace['input'] = points t = time.time() ordered = recipe.execute() print('n_points: %d, runtime: %f' % (n, time.time() - t)) print('og distance: %f, distance: %f' % (ordered.mdh['TravelingSalesperson.OriginalDistance'], ordered.mdh['TravelingSalesperson.Distance']))