00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef NUMERICS_LINEAR_COMPLEMENTARITY_PROBLEM_H_
00021 #define NUMERICS_LINEAR_COMPLEMENTARITY_PROBLEM_H_
00022
00023 #include <fmatvec/fmatvec.h>
00024
00025 #include <mbsim/numerics/nonlinear_algebra/multi_dimensional_newton_method.h>
00026 #include <mbsim/numerics/nonlinear_algebra/multi_dimensional_fixpoint_solver.h>
00027 #include <mbsim/numerics/linear_complementarity_problem/lemke_algorithm.h>
00028
00029 #include <mbsim/numerics/functions/lcp_reformulation_functions.h>
00030
00031 namespace MBSim {
00032
00038 class LinearComplementarityProblem {
00039 public:
00040 enum LCPSolvingStrategy {
00041 Standard,
00042 ReformulatedStandard,
00043 ReformulatedNewtonOnly,
00044 ReformulatedFixpointOnly,
00045 LemkeOnly
00046
00047 };
00048
00049 enum JacobianType {
00050 Numerical,
00051 LCPSpecial
00052
00053 };
00054
00055 enum CriteriaType {
00056 Global,
00057 Local
00058 };
00059
00068 LinearComplementarityProblem(const fmatvec::SymMat & M_, const fmatvec::Vec & q_, const LCPSolvingStrategy & strategy_ = Standard, const JacobianType & jacobianType_ = LCPSpecial, const unsigned int & DEBUGLEVEL = 0);
00069
00070 virtual ~LinearComplementarityProblem();
00071
00072
00073 void setSystem(const fmatvec::SymMat & M_, const fmatvec::Vec & q_);
00074 void setStrategy(const LCPSolvingStrategy & strategy_) {
00075 strategy = strategy_;
00076 oldStrategy = strategy_;
00077 }
00078 void setJacobianType(const JacobianType & jacobianType_) {
00079 jacobianType = jacobianType_;
00080 }
00081 void setNewtonCriteriaFunction(CriteriaFunction * criteriaFunction_) {
00082 newtonSolver->setCriteriaFunction(criteriaFunction_);
00083 }
00084 void setFixpointCriteriaFunction(CriteriaFunction * criteriaFunction_) {
00085 fixpointSolver->setCriteriaFunction(criteriaFunction_);
00086 }
00087 void setDebugLevel(const unsigned int & DEBUGLEVEL_) {
00088 DEBUGLEVEL = DEBUGLEVEL_;
00089 }
00090
00091
00092 fmatvec::Vec solve(const fmatvec::Vec & initialSolution = fmatvec::Vec(0, fmatvec::NONINIT));
00093
00097 static double computeMediumEigVal(const fmatvec::SqrMat & M);
00098
00102 static fmatvec::Vec createInitialSolution(const fmatvec::SymMat & M, const fmatvec::Vec & q, double mediumEigVal = 0);
00103
00107 static fmatvec::Vec createInitialSolution(const fmatvec::SqrMat & M, const fmatvec::Vec & q, double mediumEigVal = 0);
00108
00109 protected:
00113 void useNewton(fmatvec::Vec & solution, bool & solved);
00114
00118 void useFixpoint(fmatvec::Vec & solution, bool & solved);
00119
00123 fmatvec::SqrMat M;
00124
00128 fmatvec::Vec q;
00129
00133 LCPSolvingStrategy strategy;
00134
00138 LCPSolvingStrategy oldStrategy;
00139
00143 double mediumEigenValue;
00144
00148 JacobianType jacobianType;
00149
00153 LemkeAlgorithm lemkeSolver;
00154
00158 MultiDimensionalNewtonMethod * newtonSolver;
00159
00163 LCPNewtonReformulationFunction * newtonFunction;
00164
00168 NewtonJacobianFunction * jacobianFunction;
00169
00173 CriteriaFunction * criteriaNewton;
00174
00178 MultiDimensionalFixpointSolver * fixpointSolver;
00179
00183 LCPFixpointReformulationFunction * fixpointFunction;
00184
00188 CriteriaFunction * criteriaFixedpoint;
00189
00193 unsigned int DEBUGLEVEL;
00194 };
00195
00196 std::ostream& operator <<(std::ostream & o, const LinearComplementarityProblem::LCPSolvingStrategy &strategy);
00197
00198 std::ostream& operator <<(std::ostream & o, const LinearComplementarityProblem::JacobianType &jacobianType);
00199
00200 }
00201
00202 #endif