43 #define HUMOTO_CONFIG_SECTION_ID "SolverParameters" 44 #define HUMOTO_CONFIG_CONSTRUCTOR SolverParameters 45 #define HUMOTO_CONFIG_ENTRIES \ 46 HUMOTO_CONFIG_PARENT_CLASS(SolverParametersBase) 47 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 56 CONSTRAINT_ELIMINATION_LLT = 3
69 solution_method_ = LU;
70 elimination_regularization_factor_ = 1e-08;
109 switch(parameters_.solution_method_)
114 solveWithElimination(solution, hierarchy);
123 solveDirect(solution, hierarchy);
142 Eigen::VectorXd inverted_H;
143 inverted_H.resize(num_var);
144 for (
EigenIndex i = 0; i < inverted_H.size(); ++i)
146 inverted_H(i) = 1./(qp_problem_.
getHessian()(i,i) + parameters_.elimination_regularization_factor_);
149 Eigen::VectorXd iH_g = inverted_H.asDiagonal() * qp_problem_.
getGradient();
150 Eigen::MatrixXd iH_At = inverted_H.asDiagonal() * qp_problem_.
getEqualities().
getA().transpose();
152 solution.
x_.noalias() = iH_At
173 Eigen::MatrixXd kkt_matrix;
174 Eigen::VectorXd kkt_vector;
179 kkt_matrix.resize(num_var+num_ctr, num_var+num_ctr);
180 kkt_vector.resize(num_var+num_ctr);
190 switch(parameters_.solution_method_)
193 x = kkt_matrix.lu().solve(kkt_vector);
196 x = kkt_matrix.colPivHouseholderQr().solve(kkt_vector);
204 solution.
x_ = x.segment(0, num_var);
232 setParameters(parameters);
245 const std::string &name =
"kktsolver")
const 248 qp_problem_.
log(logger, subname);
std::size_t getNumberOfVariables() const
Get total number of variables in the solution vector.
void initialize(const humoto::OptimizationProblem &hierarchy, const humoto::SolutionStructure &sol_structure)
Initialize solver.
Solver()
Default constructor (with default parameters)
Eigen::VectorXd & getB()
Get vector b from equalities: 'A*x = b' or 'x = b'.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
humoto::QPProblem_AB qp_problem_
Analog of 'sol_structure' struct in Octave code. [determine_solution_structure.m].
Parameters of the solver.
Container of the solution.
#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.
EIGEN_DEFAULT_DENSE_INDEX_TYPE EigenIndex
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="kktsolver") const
Log a QP problem.
const Eigen::VectorXd & getGradient() const
Const accessor.
SolverStatus::Status return_status_
Eigen::MatrixXd & getA()
Get matrix A from general constraints: 'A*x = b', 'lb <= A*x <= ub'.
An optimization problem [initialize_stack.m, simulation_loop.m].
std::size_t getNumberOfConstraints() const
Returns number of constraints in the task.
double elimination_regularization_factor_
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
const humoto::constraints::ContainerAB & getEqualities() const
get container with equalities
HessianType getHessianType() const
Hessian type.
void setDefaults()
Set members to their default values.
Solver(const SolverParameters ¶meters)
Set parameters.
The root namespace of HuMoTo.
void solveHierarchy(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy)
Solve the hierarchy.
void solveWithElimination(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy)
Eliminate constraints and solve (only diagonal Hessians are supported).
A QP problem with constraints of a specific type.
LogEntryName & add(const char *name)
extends entry name with a subname
void solveDirect(humoto::Solution &solution, const humoto::OptimizationProblem &hierarchy)
Solve KKT system directly.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="qp_problem") const
Log a QP problem.
SolverParameters()
Default constructor.
const Eigen::MatrixXd & getHessian() const
Const accessor.
void getQPProblem(QPProblemBase< t_QPConstraints > &qp_problem, const humoto::SolutionStructure &sol_structure, const bool initialize_upper_triangular_part=true) const
Form a QP problem.