rem_area_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>
8 #include <utility>
10 #include "fields2cover/types.h"
11 
12 TEST(fields2cover_obj_remArea, computeCost) {
14 
16  {F2CPoint(-2,-2), F2CPoint(6,-2), F2CPoint(6,6), F2CPoint(-2,6), F2CPoint(-2,-2)}));
18  {F2CPoint(0,0), F2CPoint(4,0), F2CPoint(4,4), F2CPoint(0,4), F2CPoint(0,0)}));
19 
20  EXPECT_EQ(rem_area.computeCost(total_field, field), 0.25);
21  EXPECT_EQ(rem_area.computeCostWithMinimizingSign(total_field, field), -0.25);
22  EXPECT_EQ(rem_area.computeCost(F2CCells(total_field), field), 0.25);
23  EXPECT_EQ(rem_area.computeCostWithMinimizingSign(F2CCells(total_field), field), -0.25);
24  EXPECT_EQ(rem_area.computeCost(total_field, F2CCells(field)), 0.25);
25  EXPECT_EQ(rem_area.computeCostWithMinimizingSign(total_field, F2CCells(field)), -0.25);
26  EXPECT_EQ(rem_area.computeCost(F2CCells(total_field), F2CCells(field)), 0.25);
27  EXPECT_EQ(rem_area.computeCostWithMinimizingSign(F2CCells(total_field), F2CCells(field)), -0.25);
28 }
29 
30 TEST(fields2cover_obj_remArea, params_check) {
31  f2c::obj::RemArea objective;
32  EXPECT_TRUE(objective.isMaximizing());
33  EXPECT_FALSE(objective.isMinimizing());
34 }
35 
types.h
2_objective_functions.rem_area
rem_area
Definition: 2_objective_functions.py:20
F2CCells
f2c::types::Cells F2CCells
Definition: types.h:44
f2c::obj::RemArea
Compute the area of the mainland (field - headlands).
Definition: rem_area.h:17
f2c::obj::RemArea::isMinimizing
bool isMinimizing(void) const override
Return true if the objective is to minimize the cost function.
Definition: rem_area.cpp:11
f2c::types::Cell
Definition: Cell.h: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
rem_area.h
F2CLinearRing
f2c::types::LinearRing F2CLinearRing
Definition: types.h:41
f2c::types::Cells
Definition: Cells.h:21
2_objective_functions.field
field
Definition: 2_objective_functions.py:16
TEST
TEST(fields2cover_obj_remArea, computeCost)
Definition: rem_area_test.cpp:12
2_objective_functions.total_field
total_field
Definition: 2_objective_functions.py:13
F2CPoint
f2c::types::Point F2CPoint
Definition: types.h:38


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