52 placement.updateCostFull(
false);
53 int currentCost = placement.getCost();
54 int newCost = 9999999;
58 int zeroCostMoves = 0;
60 int bestCost = 999999;
63 double acceptrate = 0;
66 boost::timer epochTimer;
67 boost::timer totalTimer;
82 std::cout <<
"currentCost for epoch: " << currentCost;
85 if (!placement.randomMove(
false)) {
90 newCost = placement.getCost();
91 if (newCost < bestCost) {
95 if (currentCost < newCost) {
98 double irand = (double)rand() / (double)(std::numeric_limits<int>::max());
99 if (irand >= exp(((
double)currentCost - (
double)newCost) / temperature)) {
101 placement.undoMove(
false);
105 currentCost = newCost;
108 }
else if (currentCost == newCost) {
112 currentCost = newCost;
116 double epochTime = epochTimer.elapsed();
118 acceptrate = (double)acceptedBad / ((
double)acceptedBad + (double)movesUndone);
121 double tempadjust = 0;
122 if (acceptrate > 0.96) {
123 temperature = 0.5 * temperature;
124 tempadjust = (double)0.5;
125 }
else if (acceptrate <= 0.96 && acceptrate > 0.8) {
126 temperature = 0.9 * temperature;
127 tempadjust = (double)0.9;
128 }
else if (acceptrate <= 0.8 && acceptrate > 0.15) {
129 temperature = 0.95 * temperature;
130 tempadjust = (double)0.95;
132 temperature = 0.8 * temperature;
133 tempadjust = (double)0.8;
138 if (goodMoves == 0) {
143 if (doneCount == 10) {
148 std::cout <<
" Good moves: " << goodMoves;
149 std::cout <<
" Accepted bad: " << acceptedBad;
150 std::cout <<
" Undone: " << movesUndone;
151 std::cout <<
" ZeroCostMoves: " << zeroCostMoves;
152 std::cout <<
" Best Cost: " << bestCost;
153 std::cout <<
" Attemped Illegal Moves: " << illegalMoves;
154 std::cout <<
" Acceptance rate: " << acceptrate;
155 std::cout <<
" new temp: " << temperature;
156 std::cout <<
" tempadjust: " << tempadjust;
158 std::cout <<
" time: " << epochTime;
160 std::cout << std::endl;
163 std::cout <<
"Total time: " << totalTimer.elapsed();
164 std::cout << std::endl;
172 placement.updateCostFull(
false);
173 std::cout <<
"Actual end cost: " << placement.getCost() << std::endl;
uint32 mMovesPerTemperature
PlacerHeuristicBase & mHeuristic
uint32 getMovesPerTemperature()
uint32 getInitialTemperature()