]> ruin.nu Git - germs.git/blobdiff - src/modelidentifier.cpp
started a refactoring with Model class to score different sort actions
[germs.git] / src / modelidentifier.cpp
index 56b6935c48a4050bda6be087f9899f8f2af45b40..820d75abd73bbc58a215a704652502e17388893a 100644 (file)
@@ -22,6 +22,8 @@
 #include "genealgorithms.h"
 
 #include <doublefann.h>
+#include "models.h"
+#include "model.h"
 
 using namespace std;
 
@@ -36,7 +38,7 @@ ModelIdentifier::~ModelIdentifier(){
        fann_destroy(_ann);
 }
 
-std::map<ModelIdentifier::Model,double> ModelIdentifier::identify(const GeneOrder& go){
+priority_queue<pair<double,Model> > ModelIdentifier::identify(const GeneOrder& go){
        int pos = 0;
        int neg = 0;
        for (GeneOrder::iterator g = go.begin(); g != go.end(); ++g){
@@ -78,22 +80,11 @@ std::map<ModelIdentifier::Model,double> ModelIdentifier::identify(const GeneOrde
 
        double *output = fann_run(_ann,&input[0]);
 
-       map<Model,double> scores;
-       scores[X] = output[0];
-       scores[Zipper] = output[1];
-       scores[Whirl] = output[2];
-       scores[FatX] = output[3];
-       scores[Cloud] = output[4];
+       priority_queue<pair<double,Model> > scores;
+       scores.push(pair<double,Model>(output[0],Model(new Models::X)));
+       scores.push(pair<double,Model>(output[1],Model(new Models::Zipper)));
+       scores.push(pair<double,Model>(output[2],Model(new Models::ModelImpl)));
+       scores.push(pair<double,Model>(output[3],Model(new Models::FatX)));
+       scores.push(pair<double,Model>(output[4],Model(new Models::Cloud)));
        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";
-}