research papers\(\def\hfill{\hskip 5em}\def\hfil{\hskip 3em}\def\eqno#1{\hfil {#1}}\)

Journal logoJOURNAL OF
SYNCHROTRON
RADIATION
ISSN: 1600-5775

General method for automatic on-line beamline optimization based on genetic algorithm

CROSSMARK_Color_square_no_text.svg

aInstitute of Chemical and Engineering Sciences, A*STAR, 1 Pesek Road, Jurong Island, Singapore 627833
*Correspondence e-mail: du_yonghua@ices.a-star.edu.sg

Edited by P. Coppens, State University of New York at Buffalo, USA (Received 10 October 2014; accepted 28 January 2015; online 2 April 2015)

It is essential but inconvenient to perform high-quality on-line optimization for synchrotron radiation beamlines. Usually, synchrotron radiation beamlines are optimized manually, which is time-consuming and difficult to obtain global optimization for all optical elements of the beamline. In this contribution a general method based on the genetic algorithm for automatic beamline optimization is introduced. This method can optimize all optical components of any beamline simultaneously and efficiently. To test this method, a program developed using LabVIEW is examined at the XAFCA beamline of the Singapore Synchrotron Light Source to optimize the beam flux at the sample position. The results demonstrate that the beamline can be optimized within 17 generations even when the initial flux is as low as 4% of its maximum value.

1. Introduction

Maintaining a synchrotron radiation beamline under optimal conditions, to maximize its potential in scientific research, is a challenging and time-consuming task. A slight change in the position of any optical element may result in a large fluctuation of flux or beam position at the sample position due to the low divergence of the synchrotron radiation beam, especially in the third- and fourth-generation synchrotron radiation facilities. For example, when switching mirrors and/or crystals of a beamline in order to cover different energy ranges, the relevant optical elements often require re-optimization; otherwise, the flux may decline significantly. Thermal slope errors of mirrors and/or crystals may affect the emergent angle between the beam and these optical elements (Lenardi et al., 1989[Lenardi, C., Vecile, C. R., Vitali, R. & Rosei, R. (1989). Rev. Sci. Instrum. 60, 1969.]; Zhang et al., 2013[Zhang, L., Sánchez del Río, M., Monaco, G., Detlefs, C., Roth, T., Chumakov, A. I. & Glatzel, P. (2013). J. Synchrotron Rad. 20, 567-580.]), which results in beam position shift and a lesser beam flux at the sample position. Thus, in these situations it is necessary to re-optimize the beamline. Usually, the beamline optimization work is performed manually which is time-consuming even for experienced scientists. Moreover, the coupling among optical elements makes it even more difficult to find the global optimization for each of them. Therefore, a method which can efficiently find the global optimum of a synchrotron radiation beamline is highly desired.

Several attempts for automatic beamline optimization have been carried out. In 1995, an adaptive controller, using a linguistic control scheme, was developed by Roberto Pugliese et al. (Pugliese & Poboni, 1995[Pugliese, R. & Poboni, R. (1995). Proceedings of ICALEPCS'95, Chicago, IL, USA.]; Svensson & Pugliese, 1998[Svensson, S. O. & Pugliese, R. (1998). Proc. SPIE, 85, 3455.]). This method is based on fuzzy logic, which is highly dependent on the operating experience and cannot ensure the global optimum of the beamline. The other optimization strategy is the wavefront analysis method (Hignette et al., 1997[Hignette, O., Freund, A. K. & Chinchio, E. (1997). Proc. SPIE, 3152, 188.], 2001[Hignette, O., Rostaing, G., Cloetens, P. & Ludwig, W. (2001). Proc. SPIE, 4499, 105.]; Arzt et al., 2005[Arzt, S., Beteva, A., Cipriani, F., Delageniere, S., Felisaz, F., Förstner, G., Gordon, E., Launer, L., Lavault, B., Leonard, G., Mairs, T., McCarthy, A., McCarthy, J., McSweeney, S., Meyer, J., Mitchell, E., Monaco, S., Nurizzo, D., Ravelli, R., Rey, V., Shepard, W., Spruce, D., Svensson, O. & Theveneau, P. (2005). Prog. Biophys. Mol. Biol. 89, 124-152.]). While using this method, the optical components have to be adjusted one by one, which cannot ensure the global optimum either.

In this contribution, an automatic beamline optimization method based on the genetic algorithm (GA) is introduced, which can optimize all optical elements of a beamline simultaneously and efficiently. GA is a global optimization algorithm which ensures the final results are globally optimized. Moreover, for a subjective function to be optimized by the GA, its gradient information and mathematical model are not required. The only necessary information is the output corresponding to a certain input. These facts lead to the conclusion that a GA-based optimization can be performed at any beamline with any kind of optical components. Fundamental knowledge of the GA is introduced in §2[link], while §3[link] introduces how the automatic beamline GA-based optimization was realised. In §4[link] the empirical results of optimizing the flux at the sample position of the XAFCA beamline of the Singapore Synchrotron Light Source (Du et al., 2015[Du, Y., Zhu, Y., Xi, S., Yang, P., Moser, H. O., Breese, M. B. H. & Borgna, A. (2015). J. Synchrotron Rad. 22, 839-843.]) are outlined.

2. Genetic algorithm

In 1975, the GA was introduced as a computational analogy, simulating the main process of natural selection based on Darwin's theory of evolution, to solve optimization and search problems (Holland, 1975[Holland, J. H. (1975). Adaptation in Natural and Artificial Systems. The University of Michigan Press.]). Fig. 1[link] shows the main components and genetic operators in a GA. As shown in Fig. 1(a)[link], a possible value of each variable for an objective function is regarded as a gene; a set of genes of the whole variables is denoted as a chromosome, which is also referred to as an individual in the GA; a group of individuals is called a population, which is a collection of candidate solutions. The number of individuals in a population is called population size, which is denoted as N. For a certain individual, the value of the objective function is called the fitness of this individual. Fig. 1(b)[link] shows the four genetic operators of a typical evolution cycle:

[Figure 1]
Figure 1
(a) Main components and (b) genetic operators in a GA.

EVALUATE: the fitness of each individual is calculated.

SELECT: according to the principle of `survival of the fittest', the individuals with better fitness are picked out to generate the next-generation population. The selected individuals are called parents.

CROSSOVER: two selected individuals mate, through exchanging part of their genes, with a certain probability denoted as Pc. The individuals generated by this operator are called offspring.

MUTATE: the offspring's genes are modified randomly, with a certain probability denoted as Pm.

In the GA, a population evolves towards a better population through selection, crossover and mutation, which is analogous to biological evolution. In INITIALIZE, the first generation of the population, i.e. the initial population, is generated randomly. The initial population will then start its evolution cycles. For each generation, all individuals are EVALUATED first. Then, the better individuals will be SELECTED and generate their offspring through CROSSOVER. Each offspring will then MUTATE. The mutated offspring will form a new population and go to the next evolution cycle until the termination criteria are satisfied. When the termination criteria are satisfied, the best individual of the last generation will be regarded as the solution of the problem.

3. Framework for beamline optimization using the GA

The beamline optimization task can be defined as finding the minimum or maximum values of the objective function, subject to the given constraints:

[\eqalign{{\rm{Objective\,\,function\!:}}\,\,\,\,&g=f(x_1,x_2,x_3,\ldots,x_m), \cr {\rm{Constraints\!\!:}}\,\,\,\,&a_i \le x_i \le bi, \quad 1 \le i \le m,\cr & g \ge 0,}]

where xi represents the position of the ith stepper motor (SM), m represents the number of SMs. [ai, bi] with 1 ≤ im is called search space. The value of xi can be obtained and adjusted by a beamline control system, while g is the objective function. It may depend on several of the beamline parameters, for example flux, resolution power, spot shape and position. In this section we introduce the framework of the GA-based beam flux optimization. So the function value of g can be obtained by reading the ionization chamber (IC0) before the sample. In this case: xi corresponds to a gene; a set of candidate values of (x1, x2, x3,…, xm) corresponds to an individual (chromosome); the function value f(x1, x2, x3,…, xm) corresponds to the fitness of individual (x1, x2, x3,…, xm).

Further details of the procedure of flux optimization in a beamline based on the GA are outlined in Fig. 2[link]. This mainly consists of seven modules, i.e. INITIALIZE POPULATION, RUN SMs & READ IC0, ALL INDIVIDUALS EVALUATED, TERMINATION CRITERIA, SELECT, CROSSOVER, MUTATE. Basic details of these modules are outlined by the following six steps:

[Figure 2]
Figure 2
Flow chart of a GA-based beamline optimization.

Step 1. INITIALIZE POPULATION. This step generates N − 1 sets of random values of (x1, x2, x3,…, xm) in the search space, i.e. N − 1 individuals. In this work, the set of the initial positions of SMs is regarded as the initial individual. The N − 1 randomly generated individuals and the initial individual compose the first generation.

Step 2. RUN the SMs to the positions corresponding to the ith individual, and then READ the output of the IC0, which will be regarded as the fitness of the ith individual. Repeat this process until all of the individuals are evaluated. This step is for evaluation. In order to improve the efficiency of the algorithm, the IC0 keeps recording the value of flux during the SMs running. The positions of SMs corresponding to the largest reading will be regarded as a new individual, which will then replace the current individual. This largest reading will now replace the fitness of the current individual. This step is different from the traditional GA and leads to a higher efficiency. We named this the `Observer Mode for Evolutionary Algorithm' (OMEA). Further discussion about OMEA will be shown in another paper.

Step 3. Judge whether the TERMINATION CRITERIA are met or not. Stop the optimization if it is true; otherwise proceed towards the next step. Here, the TERMINATION CRITERIA can be: the best individual of each generation reaches a plateau which means that successive iterations no longer produce better results and the fitness of the best individual exceeds a certain threshold value.

Step 4. SELECT N/2 couples individuals from the whole population, according to the principle of `survival of the fittest'. It will ensure that the better individuals have more chance of passing on their gene to the next generation. There are various methods to select the better individuals, such as roulette wheel selection, Boltzmann selection, tournament selection, rank selection, steady state selection and so on (James, 1985[James, E. B. (1985). Proceeding of an International Conference on Genetic Algorithms and Their Applications, pp. 100-111.]; David & Kalyanmoy, 1991[David, E. G. & Kalyanmoy, D. (1991). Foundations of Genetic Algorithms, edited by G. J. E. Rawlins, pp. 69-93. Los Altos: Morgan Kaufmann.]; Chang, 2003[Chang, Y. L. (2003). IEEE Trans. Systems Man Cybernetics B, 33, 138-149.]). In our case, the roulette wheel selection method was chosen. In roulette wheel selection, the probability of one individual being selected is proportional to its share of the fitness of the whole population. In order to improve the efficiency of the algorithm, a strategy called elitist selection is applied. This ensures that the best individual of each generation will be present in the next generation (Thierens, 1997[Thierens, D. (1997). Proceedings of the Seventh International Conference on Genetic Algorithms, pp. 152-159. San Fransisco: Morgan Kaufmann.]). Under this strategy, the individual who has the best fitness of the previous generation will replace the one that has the worst fitness among the selected individuals of the current generation.

Step 5. The couples selected will CROSSOVER and generate their offspring, with a probability of Pc. In this step, a random number between 0 and 1 is generated. If this number is less than Pc, then CROSSOVER will be performed; otherwise, the algorithm returns to Step 4. In order to perform the CROSSOVER step, a crossover site along the chromosome, which is a random integer between 2 and N − 1, is chosen first. Then the genes of the two chromosomes will be exchanged up to the crossover site, as shown in Fig. 1(b)[link].

Step 6. Each offspring generated from Step 5 will MUTATE with a probability of Pm. Then the algorithm proceeds onto Step 2. In this step, random numbers between 0 and 1 are generated for each gene of the offspring. If the number is less than Pm, the MUTATE step will be performed on the gene, as shown in Fig. 1(b)[link]. The gene will be replaced by a random number in the search space.

4. Method testing

To test this method, the flux at the sample position of the XAFCA beamline of the Singapore Synchrotron Light Source (Moser et al., 2004[Moser, H. O., Casse, B. D. F., Chew, E. P., Cholewa, M., Diao, C. Z., Ding, S. X. D., Kong, J. R., Li, Z. W., Hua, M., Ng, M. L., Saw, B. T., Mahmood, S. B., Vidyaraj, S. V., Wilhelmi, O., Wong, J., Yang, P., Yu, X. J., Gao, X. Y., Wee, A. T. S. & Sim, W. S. (2004). Proceeding of APAC 2004, pp. 460-464.]) is optimized. XAFCA is an X-ray absorption fine-structure (XAFS) facility for catalysis research, which uses two sets of crystals, Si (111) and KTP (011), to cover an energy range of 1.2–12.8 keV.

Fig. 3[link] shows a schematic drawing of the XAFCA beamline. The first optical component is a vertical collimating mirror (VCM) which collimates the beam vertically. The second optical component is a double-crystal monochromator (DCM). The second Si (111) crystal is a sagittally bent crystal. The third optical component is a vertical focusing mirror (VFM) which is to refocus the beam vertically. A four-blade slit is installed before the IC0 and the beam flux is monitored by the IC0. To optimize the flux at the sample position we need to adjust the roll, pitch and yaw of the VCM, DCM and VFM which are controlled by 14 SMs. Therefore, the positions of the SMs (x1, x2, x3,…, x14) are the individuals in this test. The fitness is obtained by reading the IC0: the higher the flux, the better the fitness.

[Figure 3]
Figure 3
Basic optical arrangement of the XAFCA beamline. The 14 SMs marked in blue are needed to optimize the flux at the sample position.

A LabVIEW program based on the GA was developed to optimize the XAFCA beamline. The settings for Pc, Pm and N are not unique. In the optimization work, a large value of N causes more time to be spent within a single generation, while a smaller population size will cause the efficiency of the GA to decrease. As for Pc and Pm, usually the combinations of high Pc combined with low Pm or low Pc combined with high Pm work well for small population structures (Grefenstette, 1986[Grefenstette, J. J. (1986). IEEE Trans. Systems Man Cybernetics, SMC-16, 122.]). As a result of testing, Pc = 0.8, Pm = 0.05 and N = 10 is a good option in this application. As mentioned previously, the termination criterion is that the best fitness reaches a plateau & ≥ I_obj. A plateau, in this case, is considered to occur when five successive iterations no longer produce better results. I_obj represents a reasonable threshold reading of IC0, 1 µA for instance. The search space is ±1 mm for each SM.

The SMs were adjusted manually to obtain different initial fluxes, and then our program was used to optimize the beamline. Fig. 4[link] shows flux versus generation during the optimization for the five different initial statuses. For easier comparison, the optimized flux is normalized to unity. The initial fluxes of lines a to e were 0.91, 0.80, 0.48, 0.17 and 0.04, respectively. The number of generations for completing the optimization of line a to e were 10, 11, 11, 14 and 17, respectively. This indicates that, if the initial beam flux fluctuation is above 48%, the beamline can be optimized within 11 generations. Even if the initial beam flux is only 4% of the total flux the program still can find the optimized position of all SMs within 17 generations.

[Figure 4]
Figure 4
Performance of the GA-based optimization program on the XAFCA beamline. Lines a–e represent the normalized flux at the sample position, which was measured using the ionization chamber, corresponding to the best individual changes over generations. The initial flux from line a to line e decreases in order, which results in the increase of the number of generations needed for convergence. The initial fluxes and the generation numbers for completing optimization for each line are listed in the figure.

5. Discussion and conclusion

The GA is a computational analogy, simulating the main process of natural selection, to solve optimization and search problems. As a global optimization algorithm, it can be applied to various systems, such as synchrotron radiation beamlines, which are difficult to formalize mathematically. In this work, a general method for automatic beamline optimization based on the GA is introduced. It was demonstrated that this method can optimize all the optical components of the XAFCA beamline simultaneously and efficiently, and the beamline can be optimized within 17 generations even when the initial flux is only 4% of total flux. As mentioned previously, this method only requires the input and its output of the objective system and the mathematical model between them is not required. Therefore, it is independent of a particular beamline setup and can be expanded further to other beamlines and scientific instrumentations which are driven by SMs.

Acknowledgements

This research was supported by the Agency for Science, Technology and Research (A*Star) of Singapore.

References

First citationArzt, S., Beteva, A., Cipriani, F., Delageniere, S., Felisaz, F., Förstner, G., Gordon, E., Launer, L., Lavault, B., Leonard, G., Mairs, T., McCarthy, A., McCarthy, J., McSweeney, S., Meyer, J., Mitchell, E., Monaco, S., Nurizzo, D., Ravelli, R., Rey, V., Shepard, W., Spruce, D., Svensson, O. & Theveneau, P. (2005). Prog. Biophys. Mol. Biol. 89, 124–152.  Web of Science CrossRef PubMed CAS Google Scholar
First citationChang, Y. L. (2003). IEEE Trans. Systems Man Cybernetics B, 33, 138–149.  Google Scholar
First citationDavid, E. G. & Kalyanmoy, D. (1991). Foundations of Genetic Algorithms, edited by G. J. E. Rawlins, pp. 69–93. Los Altos: Morgan Kaufmann.  Google Scholar
First citationDu, Y., Zhu, Y., Xi, S., Yang, P., Moser, H. O., Breese, M. B. H. & Borgna, A. (2015). J. Synchrotron Rad. 22, 839–843.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationGrefenstette, J. J. (1986). IEEE Trans. Systems Man Cybernetics, SMC-16, 122.  Google Scholar
First citationHignette, O., Freund, A. K. & Chinchio, E. (1997). Proc. SPIE, 3152, 188.  CrossRef Google Scholar
First citationHignette, O., Rostaing, G., Cloetens, P. & Ludwig, W. (2001). Proc. SPIE, 4499, 105.  CrossRef Google Scholar
First citationHolland, J. H. (1975). Adaptation in Natural and Artificial Systems. The University of Michigan Press.  Google Scholar
First citationJames, E. B. (1985). Proceeding of an International Conference on Genetic Algorithms and Their Applications, pp. 100–111.  Google Scholar
First citationLenardi, C., Vecile, C. R., Vitali, R. & Rosei, R. (1989). Rev. Sci. Instrum. 60, 1969.  CrossRef Web of Science Google Scholar
First citationMoser, H. O., Casse, B. D. F., Chew, E. P., Cholewa, M., Diao, C. Z., Ding, S. X. D., Kong, J. R., Li, Z. W., Hua, M., Ng, M. L., Saw, B. T., Mahmood, S. B., Vidyaraj, S. V., Wilhelmi, O., Wong, J., Yang, P., Yu, X. J., Gao, X. Y., Wee, A. T. S. & Sim, W. S. (2004). Proceeding of APAC 2004, pp. 460–464.  Google Scholar
First citationPugliese, R. & Poboni, R. (1995). Proceedings of ICALEPCS'95, Chicago, IL, USA.  Google Scholar
First citationSvensson, S. O. & Pugliese, R. (1998). Proc. SPIE, 85, 3455.  Google Scholar
First citationThierens, D. (1997). Proceedings of the Seventh International Conference on Genetic Algorithms, pp. 152–159. San Fransisco: Morgan Kaufmann.  Google Scholar
First citationZhang, L., Sánchez del Río, M., Monaco, G., Detlefs, C., Roth, T., Chumakov, A. I. & Glatzel, P. (2013). J. Synchrotron Rad. 20, 567–580.  Web of Science CrossRef CAS IUCr Journals Google Scholar

© International Union of Crystallography. Prior permission is not required to reproduce short quotations, tables and figures from this article, provided the original authors and source are cited. For more information, click here.

Journal logoJOURNAL OF
SYNCHROTRON
RADIATION
ISSN: 1600-5775
Follow J. Synchrotron Rad.
Sign up for e-alerts
Follow J. Synchrotron Rad. on Twitter
Follow us on facebook
Sign up for RSS feeds