extrema.hh

Go to the documentation of this file.
1 
7 #ifndef extrema_hh
8 #define extrema_hh
9 
10 #include "hp2D.hh"
11 
12 using concepts::Real;
13 using concepts::Real2d;
14 
15 
16 
17 namespace alglib
18 {
19  // Forward declaration;
20  class real_1d_array;
21 }
22 
23 
24 namespace concepts{
25  //template for computing minimum or maximum
26  enum Optimize { MIN, MAX };
27 }
28 
29 
30 namespace hp2D{
40 // *************************************************************** Extrema **
41 template <concepts::Optimize T>
43 
65 public:
67  const concepts::ElementFormula<Real>& formula,
68  const concepts::ElementFormula<Real2d>* formulaGrad = 0,
69  uint np = 2,
70  bool report = false);
71 
72  //return maximum/minimum
73  Real get() const;
74 
77 
78 protected:
79  virtual std::ostream& info(std::ostream& os) const override;
80 
81 private:
82 
83 
84  //search points in one cell
85  std::vector<std::string> points_;
86  //the local (possible global) maximum on the underlying elm
87  std::set<Real> extrema_;
88  //space on which ElementFormula is given
90  //ElementFormula
92  //Gradient of ElementFormula
94  //underlying element
96  // np^2 number of start points
97  uint np_;
98  //flag for report of convergence
99  bool report_;
100  //current function max
102  //candidates of positions and vals
104 
105 
106  //returns -1 for T = MAX, 1 for T = MIN
107  Real sign_() const;
108 
109  //returns the extrema on one cell
110  Real get_(const concepts::Set<Real>& vals) const;
111 
112  //computes the maximum on one cell (of type hp2D::Quad<Real> only)
114 
121  void reportOutput_(uint K, const std::string& point, int terminationType) const;
122 
123 
124  static void Wrapper_To_Call_Grad_(const alglib::real_1d_array &x, double &func, alglib::real_1d_array &grad, void *ptr);
125 
126  static void Wrapper_To_Call_Fun_(const alglib::real_1d_array &x, double &func, void *ptr);
127 
128  //evaluation of the gradient
129  void evalsG_(const alglib::real_1d_array &x, double &func, alglib::real_1d_array &grad, void *ptr);
130 
131  //evaluation of the function
132  void evalsF_(const alglib::real_1d_array &x, double &func, void *ptr);
133 
134 };
135 
136 }//namespace hp2D
137 
138 #endif //minMax_hh
void reportOutput_(uint K, const std::string &point, int terminationType) const
Can report the current convergence behaviour if requested via setReport()
static void Wrapper_To_Call_Fun_(const alglib::real_1d_array &x, double &func, void *ptr)
void evalsG_(const alglib::real_1d_array &x, double &func, alglib::real_1d_array &grad, void *ptr)
bool report_
Definition: extrema.hh:99
Extrema(const concepts::SpaceOnCells< Real > &spc, const concepts::ElementFormula< Real > &formula, const concepts::ElementFormula< Real2d > *formulaGrad=0, uint np=2, bool report=false)
http://www.alglib.net/translator/man/manual.cpp.html#unit_minbleic
Point< Real, 2 > Real2d
Set with operations, output operator, and method of the particular element types.
Definition: traces.hh:18
virtual std::ostream & info(std::ostream &os) const override
Returns information in an output stream.
2D hp-FEM for H1-conforming elements.
const concepts::SpaceOnCells< Real > & spc_
Definition: extrema.hh:89
An interface class that computes the maximum/minimum of a function represented as an ElementFormula o...
Definition: extrema.hh:42
std::set< Real > extrema_
Definition: extrema.hh:87
concepts::Sequence< Real > vals_
Definition: extrema.hh:103
Real get_(const concepts::Set< Real > &vals) const
static Extrema< T > * pt2Object
Inner static pointer to object, used by the wrapper.
Definition: extrema.hh:76
Real compute_(const hp2D::Quad< concepts::Real > &quad)
Real sign_() const
std::vector< std::string > points_
Definition: extrema.hh:85
Real get() const
const concepts::ElementFormula< Real > & frm_
Definition: extrema.hh:91
const hp2D::Quad< Real > * elm_
Definition: extrema.hh:95
void evalsF_(const alglib::real_1d_array &x, double &func, void *ptr)
Class providing an output operator.
const concepts::ElementFormula< Real2d > * frmGrad_
Definition: extrema.hh:93
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Real curFunc_
Definition: extrema.hh:101
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
static void Wrapper_To_Call_Grad_(const alglib::real_1d_array &x, double &func, alglib::real_1d_array &grad, void *ptr)
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich