원시데이터 수집 시스템
선정목록으로

TopasOpt: An open‐source library for optimization with Topas Monte Carlo

관련 필름·전자재료 · (16) CPI(투명 폴리이미드)

기본 정보

저자
  1. Brendan Whelan — Image X Institute, School of Health Sciences, Faculty of Medicine and Health, University of Sydney, Sydney, Australia|||Department of Radiation Oncology, Stanford University School of Medicine, Stanford, California, USA
  2. Billy W. Loo — Department of Radiation Oncology, Stanford University School of Medicine, Stanford, California, USA|||Stanford Cancer Institute, Stanford University School of Medicine, Palo Alto, California, USA
  3. Jinghui Wang — Department of Radiation Oncology, Stanford University School of Medicine, Stanford, California, USA|||Varian Medical Systems, Palo Alto, California, USA
  4. Paul Keall — Image X Institute, School of Health Sciences, Faculty of Medicine and Health, University of Sydney, Sydney, Australia
DOI
10.1002/mp.16126
저널
Medical Physics
발행년도
2022
발행기관
Wiley
피인용수
8
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1002/mp.16126
토픽
Electron and X-Ray Spectroscopy Techniques
OpenAlex ID
W4310963913

평가 내용

관련도
관련
사업분야
필름·전자재료 · (16) CPI(투명 폴리이미드)
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > CPI(투명 폴리이미드)' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

To describe and test TopasOpt: a free, open-source and extensible library for performing mathematical optimization of Monte Carlo simulations in Topas.

본문 35,044자

본문 펼치기
To describe and test TopasOpt: a free, open-source and extensible library for performing mathematical optimization of Monte Carlo simulations in Topas.Methods: TopasOpt enables any Topas model to be transformed into an optimization problem, and any parameter within the model to be treated as an optimization variable.Three case studies are presented.The starting model consists of a 10 MeV electron beam striking a tungsten target.The resulting bremsstrahlung X-ray spectrum is collimated by a primary and secondary collimator before being scored in a water tank.In the first case study (electron phase space optimization), five parameters describing the electron beam were treated as optimization variables and assigned a random starting value.An objective function was defined based on differences of depth-dose and profiles in water between the original (ground truth) model and a given model generated by TopasOpt.The problem was solved using Bayesian Optimization and the Nelder-Mead method.One hundred iterations were run in each case.In the second case study, (collimator geometry optimization), this process was repeated, but three geometric parameters defining the secondary collimator were treated as optimization variables and assigned random starting values, and forty iterations were run.In the third case study, the optimization was repeated with different number of primary particles to study the effect of noise on convergence.Results: For case 1 (phase space optimization), both optimization algorithms successfully minimized the objective function, with absolute mean differences in profile dose of 0.4% (Bayesian) and 0.3% (Nelder-Mead) and 0.2% in depthdose for both algorithms.The beam energy was recovered to within 1%,however some parameters had relative errors of up to 171% -a result consistent with the known X-ray dose is insensitivity to many electron beam parameters.For case 2 (geometry optimization), absolute mean differences in profile dose were 0.6% (Bayesian) and 0.9% (Nelder-Mead), and 0.5% and 0.9% in depth-dose.The maximum percentage error in any parameter was 9% with Bayesian Optimization and 28% with Nelder-Mead.Finally, the Bayesian Optimization algorithm was demonstrated to be robust to moderate levels of noise; when the standard deviation of the objective function was 16% of the mean, the maximum error in any parameter value was 16%, and the absolute mean difference in dose was 0.9% (profile) and 0.8% (depth-dose). INTRODUCTION Monte Carlo simulation of radiation transport is ubiquitous across many scientific fields and industries and is considered the most accurate mechanism of calculating radiation dose. 1 In Medical Physics, Monte Carlo simulations are used for research studies, engineering designs, as a secondary dose check, and, increasingly, for primary clinical dose calculation. 2Any Monte Carlo simulation is based on many parameters, which for instance define geometry, describe particle sources, and control physics settings.In many cases, the optimal values for these parameters are not well known and must be estimated.In other situations, parameters are design variables with unknown optimal value. 3A common approach to tune a given parameter value is to perform a 'grid search' in which a given parameter may be varied over N simulations, and the best solution chosen.While simple, this approach is highly inefficient, especially for situations where several parameters must be tuned at once.In this situation, the size of the search space (which scales to the power of N-parameters) rapidly becomes prohibitive.A more efficient approach is the use of formal mathematical optimization algorithms to efficiently find an optimal set of parameters according to a user-defined objective function.There are some examples in the literature of this approach: Wang et al. implemented the Nelder-Mead method in conjunction with MCNP and to perform single channel collimator design, 4 while Whelan et al. used Bayesian Optimization in conjunction with Topas to optimize a novel collimator array. 5However, at present there is no simple and general-purpose method to incorporate formal optimization routines into Monte Carlo simulation. INTRODUCTION Several toolkits exist for performing Monte Carlo simulations; of note are Fluka, EGS, and Geant4.In addition, several auxiliary packages have been built on top of these primary codes to improve ease of use for end users. 3One of these is Topas: TOol for PArticle Simulation. 6Topas wraps Geant4 and enables users to develop complex simulations using only parameters files.As of 1 March 2022,Topas has 1928 licensed users at 531 institutions in 60 countries, with 476 new users in the last 12 months; at time of writing, the original paper describing Topas had been cited 641 times. 6As such, an optimization tool integrated with Topas has the potential to be used by a large and rapidly growing user base.In this work,we present and test TopasOpt:an open-source optimization library for Topas Monte Carlo.TopasOpt is the first free and open-source optimization library for Monte Carlo radiation transport.It allows any Topas model to be transformed into an optimization problem, and any parameter inside the model to be optimized.Since Topas simulations are entirely defined by parameter files, this means almost any aspect of a Monte Carlo simulation can be treated with formal optimization. Optimization of monte carlo simulations: General description of problem There are many algorithms for performing optimization, the performance of which is highly problem specific.Optimization based on Monte Carlo simulation of radiation transport can be described as noisy, expensive, and derivative free. 7Each of these terms is explained in Table 1.Together, they imply the need for a gradient-free optimization scheme well suited to expensive objective functions.In addition, since there can be no mathematical guarantee of global convergence in optimization of derivative-free objective functions of unknown form, it is highly desirable that an algorithm allow users to tune the balance between "exploitation versus exploration."Exploitation is preferentially evaluating parameter sets near the best existing sets under the assumption that clustered parameter sets will perform similarly.Exploration is preferentially evaluating parameter sets far from known solutions; these may be much better or much worse than the best existing sets.Algorithms which do not enable users to "trade-off " between these two priorities tend to be prone to becoming stuck in local minima or perform inefficiently.Many algorithms for derivative-free optimization exist.Notable examples are Nelder-Mead, Powell's method, simulated annealing, Particle Swarm, Genetic, and Bayesian. 7,8As detailed in Section 2.2, TopasOpt has been designed to enable easy extensibility to any appropriate algorithm.However, the two algorithms available at present are the Nelder-Mead method and Bayesian Optimization. Noisy The input data is noisy due to the inherently stochastic nature of Monte Carlo.Practically, what this means is that if some point in the objective function space is probed repeatedly, different values will be returned.This hinders reproducibility and convergence of optimization procedures.Noise can be reduced by running more particles, but this directly increases the expense of each evaluation. Expensive Expense refers to how long it takes to perform each optimization iteration.General purpose Monte Carlo is a computationally expensive and slow technique, taking at least several minutes per iteration.There is a direct trade-off between how noisy the data is and how expensive it was to acquire. Expensive Derivative free Derivative-free optimization refers to optimization schemes which do not use derivatives to guide the optimization, for instance because the derivative would be too time consuming to calculate or because the objective function is non-smooth. Expensive The workings of these algorithms are briefly explained below. Expensive The Nelder-Method relies on the concept of a simplex, which is an N+1 dimensional shape where N is the number of optimization parameters.For example, for a one-dimensional problem, the simplex will be two points.At each iteration, this simplex may be reflected, contracted, expanded, or shrunk; the goal is to "walk" the simplex down the objective function.This algorithm has the advantage of being simple to implement and understand and tends to have a fast period of initial convergence.On the other hand, it can sometimes become stuck in local minima and is quite sensitive to the choice of starting location and simplex vertices. Expensive Bayesian Optimization works by fitting a surrogate to the unknown objective function.At each iteration, the known value of the objective function at the current parameter set is used to update the surrogate.Essentially, the algorithm learns the shape of the objective function "on the fly."A popular choice for a surrogate is a Gaussian Process Model, which can be thought of as an infinite dimensional generalization of a multivariate Gaussian distribution.Using a Gaussian Process Model enables an estimate of both the objective function value and an estimate of uncertainty at all points.As such, users can weight the next parameter sets to be in regions of high uncertainty or regions where good solutions are expected -explicitly controlling the exploration/exploitation trade-off.The surrogate function can also handle noisy objective functions, both by smoothing the surrogate function and increasing the uncertainty estimates.In contrast to the Nelder-Mead method, Bayesian Optimization will not generally converge as quickly during the first iterations, during which it is still learning the shape of the objective function.However, once this initial period of learning is complete it will tend to find solutions faster and be less likely to get stuck in local minima. TopasOpt TopasOpt is a free and open-source Python code for performing formal optimization of parameters used in a Topas simulation. 9TopasOpt provides a framework via which any Topas project can be converted into an optimization problem, and any parameter can be optimized.A Topas model is entirely defined by a series of ASCII encoded (i.e., "normal") text files, which in turn contain a series of organized parameters defined with the Topas syntax.This makes Topas ideally suited to interfacing with third party codes such as TopasOpt, since running a Topas model simply involves passing an ASCII parameter file to the pre-compiled Topas application.To convert any existing Topas project into a TopasOpt optimization problem, an end user must create three Python files: TopasOpt 1. GenerateTopasScripts.py: Create a Python function which will generate the Topas model for a given set of parameters {x} Although this step may sound difficult, in practice TopasOpt includes functionality to automatically generate a first draft of this function from an existing model.The user must then change only a few lines manuallytypically one line for each parameter they wish to optimize.TopasOpt will automatically locate and call this function. TopasObjectiveFunction.py: Define an objective function This function accepts two parameters -the location of the results and current iteration -and must return a number to the optimizer.What happens between these two steps is defined by the user.A standard approach would be to read in the latest results, extract relevant metrics from them, and use these to calculate an objective function.TopasOpt will automatically locate and call this function. Main_RunOptimization.py: Choose a start point, define bounds, choose optimization algorithm This is the script which is executed to run the optimization.In it, the user supplies a start point for each parameter, allowed bounds, convergence criteria, optimization algorithm to run, and can also specify any algorithm specific options. F I G U R E 1 Automated optimization loop of TopasOpt Once these components are assembled, Main_RunOptimization.py can be executed, which will execute the automatic optimization loop described in Figure 1. F I G U R E 1 Automated optimization loop of TopasOpt A brief explanation of each of the steps in Figure 1 follows: F I G U R E 1 Automated optimization loop of TopasOpt • Build Model: Use GenerateTopasScripts.py (step 1 above) to generate Topas parameter files for parameter set {x}. • Run model: in this step, the generated parameter files are sent to the pre-built Topas application and executed as subprocess of TopasOpt.At this point, TopasOpt relinquishes control to Topas; it assumes control again once the Topas run is complete.• Assess objective function: Utilizes the user generated code from step 2 above to generate the value of the objective function for the current parameter set.• Termination criteria met?Convergence criteria can include e.g., number of iterations, number of iterations without improving on the best solution, percentage improvement on start point, etc.In practice, the main termination criteria used at present is number of iterations. F I G U R E 1 Automated optimization loop of TopasOpt • Choose {x next } Exactly how {x next } is selected will vary depending on the optimization algorithm.This is the only optimization algorithm specific step in this workflow. F I G U R E 1 Automated optimization loop of TopasOpt On the completion of each iteration, TopasOpt will log the results to a log file and generate and save several figures relevant to the progress of optimization, making it easy to monitor progress of the optimization.The user can choose to store all scored data, or only the most recent iteration.To ensure robustness to new developments, TopasOpt includes a test framework which is automatically run whenever changes are made to the main repository. F I G U R E 1 Automated optimization loop of TopasOpt As mentioned, at present TopasOpt includes two optimization algorithms; Bayesian Optimization which utilizes the code "Bayesian Optimization: A Python Implementation of Global Optimization with Gaussian Processes 12 " and Nelder-Mead Optimization based on scipy. 13It is simple to extend TopasOpt to new optimization algorithms, since the core functionality of TopasOpt is contained in a base class; new Optimizers inherit this base class.The base class handles everything in Figure 1 except for choosing the next parameter set to test, which is the optimizer specific step.To give an idea of the simplicity of adding new optimizers; a basic implementation of the Nelder-Mead method can be achieved with twelve lines of code, which is shown in Figure 2. In general, the process of switching optimization algorithm for an end user only involves changing one line of code, for example, "BayesisanOptimizer.RunOptimization()" to "NelderMeadOptimizer. RunOptimization()." Case studies To demonstrate the use of TopasOpt, case studies based on the production and collimation of an X-ray beam from bremsstrahlung radiation werey tested. Base model The base model consisted of a monoenergetic electron beam striking a tungsten X-ray target (Figure 3).The resultant X-ray beam passed through two collimators before being scored in a water tank.5 × 10 5 primary electrons were simulated, and bremsstrahlung X-rays in the target are split 1000 times and subject to Russian roulette with a split number of 1000 if projected outside a radius greater than 50 mm at isocenter. 14The phase space is scored just below the secondary collimator and recycled two hundred times in a second simulation of dose in water.The Geant4 G4EmStandardPhysics list was used throughout this work.Although this is less accurate than some other physics lists, since we are only testing the ability of the optimizer to match data also calculated with G4EmStandardPhysics, it can be used with no loss of generality and is substantially faster than other physics lists.The same is true of the aggressive variance reduction utilized.The case studies were developed by randomizing various parameters in this model and attempting to use TopasOpt to recover the ground truth values using an objective function based on absolute differences in profile and depth curves in water.The first case study focuses on the electron beam phase space, while the second case study focuses on the collimator geometry (Figure 3).In the third case study, the effect of varying the number of primary particles on the geometric optimization (case 2) was studied to quantify the effect of stochastic noise on optimization performance.In the first case study, the phase space properties of the electron beam are optimized.In the second and third case studies, the geometric parameters of the secondary collimator are optimized Optimization of electron beam parameters In this example, five parameters defining the electron beam phase space are optimized: Beam Energy, Beam Position Cutoff, Beam Position Spread, Beam Angular Spread, and Beam Angular Cutoff (Figure 3).For the physical basis of these parameters, please refer to the Topas user documentation. 15The values in the base model were 10.0 MeV, 2 mm, 0.3 mm, 0.07 • , 5 • .Random starting values were 7.9 MeV, 2.7 mm, 1.0 mm, 0.1 • , and 2.7 • (Table 2).Symmetry in X and Y was assumed for simplicity.The objective function was formulated based on differences between the original dose profiles for a given parameter set as described in Equation ( 1): Optimization of electron beam parameters This was considered a challenging problem since it is well known that MV X-ray dose in water is not particularly sensitive to most electron beam parameters, with energy typically the most sensitive parameter. 16he natural log in the objective function is used to emphasize small differences, although this does also come at the cost of emphasizing noise. 2 × 10 5 primary particles were run per iteration, with a run time per iteration of approximately 20 min on a 16-core server.Note that most of this time is the time required for the Topas simulations rather than the optimization algorithm.This problem was solved with both the Bayesian and Nelder-Mead optimizers. Optimization of geometric parameters Three geometric parameters were randomized: collimator thickness, upstream aperture radius, and downstream aperture radius (Figure 3).The ground truth (i.e., starting values) and randomized values for these parameters were 54.0 mm, 1.8 mm, 2.5 mm, 25.0 mm, 2.5 mm, and 1.6 mm respectively (see Table 3). Optimization of geometric parameters Since this simulation was expected to show more sensitivity to the parameters being optimized, the total number of particles was reduced to 5 × 10 4 primary particles and the natural log was removed from equation 1.These changes make the data noisier, but the objective function less sensitive to noise.With the reduced number of primary particles, each optimization iteration took around 5 min on a 16-core server, and forty iterations were run.This problem was solved with both the Bayesian and Nelder-Mead optimizers. Optimization of noisy objective functions Statistical noise is inherent in Monte Carlo simulation and is inversely proportional to the square root of the number of primary particles.To study the effect of noise on the optimization, the simulation from the prior section was repeated with the total number of particles set to (1 × 10 4 , 2 × 10 4 , 3 × 10 4 , 4 × 10 4 , 5 × 10 4 ).Ten simulations with the parameters set to the true (ground truth) parameters were run for each number of particles.Next, one hundred iterations of Bayesian Optimization were performed for each case.A custom Gaussian Process kernel was constructed consisting of a Matern kernel plus with a white kernel; the latter is specifically designed to model noise. 17The optimization performance, as well as the Gaussian Process Model predictions at the known ground truth were compared for each case. Optimization of electron beam parameters Figure 4 shows the convergence plot for each optimizer.Several features are of interest here.For the Bayesian Optimizer (Figure 4a) note that the Gaussian Process Model predictions become more accurate as more shows the Gaussian Process Model predictions as well as the actual value of the objective function at each iteration.The lowest value of the objective function found in each case is marked with a x iterations are run and the model learns the shape of the objective function.Note also that that this optimizer is quite exploratory, in that even parameter sets predicted to be poor candidates are frequently probed.Compare this with the Nelder-Mead convergence (Figure 4b)after a faster initial period of convergence, this algorithm continues to probe points around the previous best solu- Optimization of electron beam parameters F I G U R E 5 Comparative profiles (a) and depth-dose curves (b) for the optimization of phase space parameters.Note that the data is quite noisy because this is taken directly from the data used during optimization tion.Note that by observing the objective value of the last ∼10 iterations, it is possible to assess the noise in the objective function since the parameters tend to not change very much at the end of an optimization run. Optimization of electron beam parameters Based on Figure 4, it can be inferred that there is a high amount of noise around the best solutions.This is a result of both the stochastic nature of Monte Carlo, and the use of a log objective function.Despite this noise, both optimizers were effective in minimizing the difference in depth-dose and profile data (Figure 5a).The ground truth, randomized, and optimized values from both the Bayesian and Nelder-Mead optimizers are shown in Table 2, while profiles and depth-dose curves are shown in Figure 5a,b.Overall, both optimizers performed similarly, with the Bayesian algorithm finding a minimum objective function value of −0.49 and the Nelder-Mead algorithm finding a minimum of −0.53, compared with a starting value of 1.5.While Beam Energy and Beam Position Cutoff parameters were recovered to within 1% and 20% of their true values, Beam Position Spread, Beam Angular Spread, and Beam Angular Cutoff tend to have larger percentage errors (Table 2).Two points should be made here.The first is that while the percentage error is sometimes large, the absolute error is small -for instance in the case of Beam Angular Spread, the absolute error is only 0.12 • .The second is that the objective function may not actually be sensitive to these parameters, in which case any optimizer will find it difficult to recover them.For Bayesian Optimization, a useful indication of the sensitivity of the objective function to various parameters is the single parameter plots shown in Figure 6.It must be emphasized that these values are predictions -the extent to which they should be trusted depends on how well the Gaussian Process Model has been demonstrated to correlate with the true objective function.In this case the Spearman correlation between predicted and simulated objective functions across all iterations was 0.8, indicating that these plots at least correlate with simulated measurement.Based on these plots, we can see that the objective function is predicted to exhibit almost no sensitivity to Beam Angular Cutoff, explaining the comparatively large error for this parameter. Optimization of geometric parameters Figure 7 shows profiles and depth-dose curves in water for the original, random start point, and optimized models for the optimization of collimator geometry.The optimized models are well matched to the original (ground truth) data.Quantitively, the objection function was reduced from a starting value of 13.8 to 1.1 with the Bayesian Optimizer, and 1.6 with the Nelder-Mead Optimizer.Figure 8 show the Gaussian Process Model predictions of the objective function as a function of each parameter while the other parameters are held at their optimal value.Spearman correlation was 0.7 over all forty iterations. Optimization of noisy objective functions Figure 9a shows the value of the objective function versus the number of primary particles, as well as the Gaussian Process prediction of the objective value at the same parameter values.Note that for no noise, the objective function evaluated at the 'true' parameters would be zero in all cases; because we take the absolute values any noise will increase the value of the objective function.There is a high correlation between the "true" (e.g., mean) value and the Gaussian Process prediction, and the uncertainty predicted by the Gaussian Process is well correlated with the varying amount of noise in each case (note that in general the Gaussian Process Model has not seen this exact point prior to making the prediction). Optimization of noisy objective functions Figure 9b shows the convergence for different number of primary particles.As expected, with more primary particles (and hence less noise) the optimizer tends to converge faster and to lower overall values.Table 4 shows the best parameter values found for each case.The largest discrepancies between best guess and ground truth tend to be for upstream hole size, which is expected to be the least sensitive parameter in this model (Figure 8).Meanwhile, in all cases the estimate of collimator thickness is within 1 mm, which is expected to be the most sensitive parameter given the results in Figure 8.As the noise level increases the "high signal" parameters of the objective are still effectively optimized, while the low signal parameters are more likely to be washed out by noise.The general trend is for better performance with higher number of particles, although the n = 2e4 case does have surprisingly high performance -this would appear to be statisti- DISCUSSION In Monte Carlo simulation of radiation transport, it is very common for the correct or optimal value of some parameter to be unknown for a variety of reasons.Typically,and historically,these situations have been handled via non exact and labor-intensive methods such as "grid searching."A far superior approach would be to apply formal mathematical optimization algorithms which are purpose built for such situations.Historically this has not been possible due to the lack of appropriate tools.In this work, an open-source library for performing optimiza-tion based on Topas Monte Carlo simulations has been developed and tested.This is the first freely available code for optimization of general-purpose Monte Carlo simulations.Applications for this code include (1) the design of new accelerators, detectors, and equipment, and (2) Reverse engineering of models based on limited experimental or published data, and (3) Tuning of Monte Carlo 'hyper parameters' such as physics, variance reduction, scoring settings to optimize simulation efficiency with respect to some ground truth.TopasOpt is available online with detailed documentation. 9n both the optimization of phase space parameters and the optimization of geometric parameters, excellent matches to the starting profile and depth-dose data were obtained (Figures 5 and 7).In the case of the optimization of geometric parameters (case study 2,Table 3),this also corresponded with good recovery of the ground truth parameters, with the Bayesian optimizer finding all ground truth parameters within 9% and the Nelder-Mead finding all parameters within 28%.This was not the case for the optimization of phase space parameters (case study 1, Table 2) -where errors of up to 171% (Bayesian) and 64% (Nelder-Mead) were observed.This result is not entirely surprising, as it is well known that X-ray dose distributions are not especially sensitive to many parameters defining an electron phase space, 16 with energy typically the most sensitive parameter.Fundamentally, no optimization algorithm will perform well if the parameters the algorithm is varying do not affect the objective function.For instance, considering the Beam Angular Cutoff parameter in Figure 6, the objective function has almost no sensitivity to this parameter.Beam Angular Cutoff refers to the value at which the Gaussian distribution is trimmed; as such if Beam Angular Cutoff is substantially smaller than the Beam Angular Spread parameter, this parameter will have little impact on the phase space.Therefore, the result that this parameter does not affect the objective function makes intuitive sense.Another reason for the large relative errors is that very small ground truth values tend to result in large relative errors even when absolute errors are small -this is the case for instance in the Beam Angular Spread parameter (Table 2).However, this result also reflects the limitations in data supplied to the optimizers.Firstly, the objective function used was not particularly sophisticated, based on only the absolute differences between a single profile and a central depth-dose curve.A more textured objective function could include multiple profiles or off -axis curves as well as some form of output factor. DISCUSSION A fundamental difficulty in optimization of Monte Carlo parameters is statistical noise, which is an inherent aspect of the Monte Carlo method.For the case of optimization, what is important is the noise in the objective function -the same statistical Monte Carlo noise can manifest very differently depending on how the objective function is constructed.For the optimization of geometric parameters, the noise in the objective function was quantified for a varying number of primary particles, and the effect on algorithm convergence studied (Figure 9).These results demonstrate that Bayesian Optimization in particular can perform well in the presence of noise, as the Gaussian Process underlying the optimization is capable of parameterizing and predicting noise (Figure 9a). DISCUSSION Two algorithms are currently implemented in Topa-sOpt, the Nelder-Mead method and Bayesian Optimization.In principle, TopasOpt can utilize any appropriate optimization algorithm and has been designed with extensibility in mind.However, in practice, we believe that Bayesian Optimization is likely to prove the most appropriate algorithm for most situations as it is robust to noise, well suited to expensive objective functions, and does not get stuck in local minima. 18On the other hand, the Nelder-Mead algorithm is simpler to implement and understand and will generally tend to show a faster period of initial convergence than Bayesian Optimization.Other algorithms which may prove suitable for this problem domain (defined in Section 2.1) include simulated annealing, as well as ensemble-based methods such as evolutionary or particle swarm algorithms. 7,8e suspect that ensemble-based algorithms may prove inefficient for the "expensive" problem of Monte Carlo simulation, but this hypothesis remains to be tested.Under certain assumptions about the objective function (i.e., that it is smoothly varying), simulated annealing with a logarithmic cooling schedule can be guaranteed to find a global minimum.However, this cooling schedule is so slow that it is impractical. 19For other cooling schedules, it shares with Nelder-Mead the problem that it may become stuck in local minima. DISCUSSION At present, TopasOpt only handles single-objective optimization, meaning competing objectives must be combined in one objective function (e.g.,"Maximize dose rate" but "minimize target heating").An interesting topic for future research would be that of multi-objective optimization, also called Pareto optimization. 20Such an optimization strategy focuses on finding solutions for multiple objective functions in which no objective function can be decreased without increasing another objective function.Such parameter sets are said to be Pareto optimal.There are existing multi-objective optimization libraries for Python, although it would likely take some effort to integrate TopasOpt with these libraries. 21,22 CONCLUSION TopasOpt is an open-source library which can transform any Topas model into an optimization problem and any Topas parameter into an optimization variable.TopasOpt has been demonstrated to be effective at minimizing objective functions based on Monte Carlo simulations.We believe that in future, formal mathematical optimization should become de-rigueur for any Monte Carlo problem in which some parameters must be tuned.Examples include component design, reverse engineering, and tuning of simulation hyper-parameters. F I G U R E 2 F I G U R E 3 Demonstration of implementing a simple NelderMead optimizer which uses the scipy default settings.Since the major functionality is all inherited from TopasOptBaseClass, only twelve lines of code are required.This basic template is the same for any new optimization algorithm Model used in the case studies. 4 Convergence plot for (a) Bayesian Optimization and (b) Nelder-Mead optimization of electron beam parameters.(a) 6 7 Comparative profiles (a) and depth-dose curves (b) for the optimization of geometric parameters.Note that the data is quite noisy because this is taken directly from the data used during optimization Gaussian Process Model predictions of the objective function as a function of each parameter while other parameters are held at their optimal values for the phase space optimization (case study 1).The Gaussian Process Model is trained as the Bayesian Optimization is run, with each iteration serving as a data update for the model.The solid line indicates the predicted mean, and the shading the standard deviation 8 Gaussian Process Model predictions of the objective function as a function of each parameter while other parameters are held at their optimal values for the geometric optimization.The solid line indicates the predicted mean, and the shading the standard deviation n primary particles a) b) (a) Noise in objective VS n-primary-particles (b) Convergence VS n-primary-particles Iteration Best objective value found Objective values F I G U R E 9 (a) Measured objective function values versus number of histories (boxplots), and Gaussian Process predictions at the same parameters after one hundred iterations of Bayesian Optimization.For no noise, the objective function should be zero.(b) Optimizer convergence for different number of primary particles TA B L E 4 Best parameters found by optimizer versus number of primary particles Parameter Ground truth value n = 1e4 n = 2e4 n = 3e4 n = 4e4 n = 5e4 8 . and P.K. wish to acknowledge funding from NHMRC program and fellowship grants.The authors wish to thank Dr. Joseph Perl for the helpful suggestions and encouragement, Julia Johnson for input into figure design, Dr. Lars Mejnertsen for beta testing, and Dr. Helen Ball for proof reading.C O N F L I C T O F I N T E R E S TB.W.L. is a founder and board member of Tibaray.J.W. is an employee of Varian Medical Systems. 8 Parameter summary for optimization of electron beam parameters 8 TA B L E 2

섹션 본문 46문단 · 33,671자

(제목 없음)

1To describe and test TopasOpt: a free, open-source and extensible library for performing mathematical optimization of Monte Carlo simulations in Topas.Methods: TopasOpt enables any Topas model to be transformed into an optimization problem, and any parameter within the model to be treated as an optimization variable.Three case studies are presented.The starting model consists of a 10 MeV electron beam striking a tungsten target.The resulting bremsstrahlung X-ray spectrum is collimated by a primary and secondary collimator before being scored in a water tank.In the first case study (electron phase space optimization), five parameters describing the electron beam were treated as optimization variables and assigned a random starting value.An objective function was defined based on differences of depth-dose and profiles in water between the original (ground truth) model and a given model generated by TopasOpt.The problem was solved using Bayesian Optimization and the Nelder-Mead method.One hundred iterations were run in each case.In the second case study, (collimator geometry optimization), this process was repeated, but three geometric parameters defining the secondary collimator were treated as optimization variables and assigned random starting values, and forty iterations were run.In the third case study, the optimization was repeated with different number of primary particles to study the effect of noise on convergence.Results: For case 1 (phase space optimization), both optimization algorithms successfully minimized the objective function, with absolute mean differences in profile dose of 0.4% (Bayesian) and 0.3% (Nelder-Mead) and 0.2% in depthdose for both algorithms.The beam energy was recovered to within 1%,however some parameters had relative errors of up to 171% -a result consistent with the known X-ray dose is insensitivity to many electron beam parameters.For case 2 (geometry optimization), absolute mean differences in profile dose were 0.6% (Bayesian) and 0.9% (Nelder-Mead), and 0.5% and 0.9% in depth-dose.The maximum percentage error in any parameter was 9% with Bayesian Optimization and 28% with Nelder-Mead.Finally, the Bayesian Optimization algorithm was demonstrated to be robust to moderate levels of noise; when the standard deviation of the objective function was 16% of the mean, the maximum error in any parameter value was 16%, and the absolute mean difference in dose was 0.9% (profile) and 0.8% (depth-dose).

INTRODUCTION

2Monte Carlo simulation of radiation transport is ubiquitous across many scientific fields and industries and is considered the most accurate mechanism of calculating radiation dose. 1 In Medical Physics, Monte Carlo simulations are used for research studies, engineering designs, as a secondary dose check, and, increasingly, for primary clinical dose calculation. 2Any Monte Carlo simulation is based on many parameters, which for instance define geometry, describe particle sources, and control physics settings.In many cases, the optimal values for these parameters are not well known and must be estimated.In other situations, parameters are design variables with unknown optimal value. 3A common approach to tune a given parameter value is to perform a 'grid search' in which a given parameter may be varied over N simulations, and the best solution chosen.While simple, this approach is highly inefficient, especially for situations where several parameters must be tuned at once.In this situation, the size of the search space (which scales to the power of N-parameters) rapidly becomes prohibitive.A more efficient approach is the use of formal mathematical optimization algorithms to efficiently find an optimal set of parameters according to a user-defined objective function.There are some examples in the literature of this approach: Wang et al. implemented the Nelder-Mead method in conjunction with MCNP and to perform single channel collimator design, 4 while Whelan et al. used Bayesian Optimization in conjunction with Topas to optimize a novel collimator array. 5However, at present there is no simple and general-purpose method to incorporate formal optimization routines into Monte Carlo simulation.

3Several toolkits exist for performing Monte Carlo simulations; of note are Fluka, EGS, and Geant4.In addition, several auxiliary packages have been built on top of these primary codes to improve ease of use for end users. 3One of these is Topas: TOol for PArticle Simulation. 6Topas wraps Geant4 and enables users to develop complex simulations using only parameters files.As of 1 March 2022,Topas has 1928 licensed users at 531 institutions in 60 countries, with 476 new users in the last 12 months; at time of writing, the original paper describing Topas had been cited 641 times. 6As such, an optimization tool integrated with Topas has the potential to be used by a large and rapidly growing user base.In this work,we present and test TopasOpt:an open-source optimization library for Topas Monte Carlo.TopasOpt is the first free and open-source optimization library for Monte Carlo radiation transport.It allows any Topas model to be transformed into an optimization problem, and any parameter inside the model to be optimized.Since Topas simulations are entirely defined by parameter files, this means almost any aspect of a Monte Carlo simulation can be treated with formal optimization.

Optimization of monte carlo simulations: General description of problem

4There are many algorithms for performing optimization, the performance of which is highly problem specific.Optimization based on Monte Carlo simulation of radiation transport can be described as noisy, expensive, and derivative free. 7Each of these terms is explained in Table 1.Together, they imply the need for a gradient-free optimization scheme well suited to expensive objective functions.In addition, since there can be no mathematical guarantee of global convergence in optimization of derivative-free objective functions of unknown form, it is highly desirable that an algorithm allow users to tune the balance between "exploitation versus exploration."Exploitation is preferentially evaluating parameter sets near the best existing sets under the assumption that clustered parameter sets will perform similarly.Exploration is preferentially evaluating parameter sets far from known solutions; these may be much better or much worse than the best existing sets.Algorithms which do not enable users to "trade-off " between these two priorities tend to be prone to becoming stuck in local minima or perform inefficiently.Many algorithms for derivative-free optimization exist.Notable examples are Nelder-Mead, Powell's method, simulated annealing, Particle Swarm, Genetic, and Bayesian. 7,8As detailed in Section 2.2, TopasOpt has been designed to enable easy extensibility to any appropriate algorithm.However, the two algorithms available at present are the Nelder-Mead method and Bayesian Optimization.

Noisy

5The input data is noisy due to the inherently stochastic nature of Monte Carlo.Practically, what this means is that if some point in the objective function space is probed repeatedly, different values will be returned.This hinders reproducibility and convergence of optimization procedures.Noise can be reduced by running more particles, but this directly increases the expense of each evaluation.

Expensive

6Expense refers to how long it takes to perform each optimization iteration.General purpose Monte Carlo is a computationally expensive and slow technique, taking at least several minutes per iteration.There is a direct trade-off between how noisy the data is and how expensive it was to acquire.

7Derivative free Derivative-free optimization refers to optimization schemes which do not use derivatives to guide the optimization, for instance because the derivative would be too time consuming to calculate or because the objective function is non-smooth.

8The workings of these algorithms are briefly explained below.

9The Nelder-Method relies on the concept of a simplex, which is an N+1 dimensional shape where N is the number of optimization parameters.For example, for a one-dimensional problem, the simplex will be two points.At each iteration, this simplex may be reflected, contracted, expanded, or shrunk; the goal is to "walk" the simplex down the objective function.This algorithm has the advantage of being simple to implement and understand and tends to have a fast period of initial convergence.On the other hand, it can sometimes become stuck in local minima and is quite sensitive to the choice of starting location and simplex vertices.

10Bayesian Optimization works by fitting a surrogate to the unknown objective function.At each iteration, the known value of the objective function at the current parameter set is used to update the surrogate.Essentially, the algorithm learns the shape of the objective function "on the fly."A popular choice for a surrogate is a Gaussian Process Model, which can be thought of as an infinite dimensional generalization of a multivariate Gaussian distribution.Using a Gaussian Process Model enables an estimate of both the objective function value and an estimate of uncertainty at all points.As such, users can weight the next parameter sets to be in regions of high uncertainty or regions where good solutions are expected -explicitly controlling the exploration/exploitation trade-off.The surrogate function can also handle noisy objective functions, both by smoothing the surrogate function and increasing the uncertainty estimates.In contrast to the Nelder-Mead method, Bayesian Optimization will not generally converge as quickly during the first iterations, during which it is still learning the shape of the objective function.However, once this initial period of learning is complete it will tend to find solutions faster and be less likely to get stuck in local minima.

TopasOpt

11TopasOpt is a free and open-source Python code for performing formal optimization of parameters used in a Topas simulation. 9TopasOpt provides a framework via which any Topas project can be converted into an optimization problem, and any parameter can be optimized.A Topas model is entirely defined by a series of ASCII encoded (i.e., "normal") text files, which in turn contain a series of organized parameters defined with the Topas syntax.This makes Topas ideally suited to interfacing with third party codes such as TopasOpt, since running a Topas model simply involves passing an ASCII parameter file to the pre-compiled Topas application.To convert any existing Topas project into a TopasOpt optimization problem, an end user must create three Python files:

121.

GenerateTopasScripts.py: Create a Python function which will generate the Topas model for a given set of parameters {x}

13Although this step may sound difficult, in practice TopasOpt includes functionality to automatically generate a first draft of this function from an existing model.The user must then change only a few lines manuallytypically one line for each parameter they wish to optimize.TopasOpt will automatically locate and call this function.

TopasObjectiveFunction.py: Define an objective function

14This function accepts two parameters -the location of the results and current iteration -and must return a number to the optimizer.What happens between these two steps is defined by the user.A standard approach would be to read in the latest results, extract relevant metrics from them, and use these to calculate an objective function.TopasOpt will automatically locate and call this function.

Main_RunOptimization.py: Choose a start point, define bounds, choose optimization algorithm

15This is the script which is executed to run the optimization.In it, the user supplies a start point for each parameter, allowed bounds, convergence criteria, optimization algorithm to run, and can also specify any algorithm specific options.

F I G U R E 1 Automated optimization loop of TopasOpt

16Once these components are assembled, Main_RunOptimization.py can be executed, which will execute the automatic optimization loop described in Figure 1.

17A brief explanation of each of the steps in Figure 1 follows:

18• Build Model: Use GenerateTopasScripts.py (step 1 above) to generate Topas parameter files for parameter set {x}. • Run model: in this step, the generated parameter files are sent to the pre-built Topas application and executed as subprocess of TopasOpt.At this point, TopasOpt relinquishes control to Topas; it assumes control again once the Topas run is complete.• Assess objective function: Utilizes the user generated code from step 2 above to generate the value of the objective function for the current parameter set.• Termination criteria met?Convergence criteria can include e.g., number of iterations, number of iterations without improving on the best solution, percentage improvement on start point, etc.In practice, the main termination criteria used at present is number of iterations.

19• Choose {x next } Exactly how {x next } is selected will vary depending on the optimization algorithm.This is the only optimization algorithm specific step in this workflow.

20On the completion of each iteration, TopasOpt will log the results to a log file and generate and save several figures relevant to the progress of optimization, making it easy to monitor progress of the optimization.The user can choose to store all scored data, or only the most recent iteration.To ensure robustness to new developments, TopasOpt includes a test framework which is automatically run whenever changes are made to the main repository.

21As mentioned, at present TopasOpt includes two optimization algorithms; Bayesian Optimization which utilizes the code "Bayesian Optimization: A Python Implementation of Global Optimization with Gaussian Processes 12 " and Nelder-Mead Optimization based on scipy. 13It is simple to extend TopasOpt to new optimization algorithms, since the core functionality of TopasOpt is contained in a base class; new Optimizers inherit this base class.The base class handles everything in Figure 1 except for choosing the next parameter set to test, which is the optimizer specific step.To give an idea of the simplicity of adding new optimizers; a basic implementation of the Nelder-Mead method can be achieved with twelve lines of code, which is shown in Figure 2. In general, the process of switching optimization algorithm for an end user only involves changing one line of code, for example, "BayesisanOptimizer.RunOptimization()" to "NelderMeadOptimizer. RunOptimization()."

Case studies

22To demonstrate the use of TopasOpt, case studies based on the production and collimation of an X-ray beam from bremsstrahlung radiation werey tested.

Base model

23The base model consisted of a monoenergetic electron beam striking a tungsten X-ray target (Figure 3).The resultant X-ray beam passed through two collimators before being scored in a water tank.5 × 10 5 primary electrons were simulated, and bremsstrahlung X-rays in the target are split 1000 times and subject to Russian roulette with a split number of 1000 if projected outside a radius greater than 50 mm at isocenter. 14The phase space is scored just below the secondary collimator and recycled two hundred times in a second simulation of dose in water.The Geant4 G4EmStandardPhysics list was used throughout this work.Although this is less accurate than some other physics lists, since we are only testing the ability of the optimizer to match data also calculated with G4EmStandardPhysics, it can be used with no loss of generality and is substantially faster than other physics lists.The same is true of the aggressive variance reduction utilized.The case studies were developed by randomizing various parameters in this model and attempting to use TopasOpt to recover the ground truth values using an objective function based on absolute differences in profile and depth curves in water.The first case study focuses on the electron beam phase space, while the second case study focuses on the collimator geometry (Figure 3).In the third case study, the effect of varying the number of primary particles on the geometric optimization (case 2) was studied to quantify the effect of stochastic noise on optimization performance.In the first case study, the phase space properties of the electron beam are optimized.In the second and third case studies, the geometric parameters of the secondary collimator are optimized

Optimization of electron beam parameters

24In this example, five parameters defining the electron beam phase space are optimized: Beam Energy, Beam Position Cutoff, Beam Position Spread, Beam Angular Spread, and Beam Angular Cutoff (Figure 3).For the physical basis of these parameters, please refer to the Topas user documentation. 15The values in the base model were 10.0 MeV, 2 mm, 0.3 mm, 0.07 • , 5 • .Random starting values were 7.9 MeV, 2.7 mm, 1.0 mm, 0.1 • , and 2.7 • (Table 2).Symmetry in X and Y was assumed for simplicity.The objective function was formulated based on differences between the original dose profiles for a given parameter set as described in Equation ( 1):

25This was considered a challenging problem since it is well known that MV X-ray dose in water is not particularly sensitive to most electron beam parameters, with energy typically the most sensitive parameter. 16he natural log in the objective function is used to emphasize small differences, although this does also come at the cost of emphasizing noise. 2 × 10 5 primary particles were run per iteration, with a run time per iteration of approximately 20 min on a 16-core server.Note that most of this time is the time required for the Topas simulations rather than the optimization algorithm.This problem was solved with both the Bayesian and Nelder-Mead optimizers.

Optimization of geometric parameters

26Three geometric parameters were randomized: collimator thickness, upstream aperture radius, and downstream aperture radius (Figure 3).The ground truth (i.e., starting values) and randomized values for these parameters were 54.0 mm, 1.8 mm, 2.5 mm, 25.0 mm, 2.5 mm, and 1.6 mm respectively (see Table 3).

27Since this simulation was expected to show more sensitivity to the parameters being optimized, the total number of particles was reduced to 5 × 10 4 primary particles and the natural log was removed from equation 1.These changes make the data noisier, but the objective function less sensitive to noise.With the reduced number of primary particles, each optimization iteration took around 5 min on a 16-core server, and forty iterations were run.This problem was solved with both the Bayesian and Nelder-Mead optimizers.

Optimization of noisy objective functions

28Statistical noise is inherent in Monte Carlo simulation and is inversely proportional to the square root of the number of primary particles.To study the effect of noise on the optimization, the simulation from the prior section was repeated with the total number of particles set to (1 × 10 4 , 2 × 10 4 , 3 × 10 4 , 4 × 10 4 , 5 × 10 4 ).Ten simulations with the parameters set to the true (ground truth) parameters were run for each number of particles.Next, one hundred iterations of Bayesian Optimization were performed for each case.A custom Gaussian Process kernel was constructed consisting of a Matern kernel plus with a white kernel; the latter is specifically designed to model noise. 17The optimization performance, as well as the Gaussian Process Model predictions at the known ground truth were compared for each case.

Optimization of electron beam parameters

29Figure 4 shows the convergence plot for each optimizer.Several features are of interest here.For the Bayesian Optimizer (Figure 4a) note that the Gaussian Process Model predictions become more accurate as more shows the Gaussian Process Model predictions as well as the actual value of the objective function at each iteration.The lowest value of the objective function found in each case is marked with a x iterations are run and the model learns the shape of the objective function.Note also that that this optimizer is quite exploratory, in that even parameter sets predicted to be poor candidates are frequently probed.Compare this with the Nelder-Mead convergence (Figure 4b)after a faster initial period of convergence, this algorithm continues to probe points around the previous best solu-

30F I G U R E 5 Comparative profiles (a) and depth-dose curves (b) for the optimization of phase space parameters.Note that the data is quite noisy because this is taken directly from the data used during optimization tion.Note that by observing the objective value of the last ∼10 iterations, it is possible to assess the noise in the objective function since the parameters tend to not change very much at the end of an optimization run.

31Based on Figure 4, it can be inferred that there is a high amount of noise around the best solutions.This is a result of both the stochastic nature of Monte Carlo, and the use of a log objective function.Despite this noise, both optimizers were effective in minimizing the difference in depth-dose and profile data (Figure 5a).The ground truth, randomized, and optimized values from both the Bayesian and Nelder-Mead optimizers are shown in Table 2, while profiles and depth-dose curves are shown in Figure 5a,b.Overall, both optimizers performed similarly, with the Bayesian algorithm finding a minimum objective function value of −0.49 and the Nelder-Mead algorithm finding a minimum of −0.53, compared with a starting value of 1.5.While Beam Energy and Beam Position Cutoff parameters were recovered to within 1% and 20% of their true values, Beam Position Spread, Beam Angular Spread, and Beam Angular Cutoff tend to have larger percentage errors (Table 2).Two points should be made here.The first is that while the percentage error is sometimes large, the absolute error is small -for instance in the case of Beam Angular Spread, the absolute error is only 0.12 • .The second is that the objective function may not actually be sensitive to these parameters, in which case any optimizer will find it difficult to recover them.For Bayesian Optimization, a useful indication of the sensitivity of the objective function to various parameters is the single parameter plots shown in Figure 6.It must be emphasized that these values are predictions -the extent to which they should be trusted depends on how well the Gaussian Process Model has been demonstrated to correlate with the true objective function.In this case the Spearman correlation between predicted and simulated objective functions across all iterations was 0.8, indicating that these plots at least correlate with simulated measurement.Based on these plots, we can see that the objective function is predicted to exhibit almost no sensitivity to Beam Angular Cutoff, explaining the comparatively large error for this parameter.

Optimization of geometric parameters

32Figure 7 shows profiles and depth-dose curves in water for the original, random start point, and optimized models for the optimization of collimator geometry.The optimized models are well matched to the original (ground truth) data.Quantitively, the objection function was reduced from a starting value of 13.8 to 1.1 with the Bayesian Optimizer, and 1.6 with the Nelder-Mead Optimizer.Figure 8 show the Gaussian Process Model predictions of the objective function as a function of each parameter while the other parameters are held at their optimal value.Spearman correlation was 0.7 over all forty iterations.

Optimization of noisy objective functions

33Figure 9a shows the value of the objective function versus the number of primary particles, as well as the Gaussian Process prediction of the objective value at the same parameter values.Note that for no noise, the objective function evaluated at the 'true' parameters would be zero in all cases; because we take the absolute values any noise will increase the value of the objective function.There is a high correlation between the "true" (e.g., mean) value and the Gaussian Process prediction, and the uncertainty predicted by the Gaussian Process is well correlated with the varying amount of noise in each case (note that in general the Gaussian Process Model has not seen this exact point prior to making the prediction).

34Figure 9b shows the convergence for different number of primary particles.As expected, with more primary particles (and hence less noise) the optimizer tends to converge faster and to lower overall values.Table 4 shows the best parameter values found for each case.The largest discrepancies between best guess and ground truth tend to be for upstream hole size, which is expected to be the least sensitive parameter in this model (Figure 8).Meanwhile, in all cases the estimate of collimator thickness is within 1 mm, which is expected to be the most sensitive parameter given the results in Figure 8.As the noise level increases the "high signal" parameters of the objective are still effectively optimized, while the low signal parameters are more likely to be washed out by noise.The general trend is for better performance with higher number of particles, although the n = 2e4 case does have surprisingly high performance -this would appear to be statisti-

DISCUSSION

35In Monte Carlo simulation of radiation transport, it is very common for the correct or optimal value of some parameter to be unknown for a variety of reasons.Typically,and historically,these situations have been handled via non exact and labor-intensive methods such as "grid searching."A far superior approach would be to apply formal mathematical optimization algorithms which are purpose built for such situations.Historically this has not been possible due to the lack of appropriate tools.In this work, an open-source library for performing optimiza-tion based on Topas Monte Carlo simulations has been developed and tested.This is the first freely available code for optimization of general-purpose Monte Carlo simulations.Applications for this code include (1) the design of new accelerators, detectors, and equipment, and (2) Reverse engineering of models based on limited experimental or published data, and (3) Tuning of Monte Carlo 'hyper parameters' such as physics, variance reduction, scoring settings to optimize simulation efficiency with respect to some ground truth.TopasOpt is available online with detailed documentation. 9n both the optimization of phase space parameters and the optimization of geometric parameters, excellent matches to the starting profile and depth-dose data were obtained (Figures 5 and 7).In the case of the optimization of geometric parameters (case study 2,Table 3),this also corresponded with good recovery of the ground truth parameters, with the Bayesian optimizer finding all ground truth parameters within 9% and the Nelder-Mead finding all parameters within 28%.This was not the case for the optimization of phase space parameters (case study 1, Table 2) -where errors of up to 171% (Bayesian) and 64% (Nelder-Mead) were observed.This result is not entirely surprising, as it is well known that X-ray dose distributions are not especially sensitive to many parameters defining an electron phase space, 16 with energy typically the most sensitive parameter.Fundamentally, no optimization algorithm will perform well if the parameters the algorithm is varying do not affect the objective function.For instance, considering the Beam Angular Cutoff parameter in Figure 6, the objective function has almost no sensitivity to this parameter.Beam Angular Cutoff refers to the value at which the Gaussian distribution is trimmed; as such if Beam Angular Cutoff is substantially smaller than the Beam Angular Spread parameter, this parameter will have little impact on the phase space.Therefore, the result that this parameter does not affect the objective function makes intuitive sense.Another reason for the large relative errors is that very small ground truth values tend to result in large relative errors even when absolute errors are small -this is the case for instance in the Beam Angular Spread parameter (Table 2).However, this result also reflects the limitations in data supplied to the optimizers.Firstly, the objective function used was not particularly sophisticated, based on only the absolute differences between a single profile and a central depth-dose curve.A more textured objective function could include multiple profiles or off -axis curves as well as some form of output factor.

36A fundamental difficulty in optimization of Monte Carlo parameters is statistical noise, which is an inherent aspect of the Monte Carlo method.For the case of optimization, what is important is the noise in the objective function -the same statistical Monte Carlo noise can manifest very differently depending on how the objective function is constructed.For the optimization of geometric parameters, the noise in the objective function was quantified for a varying number of primary particles, and the effect on algorithm convergence studied (Figure 9).These results demonstrate that Bayesian Optimization in particular can perform well in the presence of noise, as the Gaussian Process underlying the optimization is capable of parameterizing and predicting noise (Figure 9a).

37Two algorithms are currently implemented in Topa-sOpt, the Nelder-Mead method and Bayesian Optimization.In principle, TopasOpt can utilize any appropriate optimization algorithm and has been designed with extensibility in mind.However, in practice, we believe that Bayesian Optimization is likely to prove the most appropriate algorithm for most situations as it is robust to noise, well suited to expensive objective functions, and does not get stuck in local minima. 18On the other hand, the Nelder-Mead algorithm is simpler to implement and understand and will generally tend to show a faster period of initial convergence than Bayesian Optimization.Other algorithms which may prove suitable for this problem domain (defined in Section 2.1) include simulated annealing, as well as ensemble-based methods such as evolutionary or particle swarm algorithms. 7,8e suspect that ensemble-based algorithms may prove inefficient for the "expensive" problem of Monte Carlo simulation, but this hypothesis remains to be tested.Under certain assumptions about the objective function (i.e., that it is smoothly varying), simulated annealing with a logarithmic cooling schedule can be guaranteed to find a global minimum.However, this cooling schedule is so slow that it is impractical. 19For other cooling schedules, it shares with Nelder-Mead the problem that it may become stuck in local minima.

38At present, TopasOpt only handles single-objective optimization, meaning competing objectives must be combined in one objective function (e.g.,"Maximize dose rate" but "minimize target heating").An interesting topic for future research would be that of multi-objective optimization, also called Pareto optimization. 20Such an optimization strategy focuses on finding solutions for multiple objective functions in which no objective function can be decreased without increasing another objective function.Such parameter sets are said to be Pareto optimal.There are existing multi-objective optimization libraries for Python, although it would likely take some effort to integrate TopasOpt with these libraries. 21,22

CONCLUSION

39TopasOpt is an open-source library which can transform any Topas model into an optimization problem and any Topas parameter into an optimization variable.TopasOpt has been demonstrated to be effective at minimizing objective functions based on Monte Carlo simulations.We believe that in future, formal mathematical optimization should become de-rigueur for any Monte Carlo problem in which some parameters must be tuned.Examples include component design, reverse engineering, and tuning of simulation hyper-parameters.

F I G U R E 2 F I G U R E 3

40Demonstration of implementing a simple NelderMead optimizer which uses the scipy default settings.Since the major functionality is all inherited from TopasOptBaseClass, only twelve lines of code are required.This basic template is the same for any new optimization algorithm Model used in the case studies.

4

41Convergence plot for (a) Bayesian Optimization and (b) Nelder-Mead optimization of electron beam parameters.(a)

6 7

42Comparative profiles (a) and depth-dose curves (b) for the optimization of geometric parameters.Note that the data is quite noisy because this is taken directly from the data used during optimization Gaussian Process Model predictions of the objective function as a function of each parameter while other parameters are held at their optimal values for the phase space optimization (case study 1).The Gaussian Process Model is trained as the Bayesian Optimization is run, with each iteration serving as a data update for the model.The solid line indicates the predicted mean, and the shading the standard deviation

8

43Gaussian Process Model predictions of the objective function as a function of each parameter while other parameters are held at their optimal values for the geometric optimization.The solid line indicates the predicted mean, and the shading the standard deviation n primary particles a) b) (a) Noise in objective VS n-primary-particles (b) Convergence VS n-primary-particles Iteration Best objective value found Objective values F I G U R E 9 (a) Measured objective function values versus number of histories (boxplots), and Gaussian Process predictions at the same parameters after one hundred iterations of Bayesian Optimization.For no noise, the objective function should be zero.(b) Optimizer convergence for different number of primary particles TA B L E 4 Best parameters found by optimizer versus number of primary particles Parameter Ground truth value n = 1e4 n = 2e4 n = 3e4 n = 4e4 n = 5e4

44. and P.K. wish to acknowledge funding from NHMRC program and fellowship grants.The authors wish to thank Dr. Joseph Perl for the helpful suggestions and encouragement, Julia Johnson for input into figure design, Dr. Lars Mejnertsen for beta testing, and Dr. Helen Ball for proof reading.C O N F L I C T O F I N T E R E S TB.W.L. is a founder and board member of Tibaray.J.W. is an employee of Varian Medical Systems.

45Parameter summary for optimization of electron beam parameters

46TA B L E 2

참고문헌 18건

  1. TOPAS: An innovative proton Monte Carlo platform for research and clinical applications Medical Physics · Wiley · 2012 10.1118/1.4758060
  2. Sensitivity of megavoltage photon beam Monte Carlo simulations to electron beam and other parameters Medical Physics · Wiley · 2002 10.1118/1.1446109
  3. Simulated Stochastic Approximation Annealing for Global Optimization With a Square-Root Cooling Schedule Journal of the American Statistical Association · 2014 10.1080/01621459.2013.872993
  4. Fifty years of Monte Carlo simulations for medical physics Physics in Medicine and Biology · IOP Publishing · 2006 10.1088/0031-9155/51/13/r17
  5. A View of Algorithms for Optimization without Derivatives 1 2007
  6. Blackbox and derivative-free optimization: theory, algorithms and applications Optimization and Engineering · Springer Science+Business Media · 2016 10.1007/s11081-016-9307-4
  7. ADVANCES IN NEURAL INFORMATION PROCESSING SYSTEMS 16 Neural Information Processing Systems · 2004
  8. RECORDS: improved Reporting of montE CarlO RaDiation transport Studies: Report of the <scp>AAPM</scp> Research Committee Task Group 268 Medical Physics · Wiley · 2017 10.1002/mp.12702
  9. SciPy 1.0: fundamental algorithms for scientific computing in Python Nature Methods · Nature Portfolio · 2020 10.1038/s41592-019-0686-2
  10. Pymoo: Multi-Objective Optimization in Python IEEE Access · Institute of Electrical and Electronics Engineers · 2020 10.1109/access.2020.2990567
  11. MOBOpt — multi-objective Bayesian optimization SoftwareX · Elsevier BV · 2020 10.1016/j.softx.2020.100520
  12. Multiobjective Bayesian optimization for online accelerator tuning Physical Review Accelerators and Beams · American Physical Society · 2021 10.1103/physrevaccelbeams.24.062801
  13. SciPy 1.0: fundamental algorithms for scientific computing in Python Nature Methods · Nature Portfolio · 2020 10.1038/s41592-019-0686-2
  14. An automated optimization strategy to design collimator geometry for small field radiation therapy systems Physics in Medicine and Biology · IOP Publishing · 2021 10.1088/1361-6560/abeba9
  15. Physics model-informed Gaussian process for online optimization of particle accelerators Physical Review Accelerators and Beams · American Physical Society · 2021 10.1103/physrevaccelbeams.24.072802
  16. Monte Carlo methods for device simulations in radiation therapy Physics in Medicine and Biology · IOP Publishing · 2021 10.1088/1361-6560/ac1d1f
  17. Bayesian optimization to design a novel x‐ray shaping device Medical Physics · Wiley · 2022 10.1002/mp.15887
  18. TopasOpt: An open‐source library for optimization with Topas Monte Carlo Medical Physics · Wiley · 2022 10.1002/mp.16126