mbsim  4.0.0
MBSim Kernel
multi_dimensional_fixpoint_solver.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_MULTI_DIMENSIONAL_FIXPOINT_SOLVER_H_
21#define NUMERICS_MULTI_DIMENSIONAL_FIXPOINT_SOLVER_H_
22
23#include <fmatvec/fmatvec.h>
24
25#include <mbsim/numerics/functions/criteria_functions.h>
26
27namespace MBSim {
28
35 public:
40
41 /*
42 * \brief constructor
43 * \param fct pointer to used fix-point-function
44 */
45 MultiDimensionalFixpointSolver(Function<fmatvec::Vec(fmatvec::Vec)> *function_);
46
47 virtual ~MultiDimensionalFixpointSolver()= default;;
48
49 /* GETTER / SETTER */
56 void setFunction(Function<fmatvec::Vec(fmatvec::Vec)> *function_) {function = function_;}
57 int getInfo() {
58 return info;
59 }
60 std::vector<double> getNorms() {
61 return norms;
62 }
63 double getNumberOfIterations() {
64 return iter;
65 }
66 double getNumberOfMaximalIterations() {
67 return itermax;
68 }
69 void setNumberOfMaximalIterations(int itermax_) {
70 itermax = itermax_;
71 }
72 void setCriteriaFunction(CriteriaFunction * criteria_) {
73 criteria = criteria_;
74 }
75 /*******************/
76
77 fmatvec::Vec solve(const fmatvec::Vec &initialGuess);
78
79 private:
83 Function<fmatvec::Vec(fmatvec::Vec)> *function{0};
84
85 /*
86 * \brief criteria function
87 *
88 * This function defines the criteria when to stop the fixpoint iteration
89 */
90 CriteriaFunction *criteria{0};
91
95 int iter{0};
96
100 double itermax{1e3};
101
105 std::vector<double> norms;
106
110 int info{1};
111 };
112
113} /* namespace MBSim */
114#endif /* MULTI_DIMENSIONAL_FIXPOINT_SOLVER_H_ */
Mother class for different criterias that are fulfilled or not.
Definition: criteria_functions.h:33
Definition: function.h:53
Fixpoint-Solver for multi-dimensional fixpoint-finding.
Definition: multi_dimensional_fixpoint_solver.h:34
std::vector< double > norms
vector of norms
Definition: multi_dimensional_fixpoint_solver.h:105
int iter
number of iterations
Definition: multi_dimensional_fixpoint_solver.h:95
double itermax
maximal iterations
Definition: multi_dimensional_fixpoint_solver.h:100
Function< fmatvec::Vec(fmatvec::Vec)> * function
fixpoint function
Definition: multi_dimensional_fixpoint_solver.h:83
void setFunction(Function< fmatvec::Vec(fmatvec::Vec)> *function_)
returns info of iteration progress info == 0 : a solution has been found info == -1: no converge info...
Definition: multi_dimensional_fixpoint_solver.h:56
int info
information variable about success of iteration
Definition: multi_dimensional_fixpoint_solver.h:110
MultiDimensionalFixpointSolver()
plain constructor
Definition: multi_dimensional_fixpoint_solver.cc:29
namespace MBSim
Definition: bilateral_constraint.cc:30