Model Model::modelFactory(const std::string& name){
if (name == "X"){
return Model(new Models::X());
- }else if(name == "Whirl" || name == "Standard"){
+ }else if(name == "Whirl"){
+ return Model(new Models::Whirl());
+ }else if(name == "Standard"){
return Model(new Models::ModelImpl());
}else if(name == "Zipper"){
return Model(new Models::Zipper());
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[2],Model(new Models::Whirl)));
scores.push(pair<double,Model>(output[3],Model(new Models::FatX)));
scores.push(pair<double,Model>(output[4],Model(new Models::Cloud)));
return scores;
}
+double Whirl::score(const SortAction& sa, const GeneOrder& go){
+ const ReverseAction* ra = dynamic_cast<const ReverseAction*>(&sa.impl());
+
+ if (ra){
+ return 1;
+ }
+ return -1;
+}
+const char* Whirl::name(){
+ return "Whirl";
+}
double X::score(const SortAction& sa, const GeneOrder& go){
const ReverseAction* ra = dynamic_cast<const ReverseAction*>(&sa.impl());
virtual const char* name();
};
+/**
+ * A model that favors reversals.
+ */
+class Whirl : public ModelImpl {
+ public:
+ /**
+ * Returns a higher score for reversals and a lower score
+ * for all other actions.
+ *
+ * \see Model::score
+ */
+ double score(const SortAction& sa, const GeneOrder& go);
+
+ /**
+ * \see Model::name
+ */
+ const char* name();
+};
/**
* A model that favors symmetric reversal, resulting in an X-like
GeneOrder uniform(_uniform.begin(),_uniform.end());
pq = mi.identify(uniform);
- CPPUNIT_ASSERT_EQUAL(string("Standard"),string(pq.top().second.name()));
+ CPPUNIT_ASSERT_EQUAL(string("Whirl"),string(pq.top().second.name()));
GeneOrder zipper(_zipper.begin(),_zipper.end());
pq = mi.identify(zipper);