30#ifndef CPPSRC_CORE_INCLUDE_COVERAGECONTROL_ALGORITHMS_ORACLE_EXPLORE_EXPLOIT_H_
31#define CPPSRC_CORE_INCLUDE_COVERAGECONTROL_ALGORITHMS_ORACLE_EXPLORE_EXPLOIT_H_
43#include "CoverageControl/extern/lsap/Hungarian.h"
52 size_t num_robots_ = 0;
55 std::vector<VoronoiCell> voronoi_cells_;
58 std::vector<std::vector<double>> cost_matrix_;
62 double exploration_ratio_ = 1;
63 int recompute_goal_steps_ = 0, recompute_goal_counter_ = 0;
64 bool is_converged_ =
false;
65 bool start_exploit_ =
false;
70 : params_{params}, num_robots_{num_robots}, env_{env} {
71 cost_matrix_.resize(num_robots_, std::vector<double>(num_robots_));
72 voronoi_cells_.resize(num_robots_);
75 actions_.resize(num_robots_);
76 goals_.resize(num_robots_);
101 for (
size_t i = 0; i < num_robots_; ++i) {
106 explored_idf_map_.block(index.
left + offset.
left,
111 exploration_map_.block(index.
left + offset.
left,
116 exploration_ratio_ =
static_cast<double>(exploration_map_.count()) /
118 oracle_map_ = explored_idf_map_ + 2 * exploration_ratio_ * exploration_map_;
135#pragma omp parallel for num_threads(num_robots_)
136 for (
size_t iRobot = 0; iRobot < num_robots_; ++iRobot) {
137 for (
size_t jCentroid = 0; jCentroid < voronoi_cells_.size();
139 cost_matrix_[iRobot][jCentroid] = (robot_global_positions_[iRobot] -
140 voronoi_cells_[jCentroid].centroid())
144 HungarianAlgorithm HungAlgo;
145 std::vector<int> assignment;
146 HungAlgo.Solve(cost_matrix_, assignment);
148 goals_.resize(num_robots_);
149 auto ordered_voronoi_cells = voronoi_cells_;
150 for (
size_t iRobot = 0; iRobot < num_robots_; ++iRobot) {
151 goals_[iRobot] = voronoi_cells_[assignment[iRobot]].centroid();
152 ordered_voronoi_cells[iRobot] = voronoi_cells_[assignment[iRobot]];
154 voronoi_cells_ = ordered_voronoi_cells;
155 if (exploration_ratio_ < 0.1) {
156 start_exploit_ =
true;
158 recompute_goal_steps_ = ceil(-12.5 * exploration_ratio_ + 22.5);
163 if (start_exploit_ ==
false) {
164 if (recompute_goal_counter_ >= recompute_goal_steps_ or
165 is_converged_ ==
true) {
166 recompute_goal_counter_ = 0;
169 ++recompute_goal_counter_;
Contains the abstract class for coverage control algorithms.
The CoverageSystem class is the main class for the coverage control library.
PointVector GetRobotPositions(bool force_no_noise=false)
Get the global positions of all robots.
const MapType & GetRobotSensorView(size_t const id) const
bool StepRobotsToGoals(PointVector const &goals, PointVector &actions)
double GetExplorationRatio() const
void SetGoals(PointVector const &goals)
MapType const & GetOracleMap()
OracleExploreExploit(Parameters const ¶ms, size_t const &num_robots, CoverageSystem &env)
std::vector< VoronoiCell > GetVoronoiCells()
Class to store parameters.
Class for computing Voronoi cells.
auto GetVoronoiCells() const
The file contains the CoverageSystem class, which is the main class for the coverage control library.
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MapType
std::vector< Point2 > PointVector
auto NearOptimalCVTAlgorithm(int const num_tries, int const max_iterations, int const num_sites, MapType const &map, int const map_size, double const res)
void ComputeOffsets(double const resolution, Point2 const &pos, int const submap_size, int const map_size, MapBounds &index, MapBounds &offset)
Namespace for the CoverageControl library.
Near Optimal Centroidal Voronoi Tessellation (CVT) algorithm Near-optimal Centroidal Voronoi Tessella...
Contains typedefs for the library.