Empirical
Public Member Functions | List of all members
emp::NKLandscape Class Reference

#include <NK.h>

Public Member Functions

 NKLandscape ()
 
 NKLandscape (const NKLandscape &)=default
 
 NKLandscape (NKLandscape &&)=default
 
 NKLandscape (size_t _N, size_t _K, emp::Random &random)
 
 ~NKLandscape ()
 
NKLandscapeoperator= (const NKLandscape &)=delete
 
NKLandscapeoperator= (NKLandscape &&)=default
 
void Reset (emp::Random &random)
 Randomize the landscape without changing the landscape size. More...
 
void Config (size_t _N, size_t _K, emp::Random &random)
 Configure for new values of N and K. More...
 
size_t GetN () const
 Returns N. More...
 
size_t GetK () const
 Returns K. More...
 
size_t GetStateCount () const
 Get the number of posssible states for a given site. More...
 
size_t GetTotalCount () const
 
double GetFitness (size_t n, size_t state) const
 
double GetFitness (std::vector< size_t > states) const
 Get the fitness of a whole bitstring. More...
 
double GetFitness (BitVector genome) const
 Get the fitness of a whole bitstring (pass by value so can be modified.) More...
 
void SetState (size_t n, size_t state, double in_fit)
 
void RandomizeStates (Random &random, size_t num_states=1)
 

Detailed Description

An NK Landscape is a popular tool for studying theoretical questions about evolutionary dynamics. It is a randomly generated fitness landscape on which bitstrings can evolve. NK Landscapes have two parameters: N (the length of the bitstrings) and K (epistasis). Since you have control over the amount of epistasis, NK Landscapes are often called "tunably rugged" - a useful feature, since the ruggedness of the fitness landscape is thought to be important to many evolutionary dynamics. For each possible value that a site and its K neighbors to the right can have, a random fitness contribution is chosen. These contributions are summed across the bitstring. So when K = 0, each site has a single optimal value, resulting in a single smooth fitness peak.

For more information, see Kauffman and Levin, 1987 (Towards a general theory of adaptive walks on rugged landscapes).

This object handles generating and maintaining an NK fitness landscape. Note: Overly large Ns and Ks currently trigger a seg-fault, caused by trying to build a table that is larger than will fit in memory. If you are using small values for N and K, you can get better performance by using an NKLandscapeConst instead.

Constructor & Destructor Documentation

emp::NKLandscape::NKLandscape ( )
inline
emp::NKLandscape::NKLandscape ( const NKLandscape )
default
emp::NKLandscape::NKLandscape ( NKLandscape &&  )
default
emp::NKLandscape::NKLandscape ( size_t  _N,
size_t  _K,
emp::Random random 
)
inline

N is the length of bitstrings in your population, K is the number of neighboring sites the affect the fitness contribution of each site (i.e. epistasis or ruggedness), random is the random number generator to use to generate this landscape.

emp::NKLandscape::~NKLandscape ( )
inline

Member Function Documentation

void emp::NKLandscape::Config ( size_t  _N,
size_t  _K,
emp::Random random 
)
inline

Configure for new values of N and K.

double emp::NKLandscape::GetFitness ( size_t  n,
size_t  state 
) const
inline

Get the fitness contribution of position [n] when it (and its K neighbors) have the value [state]

double emp::NKLandscape::GetFitness ( std::vector< size_t >  states) const
inline

Get the fitness of a whole bitstring.

double emp::NKLandscape::GetFitness ( BitVector  genome) const
inline

Get the fitness of a whole bitstring (pass by value so can be modified.)

size_t emp::NKLandscape::GetK ( ) const
inline

Returns K.

size_t emp::NKLandscape::GetN ( ) const
inline

Returns N.

size_t emp::NKLandscape::GetStateCount ( ) const
inline

Get the number of posssible states for a given site.

size_t emp::NKLandscape::GetTotalCount ( ) const
inline

Get the total number of states possible in the landscape (i.e. the number of different fitness contributions in the table)

NKLandscape& emp::NKLandscape::operator= ( const NKLandscape )
delete
NKLandscape& emp::NKLandscape::operator= ( NKLandscape &&  )
default
void emp::NKLandscape::RandomizeStates ( Random random,
size_t  num_states = 1 
)
inline
void emp::NKLandscape::Reset ( emp::Random random)
inline

Randomize the landscape without changing the landscape size.

void emp::NKLandscape::SetState ( size_t  n,
size_t  state,
double  in_fit 
)
inline

The documentation for this class was generated from the following file: