Parasol Planning Library (PPL)
NBS.h
Go to the documentation of this file.
1 #ifndef PPL_NBS_H_
2 #define PPL_NBS_H_
3 
4 template <typename TaskType, typename PlanType>
6  std::function<PlanType*(TaskType* _task)>;
7 
8 template <typename PlanType>
10  std::function<double(PlanType* _plan)>;
11 
12 template <typename SolutionType, typename PlanType>
14  std::function<SolutionType*(PlanType* _plan)>;
15 
16 template <typename SolutionType>
18  std::function<double(SolutionType* _solution)>;
19 
20 
21 template <typename TaskType, typename SolutionType, typename PlanType>
22 void
24  TaskType* _task,
25  SolutionType* _solution,
27  RelaxedCostFunction<PlanType>& _relaxedCost,
29  ConstrainedCostFunction<SolutionType>& _constrainedCost)
30 {
31 
32  // Initialize bounds
33  double lowerBound = 0;
34  double upperBound = MAX_DBL;
35 
36  while(true) {
37  auto relaxedPlan = _relaxedPlanner(_task);
38  lowerBound = _relaxedCost(relaxedPlan);
39 
40  if (upperBound < lowerBound)
41  break;
42 
43  auto solution = _constrainedPlanner(relaxedPlan);
44  double solutionCost = _constrainedCost(solution);
45 
46  if(solutionCost < upperBound) {
47  _solution = solution;
48  upperBound = solutionCost;
49  }
50  }
51 }
52 
53 #endif
#define MAX_DBL
Definition: MPUtils.h:33
std::function< SolutionType *(PlanType *_plan)> ConstrainedPlanFunction
Definition: NBS.h:14
std::function< double(SolutionType *_solution)> ConstrainedCostFunction
Definition: NBS.h:18
void NBS(TaskType *_task, SolutionType *_solution, RelaxedPlanFunction< TaskType, PlanType > &_relaxedPlanner, RelaxedCostFunction< PlanType > &_relaxedCost, ConstrainedPlanFunction< SolutionType, PlanType > &_constrainedPlanner, ConstrainedCostFunction< SolutionType > &_constrainedCost)
Definition: NBS.h:23
std::function< PlanType *(TaskType *_task)> RelaxedPlanFunction
Definition: NBS.h:6
std::function< double(PlanType *_plan)> RelaxedCostFunction
Definition: NBS.h:10