The Doctor Rostering Problem - Asser Fahrenholz
The Doctor Rostering Problem - Asser Fahrenholz
The Doctor Rostering Problem - Asser Fahrenholz
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Appendix A. Implementation 61<br />
16 setRotationInt ( rotationInt );<br />
17 setN ( maxRotation );<br />
18 }<br />
19<br />
20 public Change nextChange ( Schedule s) {<br />
21<br />
22 Change c = new Change ();<br />
23<br />
24 LinkedHashSet < Shift > list = new LinkedHashSet < Shift >() ;<br />
25<br />
26 // find shifts to swap around<br />
27 // Random up to N and only N - size<br />
28 Day randDay ;<br />
29 Shift randShift ;<br />
30 int randomSize ;<br />
31 if ( getRotationInt (). compareTo ( RotationInt . RandomUpToN ) == 0) {<br />
32 randomSize = ( int ) ( Math . random () * getN ());<br />
33 } else {<br />
34 randomSize = getN ();<br />
35 }<br />
36 while ( list . size () < randomSize ) {<br />
37 randDay = s. get (( int ) Math . floor ( Math . random () * s. size ()));<br />
38 randShift = randDay . getShift (( int ) Math . floor ( Math . random () * randDay<br />
. size ()));<br />
39 if ( randShift . isMiddayShift () && ! randDay . isWeekend () && randShift .<br />
isSet () && ! randDay . isHoliday ()) {<br />
40 list . add ( randShift );<br />
41 }<br />
42 }<br />
43<br />
44 // rotate doctors<br />
45 Object [] al = list . toArray ();<br />
46<br />
47 for ( int i = 0; i < al. length ; i ++) {<br />
48 Shift shi = ( Shift ) al[i];<br />
49 // Shift is the first element : Doc should be moved to the shift of<br />
50 // the last element<br />
51 if ( shi == al[al. length - 1]) {<br />
52 <strong>Doctor</strong> d = (( Shift ) al [0]) . get<strong>Doctor</strong> ();<br />
53 c. put (shi , d);<br />
54 } else {<br />
55 <strong>Doctor</strong> d = (( Shift ) al[i + 1]) . get<strong>Doctor</strong> ();<br />
56 c. put (shi , d);<br />
57 }<br />
58 }<br />
59 return c;<br />
60 }<br />
61 }<br />
A.2 Construction heuristic<br />
1 package heuristic . construction ;