X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Fmodelidentifier.cpp;h=56b6935c48a4050bda6be087f9899f8f2af45b40;hb=90e2c43b99205b0d7a300209011231cd8d11f7a0;hp=561eea3741462986cf08bfac8119a4c643f90bd7;hpb=868e1b08fbbd49e489dc1349cb3657521c5c1dd9;p=germs.git diff --git a/src/modelidentifier.cpp b/src/modelidentifier.cpp index 561eea3..56b6935 100644 --- a/src/modelidentifier.cpp +++ b/src/modelidentifier.cpp @@ -45,8 +45,55 @@ std::map ModelIdentifier::identify(const GeneOrde else ++neg; } + double length = go.size(); + vector input(8); + input[0] = pos/length; + input[1] = neg/length; + + pair seqs = longestSequences(go); + + input[2] = seqs.first/length; + input[3] = seqs.second/length; + + double cycles = countCycles(go); + input[4] = cycles/length; + + vector comps = findComponents(go); + + pos = 0; + neg = 0; + int un = 0; + for (vector::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 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; } + +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"; +}