Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FORCES
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CHS
FORCES
Commits
490999a1
Commit
490999a1
authored
4 months ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
tests: update SCE unit test
parent
de25b7ac
No related branches found
Branches containing commit
No related tags found
1 merge request
!81
Rework optimization routines
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pf_tests/test_mo_sce.pf
+26
-29
26 additions, 29 deletions
src/pf_tests/test_mo_sce.pf
with
26 additions
and
29 deletions
src/pf_tests/test_mo_sce.pf
+
26
−
29
View file @
490999a1
module test_mo_sce
use funit
use mo_kind, only: i4, i8, dp
use mo_sce, only: sce
use mo_opt_functions, only:
eval_dummy, ackley_objective, griewank_objective
use mo_optimization_utils, only:
eval_interface, objective_interfac
e
use mo_opt_functions, only:
ackley, griewank
use mo_optimization_utils, only:
function_optimize
e
use mo_message, only: error_message
implicit none
real(dp), dimension(:), allocatable :: pini
...
...
@@ -21,9 +21,8 @@ module test_mo_sce
integer(i4) :: n
logical :: parallel
procedure(eval_interface), pointer :: eval
procedure(objective_interface), pointer :: obj_func
type(function_optimizee) :: objective
contains
@test
...
...
@@ -31,7 +30,7 @@ contains
real(dp) :: t = 1.e-7_dp
integer(i4) :: iPar
! Dimension of test function = number of parameters
n = 30
...
...
@@ -51,10 +50,9 @@ contains
mask(:) = .true.
pini(:) = 0.5_dp
parallel=.false.
eval => eval_dummy
obj_func => ackley_objective
opt = sce(eval, & ! Mandatory IN: eval function
obj_func, & ! Mandatory IN: Objective function
objective%func_pointer => ackley
opt = sce( &
objective, & ! Mandatory INOUT: objective
pini, & ! Mandatory IN: initial guess
prange, & ! Mandatory IN: range for each parameter (min, max)
mymaxn=30000_i8, & ! Optional IN: maximal number of function evaluations
...
...
@@ -97,7 +95,7 @@ contains
write(*,*) ''
write(*,*) 'number of function evaluations: neval = ', neval
write(*,*) 'best function value found: bestf = ', obj
_func(opt, eval
)
write(*,*) 'best function value found: bestf = ', obj
ective%evaluate(opt
)
write(*,*) 'global minimal function value: optf = ', 0.0_dp
write(*,*) ''
...
...
@@ -116,13 +114,13 @@ contains
end if
! Check restart
bestf = 0.
neval = 0
history = 0.
opt = sce(
eval, & ! Mandatory IN : Objective function
obj_func,
& ! Mandatory IN:
O
bjective
function
opt
= sce(
&
objective,
& ! Mandatory IN
OUT
:
o
bjective
pini, & ! Mandatory IN : initial guess
prange, & ! Mandatory IN : range for each parameter (min, max)
restart=.true., & ! Do the restart
...
...
@@ -134,7 +132,7 @@ contains
write(*,*) ''
write(*,*) 'number of function evaluations: neval = ', neval
write(*,*) 'best function value found: bestf = ', obj
_func(opt, eval
)
write(*,*) 'best function value found: bestf = ', obj
ective%evaluate(opt
)
write(*,*) 'global minimal function value: optf = ', 0.0_dp
write(*,*) ''
...
...
@@ -159,7 +157,7 @@ contains
real(dp) :: t = 1.e-7_dp
integer(i4) :: iPar
! Dimension of test function = number of parameters
n = 3
...
...
@@ -179,10 +177,9 @@ contains
mask(:) = .true.
pini(:) = 0.5_dp
parallel=.false.
eval => eval_dummy
obj_func => griewank_objective
opt = sce(eval, & ! Mandatory IN: eval function
obj_func, & ! Mandatory IN: Objective function
objective%func_pointer => griewank
opt = sce( &
objective, & ! Mandatory INOUT: objective
pini, & ! Mandatory IN: initial guess
prange, & ! Mandatory IN: range for each parameter (min, max)
mymaxn=30000_i8, & ! Optional IN: maximal number of function evaluations
...
...
@@ -225,7 +222,7 @@ contains
write(*,*) ''
write(*,*) 'number of function evaluations: neval = ', neval
write(*,*) 'best function value found: bestf = ', obj
_func(opt, eval
)
write(*,*) 'best function value found: bestf = ', obj
ective%evaluate(opt
)
write(*,*) 'global minimal function value: optf = ', 0.0_dp
write(*,*) ''
...
...
@@ -244,13 +241,13 @@ contains
end if
! Check restart
bestf = 0.
neval = 0
history = 0.
opt = sce(
eval, & ! Mandatory IN : Objective function
obj_func,
& ! Mandatory IN:
O
bjective
function
opt
= sce(
&
objective,
& ! Mandatory IN
OUT
:
o
bjective
pini, & ! Mandatory IN : initial guess
prange, & ! Mandatory IN : range for each parameter (min, max)
restart=.true., & ! Do the restart
...
...
@@ -262,7 +259,7 @@ contains
write(*,*) ''
write(*,*) 'number of function evaluations: neval = ', neval
write(*,*) 'best function value found: bestf = ', obj
_func(opt, eval
)
write(*,*) 'best function value found: bestf = ', obj
ective%evaluate(opt
)
write(*,*) 'global minimal function value: optf = ', 0.0_dp
write(*,*) ''
...
...
@@ -281,5 +278,5 @@ contains
deallocate(pini, prange, opt, mask)
end subroutine test_sce_griewank
end module test_mo_sce
\ No newline at end of file
end module test_mo_sce
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment