TSPSolver.h
Go to the documentation of this file.
1/**
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @author Fabian Reister ( fabian dot kit at edu )
17 * @date 2025
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#pragma once
23
24#include <cstddef>
25#include <cstdint>
26#include <optional>
27#include <utility>
28#include <vector>
29
30#include <Eigen/Core>
31
33{
34
36 {
37 public:
39 {
40 std::int64_t timeLimitSeconds = 5;
41 };
42
43 TSPSolver(const Parameters& params);
44
45 struct Result
46 {
47 // Add result data here
48 std::vector<Eigen::Vector2f> orderedPoints;
49 std::vector<std::size_t> orderIndices;
50 };
51
52 std::optional<Result> solve(const std::vector<Eigen::Vector2f>& points,
53 const Eigen::Vector2f& startingPosition) const;
54
55 protected:
56 private:
57 Parameters params_;
58 };
59
60 namespace detail
61 {
62 std::vector<std::vector<double>>
63 buildDistanceMatrix(const std::vector<Eigen::Vector2f>& pts);
64
65 std::pair<double, std::vector<int>>
66 heldKarpTsp(const std::vector<std::vector<double>>& d);
67 } // namespace detail
68
69} // namespace armarx::navigation::algorithms::tsp
std::optional< Result > solve(const std::vector< Eigen::Vector2f > &points, const Eigen::Vector2f &startingPosition) const
std::vector< std::vector< double > > buildDistanceMatrix(const std::vector< Eigen::Vector2f > &pts)
Definition TSPSolver.cpp:48
std::pair< double, std::vector< int > > heldKarpTsp(const std::vector< std::vector< double > > &d)
Definition TSPSolver.cpp:70
This file is part of ArmarX.
Definition TSPSolver.cpp:42