MCPcopy Create free account
hub / github.com/devosoft/avida / GetNextID

Method GetNextID

avida-core/source/tools/cDemeProbSchedule.cc:39–67  ·  view source on GitHub ↗

get the next CPU cycle, awarded to the next populated deme and cycled in a round-robin fashion

Source from the content-addressed store, hash-verified

37
38//get the next CPU cycle, awarded to the next populated deme and cycled in a round-robin fashion
39int cDemeProbSchedule::GetNextID()
40{
41 // iterate the deme
42 curr_deme = ++curr_deme % num_demes;
43
44 //loop to check each deme at most once -- this could be a problem in sparse pops, best to start with populated or mostly-poulated demes
45 for (int i = 0; i < num_demes; i++) {
46
47 // check to see if deme is populated
48 if (chart[curr_deme]->GetTotalWeight() == 0) {
49 // deme is empty -- iterate the deme
50 curr_deme = ++curr_deme % num_demes;
51 } else {
52 // deme not empty -- return offset id
53
54 // calculate the offset
55 int offset = curr_deme * deme_size;
56
57 // get the within postion of the node whos corresponding cell will get the CPU cycle
58 const double position = m_rng->GetDouble(chart[curr_deme]->GetTotalWeight());
59
60 // return the adjusted ID of the cell to get the CPU cycle
61 return chart[curr_deme]->FindPosition(position) + offset;
62 }
63 }
64
65 assert(false);
66 return -1;
67}
68
69
70//adjust the weight of an org within deme

Callers

nothing calls this directly

Calls 3

GetTotalWeightMethod · 0.45
GetDoubleMethod · 0.45
FindPositionMethod · 0.45

Tested by

no test coverage detected