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.

Appendix A. Implementation 68<br />

27 super ( timeToRun , maxRotation , myRules , rotationInt , s, t, rounds );<br />

28 this . minimize = minimize ;<br />

29 this . temp = 1000;<br />

30 this . temp_end = 0.001;<br />

31 }<br />

32<br />

33 @Override<br />

34 public Void doInBackground () {<br />

35 XYDataItem point ;<br />

36 XYDataItem point2 ;<br />

37 XYDataItem point3 ;<br />

38 XYDataItem point4 ;<br />

39 try {<br />

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

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

42 series2 = new XYSeries (" Best score ");<br />

43 series3 = new XYSeries (" Working vio ");<br />

44 series4 = new XYSeries (" Working score ");<br />

45 tempSeries = new XYSeries (" Temperature ");<br />

46 seriesCol . addSeries ( series );<br />

47 seriesCol . addSeries ( series2 );<br />

48 seriesCol . addSeries ( series3 );<br />

49 seriesCol . addSeries ( series4 );<br />

50 startTime = System . currentTimeMillis ();<br />

51 int newLocalScore = 0;<br />

52 int oldScore ;<br />

53 boolean test = ( super . type . compareTo ( Type . Rounds ) == 0) ? (<br />

54<br />

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

getTimeToRun ();<br />

55 int progress = ( super . type . compareTo ( Type . Rounds ) == 0) ? (100 *<br />

loopCounter / maxRounds ) : ( int ) (100 * ( System . currentTimeMillis () -<br />

startTime ) / getTimeToRun ());<br />

56 setProgress ( progress );<br />

57 while ( test && temp > temp_end ) {<br />

58 oldScore = newLocalScore ;<br />

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

nextChange ( working );<br />

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

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

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

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

62 newLocalScore = workingSol . getE ();<br />

63 newLocalVio = workingSol . getV (). getE (). size ();<br />

64 double solutionValue_increase = newLocalScore - oldScore ;<br />

65 double rand = Math . random ();<br />

66<br />

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

68 setBestSchedule ( working );<br />

69 localImprovements ++;<br />

70 acceptedSolutions ++;<br />

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

72 if (( solutionValue_increase > 0 && ! minimize ) || (<br />

solutionValue_increase < 0 && minimize )) {

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

Saved successfully!

Ooh no, something went wrong!