19 #define HUMOTO_CONFIG_SECTION_ID "SolverParametersBase" 20 #define HUMOTO_CONFIG_CONSTRUCTOR SolverParametersBase 21 #define HUMOTO_CONFIG_ENTRIES \ 22 HUMOTO_CONFIG_SCALAR_(crash_on_any_failure) \ 23 HUMOTO_CONFIG_SCALAR_(solve_two_levels_as_qp) 24 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 30 crash_on_any_failure_ =
true;
31 solve_two_levels_as_qp_ =
true;
63 template <
class t_SolverParameters>
87 if ((
true == parameters_.crash_on_any_failure_)
143 parameters_ = parameters;
158 checkInputs(hierarchy);
159 initialize(hierarchy, solution);
160 solveHierarchy(solution, hierarchy);
161 checkResults(solution);
175 const t_SolverParameters ¶meters)
177 parameters_ = parameters;
179 checkInputs(hierarchy);
180 initialize(hierarchy, solution);
181 solveHierarchy(solution, hierarchy);
182 checkResults(solution);
193 template <
class t_Solver>
197 using t_Solver::initialize;
198 using t_Solver::solveHierarchy;
199 using t_Solver::checkResults;
200 using t_Solver::checkInputs;
219 using t_Solver::solve;
234 checkInputs(hierarchy);
235 initialize(hierarchy, solution);
236 setSolutionGuess(solution_guess);
237 solveHierarchy(solution, hierarchy);
238 checkResults(solution);
249 template <
class t_Solver>
253 using t_Solver::initialize;
254 using t_Solver::solveHierarchy;
255 using t_Solver::checkResults;
256 using t_Solver::checkInputs;
285 using t_Solver::solve;
302 checkInputs(hierarchy);
303 initialize(hierarchy, solution);
304 setActiveSet(active_set_guess, hierarchy);
305 solveHierarchy(solution, hierarchy);
306 checkResults(solution);
307 getActiveSet(active_set, hierarchy);
323 checkInputs(hierarchy);
324 initialize(hierarchy, solution);
325 setActiveSet(active_set_guess, hierarchy);
326 solveHierarchy(solution, hierarchy);
327 checkResults(solution);
343 checkInputs(hierarchy);
344 initialize(hierarchy, solution);
345 solveHierarchy(solution, hierarchy);
346 checkResults(solution);
347 getActiveSet(active_set, hierarchy);
358 template <
class t_Solver>
362 using t_Solver::initialize;
363 using t_Solver::solveHierarchy;
364 using t_Solver::checkResults;
365 using t_Solver::checkInputs;
366 using t_Solver::getActiveSet;
367 using t_Solver::setActiveSet;
368 using t_Solver::setSolutionGuess;
380 using t_Solver::solve;
399 checkInputs(hierarchy);
400 initialize(hierarchy, solution);
401 setSolutionGuess(solution_guess);
402 setActiveSet(active_set_guess, hierarchy);
403 solveHierarchy(solution, hierarchy);
404 checkResults(solution);
405 getActiveSet(active_set, hierarchy);
423 checkInputs(hierarchy);
424 initialize(hierarchy, solution);
425 setSolutionGuess(solution_guess);
426 setActiveSet(active_set_guess, hierarchy);
427 solveHierarchy(solution, hierarchy);
428 checkResults(solution);
446 checkInputs(hierarchy);
447 initialize(hierarchy, solution);
448 setSolutionGuess(solution_guess);
449 solveHierarchy(solution, hierarchy);
450 checkResults(solution);
451 getActiveSet(active_set, hierarchy);
461 template <
class t_Solver>
465 using t_Solver::parameters_;
472 "Interpretation of hierarchies as QPs is disabled.");
476 HUMOTO_ASSERT( (number_of_levels <= 2) && (number_of_levels >= 1),
477 "This type of hierarchy cannot be solved with a QP solver.");
480 std::size_t objective_level = number_of_levels - 1;
483 "This type of hierarchy cannot be solved with a QP solver.");
485 HUMOTO_ASSERT( hierarchy[objective_level].getNumberOfConstraints() > 0,
506 template <
class t_SolverParameters>
525 template <
class t_SolverParameters>
544 template <
class t_SolverParameters>
547 SolverGuessSolutionMixin<
548 SolverGuessActiveSetMixin<
549 Solver<t_SolverParameters> > > >
void solve(Solution &solution, ActiveSet &active_set, const humoto::OptimizationProblem &hierarchy, const ActiveSet &active_set_guess)
Solve an optimization problem (using previously specified parameters)
~SolverGuessSolution()
Protected destructor: prevent destruction of the child classes through a base pointer.
~SolverParametersBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
virtual void reset()
Reset solver.
void setParameters(const t_SolverParameters ¶meters)
Construct solver with specified parameters.
Mixin solver interface (active set guessing)
std::size_t getNumberOfLevels() const
Returns number of levels in the hierarchy.
t_SolverParameters parameters_
#define HUMOTO_ASSERT(condition, message)
~SolverGuessSolutionActiveSet()
Protected destructor: prevent destruction of the child classes through a base pointer.
SolverGuessSolutionActiveSet()
Default configurable base is strict.
Analog of 'sol_structure' struct in Octave code. [determine_solution_structure.m].
Container of the solution.
void setDefaults()
Set members to their default values.
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Active set corresponding to a hierarchy of Constraints.
~SolverGuessActiveSetMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
SolverStatus::Status return_status_
SolverGuessActiveSetMixin()
An optimization problem [initialize_stack.m, simulation_loop.m].
~QPSolverMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
void solve(Solution &solution, const humoto::OptimizationProblem &hierarchy, const humoto::Solution &solution_guess, const ActiveSet &active_set_guess)
Solve an optimization problem (using previously specified parameters)
void solve(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy, const humoto::Solution &solution_guess)
Solve an optimization problem (using previously specified parameters)
~SolverGuessSolutionActiveSetMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
~Solver()
Protected destructor: prevent destruction of the child classes through a base pointer.
bool solve_two_levels_as_qp_
Enable conversion of an optimization problem with two priority levels to a QP.
SolverGuessSolutionActiveSetMixin()
virtual void checkInputs(const humoto::OptimizationProblem &hierarchy) const
Checks input, does nothing by default, may include extra checks in mixins.
The root namespace of HuMoTo.
~SolverGuessActiveSet()
Protected destructor: prevent destruction of the child classes through a base pointer.
SolverGuessSolutionMixin()
Solver class with active set guessing.
Mixin solver interface (active set and solution guessing)
void solve(humoto::Solution &solution, humoto::ActiveSet &active_set, const humoto::OptimizationProblem &hierarchy, const humoto::Solution &solution_guess)
Solve an optimization problem (using previously specified parameters)
void solve(Solution &solution, const humoto::OptimizationProblem &hierarchy, const ActiveSet &active_set_guess)
Solve an optimization problem (using previously specified parameters)
Mixin solver interface (QP solver)
bool crash_on_any_failure_
Throw an exception if solver does not return sucessfully.
void solve(humoto::Solution &solution, humoto::ActiveSet &active_set, const humoto::OptimizationProblem &hierarchy)
Solve an optimization problem (using previously specified parameters)
virtual std::string getStatusDescription() const
Status description.
void solve(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy, const t_SolverParameters ¶meters)
Solve an optimization problem (using previously specified parameters)
void solve(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy)
Solve an optimization problem (using previously specified parameters)
Mixin solver interface (solution guessing)
~SolverGuessSolutionMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
void checkResults(const humoto::Solution &solution) const
Check return status and crash if it indicates a failure and crashing is enabled.
Solver class with active set and solution guessing.
void solve(Solution &solution, ActiveSet &active_set, const humoto::OptimizationProblem &hierarchy, const humoto::Solution &solution_guess, const ActiveSet &active_set_guess)
Solve an optimization problem (using previously specified parameters)
virtual void checkInputs(const humoto::OptimizationProblem &hierarchy) const
Solver class with solution guessing.