]> ruin.nu Git - germs.git/commitdiff
Only show models with positive score, and convert the enum to strings
authorMichael Andreen <harv@ruin.nu>
Wed, 1 Aug 2007 09:15:24 +0000 (09:15 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 1 Aug 2007 09:15:24 +0000 (09:15 +0000)
src/main.cpp
src/modelidentifier.cpp
src/modelidentifier.h

index 34ac34fbfc54cfa749900b90d337cd3a4b9be66f..1c6a85ecc85790716e6a8559e1ea86117d716922 100644 (file)
@@ -15,6 +15,13 @@ using namespace std;
 
 typedef pair<ModelIdentifier::Model,double> modelpair;
 
+struct ScoreCmp {
+       template<typename T>
+       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<ModelIdentifier::Model,double> scores = mi.identify(go);
+       priority_queue<pair<double,ModelIdentifier::Model>,vector<pair<double,ModelIdentifier::Model> >, ScoreCmp > pq;
        for (map<ModelIdentifier::Model,double>::iterator m = scores.begin();
                        m != scores.end(); ++m){
-               cout << "Model: " << m->first << " score: " << m->second << endl;
+               if (m->second > 0){
+                       pq.push(pair<double,ModelIdentifier::Model>(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
index 98fae9bbc48c2261dec4648efd6edb3b4733a435..56b6935c48a4050bda6be087f9899f8f2af45b40 100644 (file)
@@ -86,3 +86,14 @@ std::map<ModelIdentifier::Model,double> 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";
+}
index 1ed4809ff72319836c798cbdfd14c1c231183c86..bd990443956fd1cb6809b8bd8792e3513d0ea942 100644 (file)
@@ -54,6 +54,8 @@ class ModelIdentifier{
                 */
                std::map<Model,double> identify(const GeneOrder& go);
 
+               static std::string modelName(Model m);
+
                ~ModelIdentifier();
        private:
                fann* _ann;