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 69 73 if (( newLocalScore > bestScore && ! minimize ) || ( newLocalScore < bestScore && minimize )) { 74 setBestSchedule ( working ); 75 localImprovements ++; 76 acceptedSolutions ++; 77 } 78 } else { 79 if ( rand < ( Math . exp (( solutionValue_increase ) / temp ))) { 80 acceptedSolutions ++; 81 } else { 82 working . performChange (c, true ); 83 rejectedSolutions ++; 84 } 85 } 86 } else { 87 rejectedSolutions ++; 88 working . performChange (c, true ); 89 } 90 progress = ( super . type . compareTo ( Type . Rounds ) == 0) ? (100 * loopCounter / maxRounds ) : ( int ) (100 * ( System . currentTimeMillis () - startTime ) / getTimeToRun ()); 91 setProgress ( progress ); 92 firePropertyChange (" score ", null , bestScore ); 93 firePropertyChange (" violations ", null , bestVio ); 94 test = ( super . type . compareTo ( Type . Rounds ) == 0) ? ( loopCounter < maxRounds ) : ( System . currentTimeMillis () - startTime ) < getTimeToRun (); 95 temp = alpha * temp ; 96 point = new XYDataItem ( super . type . compareTo ( Type . Rounds ) == 0 ? loopCounter : ( System . currentTimeMillis () - startTime ), bestVio ); 97 point2 = new XYDataItem ( super . type . compareTo ( Type . Rounds ) == 0 ? loopCounter : ( System . currentTimeMillis () - startTime ), bestScore ); 98 point3 = new XYDataItem ( super . type . compareTo ( Type . Rounds ) == 0 ? loopCounter : ( System . currentTimeMillis () - startTime ), newLocalVio ); 99 point4 = new XYDataItem ( super . type . compareTo ( Type . Rounds ) == 0 ? loopCounter : ( System . currentTimeMillis () - startTime ), newLocalScore ); 100 tempPoint = new XYDataItem ( loopCounter ++ , temp ); 101 series . add ( point ); 102 series2 . add ( point2 ); 103 series3 . add ( point3 ); 104 series4 . add ( point4 ); 105 tempSeries . add ( tempPoint ); 106 } 107 printSAStatsToConsole (); 108 printMetaStatsToConsole (); 109 getBestSchedule (). setOptimizer ( this ); 110 111 } catch ( Exception e) { 112 System . out . println (" Caught exception : " + e. getCause ()); 113 e. printStackTrace (); 114 } 115 return null ; 116 } 117 118 public void printSAStatsToConsole () {

Appendix A. Implementation 70 119 Pair < Integer , Pair < HashMap < Shift , HashSet >>, HashMap < Shift , HashSet >>>> workingSol = working . getSolutionValue ( false , null ); 120 System . out . println (" -------------- SA STATS : --------------"); 121 System . out . println (" Alpha : " + alpha ); 122 System . out . println (" Working value : " + workingSol . getE ()); 123 System . out . println (" Violations : " + workingSol . getV (). getE (). size ()); 124 System . out . println (" Initial value : " + initialScore ); 125 System . out . println (" Stopped due to: " + (( System . currentTimeMillis () - startTime ) > getTimeToRun () ? " Running time " 126 : ( loopCounter > maxRounds ? " Loops " : ( temp < temp_end ? " Temperature " 127 : " Not running time , temp nor rounds ")))); 128 System . out . println (" -------------- --------------"); 129 } 130 131 @Override 132 public void exceptionThrown ( Exception e) { 133 System . out . println (" Exception was caught .. I think ... Here it is:" + e. getCause ()); 134 e. printStackTrace (); 135 } 136 137 public XYSeries getTempSeries () { 138 return tempSeries ; 139 } 140 } A.5 Choosing the assignment A.5.1 Shift assignments 1 /* * 2 * Returns the best doctor for a given shift on a given day . 3 * 4 * @param day 5 * the day 6 * @param RCLsize 7 * the size of the RCL 8 * @param shift 9 * the shift 10 * @return The best doctor for the shift 11 */ 12 public Doctor getBestDoctor ( 13 Day day , Shift shift , RCLParameter RCLsize , boolean minimize , Rules 14 rules ) { 15 if ( rules != null ) { 16 this . myRules = rules ; 17 } 18

Appendix A. Implementation 70<br />

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

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

getSolutionValue ( false , null );<br />

120 System . out . println (" -------------- SA STATS : --------------");<br />

121 System . out . println (" Alpha : " + alpha );<br />

122 System . out . println (" Working value : " + workingSol . getE ());<br />

123 System . out . println (" Violations : " + workingSol . getV (). getE (). size ());<br />

124 System . out . println (" Initial value : " + initialScore );<br />

125 System . out . println (" Stopped due to: " + (( System . currentTimeMillis () -<br />

startTime ) > getTimeToRun () ? " Running time "<br />

126 : ( loopCounter > maxRounds ? " Loops " : ( temp < temp_end ? "<br />

Temperature "<br />

127 : " Not running time , temp nor rounds "))));<br />

128 System . out . println (" -------------- --------------");<br />

129 }<br />

130<br />

131 @Override<br />

132 public void exceptionThrown ( Exception e) {<br />

133 System . out . println (" Exception was caught .. I think ... Here it is:" + e.<br />

getCause ());<br />

134 e. printStackTrace ();<br />

135 }<br />

136<br />

137 public XYSeries getTempSeries () {<br />

138 return tempSeries ;<br />

139 }<br />

140 }<br />

A.5 Choosing the assignment<br />

A.5.1 Shift assignments<br />

1 /* *<br />

2 * Returns the best doctor for a given shift on a given day .<br />

3 *<br />

4 * @param day<br />

5 * the day<br />

6 * @param RCLsize<br />

7 * the size of the RCL<br />

8 * @param shift<br />

9 * the shift<br />

10 * @return <strong>The</strong> best doctor for the shift<br />

11 */<br />

12 public <strong>Doctor</strong> getBest<strong>Doctor</strong> (<br />

13 Day day , Shift shift , RCLParameter RCLsize , boolean minimize , Rules<br />

14<br />

rules ) {<br />

15 if ( rules != null ) {<br />

16 this . myRules = rules ;<br />

17 }<br />

18

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

Saved successfully!

Ooh no, something went wrong!