14 #define FITNESS_MIN -1E9 16 #ifndef SOLUTION_SOURCE_CODE 17 #define SOLUTION_INLINE inline 19 #define SOLUTION_INLINE extern inline 43 int chainSize = hpSize - 1;
64 int nMovements = hpSize - 1;
71 for(i = 0; i < nMovements; i++)
90 int chainSize = hpSize - 1;
100 char distance = elem2 - (char) elem1;
103 double aux =
drandom_x() * (double) distance;
106 char delta = (char) round(aux);
120 if(sol.
fitness < (FITNESS_MIN + 0.1)){
Holds the opaque structure Solution, which shouldn't be modified by files other than solution files...
RANDOM_INLINE double drandom_x()
Returns a random double within [0,1)
Definition: random.h:18
Public header file with routines for calculating the fitness of a protein represented as a chain of r...
SOLUTION_INLINE void Solution_inc_idle_iterations(Solution *sol)
Increments the number of idle solutions of the given solution.
Definition: solution.h:143
SOLUTION_INLINE int Solution_idle_iterations(Solution sol)
Returns the number of iterations through which the solution didn't improve.
Definition: solution.h:137
SOLUTION_INLINE Solution Solution_copy(Solution sol, int hpSize)
Returns a deep copy (all memory recursively duplicated) of the given solution.
Definition: solution.h:38
int idle_iterations
Number of iterations through which the food didn't improve.
Definition: solution_structure_private.h:8
double fitness
Fitness of such solution.
Definition: solution_structure_private.h:7
SOLUTION_INLINE void Solution_set_fitness(Solution *sol, double fitness)
Sets the fitness of a solution.
Definition: solution.h:129
SOLUTION_INLINE Solution Solution_blank(int hpSize)
Returns a Solution whose fields are all uninitialized, but with due memory allocated.
Definition: solution.h:28
MovElem * chain
Position of such solution.
Definition: solution_structure_private.h:6
MOVELEM_INLINE MovElem MovElem_random()
Returns a uniformly random MovElem.
Definition: movelem.h:50
MOVELEM_INLINE unsigned char MovElem_to_number(MovElem elem)
Convert a MovElem to a number.
Definition: movelem.h:70
RANDOM_INLINE unsigned int urandom_max(unsigned int max)
Returns an unsigned integer within [0,max)
Definition: random.h:24
MOVELEM_INLINE MovElem MovElem_from_number(unsigned char num)
Convert a number to MovElem.
Definition: movelem.h:80
SOLUTION_INLINE void Solution_free(Solution sol)
Frees memory allocated for given solution.
Definition: solution.h:53
SOLUTION_INLINE const MovElem * Solution_chain(Solution sol)
Returns the MovChain of the given solution.
Definition: solution.h:152
unsigned char MovElem
Type that holds 2 movements, one for the backbone and one for the side chain.
Definition: movelem.h:21
SOLUTION_INLINE double Solution_fitness(Solution sol)
Returns the fitness of the given solution, calculating it only if needed.
Definition: solution.h:119
Encapsulates a solution, which is a protein conformation that is developed by a bee.
Definition: solution_structure_private.h:5
Routines for manipulating MovElem units, which represent relative movements within a protein...
SOLUTION_INLINE Solution Solution_perturb_relative(Solution perturb, Solution other, int hpSize)
Chooses a random element ELEM1 in 'perturb'.
Definition: solution.h:89
SOLUTION_INLINE Solution Solution_random(int hpSize)
Returns a Solution whose movement chain is uniformly random.
Definition: solution.h:62
Routines for random number generation.