Go to the documentation of this file.
9 #ifndef CASTARALGORITHM_H
10 #define CASTARALGORITHM_H
13 #define _USE_MATH_DEFINES // (For VS to define M_PI, etc. in cmath)
75 int getOptimalSolution(
const T &initialSol,T &finalSol,
double upperLevel=HUGE_VAL,
double maxComputationTime=HUGE_VAL) {
80 std::multimap<double,T> partialSols;
81 partialSols.insert(std::pair<double,T>(
getTotalCost(initialSol),initialSol));
83 double currentOptimal=upperLevel;
85 std::vector<T> children;
87 while (!partialSols.empty()) {
89 if (time.
Tac()>=maxComputationTime)
return found?2:0;
91 double tempCost=it->first;
93 if (tempCost>=currentOptimal)
return found?1:0;
95 partialSols.erase(it);
98 currentOptimal=tempCost;
106 bool alreadyPresent=
false;
113 if (!alreadyPresent) partialSols.insert(std::pair<double,T>(
getTotalCost(*it2),*it2));
const Scalar * const_iterator
virtual double getCost(const T &sol)=0
Client code must implement this method.
int getOptimalSolution(const T &initialSol, T &finalSol, double upperLevel=HUGE_VAL, double maxComputationTime=HUGE_VAL)
Finds the optimal solution for a problem, using the A* algorithm.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void Tic()
Starts the stopwatch.
This class is intended to efficiently solve graph-search problems using heuristics to determine the b...
This class implements a high-performance stopwatch.
virtual double getHeuristic(const T &sol)=0
Client code must implement this method.
double Tac()
Stops the stopwatch.
virtual bool isSolutionValid(const T &sol)=0
Client code must implement this method.
double getTotalCost(const T &sol)
Calculates the total cost (known+estimated) of a solution.
virtual bool isSolutionEnded(const T &sol)=0
Client code must implement this method.
virtual void generateChildren(const T &sol, std::vector< T > &sols)=0
Client code must implement this method.
Page generated by Doxygen 1.8.20 for MRPT 1.4.0 SVN: at Thu Aug 27 02:40:23 UTC 2020 | | |