The Doctor Rostering Problem - Asser Fahrenholz

The Doctor Rostering Problem - Asser Fahrenholz The Doctor Rostering Problem - Asser Fahrenholz

asser.fahrenholz.dk
from asser.fahrenholz.dk More from this publisher
27.07.2013 Views

Appendix A. Implementation 63 54 { 55 Day day ; 56 Shift s; 57 Doctor d; 58 for ( int i = 0; i < working . size (); i ++) { 59 60 setProgress (100 * i / working . size ()); 61 oldScore = newScore ; 62 workingSol = working . getSolutionValue ( false , getRules ()); 63 newScore = workingSol . getE (); 64 newVio = workingSol . getV (). getE (). size (); 65 newSoftVio = workingSol . getV (). getV (). size (); 66 firePropertyChange (" score ", oldScore , newScore ); 67 firePropertyChange (" violations ", null , newVio ); 68 firePropertyChange (" violationsSoft ", null , newSoftVio ); 69 day = working . getDay (i); 70 if (!( day . isWeekend () || day . isHoliday ())) { 71 72 if ( getDoS (). compareTo ( DayOrShift . Day ) == 0) { 73 Change c = working . getBestChange ( day . getDayID () , RCLsize , minimize , getRules ()); 74 working . performChange (c, false ); 75 continue ; 76 } 77 78 Shift : 79 for ( int j = 0; j < day . size (); j ++) { 80 s = day . getShift (j); 81 82 if (s. isMiddayShift ()) { 83 d = working . getBestDoctor (day , s, RCLsize , minimize , getRules ()); 84 working . assignDoctor2Shift (day , d, s. getShiftInt () , false ); 85 } 86 } 87 } 88 } 89 } 90 working . setConstructorID ( this . hashCode ()); 91 working . setRCL ( RCLsize ); 92 working . setDoS ( dos ); 93 94 setBestSchedule ( working ); 95 96 } catch ( Exception e) { 97 System . out . println (" Caught e: " + e. getCause ()); 98 e. printStackTrace (); 99 } 100 return null ; 101 } 102 }

Appendix A. Implementation 64 A.3 GRASP metaheuristic 1 package heuristic . meta ; 2 3 import basic . RCLParameter ; 4 import basic . Rules ; 5 import changes . Change ; 6 import changes . RotationInt ; 7 import ds.Day ; 8 import ds. Doctor ; 9 import ds. Pair ; 10 import ds. Schedule ; 11 import ds. Shift ; 12 import heuristic . Metaheuristic ; 13 import java . util . HashMap ; 14 import java . util . HashSet ; 15 import org . jfree . data .xy. XYDataItem ; 16 import org . jfree . data .xy. XYSeries ; 17 import org . jfree . data .xy. XYSeriesCollection ; 18 19 /* * 20 * A GRASP ( Greedy Randomised Adaptive Search Procedure ) class 21 * @author Asser Fahrenholz 22 * 23 */ 24 public class GRASP extends Metaheuristic { 25 26 private final RCLParameter RCLsize ; 27 private int localLoopCounter ; 28 private int counter = 0; 29 private boolean minimize ; 30 31 public GRASP ( double timeToRun , int maxRotation , Rules myRules , RotationInt rotationInt , RCLParameter RCLsize , Schedule s, Type t, int rounds , boolean diagram , DayOrShift dos , boolean minimize ) { 32 super ( timeToRun , maxRotation , myRules , rotationInt , s, t, rounds , RCLsize , dos ); 33 this . RCLsize = RCLsize ; 34 this . minimize = minimize ; 35 } 36 37 public RCLParameter getRCL () { 38 return this . RCLsize ; 39 } 40 41 @Override 42 public Void doInBackground () throws Exception { 43 XYDataItem point4 ; 44 XYDataItem point3 ; 45 XYDataItem point ; 46 XYDataItem point2 ; 47 try { 48 seriesCol = new XYSeriesCollection (); 49 series = new XYSeries (" Best vio "); 50 series2 = new XYSeries (" Best score ");

Appendix A. Implementation 64<br />

A.3 GRASP metaheuristic<br />

1 package heuristic . meta ;<br />

2<br />

3 import basic . RCLParameter ;<br />

4 import basic . Rules ;<br />

5 import changes . Change ;<br />

6 import changes . RotationInt ;<br />

7 import ds.Day ;<br />

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

9 import ds. Pair ;<br />

10 import ds. Schedule ;<br />

11 import ds. Shift ;<br />

12 import heuristic . Metaheuristic ;<br />

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

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

15 import org . jfree . data .xy. XYDataItem ;<br />

16 import org . jfree . data .xy. XYSeries ;<br />

17 import org . jfree . data .xy. XYSeriesCollection ;<br />

18<br />

19 /* *<br />

20 * A GRASP ( Greedy Randomised Adaptive Search Procedure ) class<br />

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

22 *<br />

23 */<br />

24 public class GRASP extends Metaheuristic {<br />

25<br />

26 private final RCLParameter RCLsize ;<br />

27 private int localLoopCounter ;<br />

28 private int counter = 0;<br />

29 private boolean minimize ;<br />

30<br />

31 public GRASP ( double timeToRun , int maxRotation , Rules myRules , RotationInt<br />

rotationInt , RCLParameter RCLsize , Schedule s, Type t, int rounds , boolean<br />

diagram , DayOrShift dos , boolean minimize ) {<br />

32 super ( timeToRun , maxRotation , myRules , rotationInt , s, t, rounds , RCLsize<br />

, dos );<br />

33 this . RCLsize = RCLsize ;<br />

34 this . minimize = minimize ;<br />

35 }<br />

36<br />

37 public RCLParameter getRCL () {<br />

38 return this . RCLsize ;<br />

39 }<br />

40<br />

41 @Override<br />

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

43 XYDataItem point4 ;<br />

44 XYDataItem point3 ;<br />

45 XYDataItem point ;<br />

46 XYDataItem point2 ;<br />

47 try {<br />

48 seriesCol = new XYSeriesCollection ();<br />

49 series = new XYSeries (" Best vio ");<br />

50 series2 = new XYSeries (" Best score ");

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

Saved successfully!

Ooh no, something went wrong!