MlcpGaussSeidelSolver.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_MATH_MLCPGAUSSSEIDELSOLVER_H
#define SURGSIM_MATH_MLCPGAUSSSEIDELSOLVER_H
#include <memory.h>
#include "SurgSim/Math/Matrix.h"
#include "SurgSim/Math/MlcpProblem.h"
#include "SurgSim/Math/MlcpSolver.h"
#include "SurgSim/Math/MlcpSolution.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Framework
{
class Logger;
}
namespace Math
{
class MlcpGaussSeidelSolver : public MlcpSolver
{
public:
MlcpGaussSeidelSolver();
MlcpGaussSeidelSolver(double epsilonConvergence, double contactTolerance, size_t maxIterations);
virtual ~MlcpGaussSeidelSolver();
bool solve(const MlcpProblem& problem, MlcpSolution* solution);
double getEpsilonConvergence() const;
void setEpsilonConvergence(double precision);
double getContactTolerance() const;
void setContactTolerance(double tolerance);
size_t getMaxIterations() const;
void setMaxIterations(size_t maxIterations);
private:
void computeEnforcementSystem(size_t problemSize, const MlcpProblem::Matrix& A,
const MlcpProblem::Vector& b,
const MlcpSolution::Vector& initialGuessAndSolution,
const std::vector<MlcpConstraintType>& constraintsType,
size_t constraintID, size_t matrixEntryForConstraintID);
void calculateConvergenceCriteria(size_t problemSize, const MlcpProblem::Matrix& A,
const MlcpProblem::Vector& b,
const MlcpSolution::Vector& initialGuessAndSolution,
const std::vector<MlcpConstraintType>& constraintsType,
double constraintConvergenceCriteria[MLCP_NUM_CONSTRAINT_TYPES],
double* convergenceCriteria,
bool* validSignorini);
void doOneIteration(size_t problemSize, const MlcpProblem::Matrix& A,
const MlcpProblem::Vector& b,
MlcpSolution::Vector* initialGuessAndSolution,
const MlcpProblem::Vector& frictionCoefs,
const std::vector<MlcpConstraintType>& constraintsType,
double constraintConvergenceCriteria[MLCP_NUM_CONSTRAINT_TYPES], double* convergenceCriteria,
bool* validSignorini);
void printViolationsAndConvergence(size_t problemSize, const MlcpProblem::Matrix& A,
const MlcpProblem::Vector& b,
const MlcpSolution::Vector& initialGuessAndSolution,
const std::vector<MlcpConstraintType>& constraintsType,
double convergenceCriteria,
bool validSignorini, size_t iterations);
double m_epsilonConvergence;
double m_contactTolerance;
size_t m_maxIterations;
size_t m_numEnforcedAtomicConstraints;
Matrix m_lhsEnforcedLocalSystem;
Vector m_rhsEnforcedLocalSystem;
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
};
}; // namespace Math
}; // namespace SurgSim
#endif // SURGSIM_MATH_MLCPGAUSSSEIDELSOLVER_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::MlcpGaussSeidelSolver
A solver for mixed LCP problems using the Gauss-Seidel iterative method.
Definition: MlcpGaussSeidelSolver.h:53
SurgSim::Math::MlcpProblem::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: MlcpProblem.h:63
SurgSim::Math::MLCP_NUM_CONSTRAINT_TYPES
Definition: MlcpConstraintType.h:44
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
MlcpProblem.h
SurgSim::Math::MlcpGaussSeidelSolver::m_lhsEnforcedLocalSystem
Matrix m_lhsEnforcedLocalSystem
The left-hand side matrix.
Definition: MlcpGaussSeidelSolver.h:138
SurgSim::Math::MlcpGaussSeidelSolver::m_epsilonConvergence
double m_epsilonConvergence
The precision.
Definition: MlcpGaussSeidelSolver.h:126
MlcpSolution.h
SurgSim::Math::MlcpGaussSeidelSolver::m_numEnforcedAtomicConstraints
size_t m_numEnforcedAtomicConstraints
The number of atomic constraints, aka the system size.
Definition: MlcpGaussSeidelSolver.h:135
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Math::MlcpSolution::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: MlcpSolution.h:35
SurgSim::Math::MlcpProblem::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: MlcpProblem.h:62
SurgSim::Math::MlcpGaussSeidelSolver::m_maxIterations
size_t m_maxIterations
The maximum number of iterations.
Definition: MlcpGaussSeidelSolver.h:132
SurgSim::Math::MlcpSolution
The description of a solution to a mixed linear complementarity problem.
Definition: MlcpSolution.h:33
SurgSim::Math::MlcpSolver
This class provides a solver interface for mixed linear complementarity problems. ...
Definition: MlcpSolver.h:30
Matrix.h
Definitions of small fixed-size square matrix types.
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Math::MlcpGaussSeidelSolver::m_rhsEnforcedLocalSystem
Vector m_rhsEnforcedLocalSystem
The right-hand side vector.
Definition: MlcpGaussSeidelSolver.h:141
SurgSim::Math::MlcpGaussSeidelSolver::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
The logger.
Definition: MlcpGaussSeidelSolver.h:144
SurgSim::Math::MlcpGaussSeidelSolver::m_contactTolerance
double m_contactTolerance
The contact tolerance.
Definition: MlcpGaussSeidelSolver.h:129
SurgSim::Math::solve
void solve(const T &a, const T &b, const T &epsilon, int *numRoots, std::array< T, N > *roots)
Specialized solve routine for linear polynomials (2 coefficients)
Definition: PolynomialRoots-inl.h:64
SurgSim::Math::MlcpProblem
A description of an MLCP (mixed linear complementarity problem, or mixed LCP) system to be solved...
Definition: MlcpProblem.h:57
MlcpSolver.h