#*****************************************************************************80 # ## hillclimbing_test tests hillclimbing. # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 17 March 2020 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "hillclimbing_test\n" ) cat ( " ", version$version.string, "\n" ) cat ( " hillclimbing seeks the minimum of a function using hillclimbing.\n" ) cat ( "\n" ) source ( "/home/burkardt/public_html/r_src/hillclimbing/hillclimbing.R" ) f <- function ( x ) { value = ( x[1]^2 + x[2] - 11.0 )^2 + ( x[1] + x[2]^2 - 7.0 )^2 return ( value ) } x = c( 0.0, 0.0 ) x <- hillclimbing ( f, x ) fx <- f(x) cat ( " hillclimbing(himmelblau, [0,0]) = ", x, " f(x) = ", fx, "\n" ) x = c( -1.0, -1.0 ) x <- hillclimbing ( f, x ) fx <- f(x) cat ( " hillclimbing(himmelblau, [-1,-1]) = ", x, " f(x) = ", fx, "\n" ) # # Terminate. # cat ( "\n" ) cat ( "hillclimbing_test\n" ) cat ( " Normal end of execution.\n" ) cat ( date ( ), "\n" ) quit ( )