use of com.github.davidmoten.rtree2.geometry.Rectangle in project Pathfinder2 by Wobblyyyy.
the class TestPathOptimizer method testNonlinearOptimization.
@Test
public void testNonlinearOptimization() {
Rectangle blockerShape = new Rectangle(5, 1, 6, 10);
Zone blockerZone = new Zone(blockerShape);
List<Zone> zones = new ArrayList<Zone>() {
{
add(blockerZone);
}
};
LocalizedPathGen gen = new LocalizedPathGen(zones, 0.5, 0.5);
PointXY start = new PointXY(0, 0);
PointXY end = new PointXY(10, 10);
List<PointXY> unoptimized = gen.getPath(start, end);
List<PointXY> optimized = PathOptimizer.optimize(unoptimized);
List<PointXY> overOptimized = PathOptimizer.optimize(optimized);
Assertions.assertNotNull(unoptimized);
Assertions.assertNotNull(optimized);
Assertions.assertNotNull(overOptimized);
int unoptimizedSize = unoptimized.size();
int optimizedSize = optimized.size();
int overOptimizedSize = overOptimized.size();
double unoptimizedLength = PathOptimizer.determineLength(unoptimized);
double optimizedLength = PathOptimizer.determineLength(optimized);
double overOptimizedLength = PathOptimizer.determineLength(overOptimized);
// Assertions.assertEquals(30, unoptimizedSize);
// Assertions.assertEquals(16, optimizedSize);
// Assertions.assertEquals(16, overOptimizedSize);
// Assertions.assertTrue(Equals.soft(16.778, unoptimizedLength, 0.01));
// Assertions.assertEquals(optimizedLength, overOptimizedLength);
}
Aggregations