15 #ifndef PAAL_SCHEDULING_JOBS_ON_IDENTICAL_PARALLEL_MACHINES_HPP
16 #define PAAL_SCHEDULING_JOBS_ON_IDENTICAL_PARALLEL_MACHINES_HPP
33 compare(std::vector<int> &load) : m_load(load) {}
34 bool operator()(
int lhs,
int rhs)
const {
35 return m_load[lhs] < m_load[rhs];
39 const std::vector<int> &m_load;
57 template <
class InputIterator,
class OutputIterator,
class GetTime>
61 OutputIterator result,
64 typename std::iterator_traits<InputIterator>::reference;
68 std::vector<int> load(n_machines);
70 std::priority_queue<int, std::vector<int>,
detail::compare> machines(load);
72 for (
auto machine_id :
irange(n_machines)) {
73 machines.push(machine_id);
75 for (
auto job_iter = first; job_iter < last; job_iter++) {
76 int least_loaded_machine = machines.top();
78 load[least_loaded_machine] -= get_time(*job_iter);
79 machines.push(least_loaded_machine);
80 *result = std::make_pair(least_loaded_machine, job_iter);
88 #endif // PAAL_SCHEDULING_JOBS_ON_IDENTICAL_PARALLEL_MACHINES_HPP
void scheduling_jobs_on_identical_parallel_machines(int n_machines, InputIterator first, InputIterator last, OutputIterator result, GetTime get_time)
detail
auto irange(T begin, T end)
irange
This file contains set of simple useful functors or functor adapters.
typename std::decay< typename std::result_of< F >::type >::type pure_result_of_t
return pure type of function (decays const and reference)
double Time
[Scheduling Jobs Example]