tests
cpp
objectives
rp_obj
rp_obj_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 "
fields2cover/types.h
"
9
#include "
fields2cover/objectives/rp_obj/rp_objective.h
"
10
11
TEST
(fields2cover_obj_rp_obj, computeCost_cost) {
12
f2c::obj::RPObjective
length;
13
F2CPoint
p1
(0,0),
p2
(4,0);
14
F2CMultiPoint
ps
{
p1
,
p2
};
15
std::vector<F2CPoint> vp {
p1
,
p2
};
16
EXPECT_EQ(length.
computeCost
(
p1
,
p2
), 4.0);
17
EXPECT_EQ(length.
computeCost
(
p1
, 0.0,
p2
, 0.0), 4.0);
18
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p1
, 0.0,
p2
, 0.0), 4.0);
19
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p1
,
p2
, 0.0), 4.0);
20
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p1
, 0.0,
p2
), 4.0);
21
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p1
,
p2
), 4.0);
22
23
F2CSwath
s1(
F2CLineString
({
F2CPoint
(0, 0),
F2CPoint
(1, 1)}), 1.0, 1);
24
F2CSwath
s2(
F2CLineString
({
F2CPoint
(0, 0),
F2CPoint
(2, 2)}), 1.0, 2);
25
F2CSwaths
ss {s1, s2};
26
27
EXPECT_EQ(length.
computeCostWithMinimizingSign
(s1), sqrt(2.0));
28
EXPECT_EQ(length.
computeCostWithMinimizingSign
(s1, s2), sqrt(2.0));
29
EXPECT_EQ(length.
computeCostWithMinimizingSign
(ss), 4*sqrt(2.0));
30
EXPECT_EQ(length.
computeCostWithMinimizingSign
(s1,
p1
, 0.0), sqrt(2.0));
31
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p2
, 0.0, s1), 4.0);
32
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
p2
, s1), 4.0);
33
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
ps
, s1), 4.0);
34
EXPECT_EQ(length.
computeCostWithMinimizingSign
(s2,
p1
), 2.0*sqrt(2.0));
35
EXPECT_EQ(length.
computeCostWithMinimizingSign
(s2,
ps
), 2.0*sqrt(2.0));
36
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
ps
, ss), 4.0);
37
EXPECT_EQ(length.
computeCostWithMinimizingSign
(ss,
ps
), 2.0*sqrt(2.0));
38
EXPECT_EQ(length.
computeCostWithMinimizingSign
(
ps
), 4.0);
39
EXPECT_EQ(length.
computeCostWithMinimizingSign
(vp), 4.0);
40
}
41
1_basic_types.p1
p1
Definition:
1_basic_types.py:11
types.h
f2c::types::Swath
Definition:
Swath.h:23
1_basic_types.p2
p2
Definition:
1_basic_types.py:15
f2c::types::MultiPoint
Definition:
MultiPoint.h:18
8_complete_flow.ps
list ps
Definition:
8_complete_flow.py:43
F2CLineString
f2c::types::LineString F2CLineString
Definition:
types.h:40
f2c::types::Point
Definition:
Point.h:21
rp_objective.h
f2c::obj::RPObjective::computeCost
virtual double computeCost(const F2CPoint &p1, const F2CPoint &p2)
Definition:
rp_objective.cpp:11
TEST
TEST(fields2cover_obj_rp_obj, computeCost_cost)
Definition:
rp_obj_test.cpp:11
f2c::types::Swaths
Definition:
Swaths.h:20
F2CPoint
f2c::types::Point F2CPoint
Definition:
types.h:38
f2c::obj::BaseObjective::computeCostWithMinimizingSign
double computeCostWithMinimizingSign(const T1 &t1)
Compute the cost function with minimizing sign.
Definition:
base_objective.h:26
f2c::obj::RPObjective
Base class for objective functions of route planners.
Definition:
rp_objective.h:18
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31