Closed MaartenBehn closed 1 year ago
can we close #67 and #70?
can we close #67 and #70?
yeah sure
I've added two Nesterov versions one normal that should work with every and one only for primitive shapes. The primitive shapes Version is faster in calculating the distance than Jolt. In every other case jolt is the fastest.
Ready to merge.
When running an normal unit test the coverage is not 100% this is because it takes ages to run randomly take get every possible simplex configuration. I have added a function "test_compare_gjk_intersection_with_random_shapes_extensive()" that gets the coverage up to 100% but the function is commented out because it takes just too long and is not really relevant for a regular unit testing.
Unit tests are failing now when merging to master:
FAILED distance3d/test/test_gjk.py::test_gjk_boxes - AttributeError: 'Box' object has no attribute 'frame'
FAILED distance3d/test/test_gjk.py::test_gjk_spheres - AttributeError: 'Sphere' object has no attribute 'frame'
FAILED distance3d/test/test_gjk.py::test_gjk_cylinders - AttributeError: 'Cylinder' object has no attribute 'frame'
FAILED distance3d/test/test_gjk.py::test_gjk_capsules - AttributeError: 'Capsule' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_compare_gjk_intersection_flavours_with_random_shapes - AttributeError: 'Capsule' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_compare_gjk_intersection_flavours_with_random_shapes_with_nesterov_acceleration - AttributeError: 'Capsule' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_iterations - AttributeError: 'Sphere' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_to_many_iterations - AttributeError: 'Cylinder' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_to_far - AttributeError: 'Cylinder' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_compare_gjk_intersection_all_shapes - AttributeError: 'Capsule' object has no attribute 'frame'
FAILED distance3d/test/test_gjk_nesterov.py::test_compare_gjk_intersection_only_mesh - AttributeError: 'MeshGraph' object has no attribute 'frame'
@MaartenBehn Could you fix the unit tests?
Unfortunately, two of the benchmarks fail:
python benchmarks/benchmark_gjk.py
Original Mean: 0.11491; Std. dev.: 0.00319
Jolt:
Jolt intersection with Numba Mean: 0.00479; Std. dev.: 0.00552
Jolt intersection Mean: 0.00295; Std. dev.: 0.00005
Jolt distance with Numba Mean: 0.03174; Std. dev.: 0.00935
Jolt distance Mean: 0.02860; Std. dev.: 0.00008
Nesterov accelerated:
Nesterov Mean: 0.06174; Std. dev.: 0.01163
Nesterov with Numba Mean: 0.05728; Std. dev.: 0.00013
Nesterov with acceleration Mean: 0.08942; Std. dev.: 0.00027
Nesterov with acceleration and Numba Mean: 0.09004; Std. dev.: 0.00239
Nesterov accelerated Primitives:
Traceback (most recent call last):
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/benchmarks/benchmark_gjk.py", line 100, in <module>
times = timeit.repeat(benchmark_nesterov_accelerated_primitives, repeat=10, number=1)
File "/home/dfki.uni-bremen.de/afabisch/anaconda3/lib/python3.9/timeit.py", line 238, in repeat
return Timer(stmt, setup, timer, globals).repeat(repeat, number)
File "/home/dfki.uni-bremen.de/afabisch/anaconda3/lib/python3.9/timeit.py", line 205, in repeat
t = self.timeit(number)
File "/home/dfki.uni-bremen.de/afabisch/anaconda3/lib/python3.9/timeit.py", line 177, in timeit
timing = self.inner(it, self.timer)
File "<timeit-src>", line 6, in inner
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/benchmarks/benchmark_gjk.py", line 51, in benchmark_nesterov_accelerated_primitives
gjk_nesterov_accelerated_primitives(shapes[i][0], shapes[i][1], use_nesterov_acceleration=False)
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/distance3d/gjk/_gjk_nesterov_accelerated_primitives.py", line 136, in gjk_nesterov_accelerated_primitives
minkowski_diff = get_minkowski_diff(collider0, collider1)
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/distance3d/gjk/_gjk_nesterov_accelerated_primitives.py", line 99, in get_minkowski_diff
data1, type1 = get_data_from_collider(collider1)
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/distance3d/gjk/_gjk_nesterov_accelerated_primitives.py", line 128, in get_data_from_collider
assert type(collider) == Cylinder
AssertionError
python benchmarks/compare_gjk_iterations.py
Case: 0
Traceback (most recent call last):
File "/home/dfki.uni-bremen.de/afabisch/Projekte/distance3d/benchmarks/compare_gjk_iterations.py", line 27, in <module>
collider1.round_values(6)
AttributeError: 'Cylinder' object has no attribute 'round_values'
@MaartenBehn
Merged, finally. :D Thanks for the contribution!
If you want to further tinker with the performance of GJK Nasterov please use this state of the code for easy merge later.