]> ruin.nu Git - germs.git/commitdiff
ModelIdentifier::identify implemented and passes test
authorMichael Andreen <harv@ruin.nu>
Thu, 21 Jun 2007 12:46:22 +0000 (12:46 +0000)
committerMichael Andreen <harv@ruin.nu>
Thu, 21 Jun 2007 12:46:22 +0000 (12:46 +0000)
src/modelidentifier.cpp

index 561eea3741462986cf08bfac8119a4c643f90bd7..98fae9bbc48c2261dec4648efd6edb3b4733a435 100644 (file)
@@ -45,8 +45,44 @@ std::map<ModelIdentifier::Model,double> ModelIdentifier::identify(const GeneOrde
                else
                        ++neg;
        }
+       double length = go.size();
+       vector<double> input(8);
+       input[0] = pos/length;
+       input[1] = neg/length;
+
+       pair<int,int> seqs = longestSequences(go);
+
+       input[2] = seqs.first/length;
+       input[3] = seqs.second/length;
+
+       double cycles = countCycles(go);
+       input[4] = cycles/length;
+
+       vector<Component> comps = findComponents(go);
+
+       pos = 0;
+       neg = 0;
+       int un = 0;
+       for (vector<Component>::iterator c = comps.begin(); c != comps.end(); ++c){
+               if (c->sign > 0)
+                       ++pos;
+               else if (c->sign < 0)
+                       ++neg;
+               else
+                       ++un;
+       }
+
+       input[5] = un/cycles;
+       input[6] = pos/cycles;
+       input[7] = neg/cycles;
+
+       double *output = fann_run(_ann,&input[0]);
+
        map<Model,double> scores;
-       scores[X] = 1;
-       scores[Whirl] = -1;
+       scores[X] = output[0];
+       scores[Zipper] = output[1];
+       scores[Whirl] = output[2];
+       scores[FatX] = output[3];
+       scores[Cloud] = output[4];
        return scores;
 }