-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.h
61 lines (50 loc) · 1.63 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef ACO_TSP_UTILS_H
#define ACO_TSP_UTILS_H
#include "tsp_solver.h"
namespace aco
{
/**
* Get Cost Matrix for the graph required by Ant Colony Optimization
* @details This function runs the Floyd-Warshall Algorithm for finding shortest path between each pair of the graph
* @param graph
* @return
*/
Eigen::MatrixXd get_cost_matrix(const aco::Graph& graph);
/**
* Finds fitness value for a single path of ant
* @param cost_matrix
* @param ant_path
* @return
*/
double find_fitness_values(const Eigen::MatrixXd& cost_matrix, const std::vector<aco::Node>& ant_path);
/**
* Finds fitness value for a single path of ant
* @param cost_matrix
* @param ant_path
* @return
*/
double find_fitness_values(const Eigen::MatrixXd& cost_matrix, const std::vector<std::vector<aco::Node>>& ant_paths);
/**
* Find a random index based on probabilities in the probability array
* @param probability_array
* @return
*/
int run_roulette_wheel(const Eigen::ArrayXd& probability_array);
/**
* Convert user defined graph type to aco graph type
* @tparam GraphType - GraphType must be a sequential std container (Eg. Vector) containing sequence of nodes
* @param graph
* @return
*/
template <typename GraphType>
aco::Graph convert_to_aco_graph(const GraphType& graph);
/**
* Get the directory path string
* @param package_name - name of the package/ project (eg. "Example Project)
* @param package_relative_path - path relative to the project (eg. "/config/abc.cfg"
* @return
*/
std::string get_directory_path(const std::string& package_name, const std::string& package_relative_path);
} // namespace aco
#endif //ACO_TSP_UTILS_H
#include "utils_impl.h"