All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
linear_complementarity_problem.h
1 /* Copyright (C) 2004-2012 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef NUMERICS_LINEAR_COMPLEMENTARITY_PROBLEM_H_
21 #define NUMERICS_LINEAR_COMPLEMENTARITY_PROBLEM_H_
22 
23 #include <fmatvec/fmatvec.h>
24 
25 #include <mbsim/numerics/nonlinear_algebra/multi_dimensional_newton_method.h>
26 #include <mbsim/numerics/nonlinear_algebra/multi_dimensional_fixpoint_solver.h>
27 #include <mbsim/numerics/linear_complementarity_problem/lemke_algorithm.h>
28 
29 #include <mbsim/numerics/functions/lcp_reformulation_functions.h>
30 
31 namespace MBSim {
32 
39  public:
40  enum LCPSolvingStrategy {
41  Standard, //trying to solve the LCP in a standard way (first some steps of Lemke algorithm, then trying iterative schemes in reformulated system, then trying Lemke again as fallback with all steps)
42  ReformulatedStandard, //trying to use the iterative schemes at first (as fallback use Lemke)
43  ReformulatedNewtonOnly,
44  ReformulatedFixpointOnly,
45  LemkeOnly
46  //only use LemkeAgorithm
47  };
48 
49  enum JacobianType {
50  Numerical, //use only a numerical Jacobian Matrix
51  LCPSpecial
52  //use a analytical Jacobian Matrix almost everywhere and choose a derivation at the kink (=LinearComplementarityJacobianFunction) //TODO: find a better name
53  };
54 
55  enum CriteriaType {
56  Global,
57  Local
58  };
59 
68  LinearComplementarityProblem(const fmatvec::SymMat & M_, const fmatvec::Vec & q_, const LCPSolvingStrategy & strategy_ = Standard, const JacobianType & jacobianType_ = LCPSpecial, const unsigned int & DEBUGLEVEL = 0);
69 
71 
72  /*GETTER / SETTER*/
73  void setSystem(const fmatvec::SymMat & M_, const fmatvec::Vec & q_);
74  void setStrategy(const LCPSolvingStrategy & strategy_) {
75  strategy = strategy_;
76  oldStrategy = strategy_;
77  }
78  void setJacobianType(const JacobianType & jacobianType_) {
79  jacobianType = jacobianType_;
80  }
81  void setNewtonCriteriaFunction(CriteriaFunction * criteriaFunction_) {
82  newtonSolver->setCriteriaFunction(criteriaFunction_);
83  }
84  void setFixpointCriteriaFunction(CriteriaFunction * criteriaFunction_) {
85  fixpointSolver->setCriteriaFunction(criteriaFunction_);
86  }
87  void setDebugLevel(const unsigned int & DEBUGLEVEL_) {
88  DEBUGLEVEL = DEBUGLEVEL_;
89  }
90  /****************/
91 
92  fmatvec::Vec solve(const fmatvec::Vec & initialSolution = fmatvec::Vec(0, fmatvec::NONINIT));
93 
97  static double computeMediumEigVal(const fmatvec::SqrMat & M);
98 
102  static fmatvec::Vec createInitialSolution(const fmatvec::SymMat & M, const fmatvec::Vec & q, double mediumEigVal = 0);
103 
107  static fmatvec::Vec createInitialSolution(const fmatvec::SqrMat & M, const fmatvec::Vec & q, double mediumEigVal = 0);
108 
109  protected:
113  void useNewton(fmatvec::Vec & solution, bool & solved);
114 
118  void useFixpoint(fmatvec::Vec & solution, bool & solved);
119 
124 
129 
133  LCPSolvingStrategy strategy;
134 
138  LCPSolvingStrategy oldStrategy;
139 
144 
148  JacobianType jacobianType;
149 
154 
159 
164 
169 
174 
179 
184 
189 
193  unsigned int DEBUGLEVEL;
194  };
195 
196  std::ostream& operator <<(std::ostream & o, const LinearComplementarityProblem::LCPSolvingStrategy &strategy);
197 
198  std::ostream& operator <<(std::ostream & o, const LinearComplementarityProblem::JacobianType &jacobianType);
199 
200 }
201 
202 #endif /*__LINEAR_COMPLEMENTARITY_PROBLEM_H_*/
LCPSolvingStrategy strategy
algorithm strategy to solve the LCP
Definition: linear_complementarity_problem.h:133
LCPFixpointReformulationFunction * fixpointFunction
reformulated LCP suited for a FixpointSolver
Definition: linear_complementarity_problem.h:183
Newton method for multidimensional root finding.
Definition: multi_dimensional_newton_method.h:41
Definition: lcp_reformulation_functions.h:135
LemkeAlgorithm lemkeSolver
LemkeSolver for the direct solution of the LCP.
Definition: linear_complementarity_problem.h:153
class to solve a linear complementarity problem
Definition: linear_complementarity_problem.h:38
LCPSolvingStrategy oldStrategy
save old Strategy for switching...
Definition: linear_complementarity_problem.h:138
LinearComplementarityProblem(const fmatvec::SymMat &M_, const fmatvec::Vec &q_, const LCPSolvingStrategy &strategy_=Standard, const JacobianType &jacobianType_=LCPSpecial, const unsigned int &DEBUGLEVEL=0)
solves a linear complementarity problem (w = M z + q)
Definition: linear_complementarity_problem.cc:76
double mediumEigenValue
parameter for finding the start solution for the reformulated system
Definition: linear_complementarity_problem.h:143
MultiDimensionalFixpointSolver * fixpointSolver
FixpointSolver for reformulated system.
Definition: linear_complementarity_problem.h:178
unsigned int DEBUGLEVEL
Output (information) level.
Definition: linear_complementarity_problem.h:193
Definition: lemke_algorithm.h:28
base class for square Jacobians used for the newton method
Definition: newton_method_jacobian_functions.h:31
fmatvec::Vec q
constant vector of the LCP
Definition: linear_complementarity_problem.h:128
void useFixpoint(fmatvec::Vec &solution, bool &solved)
change the incoming solution vector using the fixpoint scheme
Definition: linear_complementarity_problem.cc:385
NewtonJacobianFunction * jacobianFunction
Jacobian Function for the reformulated LCP.
Definition: linear_complementarity_problem.h:168
Definition: lcp_reformulation_functions.h:104
MBSim::MultiDimensionalNewtonMethod * newtonSolver
NewtonSolver for reformulated system.
Definition: linear_complementarity_problem.h:158
Mother class for different criterias that are fulfilled or not.
Definition: criteria_functions.h:33
static double computeMediumEigVal(const fmatvec::SqrMat &M)
compute the medium eigenvalue of a matrix (for guessing a initial solution for iterative schemes) ...
Definition: linear_complementarity_problem.cc:298
LCPNewtonReformulationFunction * newtonFunction
reformulated LCP suited for a Newton Solver
Definition: linear_complementarity_problem.h:163
void useNewton(fmatvec::Vec &solution, bool &solved)
change the incoming solution vector using the fixpoint scheme
Definition: linear_complementarity_problem.cc:335
JacobianType jacobianType
jacobian function for the solving with thew newton algorithm in the reformulated case ...
Definition: linear_complementarity_problem.h:148
Fixpoint-Solver for multi-dimensional fixpoint-finding.
Definition: multi_dimensional_fixpoint_solver.h:34
CriteriaFunction * criteriaNewton
criteria function for Newton solver
Definition: linear_complementarity_problem.h:173
CriteriaFunction * criteriaFixedpoint
criteria function for Fixedpoint solver
Definition: linear_complementarity_problem.h:188
fmatvec::SqrMat M
linear coupling matrix of the LCP
Definition: linear_complementarity_problem.h:123
static fmatvec::Vec createInitialSolution(const fmatvec::SymMat &M, const fmatvec::Vec &q, double mediumEigVal=0)
creates an initial solution for the iterative schemes that use a reformulated system ...
Definition: linear_complementarity_problem.cc:307

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML