mbsim 4.0.0 MBSim Kernel

multi_dimensional_newton_method.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_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
21 #define NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
22
23 #include <fmatvec/fmatvec.h>
24
25 #include <map>
26
27 #include <mbsim/numerics/functions/newton_method_jacobian_functions.h>
28 #include <mbsim/numerics/functions/criteria_functions.h>
29 #include <mbsim/numerics/functions/damping_functions.h>
30
31 namespace fmatvec {
32 bool operator<(const fmatvec::RangeV & i1, const fmatvec::RangeV & i2);
33 }
34
35 namespace MBSim {
36
41 class MultiDimensionalNewtonMethod : public virtual fmatvec::Atom {
42 public:
46 MultiDimensionalNewtonMethod();
47
48 virtual ~MultiDimensionalNewtonMethod() = default;
49
50 /* GETTER / SETTER */
51 int getNumberOfIterations() const {
52 return iter;
53 }
54 int getNumberOfMaximalIterations() const {
55 return itermax;
56 }
57 int getInfo() const {
58 return info;
59 }
60 void setMaximumNumberOfIterations(int itmax_) {
61 itermax = itmax_;
62 }
63 void setFunction(Function<fmatvec::Vec(fmatvec::Vec)> *function_) {
64 function = function_;
65 }
66 void setJacobianFunction(NewtonJacobianFunction * jacobian_) {
67 jacobian = jacobian_;
68 }
69 void setDampingFunction(MBSim::DampingFunction * damping_) {
70 damping = damping_;
71 }
72 void setCriteriaFunction(CriteriaFunction * criteria_) {
73 criteria = criteria_;
74 }
75 CriteriaFunction * getCriteriaFunction() {
76 return criteria;
77 }
78 void setLinearAlgebra(int linAlg_) {
79 linAlg = linAlg_;
80 }
81
82 void setJacobianUpdateFreq(int JacobianUpdateFreq_) {
83 jacobianUpdateFreq = JacobianUpdateFreq_;
84 }
85 /***************************************************/
86
91 fmatvec::Vec solve(const fmatvec::Vec & initialValue);
92
93 private:
94
98 Function<fmatvec::Vec(fmatvec::Vec)> *function;
99
103 NewtonJacobianFunction *jacobian;
104
105 /*
106 * \brief damping function
107 */
108 DampingFunction *damping;
109
110 /*
111 * \brief criteria function
112 *
113 * This function defines the criteria when to stop the Newton algorithm
114 */
115 CriteriaFunction *criteria;
116
120 int itermax;
121
122 /*
123 * \brief number of iterations
124 */
125 int iter;
126
127 /*
128 * \brief information about the result of the method
129 */
130 int info;
131
137 int linAlg;
138
142 int jacobianUpdateFreq;
143
144 };
145 }
146 #endif /* NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_ */
MBSim::MultiDimensionalNewtonMethod
Newton method for multidimensional root finding.
Definition: multi_dimensional_newton_method.h:41
MBSim::MultiDimensionalNewtonMethod::jacobian
NewtonJacobianFunction * jacobian
Jacobian matrix.
Definition: multi_dimensional_newton_method.h:103
MBSim::MultiDimensionalNewtonMethod::itermax
int itermax
maximum number of iterations, actual number of iterations, maximum number of damping steps,...
Definition: multi_dimensional_newton_method.h:120
MBSim::NewtonJacobianFunction
base class for square Jacobians used for the newton method
Definition: newton_method_jacobian_functions.h:31
MBSim::MultiDimensionalNewtonMethod::jacobianUpdateFreq
int jacobianUpdateFreq
the frequency of updating Jacobian during iteration
Definition: multi_dimensional_newton_method.h:142
MBSim::MultiDimensionalNewtonMethod::MultiDimensionalNewtonMethod
MultiDimensionalNewtonMethod()
plain constructor
Definition: multi_dimensional_newton_method.cc:57
MBSim::CriteriaFunction
Mother class for different criterias that are fulfilled or not.
Definition: criteria_functions.h:33
MBSim::Function
Definition: contact_kinematics.h:32
MBSim::DampingFunction
Definition: damping_functions.h:27
MBSim::MultiDimensionalNewtonMethod::linAlg
int linAlg
flag which linear algebra solution should be taken 0 = solve with LU-decomposition 1 = solve with LS ...
Definition: multi_dimensional_newton_method.h:137
MBSim::MultiDimensionalNewtonMethod::solve
fmatvec::Vec solve(const fmatvec::Vec &initialValue)
solve nonlinear root function
Definition: multi_dimensional_newton_method.cc:61
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30