42 const bool is_active_set_guessing_enabled)
49 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
51 hierarchy_[i].form(solution, model, control_problem, is_active_set_guessing_enabled);
52 number_of_constraints_[i] = hierarchy_[i].getNumberOfConstraints();
64 active_set.
initialize(number_of_levels_, number_of_constraints_);
66 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
68 hierarchy_[i].guessActiveSet(active_set[i]);
92 const std::size_t level_index)
94 HUMOTO_ASSERT(level_index < number_of_levels_,
"Wrong hierarchy level number.");
95 hierarchy_[level_index].pushTask(task_pointer);
110 formHierarchy(solution, model, control_problem,
false);
127 formHierarchy(solution, model, control_problem,
true);
128 guessActiveSet(active_set_guess);
149 formHierarchy(solution, model, control_problem,
true);
151 guessActiveSet(active_set_guess);
170 formHierarchy(solution, model, control_problem,
false);
184 "Wrong number of levels in the active set.");
186 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
188 hierarchy_[i].processActiveSet(active_set[i]);
205 active_set.
initialize(number_of_levels_, number_of_constraints_);
207 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
209 hierarchy_[i].determineActiveSet(active_set[i], solution);
224 violations.
initialize(number_of_levels_, number_of_constraints_);
226 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
228 hierarchy_[i].computeViolations(violations[i], solution);
238 void reset(
const std::size_t number_of_levels)
240 number_of_levels_ = number_of_levels;
243 hierarchy_.resize(number_of_levels_);
245 number_of_constraints_.resize(number_of_levels_);
258 return (hierarchy_[level_index]);
271 return (hierarchy_[level_index]);
282 return (number_of_levels_);
295 const std::string & name =
"")
const 298 subname.
add(
"tasks");
300 for (std::size_t i = 0; i < getNumberOfLevels(); ++i)
302 hierarchy_[i].log(logger,
LogEntryName(subname).add(i),
"");
314 active_set.
initialize(number_of_levels_, number_of_constraints_);
328 template<
class t_QPConstra
ints>
331 const bool initialize_upper_triangular_part =
true)
const 333 std::size_t number_of_levels = getNumberOfLevels();
335 HUMOTO_ASSERT( (number_of_levels <= 2) && (number_of_levels >= 1),
336 "Too many or too few levels.");
339 std::size_t objective_level = number_of_levels - 1;
341 qp_problem.
initializeObjective(hierarchy_[objective_level], initialize_upper_triangular_part);
343 if (number_of_levels > 1)
345 qp_problem.initializeConstraints(hierarchy_[0], sol_structure);
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="") const
Log hierarchy as a set of tasks.
Abstract base class (for control problems)
std::vector< std::size_t > number_of_constraints_
void determineActiveSet(humoto::ActiveSet &active_set, const humoto::Solution &solution) const
Determine active set based on the solution. This active set may differ from the active set returned b...
std::size_t getNumberOfLevels() const
Returns number of levels in the hierarchy.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
Analog of 'sol_structure' struct in Octave code. [determine_solution_structure.m].
Container of the solution.
This class represents one level of a hierarchy.
void reset(const std::size_t number_of_levels)
Reset the optimization problem.
OptimizationProblem()
Default constructor.
void initialize(const std::size_t number_of_levels, const std::vector< std::size_t > &number_of_constraints)
Initialize violations.
Represents log entry name.
Active set corresponding to a hierarchy of Constraints.
void initialize(const std::size_t number_of_levels, const std::vector< std::size_t > &number_of_constraints)
Initialize active set.
virtual void guessSolution(Solution &solution_guess, const Solution &old_solution) const
Guess solution.
void initSolutionStructure(humoto::Solution &solution) const
Initialize structure of the given solution based on the internally stored solution structure...
An optimization problem [initialize_stack.m, simulation_loop.m].
void formHierarchy(humoto::Solution &solution, const humoto::Model &model, const humoto::ControlProblem &control_problem, const bool is_active_set_guessing_enabled)
Form hierarchy.
std::vector< humoto::HierarchyLevel > hierarchy_
void form(humoto::Solution &solution, const humoto::Model &model, const humoto::ControlProblem &control_problem)
Form hierarchy.
void processActiveSet(const humoto::ActiveSet &active_set)
Process actual active set: extract active sets of individual tasks.
boost::shared_ptr< humoto::TaskBase > TaskSharedPointer
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void initializeObjective(const humoto::HierarchyLevel &hlevel, const bool initialize_upper_triangular_part=true)
Generates (general) objective containing all constraints on this level.
void form(humoto::Solution &solution, humoto::Solution &solution_guess, humoto::ActiveSet &active_set_guess, const humoto::Model &model, const humoto::ControlProblem &control_problem, const humoto::Solution &old_solution)
Form hierarchy.
The root namespace of HuMoTo.
void computeViolations(humoto::Violations &violations, const humoto::Solution &solution) const
Compute violations based on the solution.
void initializeActiveSet(humoto::ActiveSet &active_set) const
Initialize active set of the hierarchy.
void form(humoto::Solution &solution, humoto::Solution &solution_guess, const humoto::Model &model, const humoto::ControlProblem &control_problem, const humoto::Solution &old_solution)
Form hierarchy.
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.
std::size_t size() const
Size of the active set.
Violations corresponding to a hierarchy of Constraints.
void form(humoto::Solution &solution, humoto::ActiveSet &active_set_guess, const humoto::Model &model, const humoto::ControlProblem &control_problem)
Form hierarchy.
LogEntryName & add(const char *name)
extends entry name with a subname
void guessActiveSet(ActiveSet &active_set) const
Form active set guess.
void pushTask(TaskSharedPointer task_pointer, const std::size_t level_index)
Add task to the optimization problem.
std::size_t number_of_levels_
void getQPProblem(QPProblemBase< t_QPConstraints > &qp_problem, const humoto::SolutionStructure &sol_structure, const bool initialize_upper_triangular_part=true) const
Form a QP problem.