Class to generates a random map for the TSP with n nodes.
More...
#include <qbpp_tsp.hpp>
|
| TSPMap (uint32_t grid_size=100) |
| Constructor: Creates an empty map. More...
|
|
void | gen_random_map (uint32_t n) |
| Generate a random map with n nodes. More...
|
|
void | add_node (uint32_t x, uint32_t y) |
| Add a node to the map. More...
|
|
uint32_t | dist (const std::pair< int32_t, int32_t > &p1, const std::pair< int32_t, int32_t > &p2) const |
| Compute the Euclidean distance between two nodes. More...
|
|
uint32_t | dist (uint32_t i, uint32_t j) const |
| Compute the Euclidean distance between two nodes. More...
|
|
uint32_t | min_dist (uint32_t x, uint32_t y) const |
| Compute the minimum distance between a new node and all other nodes. More...
|
|
uint32_t | node_count () const |
| Gets the number of nodes in the map. More...
|
|
uint32_t | get_grid_size () const |
| Gets the size of the grid. More...
|
|
std::pair< int32_t, int32_t > & | operator[] (uint32_t index) |
| Get the position of the node at index i. More...
|
|
|
const uint32_t | grid_size |
| Size of the grid. grid_size x grid_size coordinates are used for the map. More...
|
|
std::vector< std::pair< int32_t, int32_t > > | nodes |
| List of nodes with coordinate (x, y) More...
|
|
Class to generates a random map for the TSP with n nodes.
The map is a grid of size grid_size x grid_size
- Note
- The nodes are randomly placed on the grid so that nodes are not too close to each other
Definition at line 30 of file qbpp_tsp.hpp.
◆ TSPMap()
qbpp::tsp::TSPMap::TSPMap |
( |
uint32_t |
grid_size = 100 | ) |
|
|
inline |
Constructor: Creates an empty map.
- Parameters
-
grid_size | Size of the grid. grid_size x grid_size coordinates are used for the map. |
Definition at line 41 of file qbpp_tsp.hpp.
◆ gen_random_map()
void qbpp::tsp::TSPMap::gen_random_map |
( |
uint32_t |
n | ) |
|
|
inline |
Generate a random map with n nodes.
- Parameters
-
Definition at line 284 of file qbpp_tsp.hpp.
◆ add_node()
void qbpp::tsp::TSPMap::add_node |
( |
uint32_t |
x, |
|
|
uint32_t |
y |
|
) |
| |
|
inline |
Add a node to the map.
- Parameters
-
x | x-coordinate of the node |
y | y-coordinate of the node |
Definition at line 50 of file qbpp_tsp.hpp.
◆ dist() [1/2]
uint32_t qbpp::tsp::TSPMap::dist |
( |
const std::pair< int32_t, int32_t > & |
p1, |
|
|
const std::pair< int32_t, int32_t > & |
p2 |
|
) |
| const |
|
inline |
Compute the Euclidean distance between two nodes.
- Parameters
-
p1 | First node |
p2 | Second node |
- Returns
- Euclidean distance between the two nodes
- Note
- The distance is rounded to the nearest integer
Definition at line 57 of file qbpp_tsp.hpp.
◆ dist() [2/2]
uint32_t qbpp::tsp::TSPMap::dist |
( |
uint32_t |
i, |
|
|
uint32_t |
j |
|
) |
| const |
|
inline |
Compute the Euclidean distance between two nodes.
- Parameters
-
i | Index of the first node |
j | Index of the second node |
- Returns
- Euclidean distance between the two nodes
Definition at line 68 of file qbpp_tsp.hpp.
◆ min_dist()
uint32_t qbpp::tsp::TSPMap::min_dist |
( |
uint32_t |
x, |
|
|
uint32_t |
y |
|
) |
| const |
|
inline |
Compute the minimum distance between a new node and all other nodes.
- Parameters
-
x | x-coordinate of the node |
y | y-coordinate of the node |
- Returns
- Minimum distance between the node and all other nodes
Definition at line 77 of file qbpp_tsp.hpp.
◆ node_count()
uint32_t qbpp::tsp::TSPMap::node_count |
( |
| ) |
const |
|
inline |
Gets the number of nodes in the map.
- Returns
- Number of nodes in the map
Definition at line 87 of file qbpp_tsp.hpp.
◆ get_grid_size()
uint32_t qbpp::tsp::TSPMap::get_grid_size |
( |
| ) |
const |
|
inline |
Gets the size of the grid.
- Returns
- Size of the grid
Definition at line 91 of file qbpp_tsp.hpp.
◆ operator[]()
std::pair<int32_t, int32_t>& qbpp::tsp::TSPMap::operator[] |
( |
uint32_t |
index | ) |
|
|
inline |
Get the position of the node at index i.
- Parameters
-
- Returns
- Pair of coordinates (x, y) of the node
Definition at line 96 of file qbpp_tsp.hpp.
◆ grid_size
const uint32_t qbpp::tsp::TSPMap::grid_size |
|
private |
Size of the grid. grid_size x grid_size coordinates are used for the map.
Definition at line 33 of file qbpp_tsp.hpp.
◆ nodes
std::vector<std::pair<int32_t, int32_t> > qbpp::tsp::TSPMap::nodes |
|
private |
List of nodes with coordinate (x, y)
Definition at line 35 of file qbpp_tsp.hpp.
The documentation for this class was generated from the following file: