ElfPSP_AntColony
Protein Structure Prediction using Ant Colony Optimization
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ACOSolution Class Reference

Encapsulates a solution that is built by an ant. More...

#include <acosolution.h>

Public Member Functions

 ACOSolution ()
 Default constructor; starts as an empty solution. More...
 
 ACOSolution (std::vector< char > &directions)
 Constructs a solution from a vector of directions. More...
 
vec3< int > bead (unsigned int i)
 Gets an specific bead. More...
 
char direction (unsigned int i)
 Gets an specific direction. More...
 
vec3< int > previous_direction () const
 Returns the relative direction between the last 2 beads. More...
 
int count_contacts (const HPChain &chain) const
 Returns the number of H-H contacts within the solution. More...
 
void perturb_one (std::mt19937 &dRandGen)
 The solution has a vector of N directions, this procedure chooses a random direction and randomizes it. More...
 
bool has_error ()
 Returns current error state. More...
 
void set_error ()
 Sets error to signalize existence of an error. More...
 
void clear_error ()
 Clears the internal error state. More...
 
std::vector< vec3< int > > & vector ()
 Vector of bead coordinates. More...
 
const std::vector< vec3< int > > & vector () const
 Vector of bead coordinates. More...
 
std::vector< char > & directions ()
 Vector of directions taken by the ant. More...
 
const std::vector< char > & directions () const
 Vector of directions taken by the ant. More...
 

Static Public Member Functions

static const char DIR_TO_CHAR (char d)
 Maps directions to characters U, D, L, R, F. More...
 
static vec3< int > DIRECTION_VECTOR (vec3< int > prevDirection, char dir)
 Given a previous direction and a relative direction, returns the corresponding delta vector. More...
 

Static Public Attributes

static const char UP = 0
 Static constants representing relative directions. More...
 
static const char DOWN = 1
 Relative direction. More...
 
static const char LEFT = 2
 Relative direction. More...
 
static const char RIGHT = 3
 Relative direction. More...
 
static const char FRONT = 4
 Relative direction. More...
 

Private Attributes

std::vector< vec3< int > > dVector
 Vector of bead coordinates. More...
 
std::vector< char > dDirections
 Vector of directions taken by the ant. More...
 
bool dError
 May be used to indicate errors. More...
 

Detailed Description

Encapsulates a solution that is built by an ant.

A solution is thus a vector of coordinates of the beads of a protein.

Constructor & Destructor Documentation

◆ ACOSolution() [1/2]

ACOSolution::ACOSolution ( )
inline

Default constructor; starts as an empty solution.

◆ ACOSolution() [2/2]

ACOSolution::ACOSolution ( std::vector< char > &  directions)
inline

Constructs a solution from a vector of directions.

Member Function Documentation

◆ bead()

vec3<int> ACOSolution::bead ( unsigned int  i)
inline

Gets an specific bead.

◆ clear_error()

void ACOSolution::clear_error ( )
inline

Clears the internal error state.

◆ count_contacts()

int ACOSolution::count_contacts ( const HPChain chain) const
inline

Returns the number of H-H contacts within the solution.

Parameters
chainThe HPChain of the protein that this ACOSolution represents.

◆ DIR_TO_CHAR()

const char ACOSolution::DIR_TO_CHAR ( char  d)
inlinestatic

Maps directions to characters U, D, L, R, F.

DIR_TO_CHAR(0) yields 'U'.

◆ direction()

char ACOSolution::direction ( unsigned int  i)
inline

Gets an specific direction.

◆ DIRECTION_VECTOR()

vec3< int > ACOSolution::DIRECTION_VECTOR ( vec3< int >  prevDirection,
char  dir 
)
inlinestatic

Given a previous direction and a relative direction, returns the corresponding delta vector.

Say we have a sequence of beads b1 and b2, each with their own coordinates, and that we want to add a new bead b3 whose relative direction is D from b2 and b1. In this case, the previous direction is (b2 - b1). This function thus returns the delta vector that should be added to bead b2 in order to obtain b3. That is, b3 = (b2 + delta), where delta is the result of this function.

Parameters
prevDirectiondirection built from the previous 2 beads as (b2 - b1).
dirrelative direction to follow, starting from the given previous direction.
Returns
the delta direction such that (b2 + delta) is the position of the next bead (say, b3)

◆ directions() [1/2]

std::vector<char>& ACOSolution::directions ( )
inline

Vector of directions taken by the ant.

◆ directions() [2/2]

const std::vector<char>& ACOSolution::directions ( ) const
inline

Vector of directions taken by the ant.

◆ has_error()

bool ACOSolution::has_error ( )
inline

Returns current error state.

◆ perturb_one()

void ACOSolution::perturb_one ( std::mt19937 &  dRandGen)
inline

The solution has a vector of N directions, this procedure chooses a random direction and randomizes it.

After randomizing it, the internal bead coordinates are also recalculated.

◆ previous_direction()

vec3< int > ACOSolution::previous_direction ( ) const
inline

Returns the relative direction between the last 2 beads.

Returns
(b2 - b1) where b2 is the last bead and b1 is the second last bead.

◆ set_error()

void ACOSolution::set_error ( )
inline

Sets error to signalize existence of an error.

◆ vector() [1/2]

std::vector<vec3<int> >& ACOSolution::vector ( )
inline

Vector of bead coordinates.

◆ vector() [2/2]

const std::vector<vec3<int> >& ACOSolution::vector ( ) const
inline

Vector of bead coordinates.

Member Data Documentation

◆ dDirections

std::vector<char> ACOSolution::dDirections
private

Vector of directions taken by the ant.

◆ dError

bool ACOSolution::dError
private

May be used to indicate errors.

◆ DOWN

const char ACOSolution::DOWN = 1
static

Relative direction.

◆ dVector

std::vector<vec3<int> > ACOSolution::dVector
private

Vector of bead coordinates.

◆ FRONT

const char ACOSolution::FRONT = 4
static

Relative direction.

◆ LEFT

const char ACOSolution::LEFT = 2
static

Relative direction.

◆ RIGHT

const char ACOSolution::RIGHT = 3
static

Relative direction.

◆ UP

const char ACOSolution::UP = 0
static

Static constants representing relative directions.

Relative direction.


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