Commit c14dca07 authored by Davis King's avatar Davis King

Added an optional thread_pool argument to find_max_global() and find_min_global()

to allow for parallel execution of the objective function calls.
parent 66c4fa81
......@@ -8,6 +8,8 @@
#include "../metaprogramming.h"
#include <utility>
#include <chrono>
#include <memory>
#include "../threads/thread_pool_extension.h"
namespace dlib
{
......@@ -118,6 +120,7 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
typename funct
>
std::pair<size_t,function_evaluation> find_max_global (
thread_pool& tp,
std::vector<funct>& functions,
std::vector<function_spec> specs,
const max_function_calls num,
......@@ -159,18 +162,23 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
// Now run the main solver loop.
for (size_t i = 0; i < num.max_calls && std::chrono::steady_clock::now() < time_to_stop; ++i)
{
auto next = opt.get_next_x();
matrix<double,0,1> x = next.x();
// Undo any log-scaling that was applied to the variables before we pass them
// to the functions being optimized.
for (long j = 0; j < x.size(); ++j)
{
if (log_scale[next.function_idx()][j])
x(j) = std::exp(x(j));
}
double y = ymult*call_function_and_expand_args(functions[next.function_idx()], x);
next.set(y);
auto next = std::make_shared<function_evaluation_request>(opt.get_next_x());
auto execute_call = [&functions,&ymult,&log_scale,next]() {
matrix<double,0,1> x = next->x();
// Undo any log-scaling that was applied to the variables before we pass them
// to the functions being optimized.
for (long j = 0; j < x.size(); ++j)
{
if (log_scale[next->function_idx()][j])
x(j) = std::exp(x(j));
}
double y = ymult*call_function_and_expand_args(functions[next->function_idx()], x);
next->set(y);
};
tp.add_task_by_value(execute_call);
}
tp.wait_for_all_tasks();
matrix<double,0,1> x;
......@@ -185,6 +193,24 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
}
return std::make_pair(function_idx, function_evaluation(x,y/ymult));
}
template <
typename funct
>
std::pair<size_t,function_evaluation> find_max_global (
std::vector<funct>& functions,
std::vector<function_spec> specs,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon,
double ymult
)
{
// disabled, don't use any threads
thread_pool tp(0);
return find_max_global(tp, functions, std::move(specs), num, max_runtime, solver_epsilon, ymult);
}
}
// ----------------------------------------------------------------------------------------
......@@ -217,6 +243,36 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return impl::find_max_global(functions, std::move(specs), num, max_runtime, solver_epsilon, -1);
}
template <
typename funct
>
std::pair<size_t,function_evaluation> find_max_global (
thread_pool& tp,
std::vector<funct>& functions,
std::vector<function_spec> specs,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return impl::find_max_global(tp, functions, std::move(specs), num, max_runtime, solver_epsilon, +1);
}
template <
typename funct
>
std::pair<size_t,function_evaluation> find_min_global (
thread_pool& tp,
std::vector<funct>& functions,
std::vector<function_spec> specs,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return impl::find_max_global(tp, functions, std::move(specs), num, max_runtime, solver_epsilon, -1);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -255,6 +311,44 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(functions, std::move(specs), num, max_runtime, solver_epsilon).second;
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
std::vector<funct> functions(1,std::move(f));
std::vector<function_spec> specs(1, function_spec(bound1, bound2, is_integer_variable));
return find_max_global(tp, functions, std::move(specs), num, max_runtime, solver_epsilon).second;
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
std::vector<funct> functions(1,std::move(f));
std::vector<function_spec> specs(1, function_spec(bound1, bound2, is_integer_variable));
return find_min_global(tp, functions, std::move(specs), num, max_runtime, solver_epsilon).second;
}
// ----------------------------------------------------------------------------------------
template <
......@@ -287,6 +381,38 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, is_integer_variable, num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), bound1, bound2, is_integer_variable, num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), bound1, bound2, is_integer_variable, num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -319,6 +445,38 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -349,6 +507,36 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -381,6 +569,38 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -411,6 +631,36 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -441,6 +691,36 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -471,6 +751,36 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -503,6 +813,38 @@ template <typename T> static auto go(T&& f, const matrix<double, 0, 1>& a) -> de
return find_min_global(std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
}
......
......@@ -7,6 +7,7 @@
#include "global_function_search_abstract.h"
#include "../metaprogramming.h"
#include "../matrix.h"
#include "../threads/thread_pool_extension_abstract.h"
#include <utility>
#include <chrono>
......@@ -74,6 +75,7 @@ namespace dlib
typename funct
>
std::pair<size_t,function_evaluation> find_max_global (
thread_pool& tp,
std::vector<funct>& functions,
const std::vector<function_spec>& specs,
const max_function_calls num,
......@@ -96,6 +98,9 @@ namespace dlib
etc.
- The range of inputs defined by specs[i] must be valid inputs to
functions[i].
- if (tp.num_threads_in_pool() != 0) then
- it must be safe to call the given functions concurrently from multiple
threads.
ensures
- This function performs global optimization on the set of given functions.
The goal is to maximize the following objective function:
......@@ -134,6 +139,25 @@ namespace dlib
being optimized. Therefore, this transformation is invisible to the user
supplied functions. In most cases, it improves the efficiency of the
optimizer.
- if (tp.num_threads_in_pool() != 0) then
- This function will make concurrent calls to the given functions. In
particular, it will submit the calls to the functions as jobs to the
given thread_pool tp.
!*/
template <
typename funct
>
std::pair<size_t,function_evaluation> find_max_global (
std::vector<funct>& functions,
const std::vector<function_spec>& specs,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
);
/*!
this function is identical to the find_max_global() defined immediately above,
except that no threading is used.
!*/
template <
......@@ -151,12 +175,31 @@ namespace dlib
except that we perform minimization rather than maximization.
!*/
template <
typename funct
>
std::pair<size_t,function_evaluation> find_min_global (
thread_pool& tp,
std::vector<funct>& functions,
const std::vector<function_spec>& specs,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
);
/*!
This function is identical to the find_max_global() defined immediately above,
except that we perform minimization rather than maximization. We also allow you to
give a thread_pool so we can make concurrent calls to the given functions during
optimization.
!*/
// ----------------------------------------------------------------------------------------
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
......@@ -179,6 +222,9 @@ namespace dlib
etc.
- The range of inputs defined by function_spec(bound1,bound2,is_integer_variable)
must be valid inputs to f().
- if (tp.num_threads_in_pool() != 0) then
- it must be safe to call the given function f() concurrently from multiple
threads.
ensures
- This function performs global optimization on the given f() function.
The goal is to maximize the following objective function:
......@@ -217,12 +263,17 @@ namespace dlib
being optimized. Therefore, this transformation is invisible to the user
supplied functions. In most cases, it improves the efficiency of the
optimizer.
- if (tp.num_threads_in_pool() != 0) then
- This function will make concurrent calls to the given function f(). In
particular, it will submit the calls to f() as jobs to the given
thread_pool tp.
!*/
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
......@@ -236,6 +287,42 @@ namespace dlib
except that we perform minimization rather than maximization.
!*/
template <
typename funct
>
function_evaluation find_max_global (
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
);
/*!
This function is identical to the find_max_global() defined immediately above,
except that we don't take a thread_pool and therefore don't make concurrent calls
to f().
!*/
template <
typename funct
>
function_evaluation find_min_global (
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
);
/*!
This function is identical to the find_min_global() defined immediately above,
except that we don't take a thread_pool and therefore don't make concurrent calls
to f().
!*/
// ----------------------------------------------------------------------------------------
// The following functions are just convenient overloads for calling the above defined
// find_max_global() and find_min_global() routines.
......@@ -271,6 +358,38 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -303,6 +422,38 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -333,6 +484,36 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), bound1, bound2, std::vector<bool>(bound1.size(),false), num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -365,6 +546,38 @@ namespace dlib
return find_min_global(std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
const std::chrono::nanoseconds max_runtime = FOREVER,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -395,6 +608,36 @@ namespace dlib
return find_min_global(std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_max_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const max_function_calls num,
double solver_epsilon
)
{
return find_min_global(tp, std::move(f), matrix<double,0,1>({bound1}), matrix<double,0,1>({bound2}), num, FOREVER, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -425,6 +668,36 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -455,6 +728,36 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const double bound1,
const double bound2,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -487,6 +790,38 @@ namespace dlib
return find_min_global(std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_max_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_max_global(tp, std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
template <
typename funct
>
function_evaluation find_min_global (
thread_pool& tp,
funct f,
const matrix<double,0,1>& bound1,
const matrix<double,0,1>& bound2,
const std::vector<bool>& is_integer_variable,
const std::chrono::nanoseconds max_runtime,
double solver_epsilon = 0
)
{
return find_min_global(tp, std::move(f), bound1, bound2, is_integer_variable, max_function_calls(), max_runtime, solver_epsilon);
}
// ----------------------------------------------------------------------------------------
}
......
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