## 3 Materials and Methods
### Genetic Algorithm  
First, we explain the basics of the genetic algorithm. GA starts with an initial set of random solutions for the problem under consideration. This set of solutions is known as the population. The individuals of the population are called chromosomes, and its representation is called encoding. The chromosomes of the population are evaluated according to a pre-defined fitness function. The chromosomes evolve through successive iterations called 'generations'. During each generation, through merging and modifying chromosomes of a given population, a new population is created. Merging chromosomes is known as 'crossover', while modifying an existing one is known as'mutation'. Crossover is the process in which the chromosomes are combined in a random fashion to produce a pair of new chromosomes (offspring). A mutation operator is used to expose unexpected changes in the values of genes. The selection of chromosomes to crossover and mutate is based on their fitness function. At each generation, a new population is created by applying the crossover and mutation operators. The process is repeated until a specific stopping criterion is reached [30]. The steps of genetic algorithm implemented to the OPC layout optimization is presented below:  
1. Encoding: An encoding scheme maps feasible solutions of the problem to the strings [31]. Encoding should be such that the minor changes in the chromosomes (individuals) translate into minor changes in corresponding solution. In this layout optimization permutation encoding is used to represent the department order. First row indicates the room numbers and the second row indicates the departments like registration, vision, refraction etc. Together, it is called chromosome, as the entries are referred as genes and we use integers 1, 2,..., 12 (to avoid confusion they are referred as locations L1, L2,..., L12 in explanation) for departments D1--D12. New registration--D1, Review Registration--D2, Vision--D3, Refraction--D4, D5, D6, D7, D8, Tension--D9 and Preliminary test and final examination--D10, D11, D12. This is implemented as a vector and is shown in Figure 2.
2. Initial population generation: The initial population is selected between 1.5 to 2 times the number of genes. As the number of genes is n =12, we use population size = 2 \(\times\) 12 = 24. Selection: Five individual parents (design) are generated randomly. A fitness function is calculated, and its value with associated parent is stored. The individual is arranged in descending order of fitness value. The first two individuals are selected as parents to apply cross over operator to generate offsprings. 4. Fitness function: The cycle time of the patient in the OPC also depends on the travel time between locations. Thus, the fitness function depends on the distance between the locations. When distance gets converted to the time, it contributes to the cycle time. In this study, optimization function is the same as fitness function, and it minimizes the cycle time. But we measure the Fitness value as the ratio of waiting time to the cycle time. The population is evaluated with this fitness function and the best two chromosomes are selected. These form parent1 and parent2. 5. Crossover and mutation: The first two rooms are at the entrance of the building, and they are currently allocated to new registration and review registration. These are left untouched. Room numbers remain same; only department numbers are exchanged. A sample vector shown in Figure 2 is repeated in Figure 3a for explaining algorithmic steps. First, the parent genes (3-12) are shuffled, and then single point swapped crossover is applied to get the offspring (Figure 3b). The colored part shows the change in the genes or department numbers. Crossover rates between 0.3 to 0.6 were used. We use swap mutation for next generation and the objective function is evaluated again. The swap mutation is shown in Figure 3c. Mutation rate was 0.08(1/n = 1/12). When the number of generations got completed, the algorithm was stopped.