ell::S_SG_NPP Class Reference
#include <S_SG_NPP.hh>
Inheritance diagram for ell::S_SG_NPP:
Detailed Description
An instance of the number partitioning problem
Definition at line 12 of file S_SG_NPP.hh.
Public Types | |
typedef biu::VirtualList< State > | NeighborList |
typedef std::auto_ptr< NeighborList > | NeighborListPtr |
typedef biu::Alphabet::Sequence | SpinArray |
typedef biu::Alphabet::AlphElem | SpinType |
typedef std::vector< double > | WeightType |
Public Member Functions | |
virtual State * | applyNeighborChange (const size_t index, State *const neigh) const |
virtual S_SG_NPP * | clone (State *toFill=NULL) const |
virtual CSequence & | compress (CSequence &toFill) const |
virtual CSequence | compress (void) const |
virtual State * | fromString (const std::string &stringRep) const |
virtual double | getEnergy () const |
virtual const std::string & | getID (void) const |
virtual unsigned int | getMinimalDistance (const State &state2) const |
virtual State * | getNeighbor (const size_t index, State *neigh) const |
virtual NeighborListPtr | getNeighborList () const |
virtual size_t | getNeighborNumber (void) const |
virtual State * | getRandomNeighbor (State *inPlaceNeigh=NULL) const |
virtual NeighborListPtr | getRandomNeighborList () const |
virtual const double | getSymmShift (void) const |
virtual const WeightType *const | getWeights (void) const |
virtual bool | operator!= (const State &state2) const |
virtual bool | operator< (const State &state2) const |
virtual void | operator= (const S_SG_NPP &sg2) |
virtual bool | operator== (const State &state2) const |
S_SG_NPP (const S_SG_NPP &s2) | |
S_SG_NPP (const WeightType *weights, const std::string &spinStr, const double symmShift=0.0) | |
S_SG_NPP (const WeightType *weights, const bool random=true, const double symmShift=0.0) | |
virtual std::string & | toString (std::string &toFill) const |
virtual std::string | toString () const |
virtual State * | uncompress (const CSequence &cseq) |
virtual State * | uncompress (const CSequence &cseq, State *toFill) const |
virtual State * | undoNeighborChange (const size_t index, State *const neigh) const |
virtual | ~S_SG_NPP () |
Static Public Member Functions | |
static bool | less (const State *s1, const State *s2) |
Static Public Attributes | |
static const std::string | ID |
static const SpinType | SPIN_DOWN |
static const SpinType | SPIN_UP |
Protected Member Functions | |
SpinType | flipSpin (SpinType s) const |
Protected Attributes | |
SpinArray | spin |
double | symmShift |
const WeightType * | weights |
Static Protected Attributes | |
static const biu::Alphabet | spinAlph |
Member Typedef Documentation
typedef biu::VirtualList<State> ell::State::NeighborList [inherited] |
typedef std::auto_ptr<NeighborList> ell::State::NeighborListPtr [inherited] |
typedef biu::Alphabet::Sequence ell::S_SG_Ising::SpinArray [inherited] |
typedef biu::Alphabet::AlphElem ell::S_SG_Ising::SpinType [inherited] |
typedef std::vector<double> ell::S_SG_NPP::WeightType |
Definition at line 15 of file S_SG_NPP.hh.
Constructor & Destructor Documentation
ell::S_SG_NPP::S_SG_NPP | ( | const WeightType * | weights, | |
const bool | random = true , |
|||
const double | symmShift = 0.0 | |||
) |
Creates a spin-ring of weights.size(). It is initializes with + spins or randomly. The weight of each spin is given by weights.
- Parameters:
-
weights the weight of each spin --> its size determines the number of spins in the ring random initialize all spins randomly or with + symmShift will be added to the sum of flipped weights in the energy function to allow for a symmetry breaking
Definition at line 8 of file S_SG_NPP.cc.
ell::S_SG_NPP::S_SG_NPP | ( | const WeightType * | weights, | |
const std::string & | spinStr, | |||
const double | symmShift = 0.0 | |||
) |
Creates a spin-ring from the string representatio spinStr. The weight of each spin is given by weights.
- Parameters:
-
weights the weight of each spin spinStr the +- string spin representation symmShift will be added to the sum of flipped weights in the energy function to allow for a symmetry breaking
Definition at line 16 of file S_SG_NPP.cc.
ell::S_SG_NPP::S_SG_NPP | ( | const S_SG_NPP & | s2 | ) |
Definition at line 23 of file S_SG_NPP.cc.
ell::S_SG_NPP::~S_SG_NPP | ( | ) | [virtual] |
Member Function Documentation
State * ell::S_SG_NPP::applyNeighborChange | ( | const size_t | index, | |
State *const | neigh | |||
) | const [virtual] |
Applies the necessary changes to a given state to get the neighbor. Note: neigh is expected to be a copy (i.e. *this == *neigh) and therefore direct changes are possible or to be NULL. If (neigh==NULL) a copy of this has to be generated, modified, and returned.
- Parameters:
-
index the neighbor to generate neigh a copy of this the changes should be applied to
- Returns:
- the neighbor state of the given index or NULL if the index is out of range
Reimplemented from ell::S_SG_Ising.
Definition at line 152 of file S_SG_NPP.cc.
Returns a pointer to a clone of the current state.
- Returns:
- a pointer to a copy of this state, if toFill is != NULL the return value corresponds to the updated state pointed to by toFill, otherwise a new object is created !!!
Reimplemented from ell::S_SG_Ising.
Definition at line 80 of file S_SG_NPP.cc.
Access to a compressed sequence representation of the state.
- Parameters:
-
toFill a data structure to write the compressed representation too
- Returns:
- the compressed sequence representation
Implements ell::State.
Definition at line 265 of file S_SG_Ising.cc.
CSequence ell::S_SG_Ising::compress | ( | void | ) | const [virtual, inherited] |
Access to a compressed sequence representation of the state.
- Returns:
- the compressed sequence representation
Implements ell::State.
Definition at line 254 of file S_SG_Ising.cc.
State * ell::S_SG_NPP::fromString | ( | const std::string & | stringRep | ) | const [virtual] |
Returns a new State based on the current state. The new state differs only by the information given by stringRep.
Reimplemented from ell::S_SG_Ising.
Definition at line 98 of file S_SG_NPP.cc.
double ell::S_SG_NPP::getEnergy | ( | ) | const [virtual] |
Returns the state specific energy, i.e. E = abs( symmShift + sum ( weights(i)*spin(i) ) ) for all 0<=i<j<=spinnumber and spin(i)=+-1 .
Reimplemented from ell::S_SG_Ising.
Definition at line 70 of file S_SG_NPP.cc.
const std::string & ell::S_SG_NPP::getID | ( | void | ) | const [virtual] |
Access to a State subclass specific ID string to identify instances of this class.
- Returns:
- the subclass specific ID string
Reimplemented from ell::S_SG_Ising.
Definition at line 34 of file S_SG_NPP.cc.
unsigned int ell::S_SG_Ising::getMinimalDistance | ( | const State & | state2 | ) | const [virtual, inherited] |
Returns the minimal number of steps via valid neighbored states from this to another valid State.
- Parameters:
-
state2 the State to reach
- Returns:
- if state2 is a S_SG_Ising state the minimal distance or UINT_MAX otherwise
Implements ell::State.
Definition at line 92 of file S_SG_Ising.cc.
Access to a specific neighbor.
- Parameters:
-
index the index of the neighbor in [0, getNeighborNumber()) neigh if != NULL this state should be converted into the neighbor otherwise a new one is created and returned
- Returns:
- the new neighbor state or NULL if the index is >= getNeighborNumber()
Reimplemented from ell::S_SG_Ising.
Definition at line 125 of file S_SG_NPP.cc.
State::NeighborListPtr ell::S_SG_Ising::getNeighborList | ( | ) | const [virtual, inherited] |
Returns a virtual list of all VALID neighbored states in the energy landscape in a specific successive order.
Implements ell::State.
Definition at line 148 of file S_SG_Ising.cc.
size_t ell::S_SG_Ising::getNeighborNumber | ( | void | ) | const [virtual, inherited] |
How many neighbor indices are accessible.
- Returns:
- the number of neighbors
Implements ell::IterableNeighbors.
Definition at line 188 of file S_SG_Ising.cc.
Returns a VALID random neighbored state. If a state is given it is overwritten and changed to a neighbor.
Reimplemented from ell::S_SG_Ising.
Definition at line 103 of file S_SG_NPP.cc.
State::NeighborListPtr ell::S_SG_Ising::getRandomNeighborList | ( | ) | const [virtual, inherited] |
Returns a virtual list of all VALID neighbored states in the energy landscape in a random order.
Implements ell::State.
Definition at line 157 of file S_SG_Ising.cc.
const double ell::S_SG_NPP::getSymmShift | ( | void | ) | const [virtual] |
Access to the weight shift used for symmetry breaking.
- Returns:
- the weight shift
Definition at line 185 of file S_SG_NPP.cc.
const S_SG_NPP::WeightType *const ell::S_SG_NPP::getWeights | ( | void | ) | const [virtual] |
Comparison function that compares two State pointer based on the less than operator '<' of the first State. The function can be used in STL algorithms, e.g. if only State pointer are stored but the ordering should be based on the object order.
- Parameters:
-
s1 the State pointer of the object that is asked to be smaller (!=NULL) s2 the State pointer of the object that is asked to be bigger (!=NULL)
- Returns:
- s1->operator <(*s1);
Reimplemented in ell::S_Explicit.
bool ell::S_SG_NPP::operator!= | ( | const State & | state2 | ) | const [virtual] |
bool ell::State::operator< | ( | const State & | state2 | ) | const [inline, virtual, inherited] |
Implements a unique order on states based on their energy and string representation. A state is smaller than another one iff it has smaller energy or it has equal energy and a lexicographically smaller string representation (tie breaker).
This function will be overwritten to achive a better performance than calling getEnergy() and getString().
If the energy function is non-degenerate the string comparison is obsolete.
- Parameters:
-
state2 the State object to compare to
- Returns:
- true if this state is smaller than state2 according to the unique order of the states
Reimplemented in ell::S_LP, ell::S_RNAfe_SingleM, ell::S_RNAfe_SingleM_TB, and ell::S_Explicit.
void ell::S_SG_NPP::operator= | ( | const S_SG_NPP & | sg2 | ) | [virtual] |
Definition at line 61 of file S_SG_NPP.cc.
bool ell::S_SG_NPP::operator== | ( | const State & | state2 | ) | const [virtual] |
std::string & ell::S_SG_Ising::toString | ( | std::string & | toFill | ) | const [virtual, inherited] |
Fills the given string with a specific std::string representation of this State.
- Parameters:
-
toFill the string to overwrite
- Returns:
- the changed toFill in parameter
Implements ell::State.
Definition at line 138 of file S_SG_Ising.cc.
std::string ell::S_SG_Ising::toString | ( | ) | const [virtual, inherited] |
Returns a +- std::string representation of this spin glass array.
Implements ell::State.
Definition at line 133 of file S_SG_Ising.cc.
Uncompresses a compressed sequencce representation into a this State object.
- Parameters:
-
cseq the compressed sequence representation of a state
- Returns:
- this or NULL in error case
Implements ell::State.
Definition at line 298 of file S_SG_Ising.cc.
Uncompresses a compressed sequencce representation into a new State object.
- Parameters:
-
cseq the compressed sequence representation of a state toFill a state object to uncompress too or NULL if a new object has to be created
- Returns:
- new State object that is encoded in cseq or NULL in error case.
Reimplemented from ell::S_SG_Ising.
Definition at line 169 of file S_SG_NPP.cc.
State * ell::S_SG_Ising::undoNeighborChange | ( | const size_t | index, | |
State *const | neigh | |||
) | const [virtual, inherited] |
Undo the changes done to this state to generate the given neighbor. The goal is to do less operations than doing a full copy like (*neigh = *this).
- Parameters:
-
index the neighbor index that was applied last [ 0, getNeighborNumber() ) neigh the state resulting from the last changes ( != NULL)
- Returns:
- the copy of this object via undoing the last changes in neigh
Implements ell::IterableNeighbors.
Definition at line 220 of file S_SG_Ising.cc.
Field Documentation
const std::string ell::S_SG_NPP::ID [static] |
the specific ID string of this class
Reimplemented from ell::S_SG_Ising.
Definition at line 18 of file S_SG_NPP.hh.
SpinArray ell::S_SG_Ising::spin [protected, inherited] |
const S_SG_Ising::SpinType ell::S_SG_Ising::SPIN_DOWN [static, inherited] |
const S_SG_Ising::SpinType ell::S_SG_Ising::SPIN_UP [static, inherited] |
const biu::Alphabet ell::S_SG_Ising::spinAlph [static, protected, inherited] |
double ell::S_SG_NPP::symmShift [protected] |
added to the sum of flipped weights in the energy function to allow for a symmetry breaking
Definition at line 28 of file S_SG_NPP.hh.
const WeightType* ell::S_SG_NPP::weights [protected] |
The documentation for this class was generated from the following files:
- src/ell/spinglass/S_SG_NPP.hh
- src/ell/spinglass/S_SG_NPP.cc