Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : !> \brief
18 : !> This file contains procedure implementations of [pm_optimization](@ref pm_optimization).
19 : !>
20 : !> \finmain
21 : !>
22 : !> \author
23 : !> \AmirShahmoradi, Thursday 1:45 AM, August 22, 2019, Dallas, TX
24 :
25 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 :
27 : submodule (pm_optimization) routines ! LCOV_EXCL_LINE
28 :
29 : #if CHECK_ENABLED
30 : use pm_err, only: getFine
31 : use pm_val2str, only: getStr
32 : use pm_err, only: setAsserted
33 : #define CHECK_ASSERTION(LINE,ASSERTION,MSG) \
34 : call setAsserted(ASSERTION,getFine(__FILE__,LINE)//MODULE_NAME//MSG);
35 : #else
36 : #define CHECK_ASSERTION(LINE,ASSERTION,MSG) continue;
37 : #endif
38 :
39 : use pm_matrixInit, only: setMatInit, uppLowDia
40 : use pm_mathConst, only: GOLDEN_RATIO
41 : implicit none
42 :
43 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 :
45 : contains
46 :
47 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 :
49 : #define isBracketMax_ENABLED 1
50 :
51 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 :
53 : #define RK_ENABLED 1
54 :
55 : #if RK5_ENABLED
56 : module procedure isBracketMax_RK5
57 : use pm_kind, only: RKC => RK5
58 : #include "pm_optimization@routines.inc.F90"
59 : end procedure
60 : #endif
61 :
62 : #if RK4_ENABLED
63 8 : module procedure isBracketMax_RK4
64 : use pm_kind, only: RKC => RK4
65 : #include "pm_optimization@routines.inc.F90"
66 8 : end procedure
67 : #endif
68 :
69 : #if RK3_ENABLED
70 0 : module procedure isBracketMax_RK3
71 : use pm_kind, only: RKC => RK3
72 : #include "pm_optimization@routines.inc.F90"
73 0 : end procedure
74 : #endif
75 :
76 : #if RK2_ENABLED
77 0 : module procedure isBracketMax_RK2
78 : use pm_kind, only: RKC => RK2
79 : #include "pm_optimization@routines.inc.F90"
80 0 : end procedure
81 : #endif
82 :
83 : #if RK1_ENABLED
84 0 : module procedure isBracketMax_RK1
85 : use pm_kind, only: RKC => RK1
86 : #include "pm_optimization@routines.inc.F90"
87 0 : end procedure
88 : #endif
89 :
90 : #undef RK_ENABLED
91 :
92 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 :
94 : #undef isBracketMax_ENABLED
95 :
96 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 :
98 : #define isBracketMin_ENABLED 1
99 :
100 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 :
102 : #define RK_ENABLED 1
103 :
104 : #if RK5_ENABLED
105 : module procedure isBracketMin_RK5
106 : use pm_kind, only: RKC => RK5
107 : #include "pm_optimization@routines.inc.F90"
108 : end procedure
109 : #endif
110 :
111 : #if RK4_ENABLED
112 8 : module procedure isBracketMin_RK4
113 : use pm_kind, only: RKC => RK4
114 : #include "pm_optimization@routines.inc.F90"
115 8 : end procedure
116 : #endif
117 :
118 : #if RK3_ENABLED
119 0 : module procedure isBracketMin_RK3
120 : use pm_kind, only: RKC => RK3
121 : #include "pm_optimization@routines.inc.F90"
122 0 : end procedure
123 : #endif
124 :
125 : #if RK2_ENABLED
126 0 : module procedure isBracketMin_RK2
127 : use pm_kind, only: RKC => RK2
128 : #include "pm_optimization@routines.inc.F90"
129 0 : end procedure
130 : #endif
131 :
132 : #if RK1_ENABLED
133 0 : module procedure isBracketMin_RK1
134 : use pm_kind, only: RKC => RK1
135 : #include "pm_optimization@routines.inc.F90"
136 0 : end procedure
137 : #endif
138 :
139 : #undef RK_ENABLED
140 :
141 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 :
143 : #undef isBracketMin_ENABLED
144 :
145 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 :
147 : #define setBracketMax_ENABLED 1
148 :
149 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150 :
151 : #define RK_ENABLED 1
152 :
153 : #if RK5_ENABLED
154 : module procedure setBracketMax_RK5
155 : use pm_kind, only: RKC => RK5
156 : #include "pm_optimization@routines.inc.F90"
157 : end procedure
158 : #endif
159 :
160 : #if RK4_ENABLED
161 8 : module procedure setBracketMax_RK4
162 : use pm_kind, only: RKC => RK4
163 : #include "pm_optimization@routines.inc.F90"
164 8 : end procedure
165 : #endif
166 :
167 : #if RK3_ENABLED
168 0 : module procedure setBracketMax_RK3
169 : use pm_kind, only: RKC => RK3
170 : #include "pm_optimization@routines.inc.F90"
171 0 : end procedure
172 : #endif
173 :
174 : #if RK2_ENABLED
175 0 : module procedure setBracketMax_RK2
176 : use pm_kind, only: RKC => RK2
177 : #include "pm_optimization@routines.inc.F90"
178 0 : end procedure
179 : #endif
180 :
181 : #if RK1_ENABLED
182 0 : module procedure setBracketMax_RK1
183 : use pm_kind, only: RKC => RK1
184 : #include "pm_optimization@routines.inc.F90"
185 0 : end procedure
186 : #endif
187 :
188 : #undef RK_ENABLED
189 :
190 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 :
192 : #undef setBracketMax_ENABLED
193 :
194 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 :
196 : #define setBracketMin_ENABLED 1
197 :
198 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 :
200 : #define RK_ENABLED 1
201 :
202 : #if RK5_ENABLED
203 : module procedure setBracketMin_RK5
204 : use pm_kind, only: RKC => RK5
205 : #include "pm_optimization@routines.inc.F90"
206 : end procedure
207 : #endif
208 :
209 : #if RK4_ENABLED
210 36 : module procedure setBracketMin_RK4
211 : use pm_kind, only: RKC => RK4
212 : #include "pm_optimization@routines.inc.F90"
213 36 : end procedure
214 : #endif
215 :
216 : #if RK3_ENABLED
217 0 : module procedure setBracketMin_RK3
218 : use pm_kind, only: RKC => RK3
219 : #include "pm_optimization@routines.inc.F90"
220 0 : end procedure
221 : #endif
222 :
223 : #if RK2_ENABLED
224 0 : module procedure setBracketMin_RK2
225 : use pm_kind, only: RKC => RK2
226 : #include "pm_optimization@routines.inc.F90"
227 0 : end procedure
228 : #endif
229 :
230 : #if RK1_ENABLED
231 0 : module procedure setBracketMin_RK1
232 : use pm_kind, only: RKC => RK1
233 : #include "pm_optimization@routines.inc.F90"
234 0 : end procedure
235 : #endif
236 :
237 : #undef RK_ENABLED
238 :
239 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 :
241 : #undef setBracketMin_ENABLED
242 :
243 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 :
245 : #define getMinBrent_ENABLED 1
246 :
247 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 :
249 : #define RK_ENABLED 1
250 :
251 : #if RK5_ENABLED
252 : module procedure getMinBrent_RK5
253 : use pm_kind, only: RKC => RK5
254 : #include "pm_optimization@routines.inc.F90"
255 : end procedure
256 : #endif
257 :
258 : #if RK4_ENABLED
259 4 : module procedure getMinBrent_RK4
260 : use pm_kind, only: RKC => RK4
261 : #include "pm_optimization@routines.inc.F90"
262 4 : end procedure
263 : #endif
264 :
265 : #if RK3_ENABLED
266 0 : module procedure getMinBrent_RK3
267 : use pm_kind, only: RKC => RK3
268 : #include "pm_optimization@routines.inc.F90"
269 0 : end procedure
270 : #endif
271 :
272 : #if RK2_ENABLED
273 0 : module procedure getMinBrent_RK2
274 : use pm_kind, only: RKC => RK2
275 : #include "pm_optimization@routines.inc.F90"
276 0 : end procedure
277 : #endif
278 :
279 : #if RK1_ENABLED
280 0 : module procedure getMinBrent_RK1
281 : use pm_kind, only: RKC => RK1
282 : #include "pm_optimization@routines.inc.F90"
283 0 : end procedure
284 : #endif
285 :
286 : #undef RK_ENABLED
287 :
288 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 :
290 : #undef getMinBrent_ENABLED
291 :
292 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 :
294 : #define setMinBrent_ENABLED 1
295 :
296 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 :
298 : #define RK_ENABLED 1
299 :
300 : #if RK5_ENABLED
301 : module procedure setMinBrent_RK5
302 : use pm_kind, only: RKC => RK5
303 : #include "pm_optimization@routines.inc.F90"
304 : end procedure
305 : #endif
306 :
307 : #if RK4_ENABLED
308 32 : module procedure setMinBrent_RK4
309 : use pm_kind, only: RKC => RK4
310 : #include "pm_optimization@routines.inc.F90"
311 : end procedure
312 : #endif
313 :
314 : #if RK3_ENABLED
315 0 : module procedure setMinBrent_RK3
316 : use pm_kind, only: RKC => RK3
317 : #include "pm_optimization@routines.inc.F90"
318 : end procedure
319 : #endif
320 :
321 : #if RK2_ENABLED
322 0 : module procedure setMinBrent_RK2
323 : use pm_kind, only: RKC => RK2
324 : #include "pm_optimization@routines.inc.F90"
325 : end procedure
326 : #endif
327 :
328 : #if RK1_ENABLED
329 0 : module procedure setMinBrent_RK1
330 : use pm_kind, only: RKC => RK1
331 : #include "pm_optimization@routines.inc.F90"
332 : end procedure
333 : #endif
334 :
335 : #undef RK_ENABLED
336 :
337 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
338 :
339 : #undef setMinBrent_ENABLED
340 :
341 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 :
343 : #define isFailedMinPowell_ENABLED 1
344 :
345 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
346 :
347 : #define RK_ENABLED 1
348 :
349 : #if RK5_ENABLED
350 : module procedure isFailedMinPowell_RK5
351 : use pm_kind, only: RKC => RK5
352 : #include "pm_optimization@routines.inc.F90"
353 : end procedure
354 : #endif
355 :
356 : #if RK4_ENABLED
357 2 : module procedure isFailedMinPowell_RK4
358 : use pm_kind, only: RKC => RK4
359 : #include "pm_optimization@routines.inc.F90"
360 2 : end procedure
361 : #endif
362 :
363 : #if RK3_ENABLED
364 0 : module procedure isFailedMinPowell_RK3
365 : use pm_kind, only: RKC => RK3
366 : #include "pm_optimization@routines.inc.F90"
367 0 : end procedure
368 : #endif
369 :
370 : #if RK2_ENABLED
371 0 : module procedure isFailedMinPowell_RK2
372 : use pm_kind, only: RKC => RK2
373 : #include "pm_optimization@routines.inc.F90"
374 0 : end procedure
375 : #endif
376 :
377 : #if RK1_ENABLED
378 0 : module procedure isFailedMinPowell_RK1
379 : use pm_kind, only: RKC => RK1
380 : #include "pm_optimization@routines.inc.F90"
381 0 : end procedure
382 : #endif
383 :
384 : #undef RK_ENABLED
385 :
386 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 :
388 : #undef isFailedMinPowell_ENABLED
389 :
390 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391 :
392 : #define setMinPowell_ENABLED 1
393 :
394 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 :
396 : #define RK_ENABLED 1
397 :
398 : #if RK5_ENABLED
399 : module procedure setMinPowell_RK5
400 : use pm_kind, only: RKC => RK5
401 : #include "pm_optimization@routines.inc.F90"
402 : end procedure
403 : #endif
404 :
405 : #if RK4_ENABLED
406 3 : module procedure setMinPowell_RK4
407 : use pm_kind, only: RKC => RK4
408 : #include "pm_optimization@routines.inc.F90"
409 : end procedure
410 : #endif
411 :
412 : #if RK3_ENABLED
413 0 : module procedure setMinPowell_RK3
414 : use pm_kind, only: RKC => RK3
415 : #include "pm_optimization@routines.inc.F90"
416 : end procedure
417 : #endif
418 :
419 : #if RK2_ENABLED
420 0 : module procedure setMinPowell_RK2
421 : use pm_kind, only: RKC => RK2
422 : #include "pm_optimization@routines.inc.F90"
423 : end procedure
424 : #endif
425 :
426 : #if RK1_ENABLED
427 0 : module procedure setMinPowell_RK1
428 : use pm_kind, only: RKC => RK1
429 : #include "pm_optimization@routines.inc.F90"
430 : end procedure
431 : #endif
432 :
433 : #undef RK_ENABLED
434 :
435 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
436 :
437 : #undef setMinPowell_ENABLED
438 :
439 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
440 :
441 : #undef CHECK_ASSERTION
442 :
443 : end submodule routines
|