src/ell/spinglass/S_SG_Ising.hh
Go to the documentation of this file.00001 #ifndef S_SG_ISING_HH_ 00002 #define S_SG_ISING_HH_ 00003 00004 #include "ell/State.hh" 00005 #include "ell/IterableNeighbors.hh" 00006 #include <biu/assertbiu.hh> 00007 #include <biu/Alphabet.hh> 00008 00009 namespace ell 00010 { 00017 class S_SG_Ising : public State, public IterableNeighbors 00018 { 00019 00020 public: 00022 typedef biu::Alphabet::AlphElem SpinType; 00024 typedef biu::Alphabet::Sequence SpinArray; 00025 00026 static const SpinType SPIN_UP; 00027 static const SpinType SPIN_DOWN; 00028 00029 protected: 00030 00032 static const biu::Alphabet spinAlph; 00033 00035 SpinArray spin; 00036 00037 public: 00038 00045 S_SG_Ising(size_t size, bool random = true); 00046 00049 S_SG_Ising(const std::string& spinStr); 00050 00051 S_SG_Ising(const S_SG_Ising& s2); 00052 00053 virtual ~S_SG_Ising(); 00054 00055 virtual bool operator== (const State& state2) const; 00056 virtual bool operator!= (const State& state2) const; 00057 00058 virtual void operator= (const S_SG_Ising& sg2); 00059 00060 00062 virtual int getFitness() const; 00063 00067 virtual double getEnergy() const; 00068 00075 virtual unsigned int getMinimalDistance(const State& state2) const; 00076 00078 virtual State* clone() const; 00079 00082 virtual State* fromString(const std::string& stringRep) const; 00083 00086 virtual std::string toString() const; 00087 00088 // neighborhood 00092 virtual NeighborListPtr getNeighborList() const; 00093 00097 virtual NeighborListPtr getRandomNeighborList() const; 00098 00102 virtual State* getRandomNeighbor(State* inPlaceNeigh = NULL) const; 00103 00104 00105 00106 00108 00111 virtual size_t getNeighborNumber(void) const; 00112 00119 virtual State* getNeighbor(const size_t index, State* neigh) const; 00120 00129 virtual State* undoNeighborChange(const size_t index, State* const neigh) const; 00130 00140 virtual State* applyNeighborChange(const size_t index, State* const neigh) const; 00141 00143 00147 virtual CSequence compress(void) const ; 00148 00154 virtual CSequence& compress(CSequence& toFill) const; 00155 00164 virtual State* uncompress(const CSequence& cseq, State* toFill) const; 00165 00171 virtual State* uncompress(const CSequence& cseq); 00172 00173 00174 00175 protected: 00176 00178 inline SpinType flipSpin( SpinType s ) const { 00179 return ( s == SPIN_UP ? SPIN_DOWN : SPIN_UP); 00180 } 00181 00182 }; // class 00183 00184 } // namespace ell 00185 00186 #endif /*S_SG_ISING_HH_*/