The Doctor Rostering Problem - Asser Fahrenholz
The Doctor Rostering Problem - Asser Fahrenholz
The Doctor Rostering Problem - Asser Fahrenholz
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Appendix A. Implementation 60<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 () && ! randDay .<br />
isHoliday ()) {<br />
40 list . add ( randShift );<br />
41 }<br />
42 }<br />
43<br />
44 // invert doctors ( meaning , that particular doctor will not have that<br />
45 // shift afterwards )<br />
46 Object [] al = list . toArray ();<br />
47<br />
48 for ( int i = 0; i < al. length ; i ++) {<br />
49 Shift shi = ( Shift ) al[i];<br />
50 // pick any other doctor for the shift :<br />
51 <strong>Doctor</strong> d = s. getRandomDoc ();<br />
52 while (d. equals ( shi . get<strong>Doctor</strong> ())) {<br />
53 d = s. getRandomDoc ();<br />
54 }<br />
55 c. put (shi , d);<br />
56 }<br />
57 return c;<br />
58 }<br />
59 }<br />
A.1.2 Rotation neighborhood<br />
1 package changes ;<br />
2<br />
3 import java . util . LinkedHashSet ;<br />
4<br />
5 import ds.Day ;<br />
6 import ds. <strong>Doctor</strong> ;<br />
7 import ds. Schedule ;<br />
8 import ds. Shift ;<br />
9<br />
10 public class N_rotation extends Change {<br />
11<br />
12 private static final long serialVersionUID = -2600577434569838673 L;<br />
13<br />
14 public N_rotation ( int maxRotation , RotationInt rotationInt ) {<br />
15 setChangeType ( ChangeType . nRotation );