28 m_expr_scalar_vars.clear();
33 parameters.CMultiObjectiveMotionOptimizerBase::TParamsBase::loadFromConfigFile(
c,
"CMultiObjectiveMotionOptimizerBase");
34 parameters.loadFromConfigFile(
c,
"CMultiObjMotionOpt_Scalarization");
39 parameters.CMultiObjectiveMotionOptimizerBase::TParamsBase::saveToConfigFile(
c,
"CMultiObjectiveMotionOptimizerBase");
40 parameters.saveToConfigFile(
c,
"CMultiObjMotionOpt_Scalarization");
46 final_evaluation.clear();
52 if (m_expr_scalar_vars.empty())
56 for (
const auto &score :
c) {
58 m_expr_scalar_vars[score.first];
67 m_expr_scalar_formula.compile(parameters.scalar_score_formula, m_expr_scalar_vars);
69 catch (std::exception &)
71 m_expr_scalar_vars.clear();
78 final_evaluation.assign(N, .0);
81 for (
size_t i = 0; i < N; i++)
88 const auto & it = m_expr_scalar_vars.find(score.first);
89 if (it == m_expr_scalar_vars.cend()) {
90 THROW_EXCEPTION_FMT(
"Error: found unexpected (unregistered) score named `%s`.", score.first.c_str());
92 double & var = it->second;
95 const double val = m_expr_scalar_formula.eval();
98 if (
val > 0 && (best_idx == -1 ||
val > best_val))
int impl_decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info) MRPT_OVERRIDE
void saveConfigFile(mrpt::utils::CConfigFileBase &c) const MRPT_OVERRIDE
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define MRPT_LOAD_CONFIG_VAR_REQUIRED_CS(variableName, variableType)
Shortcut for MRPT_LOAD_CONFIG_VAR_NO_DEFAULT() for REQUIRED variables config file object named c and ...
#define IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace)
This must be inserted in all CObject classes implementation files.
std::vector< double > final_evaluation
The final evaluation score for each candidate.
#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 clear() MRPT_OVERRIDE
Resets the object state; use if the parameters change, so they are re-read and applied.
A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a...
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...
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
Implementation of multi-objective motion chooser using scalarization: a user-given formula is used to...
GLsizei const GLchar ** string
void loadConfigFile(const mrpt::utils::CConfigFileBase &c) MRPT_OVERRIDE
Virtual base class for multi-objective motion choosers, as used for reactive navigation engines...
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. ...
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.