MBSim

Project Page
multi_dimensional_newton_method.h
00001 /* Copyright (C) 2004-2012 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@googlemail.com
00018  */
00019 
00020 #ifndef NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
00021 #define NUMERICS_NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_
00022 
00023 #include <fmatvec/fmatvec.h>
00024 
00025 #include <map>
00026 
00027 #include <mbsim/numerics/functions/newton_method_jacobian_functions.h>
00028 #include <mbsim/numerics/functions/criteria_functions.h>
00029 #include <mbsim/numerics/functions/damping_functions.h>
00030 
00031 namespace fmatvec {
00032   bool operator<(const fmatvec::Index & i1, const fmatvec::Index & i2);
00033 }
00034 
00035 namespace MBSim {
00036 
00041   class MultiDimensionalNewtonMethod {
00042     public:
00046       MultiDimensionalNewtonMethod();
00047 
00048       virtual ~MultiDimensionalNewtonMethod() {
00049       }
00050 
00051       /* GETTER / SETTER */
00052       int getNumberOfIterations() const {
00053         return iter;
00054       }
00055       int getNumberOfMaximalIterations() const {
00056         return itermax;
00057       }
00058       int getInfo() const {
00059         return info;
00060       }
00061       void setMaximumNumberOfIterations(int itmax_) {
00062         itermax = itmax_;
00063       }
00064       void setFunction(Function<fmatvec::Vec(fmatvec::Vec)> *function_) {
00065         function = function_;
00066       }
00067       void setJacobianFunction(NewtonJacobianFunction * jacobian_) {
00068         jacobian = jacobian_;
00069       }
00070       void setDampingFunction(DampingFunction * damping_) {
00071         damping = damping_;
00072       }
00073       void setCriteriaFunction(CriteriaFunction * criteria_) {
00074         criteria = criteria_;
00075       }
00076       CriteriaFunction * getCriteriaFunction() {
00077         return criteria;
00078       }
00079       void setLinearAlgebra(int linAlg_) {
00080         linAlg = linAlg_;
00081       }
00082 
00083       void setJacobianUpdateFreq(int JacobianUpdateFreq_) {
00084         jacobianUpdateFreq = JacobianUpdateFreq_;
00085       }
00086       /***************************************************/
00087 
00092       fmatvec::Vec solve(const fmatvec::Vec & initialValue);
00093 
00094     private:
00095 
00099       Function<fmatvec::Vec(fmatvec::Vec)> *function;
00100 
00104       NewtonJacobianFunction *jacobian;
00105 
00106       /*
00107        * \brief damping function
00108        */
00109       DampingFunction *damping;
00110 
00111       /*
00112        * \brief criteria function
00113        *
00114        * This function defines the criteria when to stop the Newton algorithm
00115        */
00116       CriteriaFunction *criteria;
00117 
00121       int itermax;
00122 
00123       /*
00124        * \brief number of iterations
00125        */
00126       int iter;
00127 
00128       /*
00129        * \brief information about the result of the method
00130        */
00131       int info;
00132 
00138       int linAlg;
00139 
00143       int jacobianUpdateFreq;
00144 
00145   };
00146 }
00147 #endif /* NUMERICSMULTIDIMENSIONALNEWTONMETHOD_H_ */