All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
scheduling_jobs_with_deadlines_on_a_single_machine_example.cpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2013 Piotr Smulewicz
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
16 
19 #include "paal/utils/irange.hpp"
20 
21 #include <iostream>
22 #include <utility>
23 
24 int main() {
25  // sample data
26  typedef double Time;
27  std::vector<Time> time = { 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1 };
28  std::vector<Time> release = { 1, 2, 3, 4, 5, 6, 7 };
29  std::vector<Time> due_date = { -1, 0, -2, -3, -4, -5, -6 };
30 
31  auto jobs = paal::irange(time.size());
32 
33  std::vector<std::pair<decltype(jobs)::iterator, Time>> jobs_to_start_dates;
34 
35  Time delay =
37  jobs.begin(), jobs.end(), [&](int i) { return time[i]; },
38  [&](int i) { return release[i]; },
39  [&](int i) { return due_date[i]; },
40  back_inserter(jobs_to_start_dates));
41  for (auto job_start_time : jobs_to_start_dates) {
42  std::cout << "Job " << (*job_start_time.first)
43  << " Start time: " << job_start_time.second << std::endl;
44  }
45  // print result
46  std::cout << "Solution: " << delay << std::endl;
47  return 0;
48 }
int main()
[Scheduling Jobs On Single Machine Example]
auto irange(T begin, T end)
irange
Definition: irange.hpp:22
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]