Main MRPT website > C++ reference for MRPT 1.5.7
CMultiObjectiveMotionOptimizerBase.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #pragma once
10 
14 #include <mrpt/utils/CObject.h>
16 #include <mrpt/nav/link_pragmas.h>
17 
18 namespace mrpt
19 {
20  namespace nav
21  {
22  DEFINE_MRPT_OBJECT_PRE_CUSTOM_LINKAGE(CMultiObjectiveMotionOptimizerBase, NAV_IMPEXP)
23 
24  /** Virtual base class for multi-objective motion choosers, as used for reactive navigation engines.
25  *\sa CReactiveNavigationSystem, CReactiveNavigationSystem3D
26  * \ingroup nav_reactive
27  */
29  public mrpt::utils::CObject
30  {
31  // This must be added to any CSerializable derived class:
33  public:
34  static CMultiObjectiveMotionOptimizerBase * Create(const std::string &className) MRPT_NO_THROWS; //!< Class factory from C++ class name
35 
37  {
38  /** For each candidate (vector indices), the numerical evaluation of all scores defined in TParamsBase::formula_score.
39  * A value of 0 in all scores, or an empty map, means unsuitable candidate. */
40  std::vector<std::map<std::string, double> > score_values;
41 
42  std::vector<double> final_evaluation; //!< The final evaluation score for each candidate
43  std::vector<std::string> log_entries; //!< Optionally, debug logging info will be stored here by the implementor classes
44  };
45 
46  /** The main entry point for the class: returns the 0-based index of the best of the N motion candidates in `movs`.
47  * If no valid one is found, `-1` will be returned.
48  */
49  int decide(const std::vector<mrpt::nav::TCandidateMovementPTG> &movs, TResultInfo &extra_info);
50 
51  virtual void loadConfigFile(const mrpt::utils::CConfigFileBase & c) = 0;
52  virtual void saveConfigFile(mrpt::utils::CConfigFileBase & c) const = 0;
53 
54  /** Common params for all children */
56  {
57  TParamsBase();
58 
59  /** A list of `name` -> mathematical expression (in the format of the exprtk library) for
60  * the list of "score" factors to evaluate.
61  */
62  std::map<std::string, std::string> formula_score;
63 
64  /** A list of exprtk expressions for conditions that any candidate movement must
65  * fulfill in order to get through the evaluation process. *All* assert conditions must be satisfied.
66  */
67  std::vector<std::string> movement_assert;
68 
69  /** List of score names (as defined in the key of `formula_score`) that must be normalized
70  * across all candidates, such that the maximum value is 1. */
71  std::vector<std::string> scores_to_normalize;
72 
73  virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) MRPT_OVERRIDE; // See base docs
74  virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &section) const MRPT_OVERRIDE; // See base docs
75  };
76 
77  virtual void clear(); //!< Resets the object state; use if the parameters change, so they are re-read and applied.
78 
79  protected:
81 
82  private:
83  // This virtual method is called by decide().
84  virtual int impl_decide(const std::vector<mrpt::nav::TCandidateMovementPTG> &movs, TResultInfo &extra_info) = 0;
85 
87 
88  std::map<std::string, mrpt::math::CRuntimeCompiledExpression> m_score_exprs; //!< score names -> score compiled expressions
89  std::vector<mrpt::math::CRuntimeCompiledExpression> m_movement_assert_exprs;
90  std::map<std::string, double> m_expr_vars;
91 
92  };
94 
95  }
96 }
97 
std::map< std::string, mrpt::math::CRuntimeCompiledExpression > m_score_exprs
score names -> score compiled expressions
std::vector< std::string > log_entries
Optionally, debug logging info will be stored here by the implementor classes.
std::vector< mrpt::math::CRuntimeCompiledExpression > m_movement_assert_exprs
std::vector< double > final_evaluation
The final evaluation score for each candidate.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
const GLfloat * c
Definition: glew.h:10088
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
#define DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
Definition: CObject.h:275
STL namespace.
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
std::vector< std::map< std::string, double > > score_values
For each candidate (vector indices), the numerical evaluation of all scores defined in TParamsBase::f...
This class allows loading and storing values and vectors of different types from a configuration text...
std::map< std::string, std::string > formula_score
A list of name -> mathematical expression (in the format of the exprtk library) for the list of "scor...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for multi-objective motion choosers, as used for reactive navigation engines...
GLsizei const GLcharARB ** string
Definition: glew.h:3293
std::vector< std::string > scores_to_normalize
List of score names (as defined in the key of formula_score) that must be normalized across all candi...
#define DEFINE_MRPT_OBJECT_PRE_CUSTOM_LINKAGE(class_name, _LINKAGE_)
Definition: CObject.h:213
std::vector< std::string > movement_assert
A list of exprtk expressions for conditions that any candidate movement must fulfill in order to get ...
GLfloat * params
Definition: glew.h:1436
#define DEFINE_MRPT_OBJECT_POST_CUSTOM_LINKAGE(class_name, _LINKAGE_)
Definition: CObject.h:214
GLsizei GLsizei GLchar * source
Definition: glew.h:1739
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...



Page generated by Doxygen 1.8.11 for MRPT 1.5.7 Git: 2190203 Tue May 15 02:01:15 2018 +0200 at miƩ may 16 12:40:16 CEST 2018