Skip to content

Commit 8260ee9

Browse files
committed
if vm is zero to 0 on input, initialize to abs(xu-xl)
1 parent e7c96dd commit 8260ee9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/simulated_annealing.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,9 @@ subroutine sa(me, x, rt, t, vm, xopt, fopt, nacc, nfcnev, ier)
577577
!! interest given the starting value x. for point x(i), the next
578578
!! trial point is selected is from x(i) - vm(i) to x(i) + vm(i).
579579
!! since vm is adjusted so that about half of all points are accepted,
580-
!! the input value is not very important (i.e. is the value is off,
580+
!! the input value is not very important (i.e. if the value is off,
581581
!! sa adjusts vm to the correct value).
582+
!! note: if `vm=0.0`, then it is set to abs(xu-xl)`.
582583
real(wp), dimension(me%n), intent(out) :: xopt !! the variables that optimize the function.
583584
real(wp), intent(out) :: fopt !! the optimal value of the function.
584585
integer, intent(out) :: nacc !! the number of accepted function evaluations.
@@ -629,6 +630,9 @@ subroutine sa(me, x, rt, t, vm, xopt, fopt, nacc, nfcnev, ier)
629630
xopt = x
630631
fopt = huge(1.0_wp)
631632
vm = abs(vm)
633+
where (vm == 0.0_wp)
634+
vm = abs(me%ub - me%lb)
635+
end where
632636
t_original = t
633637
vm_original = vm
634638
abort = .false.

0 commit comments

Comments
 (0)