From: Michael Andreen Date: Wed, 1 Aug 2007 09:15:24 +0000 (+0000) Subject: Only show models with positive score, and convert the enum to strings X-Git-Tag: v0.1~36 X-Git-Url: https://ruin.nu/git/?p=germs.git;a=commitdiff_plain;h=90e2c43b99205b0d7a300209011231cd8d11f7a0 Only show models with positive score, and convert the enum to strings --- diff --git a/src/main.cpp b/src/main.cpp index 34ac34f..1c6a85e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,13 @@ using namespace std; typedef pair modelpair; +struct ScoreCmp { + template + bool operator()(T s1, T s2){ + return s1.first < s2.first; + } +}; + int main(int argc, char** argv){ string ann = "default.ann"; @@ -61,9 +68,16 @@ int main(int argc, char** argv){ //TODO: Identify ModelIdentifier mi(ann); map scores = mi.identify(go); + priority_queue,vector >, ScoreCmp > pq; for (map::iterator m = scores.begin(); m != scores.end(); ++m){ - cout << "Model: " << m->first << " score: " << m->second << endl; + if (m->second > 0){ + pq.push(pair(m->second,m->first)); + } + } + while (pq.size() > 0){ + cout << "Model: " << mi.modelName(pq.top().second) << " score: " << pq.top().first << endl; + pq.pop(); } //TODO: Chose a sorter diff --git a/src/modelidentifier.cpp b/src/modelidentifier.cpp index 98fae9b..56b6935 100644 --- a/src/modelidentifier.cpp +++ b/src/modelidentifier.cpp @@ -86,3 +86,14 @@ std::map ModelIdentifier::identify(const GeneOrde scores[Cloud] = output[4]; return scores; } + +string ModelIdentifier::modelName(Model m){ + switch (m){ + case Whirl : return "Whirl"; + case X : return "X"; + case FatX : return "FatX"; + case Zipper : return "Zipper"; + case Cloud : return "Cloud"; + } + return "Unknown model"; +} diff --git a/src/modelidentifier.h b/src/modelidentifier.h index 1ed4809..bd99044 100644 --- a/src/modelidentifier.h +++ b/src/modelidentifier.h @@ -54,6 +54,8 @@ class ModelIdentifier{ */ std::map identify(const GeneOrder& go); + static std::string modelName(Model m); + ~ModelIdentifier(); private: fann* _ann;