Go to the documentation of this file.
    9 #ifndef CASTARALGORITHM_H 
   10 #define CASTARALGORITHM_H 
   75         virtual double getCost(
const T& sol) = 0;
 
   95                 const T& initialSol, T& finalSol, 
double upperLevel = HUGE_VAL,
 
   96                 double maxComputationTime = HUGE_VAL)
 
  103                 std::multimap<double, T> partialSols;
 
  105                         std::pair<double, T>(
getTotalCost(initialSol), initialSol));
 
  108                 double currentOptimal = upperLevel;
 
  110                 std::vector<T> children;
 
  113                 while (!partialSols.empty())
 
  116                         if (time.
Tac() >= maxComputationTime) 
return found ? 2 : 0;
 
  119                         double tempCost = it->first;
 
  123                         if (tempCost >= currentOptimal) 
return found ? 1 : 0;
 
  124                         T tempSol = it->second;
 
  125                         partialSols.erase(it);
 
  131                                 currentOptimal = tempCost;
 
  141                                  it2 != children.end(); ++it2)
 
  144                                         bool alreadyPresent = 
false;
 
  149                                                 range = partialSols.equal_range(cost);
 
  152                                                  it3 != 
range.second; ++it3)
 
  153                                                 if (it3->second == *it2)
 
  155                                                         alreadyPresent = 
true;
 
  164                 return found ? 1 : 0;
 
  
const Scalar * const_iterator
 
virtual double getCost(const T &sol)=0
Client code must implement this method.
 
A high-performance stopwatch, with typical resolution of nanoseconds.
 
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.
 
This class is intended to efficiently solve graph-search problems using heuristics to determine the b...
 
double Tac() noexcept
Stops the stopwatch.
 
virtual double getHeuristic(const T &sol)=0
Client code must implement this method.
 
void Tic() noexcept
Starts 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.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |   |