deactivated deprecated start_engrid copy
[engrid.git] / src / optimisation.h
blob12454a6a1a5e6e164545197db7bcc9b4aa4d7020
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef optimisation_H
24 #define optimisation_H
26 class Optimisation;
27 class ErrorFunction;
29 #include "engrid.h"
31 class ErrorFunction
34 private: // attributes
36 double m_Err0;
37 double m_ErrS;
38 double m_XS;
39 double m_Exp;
40 double m_MaxErr;
41 double m_TotalError;
42 double m_AverageError;
43 bool m_Active;
44 QString m_Name;
45 int m_NumTotalCalls;
46 int m_NumCalls;
48 public: // methods
50 ErrorFunction();
51 void set(QString settings_txt);
52 void setName(QString name) { m_Name = name; }
53 QString name() { return m_Name; }
54 double operator()(double x);
55 double maxError() { return m_MaxErr; }
56 void reset(bool reset_average);
57 bool active() { return m_Active && (m_Err0 > 1e-10); }
58 double averageError();
59 double totalError();
60 void activate() { m_Active = true; }
61 void deactivate() { m_Active = false; }
66 class Optimisation
69 protected: // attributes
71 double ***F;
72 double Dx;
73 double Dy;
74 double Dz;
75 vec3_t grad_f;
76 mat3_t J;
77 QList<ErrorFunction*> m_ErrorFunctions;
79 protected: // methods
81 virtual double func(vec3_t x) = 0;
82 virtual double func(double x, double y, double z) { return func(vec3_t(x,y,z)); };
83 virtual void computeDerivatives(vec3_t x);
85 void getErrSet(QString group, QString key, double err0, double xs, ErrorFunction* err_func);
86 double angleX(const vec3_t &v1, const vec3_t &v2);
87 void resetErrorFunctions(bool reset_average = false);
88 double totalError();
90 public: // methods
92 Optimisation();
94 vec3_t optimise(vec3_t x);
95 void setDeltas(double d) { Dx = d; Dy = d; Dz = d; };
96 void setDx(double d) { Dx = d; };
97 void setDy(double d) { Dy = d; };
98 void setDz(double d) { Dz = d; };
99 void printErrors();
103 #endif