LEMUR Packages: ompl_lemur or_lemur pr_bgl prpy_lemur
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Groups Pages
FamilyUtilityChecker.h
1 
7 namespace ompl_lemur
8 {
9 
24 {
25 public:
26 
30 
31  // called by constructor
32  void initialize();
33 
34 public: // set by calling code (e.g. or_lemur::FamilyPlanner)
35 
36  typedef std::pair<double, ompl::base::StateValidityCheckerPtr> SetChecker;
37 
38  void start_checking(std::string set_target, const std::map<std::string, SetChecker> & set_checkers);
39  void stop_checking();
40 
41 public: // used internally and by ompl_lemur::FamilyTagCache
42 
43  // this will throw if set not found!
44  size_t getSetIndex(const std::string & set_name) const;
45 
46  size_t numTags() const { return _belief_states.size(); }
47 
48  // this may add a new set (changing the result of numTags())
49  size_t tagIfSetKnown(size_t tag_in, size_t iset, bool value) const;
50 
51 public: // used by planner
52 
53  bool hasChanged();
54 
55  bool isKnown(size_t tag) const;
56 
57  bool isKnownInvalid(size_t tag) const;
58 
59  double getPartialEvalCost(size_t tag, const ompl::base::State * state) const;
60 
61  bool isValidPartialEval(size_t & tag, const ompl::base::State * state) const;
62 
63 private:
64  const Family _family;
65  bool _has_changed;
66 
67  // view into the family
68  std::vector<std::string> _sets;;
69 
70  // compound sentences (permanent)
71  // A1 n A2 n A3 => C
72  struct ConjunctionImplication
73  {
74  std::vector<std::size_t> antecedents;
75  std::size_t consequent;
76  };
77  std::vector<ConjunctionImplication> _conjunction_implications;
78 
79  std::vector< std::vector<bool> > _truth_table;
80 
81 // these are set by start_checking() and persist until stop_checkint()
82 
83  size_t _var_target;
84 
85  // subsumes var_costs and subsets[g[e].var].second.si->isValid()
86  std::vector<SetChecker> _checkers;
87 
88  // these are only the states that are on optimal paths
89  // to the target from existing states!
90  typedef std::pair< std::vector<bool>, std::vector<bool> > BeliefState;
91  mutable std::vector< BeliefState > _belief_states;
92  mutable std::map< BeliefState, size_t > _belief_state_map;
93 
94  // this is cost and target dependent stuff:
95  struct BeliefStatePolicy
96  {
97  bool computed;
98  double cost_to_go;
99  size_t iset;
100  bool result_desired;
101  size_t tag_on_valid; // 0 if not encountered yet
102  size_t tag_on_invalid; // 0 if not encountered yet
103  BeliefStatePolicy(): computed(false) {}
104  };
105  // this always must have the same length as _belief_states
106  // (even if they are not computed yet)
107  mutable std::vector< BeliefStatePolicy > _policy;
108 
109  // this is called if _policy[tag].computed is false
110  void compute_policy(size_t tag) const;
111 };
112 
113 #ifdef OMPL_LEMUR_HAS_BOOSTSMARTPTRS
114 typedef boost::shared_ptr<FamilyUtilityChecker> FamilyUtilityCheckerPtr;
115 #else
116 typedef std::shared_ptr<FamilyUtilityChecker> FamilyUtilityCheckerPtr;
117 #endif
118 
119 } // namespace ompl_lemur
bool isKnown(size_t tag) const
Determine whether a state with tag tag is known either valid or invalid.
Definition: FamilyUtilityChecker.cpp:173
Definition: Family.h:18
bool isKnownInvalid(size_t tag) const
Determine whether a state with tag tag is known to be invalid.
Definition: FamilyUtilityChecker.cpp:179
bool isValidPartialEval(size_t &tag, const ompl::base::State *state) const
Conduct the optimistic set of evaluations.
Definition: FamilyUtilityChecker.cpp:199
Type of state validity checker which enables partial evaluation of tagged states. ...
Definition: UtilityChecker.h:15
bool hasChanged()
Determine if the underlying utility model has changed since the last call to hasChanged().
Definition: FamilyUtilityChecker.cpp:166
Use a Family as a UtilityChecker.
Definition: FamilyUtilityChecker.h:23
double getPartialEvalCost(size_t tag, const ompl::base::State *state) const
Determines the optimistic planning cost entailed to call isValidPartialEval().
Definition: FamilyUtilityChecker.cpp:189