From 6b05a1ca565e894a3d754d30d7daae84ed48d386 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 3 Aug 2007 14:09:11 +0000 Subject: [PATCH] give access to reverse action members, and calculate symmetric score according to Ajana et al. --- src/models.cpp | 10 +++++++++- src/reverseaction.h | 9 +++++++++ src/sortaction.h | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/models.cpp b/src/models.cpp index 9c13090..9e6c2c3 100644 --- a/src/models.cpp +++ b/src/models.cpp @@ -38,7 +38,15 @@ const char* ModelImpl::name(){ double X::score(const SortAction& sa, const GeneOrder& go){ - return 1; + const ReverseAction* ra = dynamic_cast(&sa.impl()); + + if (ra){ + int l1 = go.size()/2 - ra->i(); + int l2 = ra->j() - go.size()/2; + double C = abs(l1 - l2)/static_cast(go.size()); + return 1/(C+1); + } + return -1; } const char* X::name(){ return "X"; diff --git a/src/reverseaction.h b/src/reverseaction.h index d69af75..e085780 100644 --- a/src/reverseaction.h +++ b/src/reverseaction.h @@ -71,6 +71,15 @@ class ReverseAction : public SortActionImpl{ os << "[" << _i << "," << _j << "]"; return os.str(); } + + size_t i() const{ + return _i; + } + size_t j() const{ + return _j; + } + + private: size_t _i; size_t _j; diff --git a/src/sortaction.h b/src/sortaction.h index faec98a..5b81050 100644 --- a/src/sortaction.h +++ b/src/sortaction.h @@ -105,7 +105,7 @@ class SortAction{ /** * Gives access to the implementation */ - const SortActionImpl& impl(){ + const SortActionImpl& impl() const{ return *_action; } private: -- 2.39.2