Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
a37c5e7c
Commit
a37c5e7c
authored
Feb 19, 2018
by
Davis King
Browse files
Add the example program contents as a test as well.
parent
9691c194
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
tools/python/test/test_global_optimization.py
tools/python/test/test_global_optimization.py
+14
-0
No files found.
tools/python/test/test_global_optimization.py
View file @
a37c5e7c
...
...
@@ -21,3 +21,17 @@ def test_global_optimization_nargs():
find_max_global
(
lambda
a
,
b
,
c
,
d
,
*
args
:
0
,
[
0
,
0
,
0
],
[
1
,
1
,
1
],
10
)
with
raises
(
Exception
):
find_min_global
(
lambda
a
,
b
,
c
,
d
,
*
args
:
0
,
[
0
,
0
,
0
],
[
1
,
1
,
1
],
10
)
from
math
import
sin
,
cos
,
pi
,
exp
,
sqrt
def
holder_table
(
x0
,
x1
):
return
-
abs
(
sin
(
x0
)
*
cos
(
x1
)
*
exp
(
abs
(
1
-
sqrt
(
x0
*
x0
+
x1
*
x1
)
/
pi
)))
def
test_on_holder_table
():
x
,
y
=
find_min_global
(
holder_table
,
[
-
10
,
-
10
],
[
10
,
10
],
200
)
assert
(
y
-
-
19.2085025679
)
<
1e-7
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment