27.07.2013 Views

The Doctor Rostering Problem - Asser Fahrenholz

The Doctor Rostering Problem - Asser Fahrenholz

The Doctor Rostering Problem - Asser Fahrenholz

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2<br />

Appendix A. Implementation 62<br />

3 import basic . RCLParameter ;<br />

4 import heuristic . Heuristic ;<br />

5<br />

6 import java . util . Vector ;<br />

7<br />

8 import basic . Rules ;<br />

9 import changes . Change ;<br />

10 import ds.Day ;<br />

11 import ds. <strong>Doctor</strong> ;<br />

12 import ds. Pair ;<br />

13 import ds. Schedule ;<br />

14 import ds. Shift ;<br />

15 import java . util . HashMap ;<br />

16 import java . util . HashSet ;<br />

17<br />

18 /* *<br />

19 * <strong>The</strong> extended version of the greedy approach to assigning the shifts is based<br />

20 * on a relative behaviour . It examines each doctor for each shift and picks the<br />

21 * best doctor . This doctor is based on a score , which again is based on the<br />

22 * rules documented in the report , as well as in Rules <br />

23 *<br />

24 * @author <strong>Asser</strong> <strong>Fahrenholz</strong><br />

25 */<br />

26 public class GreedyExt extends Heuristic {<br />

27<br />

28 public Vector < Shift > unassignedShifts ;<br />

29 private final RCLParameter RCLsize ;<br />

30 private int newScore ;<br />

31 private int oldScore ;<br />

32 private int newVio ;<br />

33 private int newSoftVio ;<br />

34 private boolean minimize ;<br />

35<br />

36 public GreedyExt ( Rules myRules , RCLParameter RCLsize , Schedule s, DayOrShift<br />

dos , boolean minimize ) {<br />

37 super ( myRules , s, RCLsize , dos );<br />

38 this . minimize = minimize ;<br />

39 this . RCLsize = RCLsize ;<br />

40 }<br />

41<br />

42 public RCLParameter getRCL () {<br />

43 return this . RCLsize ;<br />

44 }<br />

45<br />

46 @Override<br />

47 public Void doInBackground () throws Exception {<br />

48 try {<br />

49 Pair < Integer , Pair < HashMap < Shift , HashSet >>,<br />

HashMap < Shift , HashSet >>>> workingSol = working .<br />

getSolutionValue ( false , getRules ());<br />

50 oldScore = 0;<br />

51<br />

52 newScore = workingSol . getE ();<br />

53 newVio = workingSol . getV (). getE (). size ();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!