template<class T>
class drake::solvers::MobyLCPSolver< T >
A class for solving Linear Complementarity Problems (LCPs).
Solving a LCP requires finding a solution to the problem:
Mz + q = w
z ≥ 0
w ≥ 0
zᵀw = 0
(where M ∈ ℝⁿˣⁿ and q ∈ ℝⁿ are problem inputs and z ∈ ℝⁿ and w ∈ ℝⁿ are unknown vectors) or correctly reporting that such a solution does not exist. In spite of their linear structure, solving LCPs is NPHard [Cottle 1992]. However, some LCPs are significantly easier to solve. For instance, it can be seen that the LCP is solvable in worstcase polynomial time for the case of symmetric positivesemidefinite M by formulating it as the following convex quadratic program:
minimize: f(z) = zᵀw = zᵀ(Mz + q)
subject to: z ≥ 0
Mz + q ≥ 0
Note that this quadratic program's (QP) objective function at the minimum z cannot be less than zero, and the LCP is only solved if the objective function at the minimum is equal to zero. Since the seminal result of Karmarkar, it has been known that convex QPs are solvable in polynomial time [Karmarkar 1984].
The difficulty of solving an LCP is characterized by the properties of its particular matrix, namely the class of matrices it belongs to. Classes include, for example, Q, Q₀, P, P₀, copositive, and Z matrices. [Cottle 1992] and Murty 1998 describe relevant matrix classes in more detail.
 [Cottle 1992] R. Cottle, J.S. Pang, and R. Stone. The Linear Complementarity Problem. Academic Press, 1992.
 [Karmarkar 1984] N. Karmarkar. A New PolynomialTime Algorithm for Linear Programming. Combinatorica, 4(4), pp. 373395.
 [Murty 1988] K. Murty. Linear Complementarity, Linear and Nonlinear Programming. Heldermann Verlag, 1988.
Fast pivoting algorithm for LCPs of the form M = PAPᵀ, q = Pb, where b ∈ ℝᵐ, P ∈ ℝⁿˣᵐ, and A ∈ ℝᵐˣᵐ (where A is positive definite).
Therefore, q is in the range of P and M is positive semidefinite. An LCP of this form is also guaranteed to have a solution [Cottle 1992].
This particular implementation focuses on the case where the solution requires few nonzero nonbasic variables, meaning that few z variables need be nonzero to find a solution to Mz + q = w. This algorithm, which is based off of Dantzig's Principle Pivoting Method I [Cottle 1992] is described in [Drumwright 2015]. This algorithm is able to use "warm" starting a solution to a "nearby" LCP can be used to find the solution to a given LCP more quickly.
Although this solver is theoretically guaranteed to give a solution to the LCPs described above, accumulated floating point error from pivoting operations could cause the solver to fail. Additionally, the solver can be applied with some success to problems outside of its guaranteed matrix class. For these reasons, the solver returns a flag indicating success/failure.
 Parameters

[in]  M  the LCP matrix. 
[in]  q  the LCP vector. 
[in,out]  z  the solution to the LCP on return (if the solver succeeds). If the length of z is equal to the length of q, the solver will attempt to use z's value as a starting solution. If the solver fails (returns false ), z will be set to the zero vector. 
[in]  zero_tol  The tolerance for testing against zero. If the tolerance is negative (default) the solver will determine a generally reasonable tolerance. 
 Exceptions

std::logic_error  if M is nonsquare or M's dimensions do not equal q's dimension. 
 Returns
true
if the solver succeeded and false
otherwise.
 [Cottle 1992] R. Cottle, J.S. Pang, and R. Stone. The Linear Complementarity Problem. Academic Press, 1992.
 [Drumwright 2015] E. Drumwright. Rapidly computable viscous friction and noslip rigid contact models. arXiv: 1504.00719v1. 2015.
bool SolveLcpFastRegularized 
( 
const MatrixX< T > & 
M, 


const VectorX< T > & 
q, 


VectorX< T > * 
z, 


int 
min_exp = 20 , 


unsigned 
step_exp = 4 , 


int 
max_exp = 20 , 


const T & 
zero_tol = T(1) 

) 
 const 
Regularized version of the fast pivoting algorithm for LCPs of the form M = PAPᵀ, q = Pb, where b ∈ ℝᵐ, P ∈ ℝⁿˣᵐ, and A ∈ ℝᵐˣᵐ (where A is positive definite).
Therefore, q is in the range of P and M is positive semidefinite. Please see SolveLcpFast() for more documentation about the particular algorithm.
This implementation wraps that algorithm with a Tikhonovtype regularization approach. Specifically, this implementation repeatedly attempts to solve the LCP:
(M + Iα)z + q = w
z ≥ 0
w ≥ 0
zᵀw = 0
where I is the identity matrix and α ≪ 1, using geometrically increasing values of α, until the LCP is solved. Cottle et al. describe how, for sufficiently large α, the LCP will always be solvable [Cottle 1992], p. 493.
Although this solver is theoretically guaranteed to give a solution to the LCPs described above, accumulated floating point error from pivoting operations could cause the solver to fail. Additionally, the solver can be applied with some success to problems outside of its guaranteed matrix class. For these reasons, the solver returns a flag indicating success/failure.
 Parameters

[in]  M  the LCP matrix. 
[in]  q  the LCP vector. 
[in,out]  z  the solution to the LCP on return (if the solver succeeds). If the length of z is equal to the length of q, the solver will attempt to use z's value as a starting solution. 
[in]  min_exp  The minimum exponent for computing α over [10ᵝ, 10ᵞ] in steps of 10ᵟ, where β is the minimum exponent, γ is the maximum exponent, and δ is the stepping exponent. 
[in]  step_exp  The stepping exponent for computing α over [10ᵝ, 10ᵞ] in steps of 10ᵟ, where β is the minimum exponent, γ is the maximum exponent, and δ is the stepping exponent. 
[in]  max_exp  The maximum exponent for computing α over [10ᵝ, 10ᵞ] in steps of 10ᵟ, where β is the minimum exponent, γ is the maximum exponent, and δ is the stepping exponent. 
[in]  zero_tol  The tolerance for testing against zero. If the tolerance is negative (default) the solver will determine a generally reasonable tolerance. 
 Exceptions

std::logic_error  if M is nonsquare or M's dimensions do not equal q's dimension. 
 Returns
true
if the solver succeeded and false
if the solver did not find a solution for α = 10ᵞ.
 See also
 SolveLcpFast()
 [Cottle, 1992] R. Cottle, J.S. Pang, and R. Stone. The Linear Complementarity Problem. Academic Press, 1992.
Lemke's Algorithm for solving LCPs in the matrix class E, which contains all strictly semimonotone matrices, all Pmatrices, and all strictly copositive matrices.
Lemke's Algorithm is described in [Cottle 1992], Section 4.4. This implementation was adapted from the LEMKE Library [LEMKE] for Matlab; this particular implementation fixes a bug in LEMKE that could occur when multiple indices passed the minimum ratio test.
Although this solver is theoretically guaranteed to give a solution to the LCPs described above, accumulated floating point error from pivoting operations could cause the solver to fail. Additionally, the solver can be applied with some success to problems outside of its guaranteed matrix classes. For these reasons, the solver returns a flag indicating success/failure.
 Parameters

[in]  M  the LCP matrix. 
[in]  q  the LCP vector. 
[in,out]  z  the solution to the LCP on return (if the solver succeeds). If the length of z is equal to the length of q, the solver will attempt to use z's value as a starting solution. This warmstarting is generally not recommended: it has a predisposition to lead to a failing pivoting sequence. If the solver fails (returns false ), z will be set to the zero vector. 
[in]  zero_tol  The tolerance for testing against zero. If the tolerance is negative (default) the solver will determine a generally reasonable tolerance. 
[in]  piv_tol  The tolerance for testing against zero, specifically used for the purpose of finding variables for pivoting. If the tolerance is negative (default) the solver will determine a generally reasonable tolerance. 
 Returns
true
if the solver believes it has computed a solution (which it determines by the ability to "pivot out" the "artificial" variable (see [Cottle 1992]) and false
otherwise.
 Warning
 The caller should verify that the algorithm has solved the LCP to the desired tolerances on returns indicating success.
 Exceptions

std::logic_error  if M is not square or the dimensions of M do not match the length of q. 
bool SolveLcpLemkeRegularized 
( 
const MatrixX< T > & 
M, 


const VectorX< T > & 
q, 


VectorX< T > * 
z, 


int 
min_exp = 20 , 


unsigned 
step_exp = 1 , 


int 
max_exp = 1 , 


const T & 
piv_tol = T(1) , 


const T & 
zero_tol = T(1) 

) 
 const 
Lemke's Algorithm for solving LCPs in the matrix class E, which contains all strictly semimonotone matrices, all Pmatrices, and all strictly copositive matrices.
Lemke's Algorithm is described in [Cottle 1992], Section 4.4.
This implementation wraps that algorithm with a Tikhonovtype regularization approach. Specifically, this implementation repeatedly attempts to solve the LCP:
(M + Iα)z + q = w
z ≥ 0
w ≥ 0
zᵀw = 0
where I is the identity matrix and α ≪ 1, using geometrically increasing values of α, until the LCP is solved. See SolveLcpFastRegularized() for description of the regularization process and the function parameters, which are identical. See SolveLcpLemke() for a description of Lemke's Algorithm. See SolveLcpFastRegularized() for a description of all calling parameters other than z
, which apply equally well to this function.
 Parameters

[in,out]  z  the solution to the LCP on return (if the solver succeeds). If the length of z is equal to the length of q, the solver will attempt to use z's value as a starting solution. This warmstarting is generally not recommended: it has a predisposition to lead to a failing pivoting sequence. 
 See also
 SolveLcpFastRegularized()

SolveLcpLemke()
 [Cottle 1992] R. Cottle, J.S. Pang, and R. Stone. The Linear Complementarity Problem. Academic Press, 1992.