28         score_values.resize(movs.size());
    31         for (
unsigned int mov_idx = 0; mov_idx< movs.size();++mov_idx)
    33                 const auto &m = movs[mov_idx];
    36                 for (
auto &
p : m_expr_vars) {
    37                         p.second = std::numeric_limits<double>::quiet_NaN();
    40                 for (
const auto &prop : m.props) {
    41                         double & var = m_expr_vars[prop.first];
    46                 if (m_score_exprs.size() != m_params_base.formula_score.size())
    48                         m_score_exprs.clear();
    50                         for (
const auto &f : m_params_base.formula_score)
    52                                 auto &se = m_score_exprs[f.first];
    55                                         se.compile(f.second, m_expr_vars, 
std::string(
"score: ") + f.first);
    57                                 catch (std::exception &)
    59                                         m_score_exprs.clear();
    65                                         auto it = m_expr_vars.find(f.first);
    66                                         if (it != m_expr_vars.end()) {
    67                                                 THROW_EXCEPTION_FMT(
"Error: Expression name `%s` already exists as an input variable.", f.first.c_str());
    70                                         m_expr_vars[f.first] = std::numeric_limits<double>::quiet_NaN();
    76                 if (m_movement_assert_exprs.size() != m_params_base.movement_assert.size())
    78                         const size_t N = m_params_base.movement_assert.size();
    79                         m_movement_assert_exprs.clear();
    80                         m_movement_assert_exprs.resize(N);
    81                         for (
size_t i=0;i<N;i++)
    83                                 const auto &str = m_params_base.movement_assert[i];
    84                                 auto &ce = m_movement_assert_exprs[i];
    88                                         ce.compile(str, m_expr_vars, 
"assert");
    90                                 catch (std::exception &)
    92                                         m_movement_assert_exprs.clear();
    99                 for (
auto &sc : m_score_exprs)
   109                                 val = sc.second.eval();
   114                                 THROW_EXCEPTION_FMT(
"Undefined value evaluating score `%s` for mov_idx=%u!", sc.first.c_str(), mov_idx);
   118                         score_values[mov_idx][sc.first] = 
val;
   123         for (
const auto& sScoreName : m_params_base.scores_to_normalize)
   126                 double maxScore = .0;
   127                 for (
const auto &
s : score_values)
   129                         const auto it = 
s.find(sScoreName);
   137                         for (
auto &
s : score_values)
   139                                 auto it = 
s.find(sScoreName);
   146                 if (maxScore > 0 && maxScore!=1.0 )
   148                         double K = 1.0 / maxScore;
   149                         for (
auto &
s : score_values)
   151                                 auto it = 
s.find(sScoreName);
   160         for (
unsigned int mov_idx = 0; mov_idx < movs.size(); ++mov_idx)
   162                 const auto &m = movs[mov_idx];
   164                 for (
auto &
p : m_expr_vars) {
   165                         p.second = std::numeric_limits<double>::quiet_NaN();
   167                 for (
const auto &prop : m.props) {
   168                         double & var = m_expr_vars[prop.first];
   172                 bool assert_failed = 
false;
   174                         for (
auto &ma : m_movement_assert_exprs)
   176                                 const double val = ma.eval();
   178                                         assert_failed = 
true;
   179                                         extra_info.
log_entries.emplace_back(std::move(
mrpt::format(
"[CMultiObjectiveMotionOptimizerBase] mov_idx=%u ASSERT failed: `%s`", mov_idx, ma.get_original_expression().c_str())));
   186                         for (
auto &e : score_values[mov_idx]) 
   194         return impl_decide(movs, extra_info);
   199         m_score_exprs.clear();
   210                 if (!classId) 
return nullptr;
   224         formula_score[
"collision_free_distance"] = 
"collision_free_distance";
   225         formula_score[
"path_index_near_target"] = 
"var dif:=abs(target_k-move_k); if (dif>(num_paths/2)) { dif:=num_paths-dif; }; exp(-abs(dif / (num_paths/10.0)));";
   226         formula_score[
"euclidean_nearness"] = 
"(ref_dist - dist_eucl_final) / ref_dist";
   227         formula_score[
"hysteresis"] = 
"hysteresis";
   228         formula_score[
"clearance"] = 
"clearance";
   231         scores_to_normalize.push_back(
"clearance");
   238                 formula_score.clear();
   246                         const bool none = (sName.empty() && sValue.empty());
   247                         const bool both = (!sName.empty() && !sValue.empty());
   249                         if (none && idx == 1)
   250                                 THROW_EXCEPTION_FMT(
"Expect at least a first `%s` and `%s` pair defining one score in section `[%s]`", sKeyName.c_str(), sKeyValue.c_str(), 
s.c_str());
   256                                 THROW_EXCEPTION_FMT(
"Both `%s` and `%s` must be provided in section `[%s]`", sKeyName.c_str(), sKeyValue.c_str(), 
s.c_str());
   259                         formula_score[sName] = sValue;
   265                 movement_assert.clear();
   273                         movement_assert.push_back(sValue);
   278                 scores_to_normalize.clear();
   279                 std::string sLst = 
c.read_string(
s, 
"scores_to_normalize", 
"");
   293                         "# Next follows a list of `score%i_{name,formula}` pairs for i=1,...,N\n"   294                         "# Each one defines one of the scores that will be evaluated for each candidate movement.\n"   295                         "# Multiobjective optimizers will then use those scores to select the best candidate, \n"   296                         "# possibly using more parameters that follow below.\n"   301                 for (
const auto &
p : this->formula_score)
   313                         "# Next follows a list of `movement_assert%i` exprtk expressions for i=1,...,N\n"   314                         "# defining expressions for conditions that any candidate movement must fulfill\n"   315                         "# in order to get through the evaluation process. *All* assert conditions must be satisfied.\n"   319                 for (
unsigned int idx=0;idx<movement_assert.size();idx++)
   328                 for (
const auto& 
s : scores_to_normalize) {
   332                 c.write(
s, 
"scores_to_normalize", sLst);
 int BASE_IMPEXP MRPT_SAVE_VALUE_PADDING
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc. 
 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
 
#define IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class_name, NameSpace)
This must be inserted as implementation of some required members for virtual CSerializable classes: ...
 
std::vector< std::string > log_entries
Optionally, debug logging info will be stored here by the implementor classes. 
 
int decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info)
The main entry point for the class: returns the 0-based index of the best of the N motion candidates ...
 
void BASE_IMPEXP registerAllPendingClasses()
Register all pending classes - to be called just before de-serializing an object, for example...
 
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string §ion) const MRPT_OVERRIDE
This method saves the options to a ".ini"-like file or memory-stored string list. ...
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
 
virtual void clear()
Resets the object state; use if the parameters change, so they are re-read and applied. 
 
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) MRPT_OVERRIDE
This method load the options from a ".ini"-like file or memory-stored string list. 
 
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations. 
 
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...
 
mrpt::utils::CObject * createObject() const
 
const TRuntimeClassId BASE_IMPEXP * findRegisteredClass(const std::string &className)
Return info about a given class by its name, or NULL if the class is not registered. 
 
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf. 
 
GLsizei const GLchar ** string
 
Virtual base class for multi-objective motion choosers, as used for reactive navigation engines...
 
static CMultiObjectiveMotionOptimizerBase * Create(const std::string &className) MRPT_NO_THROWS
Class factory from C++ class name. 
 
Common params for all children. 
 
A structure that holds runtime class type information. 
 
The virtual base class of all MRPT classes with a unified RTTI system. 
 
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters. 
 
GLenum const GLfloat * params
 
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
 
int BASE_IMPEXP MRPT_SAVE_NAME_PADDING