]> ruin.nu Git - germs.git/commitdiff
give access to reverse action members, and calculate symmetric score according to...
authorMichael Andreen <harv@ruin.nu>
Fri, 3 Aug 2007 14:09:11 +0000 (14:09 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 3 Aug 2007 14:09:11 +0000 (14:09 +0000)
src/models.cpp
src/reverseaction.h
src/sortaction.h

index 9c13090647ca294bebf752405e6f10a245a83b0c..9e6c2c36e9750245738d3604ff3e0aaf2a5e5196 100644 (file)
@@ -38,7 +38,15 @@ const char* ModelImpl::name(){
 
 
 double X::score(const SortAction& sa, const GeneOrder& go){
-       return 1;
+       const ReverseAction* ra = dynamic_cast<const ReverseAction*>(&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<double>(go.size());
+               return 1/(C+1);
+       }
+       return -1;
 }
 const char* X::name(){
        return "X";
index d69af75b16f96e2f76728cb80efd88ecf933325f..e0857803518b2d4aa5acaa72f0c7cfe89f41bf4f 100644 (file)
@@ -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;
index faec98a0c2e94681dcba096714d7f4c2e47759d6..5b810500c2dbea3ab454415eb0cebc17361efea8 100644 (file)
@@ -105,7 +105,7 @@ class SortAction{
                /**
                 * Gives access to the implementation
                 */
-               const SortActionImpl& impl(){
+               const SortActionImpl& impl() const{
                        return *_action;
                }
        private: