Commit 4dc5c117 authored by Stephan Thober's avatar Stephan Thober
Browse files

Replace GRG2 optimization by NelderMead

- removed GRG2 optimization
- refactored objective function to be NelderMead compatible
- hard-coded parameters for NelderMead algorithm
parent 790aa2cd
!******************************************************************************
! Function To be optimised:
! VARIOGRAM TYPES: sum of errors=G(1)=> min!
! pure nugget + potential
!
!******************************************************************************
subroutine GCOMP(G,XU)
use mo_kind, only : i4, dp
use VarFit, only : vType, nbins, gamma, Nh
real(dp) G(10),XU(100)
real(dp) gCal, tvar
integer(i4) k
!
G(1) = 0.0_dp
!
do k=1,nbins
if (gamma(k,1) > 0.0_dp) then
gCal = tvar (gamma(k,1), XU(1), XU(2), XU(3))
!
! Estimator L1 weighted
if (gamma(k,1) <= 1.0_dp ) G(1)=G(1)+dabs(gamma(k,2) - gCal)*dble(Nh(k))
end if
end do
end
This diff is collapsed.
This diff is collapsed.
!******************************************************************************
! Function to be minimised for the nelder mead algorithm
!******************************************************************************
module mo_obj_func
implicit none
PRIVATE
PUBLIC :: obj_func
contains
function obj_func(p)
use mo_kind, only : i4, dp
use varfit, only : vtype, nbins, gamma, nh
implicit none
real(dp), dimension(:), intent(in) :: p
real(dp) :: obj_func
real(dp) :: xu(100)
real(dp) :: gcal, tvar
integer(i4) :: k
!
obj_func = 0.0_dp
!
do k=1,nbins
if (gamma(k,1) > 0.0_dp) then
! gcal = tvar (gamma(k,1), xu(1), xu(2), xu(3))
gcal = tvar(gamma(k,1), p(1), p(2), p(3))
!
! estimator l1 weighted
if (gamma(k,1) <= 1.0_dp ) obj_func = obj_func + dabs(gamma(k,2) - gcal) * dble(Nh(k))
end if
end do
end function obj_func
end module mo_obj_func
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment