ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_optimization::isBracketMin Interface Reference

Generate and return .true. if and only if a convex quadratic curve can fit the specified input triple [xmin, xlow, xupp] and the function value at the middle point xmin is smaller than both boundary point function values.
More...

Detailed Description

Generate and return .true. if and only if a convex quadratic curve can fit the specified input triple [xmin, xlow, xupp] and the function value at the middle point xmin is smaller than both boundary point function values.

This function is useful for testing whether the initial bracket intervals to various optimization routines enclose the desired function extremum.

Specifically, this generic interface computed and returns the following criterion: bracketed = xlow <= xmin .and. xmin <= xupp .and. flow >= fmin .or. fmin <= fupp

Parameters
[in]xmin: The input scalar of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128), containing the abscissa corresponding to the minimum function value among the triplet [xmin, xlow, xupp].
[in]xlow: The input scalar of the same type and kind as the input argument xmin, containing the lower bound of the interval specified by the triplet.
[in]xupp: The input scalar of the same type and kind as the input argument xmin, containing the upper bound of the interval specified by the triplet.
[in]fmin: The input scalar of the same type and kind as the input argument xmin, containing the target function value at xmin.
[in]flow: The input scalar of the same type and kind as the input argument xmin, containing the target function value at xlow.
[in]fupp: The input scalar of the same type and kind as the input argument xmin, containing the target function value at xupp.


Possible calling interfaces

use pm_kind, only: LK
logical(LK) :: bracketed
bracketed = isBracketMin(xmin, xlow, xupp, fmin, flow, fupp)
Generate and return .true. if and only if a convex quadratic curve can fit the specified input triple...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
This module contains procedures, generic interfaces, and types for numerical optimizations of mathema...
Remarks
The procedures under discussion are pure.
The procedures under discussion are elemental.
See also
isBracketMax
isBracketMin
setBracketMax
setBracketMin
getMinBrent
setMinBrent


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK
4 use pm_kind, only: RKG => RKH ! all processor kinds are supported.
5 use pm_io, only: display_type
7 use pm_err, only: setAsserted
8 use pm_val2str, only: getStr
9
10 implicit none
11
12 integer(IK) :: niter, minniter = 1000
13 real(RKG) :: xlow, xmin, xupp, flow, fmin, fupp
14 type(display_type) :: disp
15 disp = display_type(file = "main.out.F90")
16
17 call disp%skip()
18 call disp%show("getSqNeg(x) = (x - 1)**2")
19 call disp%show("xlow = -3; xupp = -1; niter = minniter")
20 xlow = -3; xupp = -1; niter = minniter
21 call disp%show("call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin)")
22 call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin)
23 call disp%show("if (niter > minniter) error stop 'Bracketing failed.'")
24 if (niter > minniter) error stop 'Bracketing failed.'
25 call disp%show("[xlow, xmin, xupp, getSqNeg(xlow), fmin, getSqNeg(xupp)]")
26 call disp%show( [xlow, xmin, xupp, getSqNeg(xlow), fmin, getSqNeg(xupp)] )
27 call disp%show("niter")
28 call disp%show( niter )
29 call disp%show("call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, getSqNeg(xlow), getSqNeg(xupp)))")
30 call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, getSqNeg(xlow), getSqNeg(xupp)))
31 call disp%skip()
32
33 call disp%skip()
34 call disp%show("getSqNeg(x) = (x - 1)**2")
35 call disp%show("xlow = -3; xupp = -1; niter = minniter")
36 xlow = -3; xupp = -1; niter = minniter
37 call disp%show("call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)")
38 call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
39 call disp%show("if (niter > minniter) error stop 'Bracketing failed.'")
40 if (niter > minniter) error stop 'Bracketing failed.'
41 call disp%show("[xlow, xmin, xupp, flow, fmin, fupp]")
42 call disp%show( [xlow, xmin, xupp, flow, fmin, fupp] )
43 call disp%show("niter")
44 call disp%show( niter )
45 call disp%show("call setAsserted(isBracketMin(xmin, xlow, xupp, flow, fmin, fupp))")
46 call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))
47 call disp%skip()
48
49 call disp%skip()
50 call disp%show("getSqNeg(x) = (x - 1)**2")
51 call disp%show("xlow = 3; xupp = 9; niter = minniter")
52 xlow = 3; xupp = 9; niter = minniter
53 call disp%show("call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)")
54 call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
55 call disp%show("if (niter > minniter) error stop 'Bracketing failed.'")
56 if (niter > minniter) error stop 'Bracketing failed.'
57 call disp%show("[xlow, xmin, xupp, flow, fmin, fupp]")
58 call disp%show( [xlow, xmin, xupp, flow, fmin, fupp] )
59 call disp%show("niter")
60 call disp%show( niter )
61 call disp%show("call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))")
62 call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))
63 call disp%skip()
64
65 call disp%skip()
66 call disp%show("getSqNeg(x) = (x - 1)**2")
67 call disp%show("xlow = -5; xupp = 4; niter = minniter")
68 xlow = -5; xupp = 4; niter = minniter
69 call disp%show("call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)")
70 call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
71 call disp%show("if (niter > minniter) error stop 'Bracketing failed.'")
72 if (niter > minniter) error stop 'Bracketing failed.'
73 call disp%show("[xlow, xmin, xupp, flow, fmin, fupp]")
74 call disp%show( [xlow, xmin, xupp, flow, fmin, fupp] )
75 call disp%show("niter")
76 call disp%show( niter )
77 call disp%show("call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))")
78 call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))
79 call disp%skip()
80
81contains
82
83 function getSqNeg(x) result(func)
84 real(RKG), intent(in) :: x
85 real(RKG) :: func
86 func = (x - 1)**2
87 end function
88
89end program example
Verify the input assertion holds and if it does not, print the (optional) input message on stdout and...
Definition: pm_err.F90:735
Generate and return an object of type stop_type with the user-specified input attributes.
Definition: pm_err.F90:1618
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Refine an initial input interval such that the final returned interval is guaranteed to contain the m...
Generate and return the conversion of the input value to an output Fortran string,...
Definition: pm_val2str.F90:167
This module contains classes and procedures for reporting and handling errors.
Definition: pm_err.F90:52
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
Definition: pm_kind.F90:858
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2getSqNeg(x) = (x - 1)**2
3xlow = -3; xupp = -1; niter = minniter
4call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin)
5if (niter > minniter) error stop 'Bracketing failed.'
6[xlow, xmin, xupp, getSqNeg(xlow), fmin, getSqNeg(xupp)]
7-1.00000000000000000000000000000000000, +1.00000000000000000000000000000000000, +2.23606797749978969640917366873127632, +4.00000000000000000000000000000000000, +0.00000000000000000000000000000000000, +1.52786404500042060718165266253744775
8niter
9+1
10call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, getSqNeg(xlow), getSqNeg(xupp)))
11
12
13getSqNeg(x) = (x - 1)**2
14xlow = -3; xupp = -1; niter = minniter
15call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
16if (niter > minniter) error stop 'Bracketing failed.'
17[xlow, xmin, xupp, flow, fmin, fupp]
18-1.00000000000000000000000000000000000, +1.00000000000000000000000000000000000, +2.23606797749978969640917366873127632, +4.00000000000000000000000000000000000, +0.00000000000000000000000000000000000, +1.52786404500042060718165266253744775
19niter
20+1
21call setAsserted(isBracketMin(xmin, xlow, xupp, flow, fmin, fupp))
22
23
24getSqNeg(x) = (x - 1)**2
25xlow = 3; xupp = 9; niter = minniter
26call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
27if (niter > minniter) error stop 'Bracketing failed.'
28[xlow, xmin, xupp, flow, fmin, fupp]
29-6.70820393249936908922752100619382819, +3.00000000000000000000000000000000000, +9.00000000000000000000000000000000000, +64.0000000000000000000000000000000000, +4.00000000000000000000000000000000000, +59.4164078649987381784550420123876502
30niter
31+1
32call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))
33
34
35getSqNeg(x) = (x - 1)**2
36xlow = -5; xupp = 4; niter = minniter
37call setBracketMin(getSqNeg, niter, xmin, xlow, xupp, fmin, flow, fupp)
38if (niter > minniter) error stop 'Bracketing failed.'
39[xlow, xmin, xupp, flow, fmin, fupp]
40-5.00000000000000000000000000000000000, +4.00000000000000000000000000000000000, +18.5623058987490536338412815092907438, +36.0000000000000000000000000000000000, +9.00000000000000000000000000000000000, +308.434588481235804507619222639361176
41niter
42+1
43call setAsserted(isBracketMin(xmin, xlow, xupp, fmin, flow, fupp))
44
45
Test:
test_pm_optimization


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Tuesday March 7, 2017, 3:50 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 276 of file pm_optimization.F90.


The documentation for this interface was generated from the following file: