]> ruin.nu Git - germs.git/commitdiff
lower case is nicer
authorMichael Andreen <harv@ruin.nu>
Thu, 14 Jun 2007 12:39:50 +0000 (12:39 +0000)
committerMichael Andreen <harv@ruin.nu>
Thu, 14 Jun 2007 12:39:50 +0000 (12:39 +0000)
src/CMakeLists.txt
src/GeneOrder.cpp [deleted file]
src/GeneOrder.h [deleted file]
src/GeneSorter.h [deleted file]
src/ModelIdentifier.h [deleted file]
src/SortAction.h [deleted file]
src/geneorder.cpp [new file with mode: 0644]
src/geneorder.h [new file with mode: 0644]
src/genesorter.h [new file with mode: 0644]
src/modelidentifier.h [new file with mode: 0644]
src/sortaction.h [new file with mode: 0644]

index 7367530d3f2c90905c8614e3ef8ef69c2d20eb9a..102a11b6912e2bf6f6f1f79013ec9c1f41445dbd 100644 (file)
@@ -5,6 +5,6 @@ SET(CMAKE_VERBOSE_MAKEFILE OFF)
 ADD_DEFINITIONS(-Wall -O2)
 
 INCLUDE_DIRECTORIES(.)
 ADD_DEFINITIONS(-Wall -O2)
 
 INCLUDE_DIRECTORIES(.)
-ADD_EXECUTABLE(../bin/genesort main.cpp GeneOrder.cpp)
+ADD_EXECUTABLE(../bin/genesort main.cpp geneorder.cpp)
 
 TARGET_LINK_LIBRARIES(../bin/genesort doublefann)
 
 TARGET_LINK_LIBRARIES(../bin/genesort doublefann)
diff --git a/src/GeneOrder.cpp b/src/GeneOrder.cpp
deleted file mode 100644 (file)
index f2dfc26..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Michael Andreen                                 *
- *   andreen@student.chalmers.se                                           *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
- ***************************************************************************/
-
-#include "GeneOrder.h"
-
-using namespace std;
-
-/**
- * \file GeneOrder.cpp
- * Implements the GeneOrder class
- * 
- * \author Michael Andreen
- */
-
-
-
-GeneOrder::GeneOrder(const GeneOrder& go){
-       _geneorder = go._geneorder;
-}
-
-
-GeneOrder::~GeneOrder(){
-}
-
-const GeneOrder& GeneOrder::operator=(const GeneOrder& go){
-       _geneorder = go._geneorder;
-       return *this;
-}
-
-/**
- * Check so i is in the valid range, then return the gene.
- */
-const Gene& GeneOrder::operator[](size_type i) const{
-       if (i < 0 || i >= _geneorder.size())
-               throw out_of_range("Index is not in valid range");
-       return _geneorder[i];
-}
-
-int GeneOrder::size() const{
-       return _geneorder.size();
-}
-
-const GeneOrder::GeneList& GeneOrder::list() const{
-       return _geneorder;
-}
diff --git a/src/GeneOrder.h b/src/GeneOrder.h
deleted file mode 100644 (file)
index e411a37..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Michael Andreen                                 *
- *   andreen@student.chalmers.se                                           *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
- ***************************************************************************/
-
-#ifndef __GENEORDER_H__
-#define __GENEORDER_H__
-
-#include <vector>
-#include <stdexcept>
-#include <cstdlib>
-
-#include "misc.h"
-
-/**
- * Stores a gene order permutation and ensures that all genes are present and not duplicated.
- * \author Michael Andreen
-*/
-class GeneOrder{
-       public:
-
-               typedef std::vector<Gene> GeneList;
-               typedef GeneList::size_type size_type;
-
-               /**
-                * Creates a copy of the given gene order
-                */
-               GeneOrder(const GeneOrder& go);
-
-               /**
-                * Creates a gene order from a given list.
-                *
-                * \throws invalid_argument if the list is not a valid permutation.
-                */
-               template<class T>
-               GeneOrder(T begin, T end);
-
-               /**
-                * Destroyes the gene order.
-                */
-               ~GeneOrder();
-
-               /**
-                * Copies the given gene order.
-                */
-               const GeneOrder& operator=(const GeneOrder& go);
-
-               /**
-                * Returns the gene at the given index.
-                *
-                * \throws out_of_range if i is smaller than 0 or too big.
-                */
-               const Gene& operator[](size_type i) const;
-
-               /**
-                * Returns the size of the permutation.
-                */
-               int size() const;
-
-               /**
-                * Returns the vector containing the gene order permutation.
-                */
-               const GeneList& list() const;
-
-               /**
-                * Reverses an interval and returns the new permutation
-                */
-               GeneOrder reverse(size_type i, size_type j) const;
-
-               /**
-                * Moves the gene on position i to position j, returning a new permutation
-                */
-               GeneOrder transpos(size_type i, size_type j) const;
-
-       private:
-               GeneList _geneorder;
-};
-
-
-/**
- * Put all the genes in the list, check that all genes are included, pad with 0 and n+1 if needed.
- * TODO: This is far from done atm
- */
-template<typename T>
-GeneOrder::GeneOrder(T begin, T end): _geneorder(begin,end){
-
-       /*TODO: Pad code, just not sure if I need it all the time.
-       if (_geneorder[0] != 0)
-               _geneorder.insert(_geneorder.begin(),0);
-       if(_geneorder[_geneorder.size()-1] != _geneorder.size() - 1)
-               _geneorder.push_back(_geneorder.size());
-       */
-
-       GeneList genes(_geneorder.size());
-       for (GeneList::iterator gene = _geneorder.begin(); gene != _geneorder.end(); ++gene){
-               ++genes[std::abs(*gene)];
-       }
-       for (GeneList::iterator gene = genes.begin(); gene != genes.end(); ++gene){
-               if (*gene != 1)
-                       throw std::invalid_argument("Not all genes are present only 1 time");
-       }
-}
-
-#endif
-
diff --git a/src/GeneSorter.h b/src/GeneSorter.h
deleted file mode 100644 (file)
index e37bae7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Michael Andreen                                 *
- *   andreen@student.chalmers.se                                           *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
- ***************************************************************************/
-
-#ifndef __GENESORTER_H__
-#define __GENESORTER_H__
-
-#include "GeneOrder.h"
-#include "SortAction.h"
-
-#include <vector>
-
-
-/**
- * Abstract baseclass for different gene sorters.
- * \author Michael Andreen
- */
-class GeneSorter{
-       public:
-               typedef std::vector<SortAction> ActionList;
-
-               /**
-                * Takes a GeneOrder, finds the actions to transform it into a sorted
-                * permutation and returns the list with required actions.
-                */
-               virtual ActionList sort(const GeneOrder& go1) = 0;
-
-               /**
-                * Find the safe actions for this GeneOrder.
-                */
-               virtual ActionList safeActions(const GeneOrder& go1) = 0;
-
-               virtual ~GeneSorter(){};
-};
-
-#endif
-
diff --git a/src/ModelIdentifier.h b/src/ModelIdentifier.h
deleted file mode 100644 (file)
index 1c22485..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Michael Andreen                                 *
- *   andreen@student.chalmers.se                                           *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
- ***************************************************************************/
-
-#ifndef __MODELIDENTIFIER_H__
-#define __MODELIDENTIFIER_H__
-
-#include "GeneOrder.h"
-
-#include <map>
-
-
-/**
- * Identifies the model this gene order belongs to
- * \author Michael Andreen
- */
-class ModelIdentifier{
-       public:
-               enum Model{Whirl,X,FatX,Zipper,Cloud};
-
-               /**
-                * Identifies the model for a given gene order.
-                * \returns a map with the model as key and the score between 0 and 1
-                */
-               std::map<Model,double> identify(const GeneOrder& go);
-
-               virtual ~ModelIdentifier(){};
-};
-
-#endif
-
diff --git a/src/SortAction.h b/src/SortAction.h
deleted file mode 100644 (file)
index b6c5df7..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Michael Andreen                                 *
- *   andreen@student.chalmers.se                                           *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
- ***************************************************************************/
-
-#ifndef __SORTACTION_H__
-#define __SORTACTION_H__
-
-/**
- * Abstraction of a sort action, keeping track of score
- *
- * \author Michael Andreen
- */
-class SortAction{
-       public:
-
-               virtual ~SortAction(){};
-
-               /**
-                * Sort SortActions by score
-                */
-               virtual operator<(const SortAction& sa) const;
-};
-
-#endif
-
diff --git a/src/geneorder.cpp b/src/geneorder.cpp
new file mode 100644 (file)
index 0000000..31461a1
--- /dev/null
@@ -0,0 +1,62 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Michael Andreen                                 *
+ *   andreen@student.chalmers.se                                           *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
+ ***************************************************************************/
+
+#include "geneorder.h"
+
+using namespace std;
+
+/**
+ * \file GeneOrder.cpp
+ * Implements the GeneOrder class
+ * 
+ * \author Michael Andreen
+ */
+
+
+
+GeneOrder::GeneOrder(const GeneOrder& go){
+       _geneorder = go._geneorder;
+}
+
+
+GeneOrder::~GeneOrder(){
+}
+
+const GeneOrder& GeneOrder::operator=(const GeneOrder& go){
+       _geneorder = go._geneorder;
+       return *this;
+}
+
+/**
+ * Check so i is in the valid range, then return the gene.
+ */
+const Gene& GeneOrder::operator[](size_type i) const{
+       if (i < 0 || i >= _geneorder.size())
+               throw out_of_range("Index is not in valid range");
+       return _geneorder[i];
+}
+
+int GeneOrder::size() const{
+       return _geneorder.size();
+}
+
+const GeneOrder::GeneList& GeneOrder::list() const{
+       return _geneorder;
+}
diff --git a/src/geneorder.h b/src/geneorder.h
new file mode 100644 (file)
index 0000000..e411a37
--- /dev/null
@@ -0,0 +1,120 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Michael Andreen                                 *
+ *   andreen@student.chalmers.se                                           *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
+ ***************************************************************************/
+
+#ifndef __GENEORDER_H__
+#define __GENEORDER_H__
+
+#include <vector>
+#include <stdexcept>
+#include <cstdlib>
+
+#include "misc.h"
+
+/**
+ * Stores a gene order permutation and ensures that all genes are present and not duplicated.
+ * \author Michael Andreen
+*/
+class GeneOrder{
+       public:
+
+               typedef std::vector<Gene> GeneList;
+               typedef GeneList::size_type size_type;
+
+               /**
+                * Creates a copy of the given gene order
+                */
+               GeneOrder(const GeneOrder& go);
+
+               /**
+                * Creates a gene order from a given list.
+                *
+                * \throws invalid_argument if the list is not a valid permutation.
+                */
+               template<class T>
+               GeneOrder(T begin, T end);
+
+               /**
+                * Destroyes the gene order.
+                */
+               ~GeneOrder();
+
+               /**
+                * Copies the given gene order.
+                */
+               const GeneOrder& operator=(const GeneOrder& go);
+
+               /**
+                * Returns the gene at the given index.
+                *
+                * \throws out_of_range if i is smaller than 0 or too big.
+                */
+               const Gene& operator[](size_type i) const;
+
+               /**
+                * Returns the size of the permutation.
+                */
+               int size() const;
+
+               /**
+                * Returns the vector containing the gene order permutation.
+                */
+               const GeneList& list() const;
+
+               /**
+                * Reverses an interval and returns the new permutation
+                */
+               GeneOrder reverse(size_type i, size_type j) const;
+
+               /**
+                * Moves the gene on position i to position j, returning a new permutation
+                */
+               GeneOrder transpos(size_type i, size_type j) const;
+
+       private:
+               GeneList _geneorder;
+};
+
+
+/**
+ * Put all the genes in the list, check that all genes are included, pad with 0 and n+1 if needed.
+ * TODO: This is far from done atm
+ */
+template<typename T>
+GeneOrder::GeneOrder(T begin, T end): _geneorder(begin,end){
+
+       /*TODO: Pad code, just not sure if I need it all the time.
+       if (_geneorder[0] != 0)
+               _geneorder.insert(_geneorder.begin(),0);
+       if(_geneorder[_geneorder.size()-1] != _geneorder.size() - 1)
+               _geneorder.push_back(_geneorder.size());
+       */
+
+       GeneList genes(_geneorder.size());
+       for (GeneList::iterator gene = _geneorder.begin(); gene != _geneorder.end(); ++gene){
+               ++genes[std::abs(*gene)];
+       }
+       for (GeneList::iterator gene = genes.begin(); gene != genes.end(); ++gene){
+               if (*gene != 1)
+                       throw std::invalid_argument("Not all genes are present only 1 time");
+       }
+}
+
+#endif
+
diff --git a/src/genesorter.h b/src/genesorter.h
new file mode 100644 (file)
index 0000000..fa47b05
--- /dev/null
@@ -0,0 +1,53 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Michael Andreen                                 *
+ *   andreen@student.chalmers.se                                           *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
+ ***************************************************************************/
+
+#ifndef __GENESORTER_H__
+#define __GENESORTER_H__
+
+#include "geneorder.h"
+#include "sortaction.h"
+
+#include <vector>
+
+
+/**
+ * Abstract baseclass for different gene sorters.
+ * \author Michael Andreen
+ */
+class GeneSorter{
+       public:
+               typedef std::vector<SortAction> ActionList;
+
+               /**
+                * Takes a GeneOrder, finds the actions to transform it into a sorted
+                * permutation and returns the list with required actions.
+                */
+               virtual ActionList sort(const GeneOrder& go1) = 0;
+
+               /**
+                * Find the safe actions for this GeneOrder.
+                */
+               virtual ActionList safeActions(const GeneOrder& go1) = 0;
+
+               virtual ~GeneSorter(){};
+};
+
+#endif
+
diff --git a/src/modelidentifier.h b/src/modelidentifier.h
new file mode 100644 (file)
index 0000000..bbf3037
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Michael Andreen                                 *
+ *   andreen@student.chalmers.se                                           *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
+ ***************************************************************************/
+
+#ifndef __MODELIDENTIFIER_H__
+#define __MODELIDENTIFIER_H__
+
+#include "geneorder.h"
+
+#include <map>
+
+
+/**
+ * Identifies the model this gene order belongs to
+ * \author Michael Andreen
+ */
+class ModelIdentifier{
+       public:
+               enum Model{Whirl,X,FatX,Zipper,Cloud};
+
+               /**
+                * Identifies the model for a given gene order.
+                * \returns a map with the model as key and the score between 0 and 1
+                */
+               std::map<Model,double> identify(const GeneOrder& go);
+
+               virtual ~ModelIdentifier(){};
+};
+
+#endif
+
diff --git a/src/sortaction.h b/src/sortaction.h
new file mode 100644 (file)
index 0000000..b6c5df7
--- /dev/null
@@ -0,0 +1,41 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Michael Andreen                                 *
+ *   andreen@student.chalmers.se                                           *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
+ ***************************************************************************/
+
+#ifndef __SORTACTION_H__
+#define __SORTACTION_H__
+
+/**
+ * Abstraction of a sort action, keeping track of score
+ *
+ * \author Michael Andreen
+ */
+class SortAction{
+       public:
+
+               virtual ~SortAction(){};
+
+               /**
+                * Sort SortActions by score
+                */
+               virtual operator<(const SortAction& sa) const;
+};
+
+#endif
+