Added Doxygen docs
This commit is contained in:
554
docs/docbook/_exponential_8h_source.xml
Normal file
554
docs/docbook/_exponential_8h_source.xml
Normal file
@ -0,0 +1,554 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="__exponential_8h_source" xml:lang="en-US">
|
||||
<title>Exponential.h</title>
|
||||
<indexterm><primary>Exponential/Exponential.h</primary></indexterm>
|
||||
<programlisting linenumbering="unnumbered">1 <emphasis role="preprocessor">#pragma once</emphasis>
|
||||
2 <emphasis role="preprocessor">#ifndef JONATHAN_RAMPERSAD_EXPONENTIAL_H_</emphasis>
|
||||
3 <emphasis role="preprocessor">#define JONATHAN_RAMPERSAD_EXPONENTIAL_H_</emphasis>
|
||||
4
|
||||
5 <emphasis role="preprocessor">#include <ostream></emphasis>
|
||||
6 <emphasis role="preprocessor">#include <vector></emphasis>
|
||||
7 <emphasis role="preprocessor">#include <float.h></emphasis>
|
||||
8 <emphasis role="preprocessor">#include <random></emphasis>
|
||||
9 <emphasis role="preprocessor">#include <algorithm></emphasis>
|
||||
10 <emphasis role="preprocessor">#include <execution></emphasis>
|
||||
11 <emphasis role="preprocessor">#include <exception></emphasis>
|
||||
12
|
||||
13 <emphasis role="keyword">namespace </emphasis>JRAMPERSAD
|
||||
14 {
|
||||
15     <emphasis role="keyword">namespace </emphasis>EXPONENTIAL
|
||||
16     {
|
||||
21         <emphasis role="keyword">struct </emphasis><link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>
|
||||
22         {
|
||||
24             <emphasis role="keywordtype">double</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a316979973a2a6b70b00520c2f753a43c">min_range</link> = -100;
|
||||
26             <emphasis role="keywordtype">double</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a9b8f1e5367f6b0d8b16eecaea53b40e2">max_range</link> = 100;
|
||||
28             <emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a4a67bad303f8a4fca40020a0802524c5">num_of_generations</link> = 10;
|
||||
30             <emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1ad133af29dbbc26b8c3d507d359c03326">sample_size</link> = 1000;
|
||||
32             <emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a6ec95fe6cc95dc32727659cf5bb1be12">data_size</link> = 100000;
|
||||
34             <emphasis role="keywordtype">double</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a736488b3cfeebda7b93b3e8c6f576bf8">mutation_percentage</link> = 0.01;
|
||||
35         };
|
||||
36
|
||||
37         <emphasis role="keyword">namespace </emphasis>detail
|
||||
38         {
|
||||
39             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
40             [[nodiscard(<emphasis role="stringliteral">"MATH::ABS(T) returns a value of type T"</emphasis>)]] T ABS(<emphasis role="keyword">const</emphasis> T& n) <emphasis role="keyword">noexcept</emphasis>
|
||||
41             {
|
||||
42                 <emphasis role="keywordflow">return</emphasis> n < 0 ? n * -1 : n;
|
||||
43             }
|
||||
44
|
||||
45             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
46             [[nodiscard(<emphasis role="stringliteral">"MATH::NEGATE(T) returns a value of type T"</emphasis>)]] T NEGATE(<emphasis role="keyword">const</emphasis> T& n) <emphasis role="keyword">noexcept</emphasis>
|
||||
47             {
|
||||
48                 <emphasis role="keywordflow">return</emphasis> n * -1;
|
||||
49             }
|
||||
50
|
||||
51             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
52             [[nodiscard(<emphasis role="stringliteral">"MATH::POW(T, int) returns a value of type T"</emphasis>)]] T POW(<emphasis role="keyword">const</emphasis> T& n, <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& exp) <emphasis role="keyword">noexcept</emphasis>
|
||||
53             {
|
||||
54                 <emphasis role="keywordflow">if</emphasis> (exp == 0)
|
||||
55                     <emphasis role="keywordflow">return</emphasis> 1;
|
||||
56
|
||||
57                 T res = n;
|
||||
58                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> i = 1; i < exp; i++)
|
||||
59                 {
|
||||
60                     res *= n;
|
||||
61                 }
|
||||
62
|
||||
63                 <emphasis role="keywordflow">return</emphasis> res;
|
||||
64             }
|
||||
65
|
||||
66             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
67             [[nodiscard(<emphasis role="stringliteral">"MATH::SUM(std::vector<T>) returns a value of type T"</emphasis>)]] T SUM(<emphasis role="keyword">const</emphasis> std::vector<T>& vec) <emphasis role="keyword">noexcept</emphasis>
|
||||
68             {
|
||||
69                 T res{};
|
||||
70                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : vec)
|
||||
71                     res += val;
|
||||
72                 <emphasis role="keywordflow">return</emphasis> res;
|
||||
73             }
|
||||
74
|
||||
75             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
76             [[nodiscard]] T MEDIAN(std::vector<T> vec) <emphasis role="keyword">noexcept</emphasis>
|
||||
77             {
|
||||
78                 std::sort(
|
||||
79                     vec.begin(),
|
||||
80                     vec.end(),
|
||||
81                     [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& lhs, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& rhs) {
|
||||
82                         return lhs < rhs;
|
||||
83                     });
|
||||
84
|
||||
85                 <emphasis role="keywordflow">return</emphasis> vec[vec.size() / 2];
|
||||
86             }
|
||||
87
|
||||
88             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
89             [[nodiscard]] <emphasis role="keywordtype">double</emphasis> MEAN(<emphasis role="keyword">const</emphasis> std::vector<T>& vec) <emphasis role="keyword">noexcept</emphasis>
|
||||
90             {
|
||||
91                 <emphasis role="keywordflow">return</emphasis> SUM(vec) / vec.size();
|
||||
92             }
|
||||
93
|
||||
94             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
95             [[noreturn]] <emphasis role="keywordtype">void</emphasis> SortASC(std::vector<T>& vec)
|
||||
96             {
|
||||
97                 std::sort(
|
||||
98                     std::execution::par,
|
||||
99                     vec.begin(), vec.end(),
|
||||
100                     [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& lhs, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& rhs) {
|
||||
101                         return lhs < rhs;
|
||||
102                     });
|
||||
103             }
|
||||
104
|
||||
105             <emphasis role="keyword">template</emphasis><<emphasis role="keyword">typename</emphasis> T>
|
||||
106             [[noreturn]] <emphasis role="keywordtype">void</emphasis> SortDESC(std::vector<T>& vec)
|
||||
107             {
|
||||
108                 std::sort(
|
||||
109                     std::execution::par,
|
||||
110                     vec.begin(), vec.end(),
|
||||
111                     [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& lhs, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& rhs) {
|
||||
112                         return lhs > rhs;
|
||||
113                     });
|
||||
114             }
|
||||
115
|
||||
116             <emphasis role="keyword">template</emphasis> <<emphasis role="keywordtype">int</emphasis> lrgst_expo> <emphasis role="comment">// Genetic Algorithm helper struct</emphasis>
|
||||
117             <emphasis role="keyword">struct </emphasis>GA_Solution
|
||||
118             {
|
||||
119                 <emphasis role="keywordtype">double</emphasis> rank, x, y_val;
|
||||
120                 <emphasis role="keywordtype">bool</emphasis> ranked;
|
||||
121
|
||||
122                 GA_Solution() : rank(0), x(0), y_val(0), ranked(false) {}
|
||||
123                 GA_Solution(<emphasis role="keywordtype">double</emphasis> Rank, <emphasis role="keywordtype">double</emphasis> x_val, <emphasis role="keywordtype">double</emphasis> y = 0) : rank(Rank), x(x_val), y_val(y), ranked(false) {}
|
||||
124                 <emphasis role="keyword">virtual</emphasis> ~GA_Solution() = <emphasis role="keywordflow">default</emphasis>;
|
||||
125
|
||||
126                 <emphasis role="keywordtype">void</emphasis> fitness(<emphasis role="keyword">const</emphasis> std::vector<int>& constants)
|
||||
127                 {
|
||||
128                     <emphasis role="keywordtype">double</emphasis> ans = 0;
|
||||
129                     <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> i = lrgst_expo; i >= 0; i--)
|
||||
130                         ans += constants[i] * POW(x, (lrgst_expo - i));
|
||||
131
|
||||
132                     ans -= y_val;
|
||||
133                     rank = (ans == 0) ? DBL_MAX : ABS(1 / ans);
|
||||
134                 }
|
||||
135             };
|
||||
136         }
|
||||
137
|
||||
138         <emphasis role="keyword">using namespace </emphasis>detail;
|
||||
143         <emphasis role="keyword">template</emphasis> <<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
144         <emphasis role="keyword">class </emphasis><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>
|
||||
145         {
|
||||
146         <emphasis role="keyword">private</emphasis>:
|
||||
147             std::vector<int> constants;
|
||||
148
|
||||
149         <emphasis role="keyword">public</emphasis>:
|
||||
150             <emphasis role="comment">// Speicialty function to get the real roots of a Quadratic Function without relying on a Genetic Algorithm to approximate</emphasis>
|
||||
151             <emphasis role="keyword">friend</emphasis> std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a8f5b8975b6e7318c093a963cd0b43db6">QuadraticSolve</link>(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<2></link>& f);
|
||||
152
|
||||
153         <emphasis role="keyword">public</emphasis>:
|
||||
158             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>(<emphasis role="keyword">const</emphasis> std::vector<int>& constnts);
|
||||
163             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>(std::vector<int>&& constnts);
|
||||
164             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>& other) = <emphasis role="keywordflow">default</emphasis>;
|
||||
165             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>&& other) <emphasis role="keyword">noexcept</emphasis> = <emphasis role="keywordflow">default</emphasis>;
|
||||
166             <emphasis role="keyword">virtual</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">~Function</link>();
|
||||
167
|
||||
168             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>& operator=(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>& other) = <emphasis role="keywordflow">default</emphasis>;
|
||||
169             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>& operator=(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>&& other) <emphasis role="keyword">noexcept</emphasis> = <emphasis role="keywordflow">default</emphasis>;
|
||||
170
|
||||
171             <emphasis role="comment">// Operator function to display function object in a human readable format</emphasis>
|
||||
172             <emphasis role="keyword">friend</emphasis> std::ostream& operator<<(std::ostream& os, <emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo></link> func)
|
||||
173             {
|
||||
174                 <emphasis role="keywordflow">if</emphasis> (lrgst_expo == 0)
|
||||
175                 {
|
||||
176                     os << func.constants[0];
|
||||
177                     <emphasis role="keywordflow">return</emphasis> os;
|
||||
178                 }
|
||||
179
|
||||
180                 <emphasis role="keywordflow">if</emphasis> (func.constants[0] == 1)
|
||||
181                     os << <emphasis role="stringliteral">"x"</emphasis>;
|
||||
182                 <emphasis role="keywordflow">else</emphasis> <emphasis role="keywordflow">if</emphasis> (func.constants[0] == -1)
|
||||
183                     os << <emphasis role="stringliteral">"-x"</emphasis>;
|
||||
184                 <emphasis role="keywordflow">else</emphasis>
|
||||
185                     os << func.constants[0] << <emphasis role="stringliteral">"x"</emphasis>;
|
||||
186
|
||||
187                 <emphasis role="keywordflow">if</emphasis> (lrgst_expo != 1)
|
||||
188                     os << <emphasis role="stringliteral">"^"</emphasis> << lrgst_expo;
|
||||
189
|
||||
190                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> i = lrgst_expo - 1; i > 0; i--)
|
||||
191                 {
|
||||
192                     <emphasis role="keywordtype">int</emphasis> n = func.constants[lrgst_expo - i];
|
||||
193                     <emphasis role="keywordflow">if</emphasis> (n == 0) <emphasis role="keywordflow">continue</emphasis>;
|
||||
194
|
||||
195                     <emphasis role="keyword">auto</emphasis> s = n > 0 ? <emphasis role="stringliteral">" + "</emphasis> : <emphasis role="stringliteral">" - "</emphasis>;
|
||||
196
|
||||
197                     <emphasis role="keywordflow">if</emphasis> (n != 1)
|
||||
198                         os << s << ABS(n) << <emphasis role="stringliteral">"x"</emphasis>;
|
||||
199                     <emphasis role="keywordflow">else</emphasis>
|
||||
200                         os << s << <emphasis role="stringliteral">"x"</emphasis>;
|
||||
201
|
||||
202                     <emphasis role="keywordflow">if</emphasis> (i != 1)
|
||||
203                         os << <emphasis role="stringliteral">"^"</emphasis> << i;
|
||||
204                 }
|
||||
205
|
||||
206                 <emphasis role="keywordtype">int</emphasis> n = func.constants[lrgst_expo];
|
||||
207                 <emphasis role="keywordflow">if</emphasis> (n == 0) <emphasis role="keywordflow">return</emphasis> os;
|
||||
208
|
||||
209                 <emphasis role="keyword">auto</emphasis> s = n > 0 ? <emphasis role="stringliteral">" + "</emphasis> : <emphasis role="stringliteral">" - "</emphasis>;
|
||||
210                 os << s;
|
||||
211
|
||||
212                 os << ABS(n);
|
||||
213
|
||||
214                 <emphasis role="keywordflow">return</emphasis> os;
|
||||
215             }
|
||||
216
|
||||
217             <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> e1, <emphasis role="keywordtype">int</emphasis> e2, <emphasis role="keywordtype">int</emphasis> r>
|
||||
218             <emphasis role="keyword">friend</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<r></link> operator+(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e1></link>& f1, <emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e2></link>& f2); <emphasis role="comment">// Operator to add two functions</emphasis>
|
||||
219             <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> e1, <emphasis role="keywordtype">int</emphasis> e2, <emphasis role="keywordtype">int</emphasis> r>
|
||||
220             <emphasis role="keyword">friend</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<r></link> operator-(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e1></link>& f1, <emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e2></link>& f2); <emphasis role="comment">// Operator to subtract two functions</emphasis>
|
||||
221
|
||||
222             <emphasis role="comment">// Operators to multiply a function by a constant (Scaling it)</emphasis>
|
||||
223             <emphasis role="keyword">friend</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo></link> operator*(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo></link>& f, <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& c)
|
||||
224             {
|
||||
225                 <emphasis role="keywordflow">if</emphasis> (c == 1) <emphasis role="keywordflow">return</emphasis> f;
|
||||
226                 <emphasis role="keywordflow">if</emphasis> (c == 0) <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Cannot multiply a function by 0"</emphasis>);
|
||||
227
|
||||
228                 std::vector<int> res;
|
||||
229                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f.constants)
|
||||
230                     res.push_back(c * val);
|
||||
231
|
||||
232                 <emphasis role="keywordflow">return</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo></link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>);
|
||||
233             }
|
||||
234             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo></link>& operator*=(<emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link>)
|
||||
235             {
|
||||
236                 <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link> == 1) <emphasis role="keywordflow">return</emphasis> *<emphasis role="keyword">this</emphasis>;
|
||||
237                 <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link> == 0) <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Cannot multiply a function by 0"</emphasis>);
|
||||
238
|
||||
239                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link> : this->constants)
|
||||
240                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link> *= <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link>;
|
||||
241
|
||||
242                 <emphasis role="keywordflow">return</emphasis> *<emphasis role="keyword">this</emphasis>;
|
||||
243             }
|
||||
244
|
||||
249             [[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">nodiscard</link>(<emphasis role="stringliteral">"MATH::EXP::Function::differential() returns the differential, the calling object is not changed"</emphasis>)]]
|
||||
250             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link><<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - 1> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ae43c705b427ac1ef27aed061a63e500e">differential</link>() <emphasis role="keyword">const</emphasis>;
|
||||
251
|
||||
257             [[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">nodiscard</link>]] std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ad090de9f6636094f14f1279615fccbc0">get_real_roots</link>(<emphasis role="keyword">const</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link> = <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()) <emphasis role="keyword">const</emphasis>;
|
||||
258
|
||||
264             [[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">nodiscard</link>]] <emphasis role="keywordtype">double</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a5464547daff0c43faccdc40ea480bab4">solve_y</link>(<emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">double</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">x_val</link>) <emphasis role="keyword">const</emphasis> <emphasis role="keyword">noexcept</emphasis>;
|
||||
265
|
||||
272             [[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">nodiscard</link>]] std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a46b9671c4a29b2b2b34586048a3b795a">solve_x</link>(<emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">double</emphasis>& y_val, <emphasis role="keyword">const</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link> = <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()) <emphasis role="keyword">const</emphasis>;
|
||||
273         };
|
||||
274
|
||||
280         std::vector<double> QuadraticSolve(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<2></link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>)
|
||||
281         {
|
||||
282             std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>;
|
||||
283
|
||||
284             <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">a</link> = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>.constants[0];
|
||||
285             <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">b</link> = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>.constants[1];
|
||||
286             <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">int</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link> = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>.constants[2];
|
||||
287
|
||||
288             <emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">double</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqr_val</link> = <emphasis role="keyword">static_cast<</emphasis><emphasis role="keywordtype">double</emphasis><emphasis role="keyword">></emphasis>(POW(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">b</link>, 2) - (4 * <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">a</link> * <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link>));
|
||||
289
|
||||
290             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqr_val</link> < 0)
|
||||
291             {
|
||||
292                 <emphasis role="keywordflow">return</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>;
|
||||
293             }
|
||||
294
|
||||
295             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>.push_back(((NEGATE(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">b</link>) + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqrt</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqr_val</link>)) / 2 * <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">a</link>));
|
||||
296             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>.push_back(((NEGATE(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">b</link>) - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqrt</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sqr_val</link>)) / 2 * <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">a</link>));
|
||||
297             <emphasis role="keywordflow">return</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>;
|
||||
298         }
|
||||
299
|
||||
300         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> e1, <emphasis role="keywordtype">int</emphasis> e2, <emphasis role="keywordtype">int</emphasis> r = (e1 > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link> ? <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e1</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link>)>
|
||||
301             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<r></link> <emphasis role="keyword">operator</emphasis>+(<emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e1></link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f1</link>, <emphasis role="keyword">const</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<e2></link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f2</link>)
|
||||
302         {
|
||||
303             std::vector<int> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>;
|
||||
304             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e1</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link>)
|
||||
305             {
|
||||
306                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f1</link>.constants)
|
||||
307                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>.<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">push_back</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link>);
|
||||
308
|
||||
309                 <emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e1</link> - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link>;
|
||||
310                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f2</link>.constants)
|
||||
311                 {
|
||||
312                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">res</link>[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>] += <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">val</link>;
|
||||
313                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>++;
|
||||
314                 }
|
||||
315             }
|
||||
316             <emphasis role="keywordflow">else</emphasis>
|
||||
317             {
|
||||
318                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f2.constants)
|
||||
319                     res.push_back(val);
|
||||
320
|
||||
321                 <emphasis role="keywordtype">int</emphasis> i = e2 - e1;
|
||||
322                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f1.constants)
|
||||
323                 {
|
||||
324                     res[i] += val;
|
||||
325                     i++;
|
||||
326                 }
|
||||
327             }
|
||||
328
|
||||
329             <emphasis role="keywordflow">return</emphasis> Function<r>{res};
|
||||
330         }
|
||||
331
|
||||
332         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> e1, <emphasis role="keywordtype">int</emphasis> e2, <emphasis role="keywordtype">int</emphasis> r = (e1 > e2 ? e1 : e2)>
|
||||
333             Function<r> <emphasis role="keyword">operator</emphasis>-(<emphasis role="keyword">const</emphasis> Function<e1>& f1, <emphasis role="keyword">const</emphasis> Function<e2>& f2)
|
||||
334         {
|
||||
335             std::vector<int> res;
|
||||
336             <emphasis role="keywordflow">if</emphasis> (e1 > e2)
|
||||
337             {
|
||||
338                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f1.constants)
|
||||
339                     res.push_back(val);
|
||||
340
|
||||
341                 <emphasis role="keywordtype">int</emphasis> i = e1 - e2;
|
||||
342                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f2.constants)
|
||||
343                 {
|
||||
344                     res[i] -= val;
|
||||
345                     i++;
|
||||
346                 }
|
||||
347             }
|
||||
348             <emphasis role="keywordflow">else</emphasis>
|
||||
349             {
|
||||
350                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f2.constants)
|
||||
351                     res.push_back(val);
|
||||
352
|
||||
353                 <emphasis role="keywordtype">int</emphasis> i = e2 - e1;
|
||||
354
|
||||
355                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> j = 0; j < i; j++)
|
||||
356                     res[j] *= -1;
|
||||
357
|
||||
358                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& val : f1.constants)
|
||||
359                 {
|
||||
360                     res[i] = val - res[i];
|
||||
361                     i++;
|
||||
362                 }
|
||||
363             }
|
||||
364
|
||||
365             <emphasis role="keywordflow">return</emphasis> Function<r>{res};
|
||||
366         }
|
||||
367
|
||||
368         <emphasis role="keyword">template</emphasis> <<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
369         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::Function</link>(<emphasis role="keyword">const</emphasis> std::vector<int>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>)
|
||||
370         {
|
||||
371             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> < 0)
|
||||
372                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Function template argument must not be less than 0"</emphasis>);
|
||||
373
|
||||
374             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>.size() != <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> + 1)
|
||||
375                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Function<n> must be created with (n+1) integers in vector object"</emphasis>);
|
||||
376
|
||||
377             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>[0] == 0)
|
||||
378                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"First value should not be 0"</emphasis>);
|
||||
379
|
||||
380             constants = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>;
|
||||
381         }
|
||||
382
|
||||
383         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
384         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::Function</link>(std::vector<int>&& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>)
|
||||
385         {
|
||||
386             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> < 0)
|
||||
387                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Function template argument must not be less than 0"</emphasis>);
|
||||
388
|
||||
389             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>.size() != <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> + 1)
|
||||
390                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Function<n> must be created with (n+1) integers in vector object"</emphasis>);
|
||||
391
|
||||
392             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>[0] == 0)
|
||||
393                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"First value should not be 0"</emphasis>);
|
||||
394
|
||||
395             constants = std::move(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>);
|
||||
396         }
|
||||
397
|
||||
398         <emphasis role="keyword">template</emphasis> <<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
399         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::~Function</link>()
|
||||
400         {
|
||||
401             constants.clear();
|
||||
402         }
|
||||
403
|
||||
404         <emphasis role="keyword">template</emphasis> <<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
405         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link><<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - 1> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::differential</link>()<emphasis role="keyword"> const</emphasis>
|
||||
406 <emphasis role="keyword">        </emphasis>{
|
||||
407             <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> == 0)
|
||||
408                 <emphasis role="keywordflow">throw</emphasis> std::logic_error(<emphasis role="stringliteral">"Cannot differentiate a number (Function<0>)"</emphasis>);
|
||||
409
|
||||
410             std::vector<int> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">result</link>;
|
||||
411             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> = 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> < <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link>; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>++)
|
||||
412             {
|
||||
413                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">result</link>.push_back(constants[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>] * (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>));
|
||||
414             }
|
||||
415
|
||||
416             <emphasis role="keywordflow">return</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link><<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - 1>{<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">result</link>};
|
||||
417         }
|
||||
418
|
||||
419         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
420         std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::get_real_roots</link>(<emphasis role="keyword">const</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>)<emphasis role="keyword"> const</emphasis>
|
||||
421 <emphasis role="keyword">        </emphasis>{
|
||||
422             <emphasis role="comment">// Create initial random solutions</emphasis>
|
||||
423             std::random_device <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>;
|
||||
424             std::uniform_real_distribution<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.min_range, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.max_range);
|
||||
425             std::vector<GA_Solution<lrgst_expo>> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>;
|
||||
426
|
||||
427             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.resize(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.data_size);
|
||||
428             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> = 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> < <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>++)
|
||||
429                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>] = (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">GA_Solution<lrgst_expo></link>{0, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>)});
|
||||
430
|
||||
431             <emphasis role="keywordtype">float</emphasis> timer{ 0 };
|
||||
432
|
||||
433             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> = 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> < <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.num_of_generations; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link>++)
|
||||
434             {
|
||||
435                 std::generate(std::execution::par, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin() + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(), [&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>, &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>]() {
|
||||
436                     return GA_Solution<lrgst_expo>{0, unif(device)};
|
||||
437                     });
|
||||
438
|
||||
439                 <emphasis role="comment">// Run our fitness function</emphasis>
|
||||
440                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>) { <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>.fitness(constants); }
|
||||
441
|
||||
442                 <emphasis role="comment">// Sort our solutions by rank</emphasis>
|
||||
443                 std::sort(std::execution::par, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(),
|
||||
444                     [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lhs</link>, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">rhs</link>) {
|
||||
445                         return lhs.rank > rhs.rank;
|
||||
446                     });
|
||||
447
|
||||
448                 <emphasis role="comment">// Take top solutions</emphasis>
|
||||
449                 std::vector<GA_Solution<lrgst_expo>> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>;
|
||||
450                 std::copy(
|
||||
451                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(),
|
||||
452                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin() + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size,
|
||||
453                     std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>)
|
||||
454                 );
|
||||
455                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.clear();
|
||||
456
|
||||
457                 <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> + 1 == <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.num_of_generations)
|
||||
458                 {
|
||||
459                     std::copy(
|
||||
460                         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(),
|
||||
461                         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(),
|
||||
462                         std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
463                     );
|
||||
464                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.clear();
|
||||
465                     <emphasis role="keywordflow">break</emphasis>;
|
||||
466                 }
|
||||
467
|
||||
468                 <emphasis role="comment">// Mutate the top solutions by %</emphasis>
|
||||
469                 std::uniform_real_distribution<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">m</link>((1 - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.mutation_percentage), (1 + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.mutation_percentage));
|
||||
470                 std::for_each(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(), [&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">m</link>, &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>](<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>) {
|
||||
471                     s.x *= m(device);
|
||||
472                     });
|
||||
473
|
||||
474                 <emphasis role="comment">// Cross over not needed as it's only one value</emphasis>
|
||||
475
|
||||
476                 std::copy(
|
||||
477                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(),
|
||||
478                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(),
|
||||
479                     std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
480                 );
|
||||
481                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.clear();
|
||||
482                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.resize(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.data_size);
|
||||
483             }
|
||||
484
|
||||
485             std::sort(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(),
|
||||
486                 [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lhs</link>, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">rhs</link>) {
|
||||
487                     return lhs.x < rhs.x;
|
||||
488                 });
|
||||
489
|
||||
490             std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>;
|
||||
491             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
492             {
|
||||
493                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>.push_back(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>.x);
|
||||
494             }
|
||||
495             <emphasis role="keywordflow">return</emphasis> ans;
|
||||
496         }
|
||||
497
|
||||
498         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
499         <emphasis role="keywordtype">double</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::solve_y</link>(<emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">double</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">x_val</link>) <emphasis role="keyword">const</emphasis> <emphasis role="keyword">noexcept</emphasis>
|
||||
500         {
|
||||
501             std::vector<bool> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">exceptions</link>;
|
||||
502
|
||||
503             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> : constants)
|
||||
504                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">exceptions</link>.push_back(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> != 0);
|
||||
505
|
||||
506             <emphasis role="keywordtype">double</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>{ 0 };
|
||||
507             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> = <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link>; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> >= 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>--)
|
||||
508             {
|
||||
509                 <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">exceptions</link>[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>])
|
||||
510                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link> += constants[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>] * POW(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">x_val</link>, (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>));
|
||||
511             }
|
||||
512
|
||||
513             <emphasis role="keywordflow">return</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>;
|
||||
514         }
|
||||
515
|
||||
516         <emphasis role="keyword">template</emphasis><<emphasis role="keywordtype">int</emphasis> lrgst_expo>
|
||||
517         <emphasis role="keyword">inline</emphasis> std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function<lrgst_expo>::solve_x</link>(<emphasis role="keyword">const</emphasis> <emphasis role="keywordtype">double</emphasis>& y_val, <emphasis role="keyword">const</emphasis> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>)<emphasis role="keyword"> const</emphasis>
|
||||
518 <emphasis role="keyword">        </emphasis>{
|
||||
519             <emphasis role="comment">// Create initial random solutions</emphasis>
|
||||
520             std::random_device <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>;
|
||||
521             std::uniform_real_distribution<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.min_range, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.max_range);
|
||||
522             std::vector<GA_Solution<lrgst_expo>> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>;
|
||||
523
|
||||
524             <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.resize(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.data_size);
|
||||
525             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> = 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link> < <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>++)
|
||||
526                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>[<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">i</link>] = (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">GA_Solution<lrgst_expo></link>{0, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>), y_val});
|
||||
527
|
||||
528             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keywordtype">unsigned</emphasis> <emphasis role="keywordtype">int</emphasis> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> = 0; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> < <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.num_of_generations; <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link>++)
|
||||
529             {
|
||||
530                 std::generate(std::execution::par, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin() + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(), [&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unif</link>, &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>, &y_val]() {
|
||||
531                     return GA_Solution<lrgst_expo>{0, unif(device), y_val};
|
||||
532                     });
|
||||
533
|
||||
534
|
||||
535                 <emphasis role="comment">// Run our fitness function</emphasis>
|
||||
536                 <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>) { <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>.fitness(constants); }
|
||||
537
|
||||
538                 <emphasis role="comment">// Sort our solutions by rank</emphasis>
|
||||
539                 std::sort(std::execution::par, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(),
|
||||
540                     [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lhs</link>, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">rhs</link>) {
|
||||
541                         return lhs.rank > rhs.rank;
|
||||
542                     });
|
||||
543
|
||||
544                 <emphasis role="comment">// Take top solutions</emphasis>
|
||||
545                 std::vector<GA_Solution<lrgst_expo>> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>;
|
||||
546                 std::copy(
|
||||
547                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(),
|
||||
548                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin() + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.sample_size,
|
||||
549                     std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>)
|
||||
550                 );
|
||||
551                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.clear();
|
||||
552
|
||||
553                 <emphasis role="keywordflow">if</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">count</link> + 1 == <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.num_of_generations)
|
||||
554                 {
|
||||
555                     std::copy(
|
||||
556                         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(),
|
||||
557                         <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(),
|
||||
558                         std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
559                     );
|
||||
560                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.clear();
|
||||
561                     <emphasis role="keywordflow">break</emphasis>;
|
||||
562                 }
|
||||
563
|
||||
564                 <emphasis role="comment">// Mutate the top solutions by %</emphasis>
|
||||
565                 std::uniform_real_distribution<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">m</link>((1 - <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.mutation_percentage), (1 + <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.mutation_percentage));
|
||||
566                 std::for_each(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(), [&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">m</link>, &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">device</link>](<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>) {
|
||||
567                     s.x *= m(device);
|
||||
568                     });
|
||||
569
|
||||
570                 <emphasis role="comment">// Cross over not needed as it's only one value</emphasis>
|
||||
571
|
||||
572                 std::copy(
|
||||
573                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.begin(),
|
||||
574                     <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.end(),
|
||||
575                     std::back_inserter(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
576                 );
|
||||
577                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">sample</link>.clear();
|
||||
578                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.resize(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>.data_size);
|
||||
579             }
|
||||
580
|
||||
581             std::sort(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.begin(), <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>.end(),
|
||||
582                 [](<emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lhs</link>, <emphasis role="keyword">const</emphasis> <emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">rhs</link>) {
|
||||
583                     return lhs.x < rhs.x;
|
||||
584                 });
|
||||
585
|
||||
586             std::vector<double> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>;
|
||||
587             <emphasis role="keywordflow">for</emphasis> (<emphasis role="keyword">auto</emphasis>& <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link> : <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">solutions</link>)
|
||||
588             {
|
||||
589                 <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">ans</link>.push_back(<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">s</link>.x);
|
||||
590             }
|
||||
591             <emphasis role="keywordflow">return</emphasis> ans;
|
||||
592         }
|
||||
593     }
|
||||
594 }
|
||||
595
|
||||
596 <emphasis role="preprocessor">#endif </emphasis><emphasis role="comment">// !JONATHAN_RAMPERSAD_EXPONENTIAL_H_</emphasis>
|
||||
</programlisting></section>
|
8
docs/docbook/annotated.xml
Normal file
8
docs/docbook/annotated.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_annotated" xml:lang="en-US">
|
||||
<title>Class List</title>
|
||||
Here are the classes, structs, unions and interfaces with brief descriptions:<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></link>
|
||||
<para>A class representing an Exponential <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> (e.g 2x^2 + 4x - 1), </para>
|
||||
<link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">JRAMPERSAD::EXPONENTIAL::GA_Options</link>
|
||||
<para>Structure for options to be used when running one of the two genetic algorithms in a <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> object </para>
|
||||
</section>
|
@ -0,0 +1,334 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function" xml:lang="en-US">
|
||||
<title>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo > Class Template Reference</title>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary></indexterm>
|
||||
<para>
|
||||
|
||||
<para>A class representing an Exponential <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> (e.g 2x^2 + 4x - 1),. </para>
|
||||
|
||||
</para>
|
||||
<para>
|
||||
<computeroutput>#include <Exponential.h></computeroutput>
|
||||
</para>
|
||||
<simplesect>
|
||||
<title>Public Member Functions </title>
|
||||
<itemizedlist>
|
||||
<listitem><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a0585614da72409acfbed262411ea7882">Function</link> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>)</para>
|
||||
|
||||
<para>Constructor for <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> class. </para>
|
||||
</listitem>
|
||||
<listitem><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a7216329180e93c93204f4061be9e560b">Function</link> (std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> > &&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">constnts</link>)</para>
|
||||
|
||||
<para>Constructor for <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> class. </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a38038a3b3f371ca62098ad4d4c510966"/><emphasis role="strong">Function</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">other</link>)=<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">default</link></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1aaafd98fd5dc5d0f9e4503bed1d49d323"/><emphasis role="strong">Function</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> &&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">other</link>) <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">noexcept</link>=<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">default</link></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a5c6ff5d442c8a74503312fb6bc75a1ff"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> & <emphasis role="strong">operator=</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">other</link>)=<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">default</link></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ac8934939c219d782fd1e02bca393318d"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> & <emphasis role="strong">operator=</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> &&<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">other</link>) <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">noexcept</link>=<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">default</link></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a71628f495a8a26f9584487abf05293b8"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> > & <emphasis role="strong">operator*=</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link>)</para>
|
||||
</listitem>
|
||||
<listitem><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - 1 > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ae43c705b427ac1ef27aed061a63e500e">differential</link> () <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link></para>
|
||||
|
||||
<para>Calculates the differential (dy/dx) of the function. </para>
|
||||
</listitem>
|
||||
<listitem><para>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ad090de9f6636094f14f1279615fccbc0">get_real_roots</link> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>=<link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()) <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link></para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that uses a genetic algorithm to find the approximate roots of the function. </para>
|
||||
</listitem>
|
||||
<listitem><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a5464547daff0c43faccdc40ea480bab4">solve_y</link> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">x_val</link>) <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">noexcept</link></para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that solves for y when x = user value. </para>
|
||||
</listitem>
|
||||
<listitem><para>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a46b9671c4a29b2b2b34586048a3b795a">solve_x</link> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> &y_val, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">options</link>=<link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()) <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link></para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that uses a genetic algorithm to find the values of x where y = user value. </para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</simplesect>
|
||||
<simplesect>
|
||||
<title>Friends </title>
|
||||
<itemizedlist>
|
||||
<listitem><para>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a8f5b8975b6e7318c093a963cd0b43db6">QuadraticSolve</link> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< 2 > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>)</para>
|
||||
|
||||
<para>Uses the quadratic function to solve the roots of an entered quadratic equation. </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a5de27194ad9a38f44771637a0f187562"/>std::ostream & <emphasis role="strong">operator<<</emphasis> (std::ostream &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">os</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">func</link>)</para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a08885f8e67d9d34770121c63c16f2eea"/>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> e1, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> e2, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> r> </para><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">r</link> > <emphasis role="strong">operator+</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e1</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f1</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f2</link>)</para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1afde1d3a278a171c30ff0ff00f65d120e"/>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> e1, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> e2, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> r> </para><para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">r</link> > <emphasis role="strong">operator-</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e1</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f1</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">e2</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f2</link>)</para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ae95957956718c40093891faf8dd52b0e"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> > <emphasis role="strong">operator*</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> > &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">f</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> &<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">c</link>)</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</simplesect>
|
||||
<section>
|
||||
<title>Detailed Description</title>
|
||||
<simplesect><title>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a0585614da72409acfbed262411ea7882">int</link> lrgst_expo><?linebreak?>class JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></title></simplesect>
|
||||
|
||||
<para>A class representing an Exponential <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> (e.g 2x^2 + 4x - 1),. </para>
|
||||
|
||||
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Template Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>lrgst_expo</entry><entry>
|
||||
<para>The largest exponent in the function (e.g 2 means largest exponent is x^2) </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Constructor & Destructor Documentation</title>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a0585614da72409acfbed262411ea7882"/><section>
|
||||
<title>Function()<computeroutput>[1/2]</computeroutput></title>
|
||||
<indexterm><primary>Function</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>Function</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::Function (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> > & constnts)</computeroutput></para><para>
|
||||
|
||||
<para>Constructor for <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> class. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>constnts</entry><entry>
|
||||
<para>An array with the constants for the function (e.g 2, 1, 3 = 2x^2 + 1x - 3) size of array MUST be lrgst_expo + 1 </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a7216329180e93c93204f4061be9e560b"/><section>
|
||||
<title>Function()<computeroutput>[2/2]</computeroutput></title>
|
||||
<indexterm><primary>Function</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>Function</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::Function (std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> > && constnts)</computeroutput></para><para>
|
||||
|
||||
<para>Constructor for <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> class. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>constnts</entry><entry>
|
||||
<para>An array with the constants for the function (e.g 2, 1, 3 = 2x^2 + 1x - 3) size of array MUST be lrgst_expo + 1 </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Member Function Documentation</title>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ae43c705b427ac1ef27aed061a63e500e"/><section>
|
||||
<title>differential()</title>
|
||||
<indexterm><primary>differential</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>differential</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> - 1 > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::differential ( ) const</computeroutput></para><para>
|
||||
|
||||
<para>Calculates the differential (dy/dx) of the function. </para>
|
||||
</para>
|
||||
|
||||
<para><formalpara><title>Returns</title>
|
||||
|
||||
<para>a function representing the differential (dy/dx) of the calling function object </para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1ad090de9f6636094f14f1279615fccbc0"/><section>
|
||||
<title>get_real_roots()</title>
|
||||
<indexterm><primary>get_real_roots</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>get_real_roots</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::get_real_roots (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> & options = <computeroutput><link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()</computeroutput>
|
||||
) const</computeroutput></para><para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that uses a genetic algorithm to find the approximate roots of the function. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>options</entry><entry>
|
||||
<para><link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> object specifying the options to run the algorithm </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara><title>Returns</title>
|
||||
|
||||
<para>A vector containing a n number of approximate root values (n = sample_size as defined in options) </para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a46b9671c4a29b2b2b34586048a3b795a"/><section>
|
||||
<title>solve_x()</title>
|
||||
<indexterm><primary>solve_x</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>solve_x</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::solve_x (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> & y_val, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> & options = <computeroutput><link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link>()</computeroutput>
|
||||
) const<computeroutput>[inline]</computeroutput></computeroutput></para><para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that uses a genetic algorithm to find the values of x where y = user value. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>y_val</entry><entry>
|
||||
<para>The return value that you would like to find the approximate x values needed to solve when entered into the function </para>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>options</entry><entry>
|
||||
<para><link linkend="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options">GA_Options</link> object specifying the options to run the algorithm </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara><title>Returns</title>
|
||||
|
||||
<para>A vector containing a n number of x values that cause the function to approximately equal the y_val (n = sample_size as defined in options) </para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a5464547daff0c43faccdc40ea480bab4"/><section>
|
||||
<title>solve_y()</title>
|
||||
<indexterm><primary>solve_y</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>solve_y</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">JRAMPERSAD::EXPONENTIAL::Function</link>< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">lrgst_expo</link> >::solve_y (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> & x_val) const<computeroutput>[noexcept]</computeroutput></computeroutput></para><para>
|
||||
|
||||
<para><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> that solves for y when x = user value. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>x_val</entry><entry>
|
||||
<para>the X Value you'd like the function to use </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara><title>Returns</title>
|
||||
|
||||
<para>the Y value the function returns based on the entered X value </para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Friends And Related Symbol Documentation</title>
|
||||
<anchor xml:id="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function_1a8f5b8975b6e7318c093a963cd0b43db6"/><section>
|
||||
<title>QuadraticSolve</title>
|
||||
<indexterm><primary>QuadraticSolve</primary><secondary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></secondary></indexterm>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::Function< lrgst_expo ></primary><secondary>QuadraticSolve</secondary></indexterm>
|
||||
<computeroutput>template<<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> lrgst_expo> </computeroutput><para><computeroutput>std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> > QuadraticSolve (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link>< 2 > & f)<computeroutput>[friend]</computeroutput></computeroutput></para><para>
|
||||
|
||||
<para>Uses the quadratic function to solve the roots of an entered quadratic equation. </para>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<formalpara>
|
||||
<title>
|
||||
Parameters</title>
|
||||
<para>
|
||||
<table frame="all">
|
||||
<tgroup cols="2" align="left" colsep="1" rowsep="1">
|
||||
<colspec colwidth="1*"/>
|
||||
<colspec colwidth="4*"/>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>f</entry><entry>
|
||||
<para>Quadratic function you'd like to find the roots of (Quadratic <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> object is a Function<2> object </para>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</formalpara>
|
||||
<formalpara><title>Returns</title>
|
||||
|
||||
<para>a vector containing the roots </para>
|
||||
</formalpara>
|
||||
</para>
|
||||
</section>
|
||||
<para>
|
||||
The documentation for this class was generated from the following file:</para>
|
||||
Exponential/Exponential.h</section>
|
||||
</section>
|
16
docs/docbook/index.xml
Normal file
16
docs/docbook/index.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<book xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_index" xml:lang="en-US">
|
||||
<info>
|
||||
<title>Exponential Functions</title>
|
||||
</info>
|
||||
<chapter>
|
||||
<title>Class Documentation</title>
|
||||
<xi:include href="class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>File Documentation</title>
|
||||
<xi:include href="_exponential_8h_source.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
</chapter>
|
||||
<index/>
|
||||
</book>
|
@ -0,0 +1,49 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options" xml:lang="en-US">
|
||||
<title>JRAMPERSAD::EXPONENTIAL::GA_Options Struct Reference</title>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::GA_Options</primary></indexterm>
|
||||
<para>
|
||||
|
||||
<para>Structure for options to be used when running one of the two genetic algorithms in a <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> object. </para>
|
||||
|
||||
</para>
|
||||
<para>
|
||||
<computeroutput>#include <Exponential.h></computeroutput>
|
||||
</para>
|
||||
<simplesect>
|
||||
<title>Public Attributes </title>
|
||||
<itemizedlist>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a316979973a2a6b70b00520c2f753a43c"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">min_range</emphasis> = -100</para>
|
||||
|
||||
<para>Minimum value you believe the answer can be. </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a9b8f1e5367f6b0d8b16eecaea53b40e2"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">max_range</emphasis> = 100</para>
|
||||
|
||||
<para>Maximum value you believe the answer can be. </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a4a67bad303f8a4fca40020a0802524c5"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unsigned</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> <emphasis role="strong">num_of_generations</emphasis> = 10</para>
|
||||
|
||||
<para>Number of times you'd like to run the algorithm (increasing this value causes the algorithm to take longer) </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1ad133af29dbbc26b8c3d507d359c03326"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unsigned</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> <emphasis role="strong">sample_size</emphasis> = 1000</para>
|
||||
|
||||
<para>Amount of approximate solutions you'd like to be returned. </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a6ec95fe6cc95dc32727659cf5bb1be12"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">unsigned</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> <emphasis role="strong">data_size</emphasis> = 100000</para>
|
||||
|
||||
<para>Amount of solutions you'd like the algorithm to generate (increasing this value causes the algorithm to take longer) </para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_g_a___options_1a736488b3cfeebda7b93b3e8c6f576bf8"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">mutation_percentage</emphasis> = 0.01</para>
|
||||
|
||||
<para>How much you'd like the algorithm to mutate solutions (Leave this as default in most cases) </para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</simplesect>
|
||||
<section>
|
||||
<title>Detailed Description</title>
|
||||
|
||||
<para>Structure for options to be used when running one of the two genetic algorithms in a <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Function</link> object. </para>
|
||||
<para>
|
||||
The documentation for this struct was generated from the following file:</para>
|
||||
Exponential/Exponential.h</section>
|
||||
</section>
|
@ -0,0 +1,29 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution" xml:lang="en-US">
|
||||
<title>JRAMPERSAD::EXPONENTIAL::detail::GA_Solution< lrgst_expo > Struct Template Reference</title>
|
||||
<indexterm><primary>JRAMPERSAD::EXPONENTIAL::detail::GA_Solution< lrgst_expo ></primary></indexterm>
|
||||
<simplesect>
|
||||
<title>Public Member Functions </title>
|
||||
<itemizedlist>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1a6cf25d21664ed2bd25b37ce771450dc4"/><emphasis role="strong">GA_Solution</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">Rank</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">x_val</link>, <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">y</link>=0)</para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1ac92bb2a2e6a4d39f555b907db40f46b0"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">void</link> <emphasis role="strong">fitness</emphasis> (<link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">const</link> std::vector< <link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">int</link> > &constants)</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</simplesect>
|
||||
<simplesect>
|
||||
<title>Public Attributes </title>
|
||||
<itemizedlist>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1a2e3723b62d3f4bac9e4cc573fd64e84c"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">rank</emphasis></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1a7d57801b01fab757029663439f04af65"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">x</emphasis></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1a9d6a8fae4ccfaeb1ce20afecb67c84ff"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">double</link> <emphasis role="strong">y_val</emphasis></para>
|
||||
</listitem>
|
||||
<listitem><para><anchor xml:id="_struct_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1detail_1_1_g_a___solution_1adc3ef46c48fc4b5a202131921f5c2a5f"/><link linkend="_class_j_r_a_m_p_e_r_s_a_d_1_1_e_x_p_o_n_e_n_t_i_a_l_1_1_function">bool</link> <emphasis role="strong">ranked</emphasis></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</simplesect>
|
||||
<para>
|
||||
The documentation for this struct was generated from the following file:</para>
|
||||
Exponential/Exponential.h</section>
|
Reference in New Issue
Block a user