n_swath_test.cpp
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 #include <gtest/gtest.h>
9 #include "fields2cover/types.h"
10 
11 TEST(fields2cover_obj_n_swath, get_best_value) {
12  F2CSwaths swaths3 (2);
14  EXPECT_EQ(obj.computeCost(swaths3), 2);
15 
16  for (int i = 0; i < 10; ++i) {
17  swaths3.emplace_back(F2CSwath());
18  EXPECT_EQ(obj.computeCost(swaths3), i+3);
19  }
20 }
21 
22 TEST(fields2cover_obj_n_swath, computeCost_cost) {
23  F2CSwath swaths1 (1);
24  F2CSwaths swaths2 (2);
25  F2CSwaths swaths3 (2);
26  F2CSwathsByCells swaths_cells;
27  swaths_cells.emplace_back(swaths2);
28  swaths_cells.emplace_back(swaths3);
29 
31 
32  EXPECT_EQ(obj.computeCost(swaths1), 1.0);
33  EXPECT_EQ(obj.computeCostWithMinimizingSign(swaths1), 1.0);
34 
35  EXPECT_EQ(obj.computeCost(swaths2), 2.0);
36  EXPECT_EQ(obj.computeCostWithMinimizingSign(swaths2), 2.0);
37 
38  EXPECT_EQ(obj.computeCost(swaths3), 2.0);
39  EXPECT_EQ(obj.computeCostWithMinimizingSign(swaths3), 2.0);
40 
41  EXPECT_EQ(obj.computeCost(swaths_cells), 4.0);
42  EXPECT_EQ(obj.computeCostWithMinimizingSign(swaths_cells), 4.0);
43 
44  swaths3.emplace_back(F2CSwath());
45  EXPECT_EQ(obj.computeCost(swaths3), 3.0);
46 
47  swaths3.emplace_back(F2CSwath());
48  EXPECT_EQ(obj.computeCost(swaths3), 4.0);
49 }
50 
51 TEST(fields2cover_obj_n_swath, params_check) {
52  f2c::obj::NSwath objective;
53 
54  EXPECT_FALSE(objective.isMaximizing());
55  EXPECT_TRUE(objective.isMinimizing());
56  EXPECT_FALSE(objective.isFastCompAvailable());
57 }
58 
f2c::obj::NSwath
SG cost function as the number of swaths.
Definition: n_swath.h:20
types.h
f2c::types::Swath
Definition: Swath.h:23
TEST
TEST(fields2cover_obj_n_swath, get_best_value)
Definition: n_swath_test.cpp:11
2_objective_functions.swaths1
swaths1
Definition: 2_objective_functions.py:37
7_decomposition.obj
obj
Definition: 7_decomposition.py:32
f2c::obj::BaseObjective::isMaximizing
virtual bool isMaximizing() const
Return true if the objective is to maximize the cost function.
Definition: base_objective.h:52
f2c::obj::SGObjective::isFastCompAvailable
virtual bool isFastCompAvailable() const
Definition: sg_objective.h:23
2_objective_functions.swaths3
swaths3
Definition: 2_objective_functions.py:39
f2c::types::SwathsByCells
Definition: SwathsByCells.h:17
F2CSwath
f2c::types::Swath F2CSwath
Definition: types.h:50
f2c::types::SwathsByCells::emplace_back
void emplace_back(const Swaths &s)
Definition: SwathsByCells.cpp:30
f2c::types::Swaths
Definition: Swaths.h:20
n_swath.h
f2c::obj::BaseObjective::isMinimizing
virtual bool isMinimizing() const
Return true if the objective is to minimize the cost function.
Definition: base_objective.h:50


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