11 #include "geneorder.h"
12 #include "modelidentifier.h"
13 #include "genesorter.h"
14 #include "sortaction.h"
15 #include "genealgorithms.h"
18 int main(int argc, char** argv){
20 string ann = "default.ann";
23 while ((opt = getopt(argc, argv, "n:h")) != -1) {
29 cout << "Usage: " << argv[0] << " [OPTION] [FILE]" << endl
30 << endl << " -n <ann> Specifies which artificial neural network to use for identification. '" << ann << "' is used by default"
31 << endl << " -h Prints this help message"
33 << "With no FILE, or if FILE is '-', stdin will be used"
38 cerr << "Usage: " << argv[0] << " [-n <ann>] [-h] [FILE]" << endl;
45 if (optind == argc || *argv[optind] == '-'){
48 file.open(argv[optind]);
50 cerr << "Could not open file: '" << argv[optind] << "'" << endl;
57 copy(istream_iterator<int>(*in), istream_iterator<int>(),
59 GeneOrder go(g.begin(),g.end());
62 ModelIdentifier mi(ann);
63 priority_queue<pair<double,Model> > pq = mi.identify(go);
64 Model model = pq.top().second;
65 //while (pq.size() > 0){
66 cout << "Model: " << model.name() << " score: " << pq.top().first << endl;
70 cout << "Distance: " << inversionDistance(go) << " : ";
71 copy(go.begin(), go.end(), ostream_iterator<int>(cout, " "));
74 //TODO: Chose a sorter
77 GeneSorter::ActionList al = so.sort(go,model);
80 for (GeneSorter::ActionList::iterator sa = al.begin(); sa != al.end(); ++sa){
81 cout << "Action: " << sa->toString() << " model score: " << model.score(*sa,go) << endl;
82 score += model.score(*sa,go);
84 cout << "Avg score: " << score / al.size() << endl;