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
600e0365
"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "e7e6d852822b279b88f133395bcc2dd056eb59da"
Commit
600e0365
authored
Jan 16, 2021
by
Davis King
Browse files
work around bug in gcc 4.8
parent
869097c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
dlib/global_optimization/find_max_global.h
dlib/global_optimization/find_max_global.h
+20
-1
dlib/test/global_optimization.cpp
dlib/test/global_optimization.cpp
+10
-0
No files found.
dlib/global_optimization/find_max_global.h
View file @
600e0365
...
@@ -281,12 +281,31 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
...
@@ -281,12 +281,31 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
std
::
vector
<
function_spec
>
specs
,
std
::
vector
<
function_spec
>
specs
,
const
std
::
chrono
::
nanoseconds
max_runtime
,
const
std
::
chrono
::
nanoseconds
max_runtime
,
const
max_function_calls
num
,
const
max_function_calls
num
,
double
solver_epsilon
=
0
,
double
solver_epsilon
,
Args
&&
...
args
Args
&&
...
args
)
)
{
{
return
find_max_global
(
ymult
,
tp
,
functions
,
std
::
move
(
specs
),
num
,
max_runtime
,
solver_epsilon
,
std
::
forward
<
Args
>
(
args
)...);
return
find_max_global
(
ymult
,
tp
,
functions
,
std
::
move
(
specs
),
num
,
max_runtime
,
solver_epsilon
,
std
::
forward
<
Args
>
(
args
)...);
}
}
// This overload shouldn't be required but it works around a bug in gcc 4.8 which has a bug
// that makes it complain about setting a default for solver_epsilon but then following it
// by args that "isn't defaulted" according to gcc 4.8.
template
<
typename
funct
,
typename
...
Args
>
std
::
pair
<
size_t
,
function_evaluation
>
find_max_global
(
double
ymult
,
thread_pool
&
tp
,
std
::
vector
<
funct
>&
functions
,
std
::
vector
<
function_spec
>
specs
,
const
std
::
chrono
::
nanoseconds
max_runtime
,
const
max_function_calls
num
,
double
solver_epsilon
=
0
)
{
return
find_max_global
(
ymult
,
tp
,
functions
,
std
::
move
(
specs
),
num
,
max_runtime
,
solver_epsilon
);
}
// This overload allows the num argument to be skipped.
// This overload allows the num argument to be skipped.
template
<
template
<
...
...
dlib/test/global_optimization.cpp
View file @
600e0365
...
@@ -187,6 +187,16 @@ namespace
...
@@ -187,6 +187,16 @@ namespace
DLIB_TEST_MSG
(
max
(
abs
(
true_x
-
result
.
x
))
<
1e-5
,
max
(
abs
(
true_x
-
result
.
x
)));
DLIB_TEST_MSG
(
max
(
abs
(
true_x
-
result
.
x
))
<
1e-5
,
max
(
abs
(
true_x
-
result
.
x
)));
print_spinner
();
print_spinner
();
result
=
find_max_global
(
rosen
,
{
0.1
,
0.1
},
{
2
,
2
},
std
::
chrono
::
seconds
(
5
),
max_function_calls
(
100
));
dlog
<<
LINFO
<<
"rosen: "
<<
trans
(
result
.
x
);
DLIB_TEST_MSG
(
max
(
abs
(
true_x
-
result
.
x
))
<
1e-5
,
max
(
abs
(
true_x
-
result
.
x
)));
print_spinner
();
result
=
find_max_global
(
rosen
,
{
0.1
,
0.1
},
{
2
,
2
},
max_function_calls
(
100
),
std
::
chrono
::
seconds
(
5
));
dlog
<<
LINFO
<<
"rosen: "
<<
trans
(
result
.
x
);
DLIB_TEST_MSG
(
max
(
abs
(
true_x
-
result
.
x
))
<
1e-5
,
max
(
abs
(
true_x
-
result
.
x
)));
print_spinner
();
result
=
find_max_global
(
rosen
,
{
0.1
,
0.1
},
{
2
,
2
},
{
false
,
false
},
max_function_calls
(
100
));
result
=
find_max_global
(
rosen
,
{
0.1
,
0.1
},
{
2
,
2
},
{
false
,
false
},
max_function_calls
(
100
));
dlog
<<
LINFO
<<
"rosen: "
<<
trans
(
result
.
x
);
dlog
<<
LINFO
<<
"rosen: "
<<
trans
(
result
.
x
);
...
...
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