program main !*****************************************************************************80 ! !! test_opt_con_test() tests test_opt_con(). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 15 January 2012 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'test_opt_con_test():' write ( *, '(a)' ) ' Fortran90 version' write ( *, '(a)' ) ' Test test_opt_con().' call test01 ( ) call test02 ( ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST_OPT_CON_TEST' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine test01 ( ) !*****************************************************************************80 ! !! TEST01 simply prints the title of each problem. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 October 2011 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer problem_num integer problem character ( len = 50 ) title write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' For each problem, print the title.' ! ! Get the number of problems. ! call p00_problem_num ( problem_num ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' Problem Title' write ( *, '(a)' ) ' ' do problem = 1, problem_num call p00_title ( problem, title ) write ( *, '(i6,2x,a)' ) problem, title end do return end subroutine test02 ( ) !*****************************************************************************80 ! !! TEST02 evaluates the objective function at each starting point. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 14 January 2012 ! ! Author: ! ! John Burkardt ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ), allocatable :: a(:) real ( kind = rk ), allocatable :: b(:) real ( kind = rk ), allocatable :: f(:) real ( kind = rk ) fs(1) integer i integer know integer m integer, parameter :: n = 100000 integer problem integer problem_num integer seed character ( len = 50 ) title real ( kind = rk ), allocatable :: x(:,:) real ( kind = rk ), allocatable :: xs(:) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'TEST02' write ( *, '(a)' ) ' For each problem, evaluate the function at many points.' write ( *, '(a,i8)' ) ' Number of sample points = ', n ! ! Get the number of problems. ! call p00_problem_num ( problem_num ) allocate ( f(1:n) ) do problem = 1, problem_num write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Problem ', problem call p00_title ( problem, title ) write ( *, '(2x,a)' ) trim ( title ) call p00_m ( problem, m ) write ( *, '(2x,a,i8)' ) ' M = ', m allocate ( a(1:m) ) allocate ( b(1:m) ) call p00_ab ( problem, m, a, b ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' I A(i) B(i)' write ( *, '(a)' ) ' ' do i = 1, m write ( *, '(2x,i4,2x,f10.4,2x,f10.4,2x,f10.4)' ) i, a(i), b(i) end do seed = 123456789 allocate ( x(1:m,1:n) ) call r8col_uniform ( m, n, a, b, seed, x ) call p00_f ( problem, m, n, x, f ) write ( *, '(a)' ) ' ' write ( *, '(a,g14.6)' ) ' Max(F) = ', maxval ( f(1:n) ) write ( *, '(a,g14.6)' ) ' Min(F) = ', minval ( f(1:n) ) allocate ( xs(1:m) ) know = 0 call p00_sol ( problem, m, know, xs ) if ( know /= 0 ) then call p00_f ( problem, m, 1, xs, fs ) write ( *, '(a,g14.6)' ) ' F(X*) = ', fs(1) else write ( *, '(a)' ) ' X* is not given.' end if deallocate ( a ) deallocate ( b ) deallocate ( x ) deallocate ( xs ) end do deallocate ( f ) return end subroutine timestamp ( ) !*****************************************************************************80 ! !! timestamp() prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) character ( len = 8 ) ampm integer d integer h integer m integer mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer n integer s integer values(8) integer y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end