• No se han encontrado resultados

Capítulo I: Fundamentos Teóricos sobre el adulto mayor.

Capítulo 2 Análisis de los Resultados Plan de ejercicios de bajo impacto y juegos

2.7 Plan de Juegos Recreativos

The schedule optimisation is performed using a genetic algorithm (GA), a meta-heuristic op- timisation technique that mimics the process of natural selection. The algorithm begins with an initial generation of potential solutions, which are randomly generated, and then iteratively improves the solutions in successive generations until the stopping criteria is reached.

The initial generation consists of the current staff schedule as well as N − 1 random alternative solutions. Alternative solutions are generated by starting with an empty schedule, x = (0, . . . , 0), and randomly distributing the total staff time for each process, hi, across the variables xi,t. This

is done by randomly choosing variables from the set {xi,tkxi,t< min [si, bi, ui,t]} and increasing

these variables by one unit until the total number of staff hours have been assigned.

The solutions in the initial generation are ranked in terms of their fitness values, which are calculated using the objective function. The algorithm then discards the weakest solutions and replaces them with new solutions to form a new generation. These new solutions are called children, because they are generated by combining pairs of parent solutions which are selected from the fittest solutions in the current generation.

The aim of the genetic algorithm is to mimic the process of natural selection by retaining the characteristics of fitter solutions and discarding weaker solutions in each new generation. This procedure consists of three steps: cross-over, mutation and immigration. A detailed explanation of each of these steps is provided below in § 7.4.1-7.4.3 and the stopping criteria for the algorithm is discussed in § 7.4.4

7.4.1 Cross-over

In the cross-over step, M/2 pairs of parent solutions are selected from the current generation and combined to produce M new children. Each pair of parents contains one of the strongest solutions of the current generation, so the fittest M/2 solutions are automatically selected for

crossover. The second parent in each pair is selected from among the remaining solutions in the current generation.

The normal procedure for generating child solutions in the genetic algorithm is to randomly select a set of variables in one parent solution and replace these variables with the corresponding values from the other parent solution. In this case, however, the cross-over operation has to be performed more carefully, since switching a random set of variables from two parent solutions is very likely to produce a child that breaks the constraint on the maximum number of staff-hours. To avoid this problem, the number of staff-hours for each process is fixed by the upper bounds in the optimisation constraints, so that

T

X

t=1

xi,t = hi, with i ∈ I. (7.11)

The cumulative sum of each solution vector is calculated in a new vector of n × T variables,

y = (y1, . . . , yT, . . . , y2×T, . . . , yi×T, . . . , yn×T), where yk = k

X

j=1

xj. (7.12)

If each process has been allocated exactly hi staff hours, then the staff hour constraints can be

re-written as yi×T = i X j=1 hj, with i ∈ I. (7.13)

For each pair of parent solutions, x(1) and x(2), a difference vector is calculated by subtracting

the cumulative sum vectors of the two solutions, i.e.

d = y(1)− y(2)= (d1, . . . , di×T, . . . , dn×T). (7.14)

Sequences of consecutive values (xa, xa+1, . . . , xb) can be transplanted from x(1) into x(2) pro-

vided that db = 0 = da−1, since the total number of staff hours in these sequences is the same in

both parent solutions. Switching sequences of variables that fulfil this condition will not change the overall number of staff hours assigned to each process in either parent solution.

There will always be at least n different sections in each pair of solutions that meet this require- ment, since yk×T(1) = y(2)k×T = k X i=1 hi. (7.15)

There are also likely to be many more points of intersection that occur within these sections, resulting in small sequences of two or three values. To avoid switching two identical sequences of variables, sequences are only switched if there is at least one dc6= 0 for a ≤ c < b.

To illustrate the cross-over process, consider the following two solutions:

x(1)= (2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2) y(1) = (2, 4, 6, 8, 11, 14, 17, 20, 23, 24, 25, 26, 28, 30, 32) x(2)= (1, 2, 2, 3, 4, 2, 2, 2, 2, 2, 3, 3, 2, 2, 0) y(2) = (1, 3, 5, 8, 12, 14, 16, 18, 20, 22, 25, 28, 30, 32, 32)

d = y(1)− y(2) = (1, 1, 1, 0, | {z } z }| { −1, 0, 1, 2, 3, 2, 0, | {z } z }| { −2, −2, −2, 0) x(1) = (2, 2, 2, 2 | {z } ,z}|{3, 3 , 3, 3, 3, 1, 1 | {z } ,z1, 2, 2, 2}| {) x(2)= (1, 2, 2, 3 | {z } ,z}|{4, 2 , 2, 2, 2, 2, 3 | {z } ,z3, 2, 2, 0}| {)

To produce two new children, every second section in each of the parent solutions is replaced by the corresponding section from the other parent.

c(1)= (2, 2, 2, 2 | {z } ,z}|{4, 2 ,3, 3, 3, 1, 1 | {z } ,z3, 2, 2, 0}| {) c(2) = (1, 2, 2, 3 | {z } ,z}|{3, 3 ,2, 2, 2, 2, 3 | {z } ,z1, 2, 2, 2}| {)

It may occur that two parent solutions are very similar and cannot produce more than one distinct sequence of switching variables, so the child solutions would be the same as the two original parents solutions. In this case, a different solution is substituted for the weaker parent until a better match is found.

The major advantage of this cross-over method is that it will always produce feasible children, but it is also beneficial because it can preserve important links between the schedules for different processes in the parent solutions. Strong solutions tend to encourage a steady flow of patients through the system, so the number of staff assigned to each process at a given point in the day is often aligned with the schedules at the previous process. By alternating sections from two parents, this cross-over method avoids significant disruptions to this flow.

7.4.2 Mutation

Once a successful cross-over has been performed, small alterations are made to a certain pro- portion of the child solutions. The probability of a particular solution being mutated is given by the parameter u. Mutations are performed by choosing a random, non-zero variable in the solution and decreasing the value of that variable by 1. Another variable is then selected from the same process and increased by 1 to balance the schedule, for example

c(1)= (2, 2, 2, 2,4, 3, 3, 3, 1, 1, 2,2, 2, 0) −→ c(1∗)= (2, 2, 2, 3,4, 3, 3, 3, 1, 1, 1,2, 2, 0)

If the second variable is already set to the maximum number of staff, new variables are selected until a smaller value is found.

7.4.3 Immigration

After all cross-over and mutation operations have been completed, the final step in this process is to identify any children which are an exact match to other solutions in the current genera- tion. These solutions are discarded and replaced with randomly generated solutions to maintain adequate diversity in the population. After calculating the fitness values for all child solutions, a new generation is formed by replacing the parent solutions in the current generation with the child solutions.

7.4.4 Stopping criteria

The best solution found in each iteration of the genetic algorithm is stored, and its fitness value is compared to the best solutions from all previous generations. The algorithm is terminated when there is no improvement in the best solution for ten consecutive generations.

Documento similar