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

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 66<br />

97 while ( test2 ) {<br />

98 c = Math . random () * 1 > 0.5 ? n_rot . nextChange ( working ) :<br />

n_inv . nextChange ( working );<br />

99 working . performChange (c, false );<br />

100 Pair < Integer , Pair < HashMap < Shift , HashSet >>, HashMap < Shift , HashSet >>>> sol = working .<br />

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

101 newLocalScore = sol . getE ();<br />

102 newLocalVio = sol . getV (). getE (). size ();<br />

103 if ( newLocalVio < bestVio ) {<br />

104 setBestSchedule ( working );<br />

105 localImprovements ++;<br />

106 acceptedSolutions ++;<br />

107 } else if ( newLocalVio == bestVio ) {<br />

108 if (( newLocalScore > bestScore && ! minimize ) || (<br />

newLocalScore < bestScore && minimize )) {<br />

109 setBestSchedule ( working );<br />

110 localImprovements ++;<br />

111 acceptedSolutions ++;<br />

112 } else {<br />

113 working . performChange (c, true );<br />

114 rejectedSolutions ++;<br />

115 }<br />

116 } else {<br />

117 working . performChange (c, true );<br />

118 rejectedSolutions ++;<br />

119 }<br />

120 test2 = ( super . type . compareTo ( Type . Rounds ) == 0) ? (<br />

localLoopCounter ++ < maxLocalLoops ) : ( System . currentTimeMillis () -<br />

startTimeLocal ) < timeToRunLocal ;<br />

121 point = new XYDataItem ( super . type . compareTo ( Type . Rounds )<br />

== 0 ? counter : ( System . currentTimeMillis () - startTime ), bestVio );<br />

122 point2 = new XYDataItem ( super . type . compareTo ( Type . Rounds )<br />

== 0 ? counter : ( System . currentTimeMillis () - startTime ), bestScore );<br />

123 point3 = new XYDataItem ( super . type . compareTo ( Type . Rounds )<br />

== 0 ? counter : ( System . currentTimeMillis () - startTime ), newLocalVio );<br />

124 point4 = new XYDataItem ( super . type . compareTo ( Type . Rounds )<br />

== 0 ? counter ++ : ( System . currentTimeMillis () - startTime ), newLocalScore );<br />

125 series . add ( point );<br />

126 series2 . add ( point2 );<br />

127 series3 . add ( point3 );<br />

128 series4 . add ( point4 );<br />

129 }<br />

130 }<br />

131<br />

132 test = ( super . type . compareTo ( Type . Rounds ) == 0) ? ( loopCounter ++<br />

< maxRounds ) : (( System . currentTimeMillis () - startTime ) < getTimeToRun ());<br />

133 firePropertyChange (" score ", null , bestScore );<br />

134 firePropertyChange (" violations ", null , bestVio );<br />

135 }<br />

136<br />

137 printGRASPStatsToConsole ();<br />

138 printMetaStatsToConsole ();<br />

139 } catch ( Exception e) {<br />

140 System . out . println (" Caught exception : " + e. getCause ());

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

Saved successfully!

Ooh no, something went wrong!