From 51266eb2769f08fa9c4dd4a55bd97247ba3a2e2e Mon Sep 17 00:00:00 2001 From: Markus Klinik Date: Fri, 24 May 2019 16:32:16 +0200 Subject: [PATCH] schedule builder --- greedy-fails.pdf | 293 +++++++++++++++++++++++++++++++++++++++++++ greedy-fails.pdf_tex | 73 +++++++++++ greedy-fails.svg | 4 + implementation.tex | 47 ++++++- 4 files changed, 414 insertions(+), 3 deletions(-) create mode 100644 greedy-fails.pdf create mode 100644 greedy-fails.pdf_tex create mode 100644 greedy-fails.svg diff --git a/greedy-fails.pdf b/greedy-fails.pdf new file mode 100644 index 0000000..5fe36a9 --- /dev/null +++ b/greedy-fails.pdf @@ -0,0 +1,293 @@ +%PDF-1.4 +% +4 0 obj +<< /Length 5 0 R + /Filter /FlateDecode +>> +stream +xEM +P MϬ.ҡ":C` 9E!1 0gO^7 /-$ܠl~h|DX H1jA2A -zi08 +endstream +endobj +5 0 obj + 119 +endobj +3 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +2 0 obj +<< /Type /Page % 1 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 4 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 3 0 R +>> +endobj +8 0 obj +<< /Length 9 0 R + /Filter /FlateDecode +>> +stream +x% +` <ŽiC]CQ)C_P wQHAS<8J񡅄/^[^n_~;Cٱe>&,xSz4VP  J +endstream +endobj +9 0 obj + 122 +endobj +7 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +6 0 obj +<< /Type /Page % 2 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 8 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 7 0 R +>> +endobj +12 0 obj +<< /Length 13 0 R + /Filter /FlateDecode +>> +stream +x% +` <Ž1I?KAp8JAph|}C布N!VxrzM G-hnu&?$> + >> +>> +endobj +10 0 obj +<< /Type /Page % 3 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 12 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 11 0 R +>> +endobj +16 0 obj +<< /Length 17 0 R + /Filter /FlateDecode +>> +stream +xuA +P D9\i۟ե( +Eoh; 30s`X91(6Za)$1A+2c@?i*FܑNW" +endstream +endobj +17 0 obj + 120 +endobj +15 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +14 0 obj +<< /Type /Page % 4 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 16 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 15 0 R +>> +endobj +20 0 obj +<< /Length 21 0 R + /Filter /FlateDecode +>> +stream +x=K9 +@㌻AX-BB,r)ĐI8d*$oH'zrƸ0BXG?:Ϫ%T;}aGH +endstream +endobj +21 0 obj + 103 +endobj +19 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +18 0 obj +<< /Type /Page % 5 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 20 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 19 0 R +>> +endobj +24 0 obj +<< /Length 25 0 R + /Filter /FlateDecode +>> +stream +x=K +@`S X>J9(QJm?8"uɌ-,1tMW!EnOkFaB)w1V-il;zZ +endstream +endobj +25 0 obj + 102 +endobj +23 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +22 0 obj +<< /Type /Page % 6 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 24 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 23 0 R +>> +endobj +28 0 obj +<< /Length 29 0 R + /Filter /FlateDecode +>> +stream +x=K +@Pܟp^JY`) QJ,d(M35/5#,!`>$yB: ֋sܖƍ‚<wY +{/9:RK +endstream +endobj +29 0 obj + 103 +endobj +27 0 obj +<< + /ExtGState << + /a0 << /CA 1 /ca 1 >> + >> +>> +endobj +26 0 obj +<< /Type /Page % 7 + /Parent 1 0 R + /MediaBox [ 0 0 292.725586 59.929688 ] + /Contents 28 0 R + /Group << + /Type /Group + /S /Transparency + /I true + /CS /DeviceRGB + >> + /Resources 27 0 R +>> +endobj +1 0 obj +<< /Type /Pages + /Kids [ 2 0 R 6 0 R 10 0 R 14 0 R 18 0 R 22 0 R 26 0 R ] + /Count 7 +>> +endobj +30 0 obj +<< /Producer (cairo 1.16.0 (https://cairographics.org)) + /CreationDate (D:20190524162434+02'00) +>> +endobj +31 0 obj +<< /Type /Catalog + /Pages 1 0 R +>> +endobj +xref +0 32 +0000000000 65535 f +0000003654 00000 n +0000000305 00000 n +0000000233 00000 n +0000000015 00000 n +0000000211 00000 n +0000000829 00000 n +0000000757 00000 n +0000000536 00000 n +0000000735 00000 n +0000001356 00000 n +0000001283 00000 n +0000001060 00000 n +0000001260 00000 n +0000001885 00000 n +0000001812 00000 n +0000001590 00000 n +0000001789 00000 n +0000002397 00000 n +0000002324 00000 n +0000002119 00000 n +0000002301 00000 n +0000002908 00000 n +0000002835 00000 n +0000002631 00000 n +0000002812 00000 n +0000003420 00000 n +0000003347 00000 n +0000003142 00000 n +0000003324 00000 n +0000003760 00000 n +0000003877 00000 n +trailer +<< /Size 32 + /Root 31 0 R + /Info 30 0 R +>> +startxref +3930 +%%EOF diff --git a/greedy-fails.pdf_tex b/greedy-fails.pdf_tex new file mode 100644 index 0000000..819da0d --- /dev/null +++ b/greedy-fails.pdf_tex @@ -0,0 +1,73 @@ +%% Creator: Inkscape inkscape 0.92.4, www.inkscape.org +%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 +%% Accompanies image file 'greedy-fails.pdf' (pdf, eps, ps) +%% +%% To include the image in your LaTeX document, write +%% \input{.pdf_tex} +%% instead of +%% \includegraphics{.pdf} +%% To scale the image, write +%% \def\svgwidth{} +%% \input{.pdf_tex} +%% instead of +%% \includegraphics[width=]{.pdf} +%% +%% Images with a different path to the parent latex file can +%% be accessed with the `import' package (which may need to be +%% installed) using +%% \usepackage{import} +%% in the preamble, and then including the image with +%% \import{}{.pdf_tex} +%% Alternatively, one can specify +%% \graphicspath{{/}} +%% +%% For more information, please see info/svg-inkscape on CTAN: +%% http://tug.ctan.org/tex-archive/info/svg-inkscape +%% +\begingroup% + \makeatletter% + \providecommand\color[2][]{% + \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% + \renewcommand\color[2][]{}% + }% + \providecommand\transparent[1]{% + \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% + \renewcommand\transparent[1]{}% + }% + \providecommand\rotatebox[2]{#2}% + \newcommand*\fsize{\dimexpr\f@size pt\relax}% + \newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}% + \ifx\svgwidth\undefined% + \setlength{\unitlength}{292.72558594bp}% + \ifx\svgscale\undefined% + \relax% + \else% + \setlength{\unitlength}{\unitlength * \real{\svgscale}}% + \fi% + \else% + \setlength{\unitlength}{\svgwidth}% + \fi% + \global\let\svgwidth\undefined% + \global\let\svgscale\undefined% + \makeatother% + \begin{picture}(1,0.20472993)% + \lineheight{1}% + \setlength\tabcolsep{0pt}% + \put(-0.0030175,0.08198805){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Resource A\end{tabular}}}}% + \put(-0.0030175,0.01793489){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Resource B\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=1]{greedy-fails.pdf}}% + \put(0.21476325,0.08198805){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Task 1 (capA)\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=2]{greedy-fails.pdf}}% + \put(0.47097591,0.01793489){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Task 2 (capB)\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=3]{greedy-fails.pdf}}% + \put(0.72718857,0.01793489){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}Task 3 (capB)\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=4]{greedy-fails.pdf}}% + \put(0.19426624,0.18191099){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}0\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=5]{greedy-fails.pdf}}% + \put(0.4504789,0.18191099){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}10\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=6]{greedy-fails.pdf}}% + \put(0.70669155,0.18191099){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}20\end{tabular}}}}% + \put(0,0){\includegraphics[width=\unitlength,page=7]{greedy-fails.pdf}}% + \put(0.96290421,0.18191099){\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}30\end{tabular}}}}% + \end{picture}% +\endgroup% diff --git a/greedy-fails.svg b/greedy-fails.svg new file mode 100644 index 0000000..02b16d3 --- /dev/null +++ b/greedy-fails.svg @@ -0,0 +1,4 @@ +Resource AResource BTask 1 +capA=Resource ATask 1 (capA)Task 2 +capB=Resource BTask 2 (capB)Task 3 +capB=Resource BTask 3 (capB)0102030 diff --git a/implementation.tex b/implementation.tex index 3c8cb42..af3f957 100644 --- a/implementation.tex +++ b/implementation.tex @@ -5,7 +5,7 @@ In this section we describe some design decisions of the implementation of our m We have implemented our algorithm in the functional programming language Clean. The source code is available at our university's GitLab.\footnote{\url{https://gitlab.science.ru.nl/mklinik/ga-scheduler}} -The implementation works in two phases. +The scheduler works in two phases. Phase one uses a genetic algorithm to find a set of good assignments for a given instance definition. Phase two uses these assignments to build schedules. @@ -142,8 +142,49 @@ This results in smaller intermediate numbers, which decreases the chance for inf \subsection{Greedy Schedule Building} -Depth-first dependency resolution. -This allows modelling task priorities: first in list gets scheduled first. +Our schedule builder is a modified variant of the one by \citet{MyszkowskiLNS2018}. +Given a valid assignment, it builds a schedule as follows. +\begin{itemize}[noitemsep] +\item It always keeps track of the earliest point in time when each resource is available. + Initially, this is 0 for every resource. +\item For every task in the instance definition, in the order in which they occur, first schedule all predecessor tasks. +\item Then, when a task has no more unscheduled predecessors, find the earliest time where all resources assigned to that task are available. +This becomes the start time of the task. +\item Finally, update the resource availabilities by setting them to the end time of the task. +\item Repeat until all tasks are scheduled. +\end{itemize} + +The difference between our schedule builder and the one by Myszkowski et al.~is that they do not perform depth-first dependency resolution. +In their instance definitions, all predecessors of a task must occur in the instance definition before the task. +Otherwise the generated schedule may violate the ordering constraints. +Our method allows tasks to occur in any order in the instance definition. + +This way of schedule building has some of advantages and disadvantages. + +It is simple to understand and easy to implement. +An advantage is that it allows modelling task priorities. +Tasks earlier earlier in the instance definition get scheduled first. +Another advantage is that the schedules it builds are valid by construction, where no resource is assigned to two tasks that are overlapping in time, and where tasks are always preceded by their predecessors. + +A disadvantage is it does not always find the schedule with the shortest makespan, because it schedules the tasks in the order in which they occur in the instance definition. +It is sometimes possible to find shorter schedules by changing the order of tasks. +Consider the scenario in \cref{fig:greedy-fails}. +There are two resources, A with one capability capA, and B with one capability capB. +There are three tasks 1, 2, and 3, where task 1 requires capA and tasks 2 and 3 require capB. +Furthermore, task 1 is a predecessor of task 2. +There exists only one valid assignment, namely the one shown in \cref{fig:greedy-fails}. +The greedy schedule builder processes tasks in the order in which they occur, so it fails to see that task 3 could be scheduled at time 0. +\begin{figure} + \centering + \def\svgwidth{0.95\linewidth} + \sffamily + \input{greedy-fails.pdf_tex} + \caption{greedy fails} + \label{fig:greedy-fails} +\end{figure} + +Finding the shortest schedule for a given assignment is an optimization problem on its own, which we leave for future work. + \subsection{Quality Functions} -- GitLab