public interface LCPSolver
w = M z + qand solving it entails finding w and z subject to the constraints
w >= 0, z >= 0, w z = 0Different solvers do this in different ways with varying restrictions on the matrix
M
. Some solves are also able to solve bounded linear
complementarity problems (BLCPs), which take the form
w = M z + q = wpos - wneg, 0 ≤ hi - z perp wneg ≥ 0, 0 ≤ z - lo perp wpos ≥ 0
Full details on the solution of LCPs can be found in The Linear Complementarity Problem, by Cottle, Pang, and Stone, in the review paper ``Algorithms for Linear Complementarity Problems'', by Joaquim Judice (1994), and in Claude Lacoursiere's Ph.D. thesis. Ghosts and Machines: Regularized Variational Methods for Interactive Simulations of Multibodies with Dry Frictional Contact.
Modifier and Type | Interface and Description |
---|---|
static class |
LCPSolver.Status
Solver return status
|
Modifier and Type | Field and Description |
---|---|
static double |
INF |
static int |
W_VAR_LOWER
Indicates that a variable is non-basic and at its lower bound.
|
static int |
W_VAR_UPPER
Indicates that a variable is non-basic and at its upper bound.
|
static int |
Z_VAR
Indicates that a variable is basic.
|
Modifier and Type | Method and Description |
---|---|
static void |
clearState(VectorNi state)
Set all elements in the specified state vector to
W_VAR_LOWER . |
int |
getIterationCount()
Returns the number of iterations that were used in the most recent
solution operation.
|
double |
getLastSolveTol()
Returns the numeric tolerance used to determine complementarity for the
most recent solution.
|
int |
getPivotCount()
Returns the number of pivots that were used in the most recent solution
operation.
|
boolean |
isBLCPSupported()
Queries whether this solver supported the solution of bounded linear
complementarity problems (BLCPs).
|
boolean |
isWarmStartSupported()
Queries whether this solver supports warm starts.
|
int |
numFailedPivots()
Returns the number of pivots that were attempted and rejected because
they would have resulted in a basis matrix that was not SPD.
|
LCPSolver.Status |
solve(VectorNd z,
VectorNd w,
VectorNi state,
MatrixNd M,
VectorNd q,
VectorNd lo,
VectorNd hi,
int nub)
If
isBLCPSupported() returns true , solves the BLCP |
LCPSolver.Status |
solve(VectorNd z,
VectorNi state,
MatrixNd M,
VectorNd q)
Solves the LCP
|
static char |
stateToChar(int sval)
Returns a character representation of a state variable.
|
static java.lang.String |
stateToString(int[] state,
int size)
Returns a string representation of a state vector.
|
static java.lang.String |
stateToString(VectorNi state)
Returns a string representation of a state vector.
|
static java.lang.String |
stateToString(VectorNi state,
int size)
Returns a string representation of a state vector.
|
static VectorNi |
stringToState(java.lang.String str)
Creates a state vector from a string representation
|
static final double INF
static final int W_VAR_LOWER
static final int W_VAR_UPPER
static final int Z_VAR
static char stateToChar(int sval)
sval
- state value to convertstatic java.lang.String stateToString(VectorNi state)
state
- state vector to convert to stringstatic java.lang.String stateToString(VectorNi state, int size)
state
- state vector to convert to stringstatic java.lang.String stateToString(int[] state, int size)
state
- state vector to convert to stringsize
- number of entries of state
to convertstatic VectorNi stringToState(java.lang.String str)
str
- string representation of the statestatic void clearState(VectorNi state)
W_VAR_LOWER
.state
- state vector to clearLCPSolver.Status solve(VectorNd z, VectorNi state, MatrixNd M, VectorNd q)
w = M z + qwhere M is a matrix whose characteristics should match the capabilities of the solver.
z
- returns the solution for zstate
- optional argument, which if non-null
, returns the
state vector resulting from the LCP solve. For solvers capable of warm
starts (i.e., if isWarmStartSupported()
returns true
), the
value of this vector on input will also specify the initial starting
state.M
- system matrixq
- system vectorLCPSolver.Status solve(VectorNd z, VectorNd w, VectorNi state, MatrixNd M, VectorNd q, VectorNd lo, VectorNd hi, int nub)
isBLCPSupported()
returns true
, solves the BLCP
w = M z + q = wpos - wneg, 0 ≤ hi - z perp wneg ≥ 0, 0 ≤ z - lo perp wpos ≥ 0,where M is a matrix whose characteristics should match the capabilities of the solver. If BLCPs are not supported, then this method returns
LCPSolver.Status.UNIMPLEMENTED
.z
- returns the solution for zw
- returns the solution for wstate
- optional argument, which if non-null
, returns the
state vector resulting from the LCP solve. For solvers capable of warm
starts (i.e., if isWarmStartSupported()
returns true
), the
value of this vector on input will also specify the initial starting
state.M
- system matrixq
- system vectorlo
- lower bounds for the z variableshi
- upper bounds for the z variablesnub
- number of unbounded variables (corresponding to bilateral constraints).
If nub > 0
, then the first nub
entries of lo
and hi
must be negative and positive infinity, respectively.boolean isBLCPSupported()
true
if BLCPs are supported.boolean isWarmStartSupported()
true
if warm starts are supported.int getIterationCount()
int getPivotCount()
int numFailedPivots()
double getLastSolveTol()