22 #define HUMOTO_CONFIG_ENTRIES 23 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 44 void preForm(
const std::size_t number_of_variables)
48 setNumberOfVariables(number_of_variables);
64 catch (
const std::exception &e)
66 HUMOTO_THROW_MSG(std::string(
"Task '") + getDescription() +
"' is inconsistent: " + e.what());
69 HUMOTO_ASSERT( (active_set_guess_.
size() == 0) || (active_set_guess_.
size() == getNumberOfConstraints()),
70 std::string(
"Wrong size of the active set guess. Task: ") + getDescription());
84 active_set_actual_.initialize(active_set, location);
98 active_set.
copyTo( location,
124 return (string_description_);
151 std::size_t num_ctr = getNumberOfConstraints();
153 if (is_modified_ || (0 == active_set_actual_.
size()))
169 std::string(
"The task is marked as unmodified, " 170 "but the size of the active set is not the same. Task: ")
173 active_set_guess_ = active_set_actual_;
206 is_modified_ =
false;
217 return (active_set_actual_);
228 return (active_set_guess_);
241 const std::string & name =
"task")
const = 0;
251 return (string_description_);
262 string_description_ = description;
275 const std::string & name =
"task")
const 280 logger.log(
LogEntryName(subname).add(
"id"), getDescription());
281 logTask(logger, subname,
"");
283 active_set_guess_.
log(logger, subname,
"active_set_guess");
284 active_set_actual_.
log(logger, subname,
"active_set_actual");
286 ConstraintsBase::log(logger, subname,
"");
297 template<
class t_Constra
ints>
305 #define HUMOTO_CONFIG_ENTRIES \ 306 HUMOTO_CONFIG_PARENT_CLASS(TaskBase) \ 307 HUMOTO_CONFIG_SCALAR_(gain) 308 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 325 const double gain = 0.0)
327 t_Constraints::setDescription(description);
349 const std::string & name =
"task")
const 351 logger.log(
LogEntryName(parent).add(name).add(
"gain"), getGain());
364 t_Constraints::is_modified_ =
true;
385 template<
class t_Constra
ints>
397 #define HUMOTO_CONFIG_ENTRIES \ 398 HUMOTO_CONFIG_PARENT_CLASS(TaskBase) \ 399 HUMOTO_CONFIG_SCALAR_(gain) 400 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 417 const double gain = 0.0)
419 t_Constraints::setDescription(description);
440 const std::string & name =
"task")
const 442 logger.log(
LogEntryName(parent).add(name).add(
"gain"), getGain());
455 t_Constraints::is_modified_ =
true;
477 template<
class t_Constra
ints>
500 t_Constraints::setDescription(description);
514 const std::string & name =
"task")
const 520 #ifdef HUMOTO_DOXYGEN_PROCESSING 523 #define HUMOTO_TASK_CLASS_GENERATOR(parent, name) class name : public parent {} 525 #define HUMOTO_TASK_CLASS_GENERATOR(parent, name) typedef parent name 582 #undef HUMOTO_TASK_CLASS_GENERATOR
GeneralTaskBaseMixin(const std::string &description, const double gain=0.0)
Constructor.
Abstract base class (for control problems)
std::string string_description_
Constraint is an equality (always active)
const ActiveSetConstraints & getActualActiveSet() const
Get actual active set.
~SimpleTaskBaseMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
virtual void guessActiveSet(const humoto::SolutionStructure &sol_structure, const humoto::Model &model_base, const humoto::ControlProblem &control_problem)
Initialize active set guess with defaults.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="") const
Log an active set.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
Abstract base class (a task in a stack of tasks / hierarchy).
void copyActualActiveSetFrom(const ActiveSetConstraints &active_set, const Location &location)
Copy the actual active set of the task from the given active set.
std::size_t size() const
Size of the active set.
void markAsUnmodified()
By default the task is assumed to be modified. Use this function to mark it as unmodified to avoid un...
Analog of 'sol_structure' struct in Octave code. [determine_solution_structure.m].
virtual void setDefaults()
Active set corresponding to Constraints class.
This class represents one level of a hierarchy.
const std::string & getConfigSectionID() const
Return the default name of a configuration node corresponding to this class.
void preForm(const std::size_t number_of_variables)
Prepare formulation of a task.
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
const std::string getDescription() const
Get description of the task.
virtual void setGain(const double gain)
Sets gain.
ActiveSetConstraints active_set_guess_
void postForm() const
Finalize formulation of a task.
void initialize(const std::size_t number_of_constraints)
Initialize active set.
#define HUMOTO_TASK_CLASS_GENERATOR(parent, name)
boost::shared_ptr< humoto::TaskBase > TaskSharedPointer
~WeightedSimpleTaskBaseMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
virtual void logTask(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="task") const
Log task.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void setDescription(const std::string &description)
Set description of the task.
ActiveSetConstraints active_set_actual_
SimpleTaskBaseMixin(const std::string &description)
Constructor.
Task: lb <= diag(G)*x[I] <= ub.
simple task mixin – should be used in building general tasks
The root namespace of HuMoTo.
simple task mixin – should be used in building general tasks
WeightedSimpleTaskBaseMixin(const std::string &description, const double gain=0.0)
Constructor.
Instances of this class are passed to a virtual method 'humoto::TaskBase::form()', so even though this class is basically useless in its present form we cannot avoid its definition using a template.
~GeneralTaskBaseMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
void copyTo(const Location &location, const ActiveSetConstraints &other_active_set)
Set type of a set of constraints.
void setGain(const double gain)
Sets gain.
double getGain() const
Returns gain.
virtual void setDefaults()
virtual void setDefaults()
Set members to their default values.
LogEntryName & add(const char *name)
extends entry name with a subname
Location of a data chunk (offset + length).
Task: diag(G)*x[I] <= ub.
General task mixin – should be used in building general tasks.
double getGain() const
Returns gain.
Task: lb <= diag(G)*x[I].
ActiveSetConstraints & getActiveSetGuess()
Get active set guess.
void copyActiveSetGuessTo(ActiveSetConstraints &active_set, const Location &location) const
Copy the active set guess of the task to the given active set.
~TaskBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
Constraints abstract interface class.