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

Method LoadMiniTraceQ

avida-core/source/main/cPopulation.cc:1546–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1544}
1545
1546void cPopulation::LoadMiniTraceQ(const cString& filename, int orgs_per, bool print_genomes, bool print_reacs)
1547{
1548 cInitFile input_file(filename, m_world->GetWorkingDir());
1549 if (!input_file.WasOpened()) {
1550 const cUserFeedback& feedback = input_file.GetFeedback();
1551 for (int i = 0; i < feedback.GetNumMessages(); i++) {
1552 switch (feedback.GetMessageType(i)) {
1553 case cUserFeedback::UF_ERROR: m_world->GetDriver().Feedback().Error(feedback.GetMessage(i)); break;
1554 case cUserFeedback::UF_WARNING: m_world->GetDriver().Feedback().Warning(feedback.GetMessage(i)); break;
1555 default: m_world->GetDriver().Feedback().Notify(feedback.GetMessage(i)); break;
1556 };
1557 }
1558 }
1559
1560 Apto::Array<int, Apto::Smart> bg_id_list;
1561 Apto::Array<int, Apto::Smart> queue = m_world->GetPopulation().GetMiniTraceQueue();
1562 for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
1563 cString cur_line = input_file.GetLine(line_id);
1564
1565 Apto::SmartPtr<Apto::Map<Apto::String, Apto::String> > line = input_file.GetLineAsDict(line_id);
1566 int gen_id_num = Apto::StrAs(line->Get("id"));
1567
1568 // setup the genotype 'list' which will be checked in activateorg
1569 // skip if enough already in the existing trace queue (e.g if loading multiple genotype id files that overlap)
1570 int add_num = orgs_per;
1571 for (int i = 0; i < queue.GetSize(); i++) {
1572 if (gen_id_num == queue[i]) {
1573 add_num--;
1574 if (add_num <= 0) break;
1575 }
1576 }
1577 for (int j = 0; j < add_num; j++) {
1578 bg_id_list.Push(gen_id_num);
1579 }
1580 }
1581
1582 if (queue.GetSize() > 0) {
1583 AppendMiniTraces(bg_id_list, print_genomes, print_reacs);
1584 }
1585 else {
1586 SetMiniTraceQueue(bg_id_list, print_genomes, print_reacs);
1587 }
1588}
1589
1590Apto::Array<int, Apto::Smart> cPopulation::SetRandomTraceQ(int max_samples)
1591{

Callers 1

ProcessMethod · 0.80

Calls 13

WasOpenedMethod · 0.80
GetNumMessagesMethod · 0.80
FeedbackMethod · 0.80
GetNumLinesMethod · 0.80
GetLineAsDictMethod · 0.80
GetMessageTypeMethod · 0.45
ErrorMethod · 0.45
WarningMethod · 0.45
NotifyMethod · 0.45
GetLineMethod · 0.45
GetMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected