ElfPSP_AntColony
Protein Structure Prediction using Ant Colony Optimization
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CUDAThread Struct Reference

Holds data needed by each CUDA thread to execute its work. More...

Public Member Functions

__device__ void solution_from_directions (int3 *solution, char *directions)
 Given a vector of relative directions, returns a vector of coordinates generated by these directions. More...
 
__device__ void local_search (int &solContact, int lsFreq)
 Performs local search in the thread's own solution, replacing mySolution if a better solution is found. More...
 
__device__ double & pheromone (int i, int d)
 Getter for individual pheromones. More...
 
__device__ int calculate_contacts (int3 *solution)
 Counts contacts within the given solution. More...
 
__device__ void get_heuristics (int curSize, int3 *solution, double *heurs, int3 *possiblePos)
 Calculates the heuristic value for the step being decided. More...
 
__device__ void get_probabilities (int movIndex, double *probs, double *heurs)
 Calculates probability of following each of the 5 directions. More...
 
__device__ void develop_solution (int3 *solution, char *directions)
 Simulates the behavior of an ant walking through the pheromone matrix, developing a solution. More...
 

Static Public Member Functions

static __device__ int3 DIRECTION_VECTOR (int3 prevDir, char dir)
 Returns the vector obtained by following the vector 'prevDir' and turning to direction 'dir'. More...
 

Public Attributes

int tid
 Unique identifier for the thread within all blocks (the grid). More...
 
int randNumber
 Random number that also serves as the seed for generation. More...
 
int3 * mySolution
 Memory region containing coordinates of the solution this thread is developing. More...
 
int3 * myOtherSolution
 Memory region that the thread uses for performing local seach (small perturbation) on mySolution. More...
 
char * myDirections
 Memory containing relative directions for mySolution. More...
 
char * myOtherDirections
 Memory containing relative directions for myOtherSolution. More...
 
double * pheromones
 Pointer to the pheromone matrix (shared by all threads). More...
 
char * hpChain
 hpChain of the protein being predicted (shared by all threads). More...
 
int nCoords
 Number of coordinates of the protein. More...
 
int nMovElems
 Number of directions of the protein. More...
 
double dAlpha
 Alpha parameter of the ACO algorithm. More...
 
double dBeta
 Beta parameter of the ACO algorithm. More...
 

Detailed Description

Holds data needed by each CUDA thread to execute its work.

We associate device functions with this structure, which makes access to this struct's data by a thread much easier.

Member Function Documentation

◆ calculate_contacts()

__device__ int CUDAThread::calculate_contacts ( int3 *  solution)

Counts contacts within the given solution.

Returns
Number of contacts within the given solution, or -1 if the solution is invalid, that is, it contains a collision.

◆ develop_solution()

__device__ void CUDAThread::develop_solution ( int3 *  solution,
char *  directions 
)

Simulates the behavior of an ant walking through the pheromone matrix, developing a solution.

Parameters
[out]solutionOutput memory region in which to store the solution coordinates.
[out]directionsOutput memory region in which to store the solution directions.

◆ DIRECTION_VECTOR()

__device__ int3 CUDAThread::DIRECTION_VECTOR ( int3  prevDir,
char  dir 
)
static

Returns the vector obtained by following the vector 'prevDir' and turning to direction 'dir'.

◆ get_heuristics()

__device__ void CUDAThread::get_heuristics ( int  curSize,
int3 *  solution,
double *  heurs,
int3 *  possiblePos 
)

Calculates the heuristic value for the step being decided.

Parameters
curSizeNumber of coordinates that have already been decided. should correspond to the number of valid coordinates in the given solution.
solutionMemory region containing the coordinates being decided.
[out]heursOutput array of 5 doubles where we store heuristic values for each direction.
possiblePosArray of the 5 possible positions that result by following each of the 5 directions in the current solution.

◆ get_probabilities()

__device__ void CUDAThread::get_probabilities ( int  movIndex,
double *  probs,
double *  heurs 
)

Calculates probability of following each of the 5 directions.

Parameters
movIndexIndex of the direction being decided.
[out]probsOutput array with 5 doubles where we store the probability of following each of the 5 directions.
heursArray with the 5 heuristic values of each possible direction.

◆ local_search()

__device__ void CUDAThread::local_search ( int &  solContact,
int  lsFreq 
)

Performs local search in the thread's own solution, replacing mySolution if a better solution is found.

Parameters
[out]solContactOutput argument where we store the highest number of contacts found.
lsFreqLocal search frequency, which defines the number of perturbations to generate.

◆ pheromone()

__device__ double & CUDAThread::pheromone ( int  i,
int  d 
)

Getter for individual pheromones.

Parameters
iThe index of relative direction that is currently being decided.
dThe relative direction in [0-4] that is being considered.

◆ solution_from_directions()

__device__ void CUDAThread::solution_from_directions ( int3 *  solution,
char *  directions 
)

Given a vector of relative directions, returns a vector of coordinates generated by these directions.

Parameters
solutionMemory region where we should store the resulting solution.
directionsMemory region containing the directions.

Member Data Documentation

◆ dAlpha

double CUDAThread::dAlpha

Alpha parameter of the ACO algorithm.

◆ dBeta

double CUDAThread::dBeta

Beta parameter of the ACO algorithm.

◆ hpChain

char* CUDAThread::hpChain

hpChain of the protein being predicted (shared by all threads).

◆ myDirections

char* CUDAThread::myDirections

Memory containing relative directions for mySolution.

◆ myOtherDirections

char* CUDAThread::myOtherDirections

Memory containing relative directions for myOtherSolution.

◆ myOtherSolution

int3* CUDAThread::myOtherSolution

Memory region that the thread uses for performing local seach (small perturbation) on mySolution.

◆ mySolution

int3* CUDAThread::mySolution

Memory region containing coordinates of the solution this thread is developing.

◆ nCoords

int CUDAThread::nCoords

Number of coordinates of the protein.

◆ nMovElems

int CUDAThread::nMovElems

Number of directions of the protein.

◆ pheromones

double* CUDAThread::pheromones

Pointer to the pheromone matrix (shared by all threads).

◆ randNumber

int CUDAThread::randNumber

Random number that also serves as the seed for generation.

◆ tid

int CUDAThread::tid

Unique identifier for the thread within all blocks (the grid).


The documentation for this struct was generated from the following files: