19 #ifndef TORC_PLACER_PLACER_HPP
20 #define TORC_PLACER_PLACER_HPP
25 #include <boost/timer.hpp>
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;
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)) {
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;
173 std::cout <<
"Actual end cost: " << placement.
getCost() << std::endl;
180 #endif // TORC_PLACER_PLACER_HPP
Simulated annealing algorithm class.
Device database, including complete wiring and logic support.
Placer(DDB &inDB, PlacerHeuristicBase &inHeuristic)
Header for the Placement class.
Wrapper of the Design for placing the design.
uint32 mMovesPerTemperature
PlacerHeuristicBase & mHeuristic
void updateCostFull(bool debug)
Simulated annealing algorithm class.
uint32 getMovesPerTemperature()
Header for the Placer class.
uint32 getInitialTemperature()
void generatePlacement(Placement &placement)
Header for the DDB class.
void undoMove(bool debug)
bool randomMove(bool debug)