snake_order_test.py
Go to the documentation of this file.
1 #==============================================================================
2 # Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 # Author: Gonzalo Mier
4 # BSD-3 License
5 #==============================================================================
6 
7 import pytest
8 import fields2cover as f2c
9 
10 def near(a, b):
11  assert pytest.approx(a) == pytest.approx(b)
12 
13 
15  n = 11;
16  swaths = f2c.Swaths();
17  for i in range(1, n):
18  swaths.push_back(f2c.Swath(f2c.LineString(f2c.VectorPoint( \
19  [f2c.Point(0, i), f2c.Point(1, i)])), i, i));
20 
21  swath_sorter = f2c.RP_Snake();
22  objective = f2c.OBJ_DirectDistPathObj();
23 
24  swaths = swath_sorter.genSortedSwaths(swaths, 0);
25 
26  near(swaths[0].getWidth(), 1);
27  near(swaths[1].getWidth(), 3);
28  near(swaths[2].getWidth(), 5);
29  near(swaths.back().getWidth(), 2);
30 
31  near(objective.computeCost(swaths), 3*((n-1)-1));
32 
33 
35  n = 100;
36  swaths = f2c.Swaths();
37  for i in range(1, n):
38  swaths.push_back(f2c.Swath(f2c.LineString(f2c.VectorPoint( \
39  [f2c.Point(0, i), f2c.Point(1, i)])), i, i));
40 
41  swath_sorter = f2c.RP_Snake();
42  objective = f2c.OBJ_DirectDistPathObj();
43 
44  swaths = swath_sorter.genSortedSwaths(swaths, 0);
45 
46  near(swaths[0].getWidth(), 1);
47  near(swaths[1].getWidth(), 3);
48  near(swaths[2].getWidth(), 5);
49  near(swaths.back().getWidth(), 2);
50  near(objective.computeCost(swaths), 3*((n-1)-1));
snake_order_test.near
def near(a, b)
Definition: snake_order_test.py:10
snake_order_test.test_fields2cover_route_snake_genSortedSwathsOdd
def test_fields2cover_route_snake_genSortedSwathsOdd()
Definition: snake_order_test.py:34
snake_order_test.test_fields2cover_route_snake_genSortedSwathsEven
def test_fields2cover_route_snake_genSortedSwathsEven()
Definition: snake_order_test.py:14


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31