Skip to content

Commit d1a7d8f

Browse files
committedMay 21, 2017
PAREngine: fixed annealing so that probability always depends on iteration count rather than saturating at 100% p(accept) when we have >100 iterations allowed
1 parent be7a0da commit d1a7d8f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎src/xbpar/PAREngine.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PAREngine::PAREngine(PARGraph* netlist, PARGraph* device)
2929
: m_netlist(netlist)
3030
, m_device(device)
3131
, m_temperature(0)
32+
, m_maxTemperature(500) //max number of iterations allowed
3233
{
3334

3435
}
@@ -48,7 +49,7 @@ PAREngine::~PAREngine()
4849
bool PAREngine::PlaceAndRoute(map<uint32_t, string> label_names, uint32_t seed)
4950
{
5051
LogVerbose("\nXBPAR initializing...\n");
51-
m_temperature = 250;
52+
m_temperature = m_maxTemperature;
5253

5354
//TODO: glibc rand sucks, replace with something a bit more random
5455
//(this may not make a difference for a device this tiny though)
@@ -346,11 +347,11 @@ bool PAREngine::OptimizePlacement(
346347

347348
//LogVerbose("Original cost %u, new cost %u\n", original_cost, new_cost);
348349

349-
//If new cost is less, or greater with probability temperature, accept it
350+
//If new cost is less, or greater with temperature-dependent probability, accept it
350351
//TODO: make probability depend on dCost?
351352
if(new_cost < original_cost)
352353
return true;
353-
if( (rand() % 100) < (int)m_temperature )
354+
if( (rand() % m_maxTemperature) < m_temperature )
354355
return true;
355356

356357
//If we don't like the change, revert

‎src/xbpar/PAREngine.h

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class PAREngine
7373
void RestorePreviousBestPlacement();
7474

7575
uint32_t m_temperature;
76+
uint32_t m_maxTemperature;
7677
};
7778

7879
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.