All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
criteria_functions.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 NUMERICSCRITERIAFUNCTIONS_H_
21 #define NUMERICSCRITERIAFUNCTIONS_H_
22 
23 #include <fmatvec/fmatvec.h>
24 #include <mbsim/functions/function.h>
25 
26 #include <map>
27 
28 namespace MBSim {
29 
33  class CriteriaFunction : public Function<int(fmatvec::Vec)> {
34 
35  public:
40 
44  virtual ~CriteriaFunction();
45 
46  /* GETTER / SETTER*/
47  void setFunction(Function<fmatvec::Vec(fmatvec::Vec)> *function_) {
48  function = function_;
49  }
50  /*****************/
51 
61  virtual int operator ()(const fmatvec::Vec & vector) = 0;
62 
66  virtual void clear() = 0;
67 
71  virtual bool isBetter(const fmatvec::Vec & vector, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT)) = 0;
72 
73  protected:
78 
79  };
80 
85 
86  public:
90  GlobalCriteriaFunction(const double & tolerance_ = 1e-10);
91 
95  virtual ~GlobalCriteriaFunction();
96 
97  /* INHERITED INTERFACE */
98  virtual int operator ()(const fmatvec::Vec & vector);
99  virtual bool isBetter(const fmatvec::Vec & vector, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
100  virtual void clear();
101  /*END - INHERITED INTERFACE*/
102 
103  const std::vector<double> & getResults() {
104  return criteriaResults;
105  }
106 
107  void setTolerance(double tol) {
108  tolerance = tol;
109  }
110 
111  protected:
112  /*INHERITED INTERFACE*/
113  virtual double computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT)) = 0;
114  /********************/
115 
119  double tolerance;
120 
124  std::vector<double> criteriaResults;
125  };
126 
131 
132  public:
136  LocalCriteriaFunction(const std::map<fmatvec::RangeV, double> & tolerances_);
137 
141  virtual ~LocalCriteriaFunction();
142 
143  /* INHERITED INTERFACE */
144  virtual int operator ()(const fmatvec::Vec & vector);
145  virtual bool isBetter(const fmatvec::Vec & vector, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
146  virtual void clear();
147  /*END - INHERITED INTERFACE*/
148 
149  virtual void setTolerances(const std::map<fmatvec::RangeV, double> & tolerances_) {
150  tolerances = tolerances_;
151  }
152 
153  protected:
154  virtual std::vector<double> computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT)) = 0;
155 
156  /*
157  * \brief saves the tolerance for a specified index sets
158  */
159  std::map<fmatvec::RangeV, double> tolerances;
160 
164  std::vector<std::vector<double> > criteriaResults;
165  };
166 
171 
172  public:
176  GlobalResidualCriteriaFunction(const double & tolerance_ = 1e-10);
177 
182 
183  protected:
184  /* INHERITED INTERFACE */
185  virtual double computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
186  /*END - INHERITED INTERFACE*/
187  };
188 
193 
194  public:
198  LocalResidualCriteriaFunction(const std::map<fmatvec::RangeV, double> & tolerances_);
199 
204 
205  protected:
206 
207  virtual std::vector<double> computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
208  };
209 
214  public:
218  GlobalShiftCriteriaFunction(const double & tolerance_ = 1e-10);
219 
224 
225  virtual fmatvec::Vec getLastPoint() {
226  return lastPoint;
227  }
228 
229  protected:
230  /* INHERITED INTERFACE */
231  virtual double computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
232  /*END - INHERITED INTERFACE*/
233 
238 
239  };
240 
245 
246  public:
250  LocalShiftCriteriaFunction(const std::map<fmatvec::RangeV, double> & tolerances_);
251 
255  virtual ~LocalShiftCriteriaFunction();
256 
257  virtual fmatvec::Vec getLastPoint() {
258  return lastPoint;
259  }
260 
261  protected:
262  virtual std::vector<double> computeResults(const fmatvec::Vec & x, const fmatvec::Vec & fVal = fmatvec::Vec(0,fmatvec::NONINIT));
263 
268  };
269 
277 }
278 #endif //NUMERICSCRITERIAFUNCTIONS_H_
This criteria function class applies the infinity norm globally on the complete vector and compares i...
Definition: criteria_functions.h:170
CriteriaFunction()
Constructor.
Definition: criteria_functions.cc:30
fmatvec::Vec lastPoint
save the point of the last step for comparison
Definition: criteria_functions.h:237
LocalCriteriaFunction(const std::map< fmatvec::RangeV, double > &tolerances_)
Constructor.
Definition: criteria_functions.cc:66
virtual void clear()
deletes the list of criteria results
Definition: criteria_functions.cc:62
This criteria function class applies the infinity norm globally on the difference between the complet...
Definition: criteria_functions.h:213
virtual int operator()(const fmatvec::Vec &vector)
computes the criteria
Definition: criteria_functions.cc:38
virtual int operator()(const fmatvec::Vec &vector)=0
computes the criteria
std::vector< double > criteriaResults
saves the results of the criteria
Definition: criteria_functions.h:124
virtual void clear()=0
deletes the list of criteria results
This criteria function class applies the infinity norm globally for complete vectors thus it has one ...
Definition: criteria_functions.h:84
virtual ~GlobalResidualCriteriaFunction()
Destructor.
Definition: criteria_functions.h:273
fmatvec::Vec lastPoint
save the point of the last step for comparison
Definition: criteria_functions.h:267
GlobalShiftCriteriaFunction(const double &tolerance_=1e-10)
Constructor.
Definition: criteria_functions.cc:132
virtual ~LocalCriteriaFunction()
Destructor.
Definition: criteria_functions.h:272
GlobalResidualCriteriaFunction(const double &tolerance_=1e-10)
Constructor.
Definition: criteria_functions.cc:105
This criteria function class applies the infinity norm on single indices sets (each with another tole...
Definition: criteria_functions.h:192
double tolerance
tolerance value for the criteria results
Definition: criteria_functions.h:119
virtual ~LocalResidualCriteriaFunction()
Destructor.
Definition: criteria_functions.h:275
virtual bool isBetter(const fmatvec::Vec &vector, const fmatvec::Vec &fVal=fmatvec::Vec(0, fmatvec::NONINIT))
compares the result of given vector with the last result and returns if it got better (for damping) ...
Definition: criteria_functions.cc:87
Mother class for different criterias that are fulfilled or not.
Definition: criteria_functions.h:33
This criteria function class applies the infinity norm on single indices sets (each with another tole...
Definition: criteria_functions.h:244
Definition: planar_contour.h:31
This criteria function class applies the infinity norm locally for arbitrary combinations of sub-vect...
Definition: criteria_functions.h:130
LocalResidualCriteriaFunction(const std::map< fmatvec::RangeV, double > &tolerances_)
Constructor.
Definition: criteria_functions.cc:116
virtual void clear()
deletes the list of criteria results
Definition: criteria_functions.cc:101
virtual bool isBetter(const fmatvec::Vec &vector, const fmatvec::Vec &fVal=fmatvec::Vec(0, fmatvec::NONINIT))=0
compares the result of given vector with the last result and returns if it got better (for damping) ...
virtual int operator()(const fmatvec::Vec &vector)
computes the criteria
Definition: criteria_functions.cc:70
GlobalCriteriaFunction(const double &tolerance_=1e-10)
Constructor.
Definition: criteria_functions.cc:34
virtual ~GlobalShiftCriteriaFunction()
Destructor.
Definition: criteria_functions.h:274
virtual ~CriteriaFunction()
Destructor.
Definition: criteria_functions.h:270
std::vector< std::vector< double > > criteriaResults
saves the results of the criteria for each index set and each operator step
Definition: criteria_functions.h:164
virtual ~GlobalCriteriaFunction()
Destructor.
Definition: criteria_functions.h:271
LocalShiftCriteriaFunction(const std::map< fmatvec::RangeV, double > &tolerances_)
Constructor.
Definition: criteria_functions.cc:151
virtual bool isBetter(const fmatvec::Vec &vector, const fmatvec::Vec &fVal=fmatvec::Vec(0, fmatvec::NONINIT))
compares the result of given vector with the last result and returns if it got better (for damping) ...
Definition: criteria_functions.cc:51
virtual ~LocalShiftCriteriaFunction()
Destructor.
Definition: criteria_functions.h:276

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML