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";
22 bool detectModel = true;
25 while ((opt = getopt(argc, argv, "m:n:h")) != -1) {
28 model = Model::modelFactory(optarg);
35 cout << "Usage: " << argv[0] << " [OPTION] [FILE]" << endl
36 << endl << " -m <model> Specifies which model to use for sorting: Whirl, X, Zipper, FatX or Cloud "
37 << endl << " -n <ann> Specifies which artificial neural network to use for identification. '" << ann << "' is used by default"
38 << endl << " -h Prints this help message"
40 << "With no FILE, or if FILE is '-', stdin will be used"
45 cerr << "Usage: " << argv[0] << " [-n <ann>] [-h] [FILE]" << endl;
52 if (optind == argc || *argv[optind] == '-'){
55 file.open(argv[optind]);
57 cerr << "Could not open file: '" << argv[optind] << "'" << endl;
64 copy(istream_iterator<int>(*in), istream_iterator<int>(),
66 GeneOrder go(g.begin(),g.end());
69 ModelIdentifier mi(ann);
70 priority_queue<pair<double,Model> > pq = mi.identify(go);
72 model = pq.top().second;
74 while (pq.size() > 0){
75 cout << "Model: " << pq.top().second.name() << " score: " << pq.top().first << endl;
78 cout << "Using model: " << model.name() << endl;
80 cout << "Distance: " << inversionDistance(go) << endl;
81 //copy(go.begin(), go.end(), ostream_iterator<int>(cout, " "));
84 //TODO: Chose a sorter
87 GeneSorter::ActionList al = so.sort(go,model);
90 for (GeneSorter::ActionList::iterator sa = al.begin(); sa != al.end(); ++sa){
91 cout << "Action: " << sa->toString() << " model score: " << model.score(*sa,go) << endl;
92 score += model.score(*sa,go);
94 cout << "Avg score: " << score / al.size() << endl;