15 #ifndef PAAL_SCHEDULING_JOBS_WITH_DEADLINES_ON_A_SINGLE_MACHINE_HPP
16 #define PAAL_SCHEDULING_JOBS_WITH_DEADLINES_ON_A_SINGLE_MACHINE_HPP
22 #include <boost/iterator/counting_iterator.hpp>
23 #include <boost/range/algorithm/sort.hpp>
53 template <
class InputIterator,
class OutputIterator,
class GetTime,
54 class GetDueDate,
class GetReleaseDate>
56 const InputIterator first,
const InputIterator last, GetTime get_time,
57 GetReleaseDate get_release_date, GetDueDate get_due_date,
58 OutputIterator result) {
60 std::vector<InputIterator> jobs;
61 std::copy(boost::make_counting_iterator(first),
62 boost::make_counting_iterator(last), std::back_inserter(jobs));
64 auto get_due_date_from_iterator =
68 using QueueType = std::priority_queue<
69 InputIterator, std::vector<InputIterator>, decltype(due_date_compatator)>;
70 QueueType active_jobs_iters(due_date_compatator);
72 auto get_release_date_from_iterator =
79 auto job_iter = active_jobs_iters.top();
80 active_jobs_iters.pop();
81 Time start_time = std::max(start_idle, get_release_date(*job_iter));
82 start_idle = start_time + get_time(*job_iter);
83 assign_max(longest_delay, start_idle - get_due_date(*job_iter));
84 *result = std::make_pair(job_iter, start_time);
87 for (
auto job_iter : jobs) {
88 while (!active_jobs_iters.empty() &&
89 get_release_date(*job_iter) > start_idle)
91 active_jobs_iters.push(job_iter);
93 while (!active_jobs_iters.empty()) {
103 #endif // PAAL_SCHEDULING_JOBS_WITH_DEADLINES_ON_A_SINGLE_MACHINE_HPP
auto make_functor_to_comparator(Functor functor, Compare compare=Compare())
make for functor to comparator
#define puretype(t)
for given expression returns its type with removed const and reference
This file contains set of simple useful functors or functor adapters.
void assign_max(T &t, const T &u)
auto make_lift_iterator_functor(Functor f)
make function for lift_iterator_functor
auto scheduling_jobs_with_deadlines_on_a_single_machine(const InputIterator first, const InputIterator last, GetTime get_time, GetReleaseDate get_release_date, GetDueDate get_due_date, OutputIterator result)
solve scheduling jobs on identical parallel machines problem and fill start time of all jobs example:...
double Time
[Scheduling Jobs Example]