testOptimize_prg Program

program~~testoptimize_prg~~UsesGraph program~testoptimize_prg testOptimize_prg module~kinds_mod kinds_mod module~kinds_mod->program~testoptimize_prg module~optimize_mod optimize_mod module~kinds_mod->module~optimize_mod module~objective_mod objective_mod module~kinds_mod->module~objective_mod module~array_mod array_mod module~kinds_mod->module~array_mod module~text_mod text_mod module~kinds_mod->module~text_mod module~plplotlib_mod plplotlib_mod module~kinds_mod->module~plplotlib_mod module~time_mod time_mod module~kinds_mod->module~time_mod module~optimize_mod->program~testoptimize_prg module~optimize_mod->module~objective_mod module~objective_mod->program~testoptimize_prg module~array_mod->module~optimize_mod module~array_mod->module~objective_mod module~array_mod->module~plplotlib_mod module~text_mod->module~objective_mod module~text_mod->module~plplotlib_mod module~plplotlib_mod->module~objective_mod module~time_mod->module~text_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~text_mod iso_c_binding iso_c_binding iso_c_binding->module~time_mod plplot plplot plplot->module~plplotlib_mod
Help


Test program for Optimize_mod

Calls

program~~testoptimize_prg~~CallsGraph program~testoptimize_prg testOptimize_prg proc~testobjectiven testObjectiveN program~testoptimize_prg->proc~testobjectiven proc~testobjective testObjective program~testoptimize_prg->proc~testobjective proc~testplot testPlot program~testoptimize_prg->proc~testplot setup setup proc~testplot->setup span span proc~testplot->span mixval mixval proc~testplot->mixval ticks ticks proc~testplot->ticks contourf contourf proc~testplot->contourf linspace linspace proc~testplot->linspace xlog xlog proc~testplot->xlog subplot subplot proc~testplot->subplot labels labels proc~testplot->labels plot plot proc~testplot->plot inttochar inttochar proc~testplot->inttochar show show proc~testplot->show colorbar2 colorbar2 proc~testplot->colorbar2 figure figure proc~testplot->figure xylim xylim proc~testplot->xylim
Help

Source Code


Subroutines

subroutine testObjective()

Verify operation of obj_t

Arguments

None

subroutine testObjectiveN()

Arguments

None

subroutine testPlot()

Arguments

None

Source Code

program testOptimize_prg
	!! Test program for Optimize_mod
	!! @todo
	!! Finish tests
	use kinds_mod
	use optimize_mod
	use objective_mod
	implicit none
	
	call testObjective
	call testObjectiveN
	call testPlot
	
contains

	subroutine testObjective
		!! Verify operation of obj_t
		type(test_t)::test
		
		write(*,*) test%eval(2.0_wp)-3.0_wp
		write(*,*) test%der1(0.0_wp)
		write(*,*) test%der2(0.0_wp)
		write(*,*) test%rootNewton(4.0_wp,tol=1.0E-10_wp,maxIts=1000000)
		write(*,*) test%minNewton(4.0_wp,tol=1.0E-10_wp,maxIts=1000000)
	end subroutine testObjective

	subroutine testObjectiveN
		type(testN_t)::test
		real(wp),dimension(:),allocatable::xSD,xMN,xNM
		
		xSD = test%steepestDescent([5.0_wp,5.0_wp])
		xMN = test%minNewton([5.0_wp,5.0_wp])
		xNM = test%nelderMead([5.0_wp,5.0_wp])
		write(*,*) xSD
		write(*,*) xMN
		write(*,*) xNM
	end subroutine testObjectiveN

	subroutine testPlot
		type(testN_t)::test
		real(wp),dimension(:),allocatable::x,y
		real(wp),dimension(:,:),allocatable::f
		integer::N,i,j
		
		real(wp),dimension(:),allocatable::xm
		
		N = 100
		x = linspace(0.0_wp,7.0_wp,N)
		y = linspace(0.0_wp,7.0_wp,N)
		allocate( f(N,N) )
		
		do j=1,N
			do i=1,N
				f(i,j) = test%eval([ x(i) , y(j) ])
			end do
		end do
		
		call setup(fileName='testsOptimize-%n.svg',figSize=[400,350])
		
		kLog = 1
		xm = test%steepestDescent([5.0_wp,5.0_wp])
		call figure()
		call subplot(1,1,1,aspect=span(y)/span(x))
		call xylim(mixval(x),mixval(y))
		call contourf(x,y,f,30)
		call plot(xLog(:kLog-1,1),xLog(:kLog-1,2),lineStyle='-',markStyle='x',markColor='k')
		call colorbar2(f,30)
		call ticks()
		call labels('x','y','Steepest Descent ['//intToChar(kLog-1)//']')
		
		kLog = 1
		xm = test%minNewton([5.0_wp,5.0_wp])
		call figure()
		call subplot(1,1,1,aspect=span(y)/span(x))
		call xylim(mixval(x),mixval(y))
		call contourf(x,y,f,30)
		call plot(xLog(:kLog-1,1),xLog(:kLog-1,2),lineStyle='-',markStyle='x',markColor='k')
		call colorbar2(f,30)
		call ticks()
		call labels('x','y','Newton-Raphson ['//intToChar(kLog-1)//']')
		
		kLog = 1
		xm = test%nelderMead([5.0_wp,5.0_wp])
		call figure()
		call subplot(1,1,1,aspect=span(y)/span(x))
		call xylim(mixval(x),mixval(y))
		call contourf(x,y,f,30)
		call plot(xLog(:kLog-1,1),xLog(:kLog-1,2),lineStyle='-',markStyle='x',markColor='k')
		call colorbar2(f,30)
		call ticks()
		call labels('x','y','Nelder-Mead Simplex ['//intToChar(kLog-1)//']')
		
		call show()
		
	end subroutine testPlot

end program testOptimize_prg