maspack.solvers
Class KKTSolver

java.lang.Object
  extended by maspack.solvers.KKTSolver

public class KKTSolver
extends java.lang.Object


Nested Class Summary
static class KKTSolver.Status
          Described whether or not a solution was found.
 
Constructor Summary
KKTSolver()
           
 
Method Summary
 void analyze(SparseBlockMatrix M, int sizeM, SparseBlockMatrix GT, int typeM)
          Performs symbolic analysis on the equality portion of the KKT system defined by matrices M and GT.
 void analyze(VectorNd Mdiag, int sizeM, SparseBlockMatrix GT)
          Performs symbolic analysis on the equality portion of the KKT system defined by a diagonal M matrix and G.
 void analyzeMG(java.lang.Object M, int sizeM, SparseBlockMatrix GT, VectorNd Rg, int typeM)
          Performs symbolic analysis on the equality portion of the KKT system defined by M and G.
 void dispose()
           
 void factor(SparseBlockMatrix M, int sizeM, SparseBlockMatrix GT, VectorNd Rg)
          Does a numeric factorization of a KKT system containg only equality constraints.
 void factor(SparseBlockMatrix M, int sizeM, SparseBlockMatrix GT, VectorNd Rg, SparseBlockMatrix NT, VectorNd Rn)
          Does a numeric factorization of a KKT system containing equality and inequality constraints.
 void factor(SparseBlockMatrix M, int sizeM, SparseBlockMatrix GT, VectorNd Rg, SparseBlockMatrix NT, VectorNd Rn, SparseBlockMatrix DT)
          Does a numeric factorization of a KKT system containg equality, inequality, and friction constraints.
 void factor(VectorNd Mdiag, int sizeM, SparseBlockMatrix GT, VectorNd Rg)
          Does a numeric factorization of a KKT system containg only equality constraints.
 void factor(VectorNd Mdiag, int sizeM, SparseBlockMatrix GT, VectorNd Rg, SparseBlockMatrix NT, VectorNd Rn)
          Does a numeric factorization of a KKT system containg equality and inequality constraints.
 KKTSolver.Status factorAndSolve(SparseBlockMatrix M, int sizeM, SparseBlockMatrix GT, VectorNd Rg, VectorNd vel, VectorNd lam, VectorNd bm, VectorNd bg, int tolExp)
          Does a numeric factorization of a KKT system containg only equality constraints.
 void finalize()
           
 int getNumNonZerosInFactors()
           
 boolean[] getZBasic()
           
 int[] getZState()
           
 boolean isFactored()
           
 boolean lastSolveWasIterative()
           
 void printLinearProblem(java.io.PrintWriter pw, VectorNd bf, VectorNd bg, java.lang.String fmtStr, boolean omitLowerRightDiagonal)
           
 void printStructure(java.io.PrintStream ps)
           
 void printValues(java.io.PrintStream ps, java.lang.String fmtStr)
           
 void printValues(java.io.PrintStream ps, java.lang.String fmtStr, double[] vals, int[] rowOffs, int[] colIdxs, int size, int numVals)
           
 KKTSolver.Status solve(VectorNd vel, VectorNd lam, VectorNd bm, VectorNd bg)
          Solves the equality parts of a factored system.
 KKTSolver.Status solve(VectorNd vel, VectorNd lam, VectorNd the, VectorNd bm, VectorNd bg, VectorNd bn)
          Solves the equality and inequality parts of a factored system.
 KKTSolver.Status solve(VectorNd vel, VectorNd lam, VectorNd the, VectorNd phi, VectorNd bm, VectorNd bg, VectorNd bn, VectorNd bd, VectorNd flim)
          Solves the equality, inequality, and frictional parts of a factored system.
 void solveMG(VectorNd x, VectorNd b)
          Solve the system
 void solveMG(VectorNd xm, VectorNd xg, VectorNd bm, VectorNd bg)
          Solve the system
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KKTSolver

public KKTSolver()
Method Detail

analyzeMG

public void analyzeMG(java.lang.Object M,
                      int sizeM,
                      SparseBlockMatrix GT,
                      VectorNd Rg,
                      int typeM)
Performs symbolic analysis on the equality portion of the KKT system defined by M and G. This step must be called before any calls are made to factor().


analyze

public void analyze(VectorNd Mdiag,
                    int sizeM,
                    SparseBlockMatrix GT)
Performs symbolic analysis on the equality portion of the KKT system defined by a diagonal M matrix and G. This step must be called before any calls are made to factor().

Parameters:
Mdiag - vector defining the diagonal entries of M
sizeM - size of M
GT - Sparse matrix defining the transpose of G

analyze

public void analyze(SparseBlockMatrix M,
                    int sizeM,
                    SparseBlockMatrix GT,
                    int typeM)
Performs symbolic analysis on the equality portion of the KKT system defined by matrices M and GT. This step must be called before any calls are made to factor().

Parameters:
M - Sparse matrix defining M
sizeM - size of M
GT - Sparse matrix defining the transpose of G
typeM - describes the type of M, to be used in determining how the resulting KKT system should be factored. Should be either Matrix.INDEFINITE, Matrix.SYMMETRIC, or Matrix.SPD.

factor

public void factor(SparseBlockMatrix M,
                   int sizeM,
                   SparseBlockMatrix GT,
                   VectorNd Rg)
Does a numeric factorization of a KKT system containg only equality constraints. analyze() must have been previously called with M and G matrices having the same symbolic structure as the ones supplied to this method.


factor

public void factor(SparseBlockMatrix M,
                   int sizeM,
                   SparseBlockMatrix GT,
                   VectorNd Rg,
                   SparseBlockMatrix NT,
                   VectorNd Rn)
Does a numeric factorization of a KKT system containing equality and inequality constraints. analyze() must have been previously called with M and G matrices having the same symbolic structure as the ones supplied to this method.


factor

public void factor(SparseBlockMatrix M,
                   int sizeM,
                   SparseBlockMatrix GT,
                   VectorNd Rg,
                   SparseBlockMatrix NT,
                   VectorNd Rn,
                   SparseBlockMatrix DT)
Does a numeric factorization of a KKT system containg equality, inequality, and friction constraints. analyze() must have been previously called with M and G matrices having the same symbolic structure as the ones supplied to this method.


factor

public void factor(VectorNd Mdiag,
                   int sizeM,
                   SparseBlockMatrix GT,
                   VectorNd Rg)
Does a numeric factorization of a KKT system containg only equality constraints. analyze() must have been previously called with M and GT matrices having the same symbolic structure as the ones supplied to this method.


factor

public void factor(VectorNd Mdiag,
                   int sizeM,
                   SparseBlockMatrix GT,
                   VectorNd Rg,
                   SparseBlockMatrix NT,
                   VectorNd Rn)
Does a numeric factorization of a KKT system containg equality and inequality constraints. analyze() must have been previously called with M and G matrices having the same symbolic structure as the ones supplied to this method.


isFactored

public boolean isFactored()

solve

public KKTSolver.Status solve(VectorNd vel,
                              VectorNd lam,
                              VectorNd the,
                              VectorNd phi,
                              VectorNd bm,
                              VectorNd bg,
                              VectorNd bn,
                              VectorNd bd,
                              VectorNd flim)
Solves the equality, inequality, and frictional parts of a factored system.


solve

public KKTSolver.Status solve(VectorNd vel,
                              VectorNd lam,
                              VectorNd the,
                              VectorNd bm,
                              VectorNd bg,
                              VectorNd bn)
Solves the equality and inequality parts of a factored system.


solve

public KKTSolver.Status solve(VectorNd vel,
                              VectorNd lam,
                              VectorNd bm,
                              VectorNd bg)
Solves the equality parts of a factored system.


factorAndSolve

public KKTSolver.Status factorAndSolve(SparseBlockMatrix M,
                                       int sizeM,
                                       SparseBlockMatrix GT,
                                       VectorNd Rg,
                                       VectorNd vel,
                                       VectorNd lam,
                                       VectorNd bm,
                                       VectorNd bg,
                                       int tolExp)
Does a numeric factorization of a KKT system containg only equality constraints. analyze() must have been previously called with M and G matrices having the same symbolic structure as the ones supplied to this method.


getZBasic

public boolean[] getZBasic()

getZState

public int[] getZState()

printStructure

public void printStructure(java.io.PrintStream ps)

printValues

public void printValues(java.io.PrintStream ps,
                        java.lang.String fmtStr)

printLinearProblem

public void printLinearProblem(java.io.PrintWriter pw,
                               VectorNd bf,
                               VectorNd bg,
                               java.lang.String fmtStr,
                               boolean omitLowerRightDiagonal)
                        throws java.io.IOException
Throws:
java.io.IOException

printValues

public void printValues(java.io.PrintStream ps,
                        java.lang.String fmtStr,
                        double[] vals,
                        int[] rowOffs,
                        int[] colIdxs,
                        int size,
                        int numVals)

solveMG

public void solveMG(VectorNd x,
                    VectorNd b)
Solve the system
 [ M -G ] [ x ]   [ b ]
 [      ] [   ] = [   ]
 [ G Rg ] [lam]   [ a ]
 
using the factorization of
 [ M  G ]
 [      ] 
 [ G -Rg ]
 
This requires negating the value of lam from the original solve


solveMG

public void solveMG(VectorNd xm,
                    VectorNd xg,
                    VectorNd bm,
                    VectorNd bg)
Solve the system
 [ M -G ] [ x ]   [ b ]
 [      ] [   ] = [   ]
 [ G Rg ] [lam]   [ a ]
 
using the factorization of
 [ M  G ]
 [      ] 
 [ G -Rg ]
 
This requires negating the value of lam from the original solve


getNumNonZerosInFactors

public int getNumNonZerosInFactors()

lastSolveWasIterative

public boolean lastSolveWasIterative()

dispose

public void dispose()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object