hpp-core 9.3.0
Implement basic classes for canonical path planning for kinematic chains.
Loading...
Searching...
No Matches
quadratic-program.hh
Go to the documentation of this file.
1// Copyright (c) 2018, Joseph Mirabel
2// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3//
4
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// 1. Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11//
12// 2. Redistributions in binary form must reproduce the above copyright
13// notice, this list of conditions and the following disclaimer in the
14// documentation and/or other materials provided with the distribution.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27// DAMAGE.
28
29#ifndef HPP_CORE_PATH_OPTIMIZATION_QUADRATIC_PROGRAM_HH
30#define HPP_CORE_PATH_OPTIMIZATION_QUADRATIC_PROGRAM_HH
31
32#include <hpp/core/fwd.hh>
34
35namespace hpp {
36namespace core {
39namespace pathOptimization {
62 typedef Eigen::JacobiSVD<matrix_t> Decomposition_t;
63 typedef Eigen::LLT<matrix_t, Eigen::Lower> LLT_t;
64
69 : H(inputSize, inputSize),
70 b(inputSize),
71 xStar(inputSize),
72 accuracy_(1e-4),
74 b.setZero();
75 bIsZero = true;
76 }
77
83 : H(lc.PK.cols(), lc.PK.cols()),
84 b(lc.PK.cols()),
85 bIsZero(false),
86 xStar(lc.PK.cols()),
87 accuracy_(1e-4),
89 QP.reduced(lc, *this);
90 }
91
93 : H(QP.H),
94 b(QP.b),
96 dec(QP.dec),
97 xStar(QP.xStar),
100
102
109 void accuracy(value_type acc) { accuracy_ = acc; }
115 value_type accuracy() const { return accuracy_; }
122 void addRows(const std::size_t& nbRows) {
123 H.conservativeResize(H.rows() + nbRows, H.cols());
124 b.conservativeResize(b.rows() + nbRows, b.cols());
125 b.tail(nbRows).setZero();
126 }
127
130
131 /*/ Compute the problem
132 * \f{eqnarray*}{
133 * \min & \frac{1}{2} * x^T H x + b^T x \\
134 * lc.J * x = lc.b
135 * \f}
136 **/
137 void reduced(const LinearConstraint& lc, QuadraticProgram& QPr) const {
138 SparseMatrix_t H_PK(H * lc.PK);
139 QPr.H = lc.PK.transpose() * H_PK;
140 QPr.b.noalias() = H_PK.transpose() * lc.xStar;
141 if (!bIsZero) {
142 QPr.b.noalias() += lc.PK.transpose() * b;
143 }
144 QPr.bIsZero = false;
145 }
146
148 void decompose();
149
150 void solve() { xStar.noalias() = -dec.solve(b); }
151
153
156
160 void computeLLT();
161
168 double solve(const LinearConstraint& ce, const LinearConstraint& ci);
169
171
176 bool bIsZero;
178
183 Eigen::VectorXi activeConstraint;
186
194};
195} // namespace pathOptimization
196} // namespace core
197} // namespace hpp
198
199#endif // HPP_CORE_PATH_OPTIMIZATION_QUADRATIC_PROGRAM_HH
void solve()
Definition quadratic-program.hh:150
vector_t xStar
Definition quadratic-program.hh:190
void reduced(const LinearConstraint &lc, QuadraticProgram &QPr) const
Definition quadratic-program.hh:137
size_type maxIterations() const
Get maximal number of iterations of internal QP solver.
Definition quadratic-program.hh:121
Eigen::LLT< matrix_t, Eigen::Lower > LLT_t
Definition quadratic-program.hh:63
double solve(const LinearConstraint &ce, const LinearConstraint &ci)
SparseMatrix_t H
Definition quadratic-program.hh:174
bool bIsZero
Definition quadratic-program.hh:176
value_type trace
Definition quadratic-program.hh:182
void accuracy(value_type acc)
Definition quadratic-program.hh:109
Eigen::VectorXi activeConstraint
Definition quadratic-program.hh:183
Eigen::JacobiSVD< matrix_t > Decomposition_t
Definition quadratic-program.hh:62
QuadraticProgram(const QuadraticProgram &QP)
Definition quadratic-program.hh:92
QuadraticProgram(const QuadraticProgram &QP, const LinearConstraint &lc)
Definition quadratic-program.hh:82
Decomposition_t dec
Definition quadratic-program.hh:189
QuadraticProgram(size_type inputSize)
Definition quadratic-program.hh:68
size_type maxIterations_
Definition quadratic-program.hh:193
value_type accuracy() const
Definition quadratic-program.hh:115
void maxIterations(size_type n)
Definition quadratic-program.hh:119
vector_t b
Definition quadratic-program.hh:175
value_type accuracy_
Definition quadratic-program.hh:192
void addRows(const std::size_t &nbRows)
Definition quadratic-program.hh:122
int activeSetSize
Definition quadratic-program.hh:184
LLT_t llt
Definition quadratic-program.hh:181
Definition fwd.hh:290
Eigen::SparseMatrix< value_type, Eigen::ColMajor > SparseMatrix_t
Definition linear-constraint.hh:41
Definition bi-rrt-planner.hh:36
pinocchio::value_type value_type
Definition fwd.hh:175
pinocchio::vector_t vector_t
Definition fwd.hh:221
pinocchio::size_type size_type
Definition fwd.hh:174
Definition linear-constraint.hh:47
SparseMatrix_t PK
Projector onto .
Definition linear-constraint.hh:154
vector_t xStar
is a particular solution.
Definition linear-constraint.hh:156