Skip to content

Commit

Permalink
PAREngine: fixed annealing so that probability always depends on iter…
Browse files Browse the repository at this point in the history
…ation count rather than saturating at 100% p(accept) when we have >100 iterations allowed
azonenberg committed May 21, 2017
1 parent be7a0da commit d1a7d8f
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/xbpar/PAREngine.cpp
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ PAREngine::PAREngine(PARGraph* netlist, PARGraph* device)
: m_netlist(netlist)
, m_device(device)
, m_temperature(0)
, m_maxTemperature(500) //max number of iterations allowed
{

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

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

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

//If new cost is less, or greater with probability temperature, accept it
//If new cost is less, or greater with temperature-dependent probability, accept it
//TODO: make probability depend on dCost?
if(new_cost < original_cost)
return true;
if( (rand() % 100) < (int)m_temperature )
if( (rand() % m_maxTemperature) < m_temperature )
return true;

//If we don't like the change, revert
1 change: 1 addition & 0 deletions src/xbpar/PAREngine.h
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ class PAREngine
void RestorePreviousBestPlacement();

uint32_t m_temperature;
uint32_t m_maxTemperature;
};

#endif

0 comments on commit d1a7d8f

Please sign in to comment.