Commit 65d4bce9 authored by Leonardo Solis's avatar Leonardo Solis
Browse files

added first working version in harp2


Former-commit-id: 4b1a6b88
parent 4dfbba66
......@@ -141,10 +141,10 @@ ENABLE_K1 = YES
ENABLE_K2 = YES
ENABLE_K3 = YES
ENABLE_K4 = YES
ENABLE_K5 = YES
ENABLE_K6 = YES
ENABLE_K7 = YES
ENABLE_K8 = YES
ENABLE_K5 = NO
ENABLE_K6 = NO
ENABLE_K7 = NO
ENABLE_K8 = NO
ifeq ($(ENABLE_K1),YES)
K1 =-DENABLE_KERNEL1
......@@ -259,8 +259,8 @@ $(TARGET_DIR)/$(TARGET) : Makefile $(SRCS) $(INCS) $(TARGET_DIR)
# Docking parameters
PDB := 3ptb
NRUN := 10
NEV := 200000
NRUN := 20
NEV := 40000
# Device folder
# Device main kernel name
......@@ -268,6 +268,7 @@ NEV := 200000
DEV_DIRS := device
DEV_SRC := $(DEV_DIRS)/Krnl_GA.cl
BOARD_HARP2 := bdw_fpga_v1.0
#BOARD_HARP2 := a10gx
## Make it all: compilation (host & device) + run emulation
## Notice, it switches automatically to /bin folder
......
......@@ -26,11 +26,12 @@ void Krnl_Conform(
char mode = 0;
ushort cnt = 0; //uint cnt = 0;
char IC_active, GG_active, LS_active;
char IC_active, GG_active, LS_active, Off_active;
bool IC_valid = false;
bool GG_valid = false;
bool LS_valid = false;
char IC_mode, GG_mode, LS_mode = 0;
bool Off_valid = false;
char IC_mode, GG_mode, LS_mode, Off_mode = 0;
float phi, theta, genrotangle;
......@@ -59,10 +60,11 @@ while(active) {
// --------------------------------------------------------------
// Wait for genotypes in channel
// --------------------------------------------------------------
while ((IC_valid == false) && (GG_valid == false) && (LS_valid == false)) {
while ((IC_valid == false) && (GG_valid == false) && (LS_valid == false) && (Off_valid == false)) {
IC_active = read_channel_nb_altera(chan_IC2Conf_active, &IC_valid);
GG_active = read_channel_nb_altera(chan_GG2Conf_active, &GG_valid);
LS_active = read_channel_nb_altera(chan_LS2Conf_active, &LS_valid);
Off_active = read_channel_nb_altera(chan_Off2Conf_active, &Off_valid);
}
if (IC_valid) {
......@@ -100,16 +102,31 @@ while(active) {
for (uchar pipe_cnt=0; pipe_cnt<ACTUAL_GENOTYPE_LENGTH; pipe_cnt++) {
genotype[pipe_cnt] = read_channel_altera(chan_LS2Conf_genotype);}
}
else {
if (Off_valid) {
active = Off_active;
mem_fence(CLK_CHANNEL_MEM_FENCE);
mode = read_channel_altera(chan_Off2Conf_mode);
mem_fence(CLK_CHANNEL_MEM_FENCE);
cnt = read_channel_altera(chan_Off2Conf_cnt);
mem_fence(CLK_CHANNEL_MEM_FENCE);
for (uchar pipe_cnt=0; pipe_cnt<ACTUAL_GENOTYPE_LENGTH; pipe_cnt++) {
genotype[pipe_cnt] = read_channel_altera(chan_Off2Conf_genotype);}
}
}
}
}
IC_valid = false;
GG_valid = false;
LS_valid = false;
Off_valid = false;
IC_active = 0;
GG_active = 0;
LS_active = 0;
Off_active = 0;
#if defined (DEBUG_ACTIVE_KERNEL)
if (active == 0) {printf(" %-20s: %s\n", "Krnl_Conform", "must be disabled");}
......@@ -263,12 +280,15 @@ while(active) {
//////======================================================
//printf("Conform: %u %u\n", active, cnt);
/*
if ((active == 0) && (cnt == (DockConst->pop_size -1))) {
active = 0;
}
else {
active = 1;
}
*/
//////======================================================
// --------------------------------------------------------------
......@@ -277,9 +297,8 @@ while(active) {
write_channel_altera(chan_Conf2Intere_active, active);
write_channel_altera(chan_Conf2Intrae_active, active);
mem_fence(CLK_CHANNEL_MEM_FENCE);
/*
write_channel_altera(chan_Conf2Intere_mode, mode);
*/
write_channel_altera(chan_Conf2Intrae_mode, mode);
mem_fence(CLK_CHANNEL_MEM_FENCE);
......
......@@ -12,16 +12,14 @@
// Buffered channels
// MAX_NUM_OF_ATOMS=90
// ACTUAL_GENOTYPE_LENGTH (MAX_NUM_OF_ROTBONDS+6) =38
/*
channel char chan_GA2IC_active;
channel uint chan_IC2GA_eval_cnt;
channel char chan_GA2GG_active;
channel uint chan_GG2GA_eval_cnt;
channel char chan_GA2LS_active;
channel uint chan_LS2GA_eval_cnt;
*/
// active 1: receiving Kernel is active, 0 receiving Kernel is disabled
// mode 1 for I: init calculation energy, 2 for G: genetic generation, 3 for L: local search
// cnt: population count
......@@ -41,39 +39,43 @@ channel char chan_LS2Conf_mode;
channel ushort chan_LS2Conf_cnt;
channel float chan_LS2Conf_genotype __attribute__((depth(38)));
//channel float chan_Conf2Intere_x __attribute__((depth(90)));
//channel float chan_Conf2Intere_y __attribute__((depth(90)));
//channel float chan_Conf2Intere_z __attribute__((depth(90)));
// To turn off Conform, InterE, IntraE
channel char chan_Off2Conf_active;
channel char chan_Off2Conf_mode;
channel ushort chan_Off2Conf_cnt;
channel float chan_Off2Conf_genotype __attribute__((depth(38)));
channel float3 chan_Conf2Intere_xyz __attribute__((depth(90)));
channel char chan_Conf2Intere_active;
/*
channel char chan_Conf2Intere_mode;
*/
channel ushort chan_Conf2Intere_cnt;
//channel float chan_Conf2Intrae_x __attribute__((depth(90)));
//channel float chan_Conf2Intrae_y __attribute__((depth(90)));
//channel float chan_Conf2Intrae_z __attribute__((depth(90)));
channel float3 chan_Conf2Intrae_xyz __attribute__((depth(90)));
channel char chan_Conf2Intrae_active;
channel char chan_Conf2Intrae_mode;
channel ushort chan_Conf2Intrae_cnt;
channel float chan_Intere2Store_intere;
/*
channel char chan_Intere2Store_active;
channel char chan_Intere2Store_mode;
channel ushort chan_Intere2Store_cnt;
*/
channel float chan_Intrae2Store_intrae;
channel char chan_Intrae2Store_active;
channel char chan_Intrae2Store_mode;
channel ushort chan_Intrae2Store_cnt;
channel float chan_Intere2StoreIC_intere;
channel float chan_Intere2StoreGG_intere;
channel float chan_Intere2StoreLS_intere;
channel float chan_Intere2StoreOff_intere;
//channel char chan_Intere2Store_active;
//channel char chan_Intere2Store_mode;
//channel ushort chan_Intere2Store_cnt;
channel float chan_Intrae2StoreIC_intrae;
channel float chan_Intrae2StoreGG_intrae;
channel float chan_Intrae2StoreLS_intrae;
channel float chan_Intrae2StoreOff_intrae;
//channel char chan_Intrae2Store_active;
//channel char chan_Intrae2Store_mode;
//channel ushort chan_Intrae2Store_cnt;
/*
channel char chan_Store2IC_ack;
channel char chan_Store2GG_ack;
channel float chan_Store2LS_LSenergy;
*/
#include "../defines.h"
......@@ -173,6 +175,9 @@ typedef struct
//#include "auxiliary_performls.cl"
// --------------------------------------------------------------------------
// The function performs a generational genetic algorithm based search
// on the search space.
......@@ -185,8 +190,9 @@ typedef struct
__kernel __attribute__ ((max_global_work_dim(0)))
void Krnl_GA(__global float* restrict GlobPopulationCurrent,
__global float* restrict GlobEnergyCurrent,
__global const float* restrict GlobPopulationNext,
__global const float* restrict GlobEnergyNext,
__global float* restrict GlobPopulationNext,
__global float* restrict GlobEnergyNext,
__global unsigned int* restrict GlobPRNG,
__constant Dockparameters* restrict DockConst,
__global unsigned int* restrict GlobEvalsGenerations_performed
)
......@@ -194,152 +200,513 @@ void Krnl_GA(__global float* restrict GlobPopulationCurrent,
//Print algorithm parameters
#if defined (DEBUG_KRNL_GA)
printf("\nParameters of the genetic algorihtm:\n");
printf("\nLigand num_of_atoms: %u\n", DockConst->num_of_atoms);
printf("Ligand num_of_atypes: %u\n", DockConst->num_of_atypes);
printf("Ligand num_of_intraE_contributors: %u\n", DockConst->num_of_atypes);
printf("Grid size_x: %u\n", DockConst->gridsize_x);
printf("Grid size_y: %u\n", DockConst->gridsize_y);
printf("Grid size_z: %u\n", DockConst->gridsize_z);
printf("Grid spacing: %f\n", DockConst->grid_spacing);
printf("Ligand rotbondlist_length: %u\n", DockConst->rotbondlist_length);
printf("Ligand coeff_elec: %f\n", DockConst->coeff_elec);
printf("Ligand coeff_desolv: %f\n", DockConst->coeff_desolv);
printf("\nnum_of_energy_evals: %u\n", DockConst->num_of_energy_evals);
printf("num_of_generations: %u\n", DockConst->num_of_generations);
printf("Population size: %u\n", DockConst->pop_size);
printf("Number of genes: %u\n", DockConst->num_of_genes);
printf("Tournament rate: %f\n", DockConst->tournament_rate);
printf("Crossover rate: %f\n", DockConst->crossover_rate);
printf("Mutation rate: %f\n", DockConst->mutation_rate);
printf("Maximal delta movement during mutation: +/-%fA\n", DockConst->abs_max_dmov);
printf("maximal delta angle during mutation: +/-%f°\n", DockConst->abs_max_dang);
printf("LS rate: %f\n", DockConst->lsearch_rate);
printf("LS num_of_lsentities: %u\n", DockConst->num_of_lsentities);
printf("LS rho_lower_bound: %f\n", DockConst->rho_lower_bound); //Rho lower bound
printf("LS base_dmov_mul_sqrt3: %f\n", DockConst->base_dmov_mul_sqrt3); //Maximal delta movement during ls
printf("LS base_dang_mul_sqrt3: %f\n", DockConst->base_dang_mul_sqrt3); //Maximal delta angle during ls
printf("LS cons_limit: %u\n", DockConst->cons_limit);
printf("LS max_num_of_iters: %u\n", DockConst->max_num_of_iters);
printf("qasp: %f\n", DockConst->qasp);
printf("\n");
printf("%-40s %u\n", "DockConst->num_of_atoms: ", DockConst->num_of_atoms);
printf("%-40s %u\n", "DockConst->num_of_atypes: ", DockConst->num_of_atypes);
printf("%-40s %u\n", "DockConst->num_of_intraE_contributors: ", DockConst->num_of_intraE_contributors);
printf("%-40s %u\n", "DockConst->gridsize_x: ", DockConst->gridsize_x);
printf("%-40s %u\n", "DockConst->gridsize_y: ", DockConst->gridsize_y);
printf("%-40s %u\n", "DockConst->gridsize_z: ", DockConst->gridsize_z);
printf("%-40s %u\n", "DockConst->g1: ", DockConst->g1);
printf("%-40s %u\n", "DockConst->g2: ", DockConst->g2);
printf("%-40s %u\n", "DockConst->g3: ", DockConst->g3);
printf("%-40s %f\n", "DockConst->grid_spacing: ", DockConst->grid_spacing);
printf("%-40s %u\n", "DockConst->rotbondlist_length: ", DockConst->rotbondlist_length);
printf("%-40s %f\n", "DockConst->coeff_elecc: ", DockConst->coeff_elec);
printf("%-40s %f\n", "DockConst->coeff_desolv: ", DockConst->coeff_desolv);
printf("%-40s %u\n", "DockConst->num_of_energy_evals: ", DockConst->num_of_energy_evals);
printf("%-40s %u\n", "DockConst->num_of_generations: ", DockConst->num_of_generations);
printf("%-40s %u\n", "DockConst->pop_size: ", DockConst->pop_size);
printf("%-40s %u\n", "DockConst->num_of_genes: ", DockConst->num_of_genes);
printf("%-40s %f\n", "DockConst->tournament_rate: ", DockConst->tournament_rate);
printf("%-40s %f\n", "DockConst->crossover_rate: ", DockConst->crossover_rate);
printf("%-40s %f\n", "DockConst->mutation_rate: ", DockConst->mutation_rate);
printf("%-40s +/-%fA\n", "DockConst->abs_max_dmov: ", DockConst->abs_max_dmov);
printf("%-40s +/-%f°\n", "DockConst->abs_max_dang: ", DockConst->abs_max_dang);
printf("%-40s %f\n", "DockConst->lsearch_rate: ", DockConst->lsearch_rate);
printf("%-40s %u\n", "DockConst->num_of_lsentities: ", DockConst->num_of_lsentities);
printf("%-40s %f\n", "DockConst->rho_lower_bound: ", DockConst->rho_lower_bound);
printf("%-40s %f\n", "DockConst->base_dmov_mul_sqrt3: ", DockConst->base_dmov_mul_sqrt3);
printf("%-40s %f\n", "DockConst->base_dang_mul_sqrt3: ", DockConst->base_dang_mul_sqrt3);
printf("%-40s %u\n", "DockConst->cons_limit: ", DockConst->cons_limit);
printf("%-40s %u\n", "DockConst->max_num_of_iters: ", DockConst->max_num_of_iters);
printf("%-40s %f\n", "DockConst->qasp: ", DockConst->qasp);
#endif
uint eval_cnt = 0;
uint generation_cnt = 1;
char active = 1;
char mode = 1;
// IC : Init Calculation
// ------------------------------------------------------------------
// IC: Init Calculation
// ------------------------------------------------------------------
/*
write_channel_altera(chan_GA2IC_active, active);
mem_fence(CLK_CHANNEL_MEM_FENCE);
eval_cnt = read_channel_altera(chan_IC2GA_eval_cnt);
mem_fence(CLK_CHANNEL_MEM_FENCE);
*/
__local float genotype_tx [ACTUAL_GENOTYPE_LENGTH];
__local float energyIE_ICGG_rx [MAX_POPSIZE];
__local float energyIA_ICGG_rx [MAX_POPSIZE];
/*
__local float energyIE_GG_rx [MAX_POPSIZE];
__local float energyIA_GG_rx [MAX_POPSIZE];
*/
/*__local*/ float energyIE_LS_rx;
/*__local*/ float energyIA_LS_rx;
// Send genotype: only (0)
// Send genotype: from (1) to (last-1), receive energy: from (0) to (last-2)
// Receive energy: (last-1)
for (ushort pop_cnt = 0; pop_cnt < DockConst->pop_size+1; pop_cnt++) {
if (pop_cnt < DockConst->pop_size) {
for (uchar pipe_cnt=0; pipe_cnt<ACTUAL_GENOTYPE_LENGTH; pipe_cnt++) {
genotype_tx[pipe_cnt] = GlobPopulationCurrent[pop_cnt*ACTUAL_GENOTYPE_LENGTH + pipe_cnt];
}
write_channel_altera(chan_IC2Conf_active, active);
mem_fence(CLK_CHANNEL_MEM_FENCE);
write_channel_altera(chan_IC2Conf_mode, mode);
mem_fence(CLK_CHANNEL_MEM_FENCE);
write_channel_altera(chan_IC2Conf_cnt, pop_cnt);
mem_fence(CLK_CHANNEL_MEM_FENCE);
for (uchar pipe_cnt=0; pipe_cnt<ACTUAL_GENOTYPE_LENGTH; pipe_cnt++) {
write_channel_altera(chan_IC2Conf_genotype, genotype_tx[pipe_cnt]);
}
#if defined (DEBUG_KRNL_IC)
printf("IC - tx pop: %u", pop_cnt);
#endif
}
if (pop_cnt > 0) {
energyIA_ICGG_rx[pop_cnt-1] = read_channel_altera(chan_Intrae2StoreIC_intrae);
energyIE_ICGG_rx[pop_cnt-1] = read_channel_altera(chan_Intere2StoreIC_intere);
#if defined (DEBUG_KRNL_IC)
printf(", IC - rx pop: %u\n", pop_cnt-1);
#endif
}
} // End of IC for-loop pop_cnt
// Store energies to Current-Energies
for (ushort pop_cnt = 0; pop_cnt < DockConst->pop_size; pop_cnt++) {
GlobEnergyCurrent[pop_cnt] = energyIA_ICGG_rx[pop_cnt] + energyIE_ICGG_rx[pop_cnt];
}
// ------------------------------------------------------------------
bool GG_act = false;
bool GG_done = false;
bool LS_act = false;
bool LS_done = false;
uint array_evals_and_generations_performed [2];
while (active) {
if ((eval_cnt < DockConst->num_of_energy_evals) && (generation_cnt < DockConst->num_of_generations)) {
// ---------------------------
// Temporal storage for GG
// ---------------------------
// Find_best
uint best_entity_id;
__local float loc_energies[MAX_POPSIZE];
if (LS_done == true) {
generation_cnt++;
// Binary tournament
uint parent1, parent2;
float local_entity_1 [ACTUAL_GENOTYPE_LENGTH];
float local_entity_2 [ACTUAL_GENOTYPE_LENGTH];
// Offspring
__local float offspring_genotype [ACTUAL_GENOTYPE_LENGTH];
// ---------------------------
// Temporal storage for LS
// ---------------------------
for (ushort i=0;i<DockConst->pop_size*ACTUAL_GENOTYPE_LENGTH; i++) {
GlobPopulationCurrent[i] = GlobPopulationNext[i];
if (i<DockConst->pop_size) {
GlobEnergyCurrent[i] = GlobEnergyNext[i];
}
}
mem_fence(CLK_GLOBAL_MEM_FENCE); // lvs added during hw evaluation
// read GlobPRNG
uint prng = GlobPRNG[0];
#if defined (DEBUG_KRNL_GA)
printf("eval_cnt: %u, generation_cnt: %u\n", eval_cnt, generation_cnt);
while ((eval_cnt < DockConst->num_of_energy_evals) && (generation_cnt < DockConst->num_of_generations)) {
// ------------------------------------------------------------------
// GG: Genetic Generation
// ------------------------------------------------------------------
active = 1;
mode = 2;
// copy energy to local memory
for (ushort i=0; i<DockConst->pop_size; i++) {
loc_energies[i] = GlobEnergyCurrent[i];
}
// identifying best entity
best_entity_id = find_best(loc_energies, DockConst->pop_size);
// elitism - copying the best entity to new population
for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) {
GlobPopulationNext[i] = GlobPopulationCurrent[best_entity_id*ACTUAL_GENOTYPE_LENGTH+i];
}
GlobEnergyNext[0] = loc_energies[best_entity_id];
/*
// read GlobPRNG
uint prng = GlobPRNG[0];
*/
// Send genotype: only (1)
// Send genotype: from (2) to (last-1), receive energy: from (2) to (last-2)
// Receive energy: (last-1)
for (ushort new_pop_cnt = 1; new_pop_cnt < DockConst->pop_size+1; new_pop_cnt++) {
if (new_pop_cnt < DockConst->pop_size) {
//selecting two individuals randomly
binary_tournament_selection(&prng, loc_energies, &parent1, &parent2,
DockConst->pop_size, DockConst->tournament_rate);
//mating parents
for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) {
local_entity_1[i] = GlobPopulationCurrent[parent1*ACTUAL_GENOTYPE_LENGTH+i];
local_entity_2[i] = GlobPopulationCurrent[parent2*ACTUAL_GENOTYPE_LENGTH+i];
}
// first two args are population [parent1], population [parent2]
gen_new_genotype(&prng, local_entity_1, local_entity_2,
DockConst->mutation_rate,
DockConst->abs_max_dmov,
DockConst->abs_max_dang,
DockConst->crossover_rate,
offspring_genotype);
write_channel_altera(chan_GG2Conf_active, active);
mem_fence(CLK_CHANNEL_MEM_FENCE);
write_channel_altera(chan_GG2Conf_mode, mode);
mem_fence(CLK_CHANNEL_MEM_FENCE);
write_channel_altera(chan_GG2Conf_cnt, new_pop_cnt);
mem_fence(CLK_CHANNEL_MEM_FENCE);
for (uchar pipe_cnt=0; pipe_cnt<ACTUAL_GENOTYPE_LENGTH; pipe_cnt++) {
GlobPopulationNext [new_pop_cnt*ACTUAL_GENOTYPE_LENGTH + pipe_cnt] = offspring_genotype [pipe_cnt];
write_channel_altera(chan_GG2Conf_genotype, offspring_genotype[pipe_cnt]);
}
#if defined (DEBUG_KRNL_GG)
printf("GG - tx pop: %u", new_pop_cnt);
#endif
}
if (new_pop_cnt > 1) {
energyIA_ICGG_rx[new_pop_cnt-1] = read_channel_altera(chan_Intrae2StoreGG_intrae);
energyIE_ICGG_rx[new_pop_cnt-1] = read_channel_altera(chan_Intere2StoreGG_intere);
#if defined (DEBUG_KRNL_GG)
printf(", GG - rx pop: %u\n", new_pop_cnt-1);
#endif
}
} // End of for-loop new_pop_cnt
//active = 1;
GG_act = true;
LS_act = false;
if (GG_done == true) {
/*
// write back to GlobPRNG FIXME FIXME
GlobPRNG[0] = prng;
*/
// store energies to Next-Energies
for (ushort pop_cnt = 0; pop_cnt < DockConst->pop_size; pop_cnt++) {
GlobEnergyNext[pop_cnt] = energyIA_ICGG_rx[pop_cnt] + energyIE_ICGG_rx[pop_cnt];
}
// ------------------------------------------------------------------
// update energy-evaluation count
eval_cnt += DockConst->pop_size;
// ------------------------------------------------------------------
// LS: Local Search
// ------------------------------------------------------------------
active = 1;
mode = 3;
uint entity_for_ls;
//__local float offspring_genotype [ACTUAL_GENOTYPE_LENGTH]; // FIXME defined above
float offspring_energy;
//__local float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH];
float entity_possible_new_genotype [ACTUAL_GENOTYPE_LENGTH];
float candidate_energy;
float genotype_deviate [ACTUAL_GENOTYPE_LENGTH];
float genotype_bias [ACTUAL_GENOTYPE_LENGTH];
float rho = 1.0f;
uint iteration_cnt = 0;
uint cons_succ = 0;
uint cons_fail = 0;
bool positive_direction = true;
bool ls_pass_complete = false;
uint LS_eval = 0;
/*
for (ushort i=0;i<DockConst->pop_size*ACTUAL_GENOTYPE_LENGTH; i++) {
GlobPopulationCurrent[i] = GlobPopulationNext[i];
if (i<DockConst->pop_size) {
GlobEnergyCurrent[i] = GlobEnergyNext[i];
}
}
// read GlobPRNG FIXME FIXME
prng = GlobPRNG[0];
*/
// subject num_of_entity_for_ls pieces of offsprings to LS
for (ushort ls_ent_cnt=0; ls_ent_cnt<DockConst->num_of_lsentities; ls_ent_cnt++) {
// LS
LS_act = true;
// choosing an entity randomly,
// and without checking if it has already been subjected to LS in this cycle
entity_for_ls = myrand_uint(&prng, DockConst->pop_size);
// performing local search
for (uchar i=0; i<ACTUAL_GENOTYPE_LENGTH; i++) {
offspring_genotype [i] = GlobPopulationNext[entity_for_ls*ACTUAL_GENOTYPE_LENGTH + i];
genotype_bias [i] = 0.0f;
}
}
else {
active = 0;
// read energy
offspring_energy = GlobEnergyNext[entity_for_ls];
positive_direction = true;
ls_pass_complete = true;
LS_eval = 0;
//------------------------------------------------------------------------------------------------------------
while ((iteration_cnt < DockConst->max_num_of_iters) && (rho > DockConst->rho_lower_bound)) {
//new random deviate
//rho is the deviation of the uniform distribution
for (uchar i=0; i<3; i++) {
genotype_deviate [i] = rho*DockConst->base_dmov_mul_sqrt3*(2*myrand(&prng)-1);
}
for (uchar i=3; i<DockConst->num_of_genes; i++) {
genotype_deviate [i] = rho*DockConst->base_dang_mul_sqrt3*(2*myrand(&prng)-1);
}
// define genotype values depending on descent direction
if (positive_direction == true) {
for (uchar i=0; i<DockConst->num_of_genes; i++) {
entity_possible_new_genotype[i] = offspring_genotype[i] + genotype_deviate[i] + genotype_bias[i];
}
}
else {
for (uchar i=0; i<DockConst->num_of_genes; i++) {
entity_possible_new_genotype[i] = offspring_genotype[i] - genotype_deviate[i] - genotype_bias[i];
}
}
entity_possible_new_genotype [3] = map_angle_360(entity_possible_new_genotype [3]);
entity_possible_new_genotype [4] = map_angle_180(entity_possible_new_genotype [4]);
for (uchar i=5; i<DockConst->num_of_genes; i++) {
entity_possible_new_genotype [i] = map_angle_360(entity_possible_new_genotype [i]);
}
// calculate energy of genotype
write_channel_altera(chan_LS2Conf_active, active);
mem_fence(CLK_CHANNEL_MEM_FENCE);