A method for self-calibration of a synchrotron beamline based on an active learning agent model
Patent Information
- Application Number
- CN202611469712.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-10-30
AI Technical Summary
该类方法的共同局限在于:高维参数空间的非线性和强耦合特性使单一模型难以维持高预测精度;全局搜索和局部精调未有效分离,导致搜索效率低或硬件磨损严重;缺乏完整的系统化闭环设计,各功能模块之间缺乏标准化接口,难以集成使用
[0026]校准效率的飞跃。标准模式下从初始状态到完成校准的总耗时小于3分钟,对比人工校准的30分钟以上,效率提升10倍以上。全流程自动运行,无需任何人工干预,操作人员无需具备专业的光学或控制知识。
Smart Images

Figure CN123010437A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of control and regulation systems and machine learning, specifically relating to a synchrotron radiation beamline self-calibration method based on an active learning agent model. Background Technology
[0002] In the beamline of the High Energy Photon Source (HEPS), the Kirkpatrick-Baez (KB) focusing system consists of horizontal and vertical focusing mirrors arranged in an orthogonal configuration. Two-dimensional focusing of the beam is achieved through the sequential reflection of two mirrors. The calibration status of the KB system directly determines the beam quality reaching the sample location at the experimental station, including key indicators such as spot size, intensity distribution, symmetry, and wavefront flatness.
[0003] In practical operation, KB mirror systems typically require simultaneous adjustment of multiple control parameters, including the tilt angle of the wavefront position monitor, the center positions of multiple slits, and their opening sizes. These parameters exhibit strong coupling effects: a change in one angle affects the incident position and angle of the beam on the slit plane, thus altering the actual beam clipping effect of each slit; the opening and closing states of different slits also influence each other, jointly determining the final beam flux and spatial distribution. This makes KB mirror calibration a typical ultra-high-dimensional non-convex optimization problem, with its objective function exhibiting multiple sets of solutions with multi-peak distributions, posing a significant challenge to global optimization.
[0004] Currently, KB mirror calibration mainly relies on the following methods:
[0005] Manual calibration involves operators observing the real-time image of the light spot displayed on the detector. Based on visual characteristics such as the shape, size, and intensity distribution of the light spot, they judge the current calibration status based on experience and gradually adjust various control parameters. This iterative process of "observation → judgment → adjustment" is repeated to find the optimal calibration state. This method is highly dependent on the operator's personal experience, resulting in significant differences in calibration quality between different operators. It lacks standardization and reproducibility. A typical calibration usually requires a long continuous operation time, making operators prone to fatigue and errors. Manual operation tends to conservatively adjust in small increments to avoid over-adjustment, often resulting in a local optimum rather than a global optimum. Furthermore, this method cannot automatically recover calibration drift caused by environmental changes during unattended periods.
[0006] Optimization methods based on physical optics simulations. Some studies attempt to combine synchrotron radiation physical optics simulation software with optimization algorithms, searching for optimal calibration parameters by repeatedly calling physical simulations. The advantage of this type of method is the high accuracy of the physical model, capable of capturing complex physical effects such as diffraction and interference during beam propagation. However, a single physical simulation typically takes several seconds to minutes, while a global search usually requires thousands to tens of thousands of evaluations, making the total time consumption unacceptable. Furthermore, physical simulations require precise beamline geometry parameters and optical element surface shape data as input, and these data themselves contain measurement errors, leading to deviations between simulation results and actual conditions.
[0007] Optimization methods based on single machine learning models. In recent years, researchers have begun to introduce machine learning models into synchrotron beamline optimization. Typical approaches include using Gaussian process regression or neural networks to train parameter-quality surrogate models, and then combining genetic algorithms or Bayesian optimization to search for parameters on the surrogate models. Common limitations of these methods include: the nonlinearity and strong coupling of the high-dimensional parameter space make it difficult for a single model to maintain high prediction accuracy; the lack of effective separation between global search and local fine-tuning leads to low search efficiency or severe hardware wear; and the lack of a complete, systematic closed-loop design, with a lack of standardized interfaces between functional modules, making integration difficult.
[0008] In summary, existing KB mirror calibration methods have significant shortcomings in terms of efficiency, accuracy, automation, and hardware protection. There is an urgent need for a fully automated calibration scheme that can balance global optimization capabilities with local fine-tuning efficiency. Summary of the Invention
[0009] To address the aforementioned technical issues, this invention provides a synchrotron beamline self-calibration method based on an active learning surrogate model. It combines the XGBoost high-precision surrogate model with the JADE (Global Optimizer) adaptive differential evolution algorithm and employs a two-stage closed-loop strategy of "global search with zero hardware movement on the surrogate model + local fine-tuning with a small amount of movement on the real hardware" to achieve efficient and fully automatic calibration of the synchrotron KB mirror focusing system.
[0010] To achieve the above objectives, the present invention adopts the following technical solution:
[0011] A synchrotron beamline self-calibration method based on an active learning agent model includes:
[0012] Step 1: Collect multiple sets of original 9-dimensional control parameter combinations of the KB focusing system and the corresponding detector spot images. Divide the detector spot images into several sub-apertures and calculate the standard deviation of the centroid of each sub-aperture as a beam quality index.
[0013] Step 2: Retain the original 9-dimensional control parameters, multiply the motor parameters with each slit parameter to construct interactive features, and calculate the squared terms for the original 9-dimensional control parameters to capture the squared features near the optimal solution. Concatenate the original 9-dimensional control parameters, interactive features, and squared features into a 26-dimensional feature vector and perform standardization processing. Train the XGBoost extreme gradient boosting model as a surrogate model.
[0014] Step 3: Using the predicted value of the surrogate model as the fitness function, a global search is performed in the original 9-dimensional control parameter space using an adaptive differential evolution algorithm with optional external archive. The adaptive differential evolution algorithm independently generates scaling factors and crossover probabilities for each individual and follows a distribution controlled by the mean parameter that is adaptively updated based on historical success records. The fitness evaluation of all candidate solutions is completed on the surrogate model without moving any hardware devices during the entire search process. The predicted optimal solution is obtained after the search converges.
[0015] Step 4: Move the hardware device to the predicted optimal solution position, use the actual measured value of the beam quality index as the feedback standard for local hill climbing fine adjustment, apply positive and negative perturbations in each dimension and adaptively adjust the step size according to the improvement of the actual measured value. When the step size of all dimensions is less than the preset threshold or the number of consecutive times without improvement reaches the upper limit, terminate the search and output the final calibration parameters.
[0016] Furthermore, in step 1: the 9-dimensional control parameters include: the tilt angle of the wavefront position monitor, the center position of the horizontal slit, the opening size of the horizontal slit, the center position of the vertical slit, the opening size of the vertical slit, the position of the lower slit, the position of the left slit, the position of the right slit, and the position of the upper slit.
[0017] Furthermore, in step 1: for each sub-aperture, the horizontal and vertical coordinates of the spot centroid are calculated using the gray values of all pixels within that sub-aperture, with the gray values as weights; the standard deviations of the horizontal coordinates and vertical coordinates of all sub-aperture centroids are calculated; and the average of the horizontal and vertical coordinate standard deviations is taken as the beam quality index.
[0018] Furthermore, the 26-dimensional feature vector in step 2 is specifically composed as follows: the first 9 dimensions are the original 9-dimensional control parameters; the middle 8 dimensions are the interactive features obtained by multiplying the motor parameters by the 8 slit parameters respectively; and the last 9 dimensions are the squared terms of the original 9-dimensional control parameters respectively.
[0019] Furthermore, in step 2, before training the XGBoost proxy model, a data augmentation method based on synchrotron radiation physics simulation software is used to expand the training samples: taking the collected original experimental data as a benchmark, systematic parameter sampling is performed in the feasible region of the 9-dimensional control parameter space, the sampled parameter combination is input into the synchrotron radiation physics simulation software for simulation and calculation of the corresponding beam quality index, and the effective data generated by the simulation is merged with the original experimental data to obtain the augmented training dataset.
[0020] Furthermore, in step 2, the hyperparameters of the XGBoost model are automatically determined by random search combined with K-fold cross-validation. The hyperparameter search space includes: the number of trees, maximum depth, learning rate, sample subsampling ratio, and feature subsampling ratio. The optimal hyperparameter combination is selected with the goal of minimizing the mean square error of cross-validation, and the final XGBoost surrogate model is obtained by retraining on all training data using the optimal hyperparameter combination.
[0021] Furthermore, in step 3, the adaptive differential evolution algorithm adopts the mutation strategy of current optimal guidance, randomly selects one of the top individuals in the current population from the top specified percentage as the optimal guidance direction, and selects the source of the difference vector from the union of the current population and the external archive; the scaling factor follows a Cauchy distribution, and the crossover probability follows a normal distribution. The distribution mean parameters of both are updated based on the history of successful evolution using the Lymer mean method, so that the scaling factor and crossover probability are adaptively adjusted as the search process progresses.
[0022] Furthermore, three optional calibration modes are provided: in fast mode, the global search in step 3 is skipped, and the local hill-climbing fine-tuning in step 4 is performed directly from the current hardware position; in standard mode, the global search in step 3 is performed once, and then the local hill-climbing fine-tuning in step 4 is performed; in fine mode, the global search in step 3 is performed multiple times independently, and after each search, the hardware is moved to the corresponding predicted optimal solution and the local hill-climbing fine-tuning in step 4 is performed. The results of each verification are compared, and the one with the best beam quality index is selected as the final output.
[0023] In a second aspect, the present invention provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned synchrotron beamline self-calibration method based on an active learning agent model.
[0024] Thirdly, the present invention provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enable the processor to implement the aforementioned synchrotron beamline self-calibration method based on an active learning agent model.
[0025] The beneficial effects of this invention are as follows:
[0026] A leap in calibration efficiency. In standard mode, the total time from initial state to completion of calibration is less than 3 minutes, compared to more than 30 minutes for manual calibration, representing an efficiency improvement of more than 10 times. The entire process is automated, requiring no manual intervention, and operators do not need to have professional optical or control knowledge.
[0027] Industry-leading calibration accuracy. The XGBoost surrogate model achieves a test set determination coefficient of 0.8143, providing a highly reliable objective function alternative for global search. Combined with local fine-tuning stages utilizing real detector feedback for correction, the final beam quality index is reduced by 15% to 25% compared to manual calibration. A gradient design with three modes (Fast < Standard < Fine) allows users to flexibly balance accuracy and speed.
[0028] The hardware protection effect is significant. The global search phase is completed entirely at the software level of the XGBoost proxy model, without involving any physical movement of motors or slits. The local fine-tuning phase requires only 10 to 25 hardware movements, a reduction of over 90% compared to the hundreds of operations required for manual calibration. This feature is of great significance for extending the service life of precision motors and slits and reducing maintenance costs.
[0029] Strong robustness. JADE's adaptive parameter mechanism can automatically adapt to the needs of different search stages, achieving stable global search in a 9-dimensional multimodal non-convex space. Comparative validation shows that JADE's quality standard deviation under different random seeds is only 0.53, far lower than the 2.40 of standard deviation evolution and the 4.07 of particle swarm optimization. Meanwhile, XGBoost's ensemble tree structure has good tolerance to noise and outliers in the training data.
[0030] Low development and deployment costs. The hardware interface module has a built-in simulation mode, allowing all algorithm development and system debugging to be completed in an environment without real hardware. Switching to real hardware only requires changing one configuration parameter, without modifying any algorithm code, significantly reducing development and testing costs and risks.
[0031] Highly scalable. The system's modular architecture allows each component to be upgraded independently. In the future, more advanced models can replace XGBoost as the proxy model, or new evolutionary algorithms can replace JADE. Only the corresponding modules need to be replaced, without affecting the overall architecture and operating logic of the system. Attached Figure Description
[0032] Figure 1 This is a block diagram illustrating the overall architecture principle of the synchrotron beamline self-calibration system based on an active learning agent model of the present invention.
[0033] Figure 2 This is a flowchart of the synchrotron radiation beamline self-calibration method based on an active learning agent model according to the present invention. Detailed Implementation
[0034] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0035] This invention provides a synchrotron beamline self-calibration method based on an active learning surrogate model. The core concept addresses the calibration challenges of strongly coupled 9-dimensional control parameters and a multi-peaked, non-convex objective function in synchrotron KB mirror focusing systems. It constructs a high-precision XGBoost surrogate model to replace time-consuming physical simulations or manual trial and error. The JADE adaptive differential evolution algorithm performs a global search on the surrogate model with zero hardware movement to quickly locate the optimal solution region. Then, adaptive step-size local hill-climbing fine-tuning based on feedback from the real detector compensates for model prediction biases, forming a two-stage closed-loop calibration architecture of "software global search for orientation and hardware local fine-tuning for accuracy." This concept systematically solves the contradiction between calibration efficiency, accuracy, and hardware protection from three levels: "model construction—global search—local fine-tuning," enabling the system to autonomously, quickly, and stably converge to a high-quality calibration state under any initial state.
[0036] like Figure 1 As shown, the method proposed in this invention relies on an automatic calibration system. This system adopts a modular, layered architecture and consists of eight core functional modules, which communicate and collaborate with each other through standardized data interfaces:
[0037] The Data Acquisition & Quality Assessment module is responsible for reading raw beam images from the detector, performing sub-aperture division and centroid calculation, and outputting a quantitative beam quality index, Q. This module is the system's data entry point, and its output quality directly affects the accuracy of all subsequent stages.
[0038] Data Augmentation Module: To address the problem of insufficient sample size in the original experimental data (usually only about 599 valid data points), the SRW data augmentation module expands the valid data to more than 10,000 points, providing sufficient statistical sample support for the training of deep models.
[0039] Feature Engineering module: Apply two feature transformations—interactive features and squared features—to the original 9-dimensional control parameters, mapping the data from the original 9-dimensional space to a 26-dimensional feature space, providing richer input information for the surrogate model.
[0040] The XGBoost Surrogate Model module trains an extreme gradient boosting regression model in a 26-dimensional feature space, establishing a high-precision mapping relationship between "control parameters and beam quality". This module is the intelligent core of the entire system, and its prediction accuracy directly determines the reliability of the upper-layer optimization.
[0041] The JADE Global Optimizer module uses the predictions from the XGBoost surrogate model as the objective function and performs model queries in a 9-dimensional parameter space to achieve adaptive differential evolution global search. All evaluations in this stage are performed on the surrogate model without any hardware changes, thus enabling large-scale population iterations.
[0042] Local Refinement - Hill Climbing: Near the optimal solution obtained by JADE global search, local fine-tuning control is performed on real hardware using an adaptive step-size hill climbing algorithm to eliminate the impact of surrogate model prediction errors on the final result.
[0043] Hardware Interface Module: Provides a unified upper-layer application programming interface (API), encapsulates the low-level hardware operations of the motor (EPICS / Python serial port) and various slits, and supports seamless switching between simulation mode and real hardware mode.
[0044] The Auto-Calibrator module serves as the control center of the system. It coordinates the workflow of the various modules using a calibration control coordinator, provides three calibration modes for users to choose from (Quick, Standard, and Thorough), and manages the entire lifecycle of the calibration task.
[0045] The system's workflow can be summarized in three stages: Preparation stage (offline) – acquiring raw datasets through SRW simulations or historical experiments, amplifying and feature-engineering them to train an XGBoost surrogate model; Global search stage (online, no hardware movement) – feeding the 9-dimensional parameters to be optimized into 26 dimensions via the feature engineering module, predicting the beam quality Q-value using the XGBoost model, and the JADE optimizer performing a global search on the predicted values, converging to the global optimum after approximately 100 iterations; Fine-tuning stage (online, minimal hardware movement) – moving the hardware to the optimal position obtained from the JADE search, performing adaptive hill-climbing fine-tuning on real detector feedback, and outputting the final optimal 9-dimensional control parameters after convergence. Specifically, such as... Figure 2 As shown, the synchrotron beamline self-calibration method based on an active learning agent model described in this invention includes:
[0046] Step 1: Collect multiple sets of original 9-dimensional control parameter combinations of the KB focusing system and the corresponding detector spot images. Divide the detector spot images into several sub-apertures and calculate the standard deviation of the centroid of each sub-aperture as a beam quality index.
[0047] Step 2: Retain the original 9-dimensional control parameters, multiply the motor parameters with each slit parameter to construct interactive features, and calculate the squared terms for the original 9-dimensional control parameters to capture the squared features near the optimal solution. Concatenate the original 9-dimensional control parameters, interactive features, and squared features into a 26-dimensional feature vector and perform standardization processing. Train the XGBoost extreme gradient boosting model as a surrogate model.
[0048] Step 3: Using the predicted value of the surrogate model as the fitness function, a global search is performed in the original 9-dimensional control parameter space using an adaptive differential evolution algorithm with optional external archive. The adaptive differential evolution algorithm independently generates scaling factors and crossover probabilities for each individual and follows a distribution controlled by the mean parameter that is adaptively updated based on historical success records. The fitness evaluation of all candidate solutions is completed on the surrogate model without moving any hardware devices during the entire search process. The predicted optimal solution is obtained after the search converges.
[0049] Step 4: Move the hardware device to the predicted optimal solution position, use the actual measured value of the beam quality index as the feedback standard for local hill climbing fine adjustment, apply positive and negative perturbations in each dimension and adaptively adjust the step size according to the improvement of the actual measured value. When the step size of all dimensions is less than the preset threshold or the number of consecutive times without improvement reaches the upper limit, terminate the search and output the final calibration parameters.
[0050] Furthermore, in step 1:
[0051] The data acquisition process was performed automatically on the KB mirror system. The WPM_Pitch motor scanned approximately 50 positions in uniform steps within its adjustable range [-2553, -2524]. At each motor position, the eight slits maintained a fixed configuration. A total of 12 different slit configuration combinations were used for scanning, with each combination yielding approximately 50 data points, for a total of approximately 599 raw data points. For each data point, the detector acquired a complete spot image and simultaneously recorded the current 9-dimensional control parameter vector, including: the pitch angle of the wavefront position monitor (WPM, denoted as motor); the horizontal slit center position (slit_H_center); the horizontal slit opening size (slit_H_size); the vertical slit center position (slit_V_center); the vertical slit opening size (slit_V_size); the lower slit position (slit_Down); the left slit position (slit_Left); the right slit position (slit_Right); and the upper slit position (slit_Up), corresponding to the following steps in step 2. .
[0052] The raw output of each scan is a data structure containing: (1) wavelength; (2) motor_positions (N scan positions of the motor, N is approximately 50); (3) fixed_values (slit parameter vector fixed during scanning); (4) images (N frames of detector images, each frame is 2048x2448 pixels, 16-bit grayscale).
[0053] For each frame of detector image, calculate the quality index according to the following steps. :
[0054] Step 1.1: [The text appears to be incomplete and contains several grammatical errors. A more accurate translation would require the full context.] The original image of pixels is divided into The sub-aperture mesh of the pixel was obtained in total. Aperture size.
[0055] Step 1.2: Calculate the centroid coordinates for each sub-aperture. Let the number of pixels within the sub-aperture be... grayscale value centroid coordinates The calculation formula is:
[0056] ,
[0057] The summation of the molecules covers all pixels within the sub-aperture. This calculation is equivalent to calculating the first moment of the light intensity distribution within the sub-aperture, which physically represents the location of the energy center of the light beam within that region.
[0058] Step 1.3: Calculate the standard deviation of the centroid of all sub-apertures.
[0059] Assume there is a total Aperture size, number The centroid of the individual aperture is ,but:
[0060] ,
[0061] ,
[0062] in, and Each for all and The mean, and Then they correspond to all and The standard deviation. The smaller the value, the more concentrated the centroid of the light spot of each sub-aperture is, that is, the flatter the wavefront and the better the beam quality.
[0063] The design of this metric is based on the Shack-Hartmann wavefront sensing principle in adaptive optics: When an ideal plane wave passes through a microlens array, the focal point within each sub-aperture is located at the reference position; however, when wavefront distortion exists, the focal point position of the sub-aperture will shift, and the standard deviation of this shift reflects the degree of wavefront distortion. The method presented in this paper directly calculates the centroid standard deviation by dividing the detector into sub-apertures, equivalent to a digital Shack-Hartmann detection scheme. It requires no additional wavefront sensor hardware and can achieve wavefront quality assessment solely through calculations on the detector image.
[0064] The original experimental data contained only about 599 valid sample points, which is far from sufficient for training a high-precision surrogate model. Typical machine learning regression tasks require thousands to tens of thousands of training samples to achieve stable generalization performance in a 9-dimensional parameter space. Therefore, this invention employs a data augmentation method based on SRW physical simulation.
[0065] Using the SRW (Synchrotron Radiation Workshop) physical simulation software, a systematic gridded scan and random sampling of the 9-dimensional parameter space was performed on the original parameter space covered by 599 experimental data points to generate new parameter-quality data pairs. SRW accurately simulated the propagation process of the synchrotron radiation beam in the KB mirror system by numerically solving Maxwell's equations, including physical effects such as diffraction and reflection, thereby calculating the corresponding beam quality index for each newly generated parameter combination. value.
[0066] The specific amplification process is as follows:
[0067] Data alignment and merging: Experimental scan data from 12 different slit configurations were aligned according to parameter positions and merged into a unified dataset, totaling 599 valid data records.
[0068] SRW Physical Simulation Augmentation: Based on the original 599 data points, systematic parameter sampling is performed within a feasible region of the 9-dimensional parameter space. The sampled parameter combinations are then input into the SRW simulator for physical simulation to calculate the corresponding beam quality indices. The high-fidelity physical model of SRW ensures the physical plausibility of the augmented data in the global space, providing reliable data even in regions without experimental samples. Value estimation.
[0069] Data cleaning and integration: Outliers in the SRW simulation results (such as computational divergence caused by physically infeasible parameter combinations) were removed, and the effective simulation data was merged with the original experimental data to finally obtain about 10,000 high-quality training samples.
[0070] After the SRW physical simulation amplification, the dataset (10,000 points) was increased by about 16.7 times compared to the original data (599 points), providing a sufficient statistical basis for training the XGBoost surrogate model.
[0071] Furthermore, in step 2:
[0072] In the specific problem of KB mirror calibration, there are significant coupling effects among the various control parameters. For example, changing the motor pitch angle affects the incident angle of the beam in the slit plane, thus altering the actual beam clipping effect of the slit—meaning there is a nonlinear interaction between the motor parameters and the various slit parameters. Simultaneously, the relationship between the beam quality Q-value and the control parameters exhibits overall nonlinear characteristics, and a simple linear model cannot accurately describe this relationship.
[0073] To effectively capture the aforementioned coupling effects and nonlinear characteristics, this invention introduces two feature transformations based on the original 9-dimensional parameter vector, expanding the input dimension to 26 dimensions.
[0074] (a) Original features (9 dimensions):
[0075] The original 9-dimensional parameters are directly retained as model input. Let the original parameter vector be x:
[0076] ,
[0077] in (Electric motor) , , .
[0078] (b) Interaction features (8 dimensions):
[0079] Multiply the motor parameters by the eight slit parameters respectively to construct an 8-dimensional interactive feature. :
[0080] These eight interaction items directly model the physical coupling relationship of "how changes in motor state affect the actual cutting effect of each slit". For example, when When a larger value is taken, the incident angle of the light beam on the slit plane is larger, and the actual light-transmitting area corresponding to the same slit opening will change; through Through product interactions, XGBoost can automatically learn this nonlinear coupling relationship.
[0081] (c) Square features (9 dimensions):
[0082] Calculate the squared terms for each of the nine original parameters to construct a nine-dimensional squared feature. :
[0083] ,
[0084] Squared features provide the model with the ability to capture the parabolic relationship between parameters and quality metrics. Physically, the performance metrics of many optical systems exhibit an approximately quadratic distribution around the optimal parameters (for example, the relationship between defocus and Strehl ratio is approximately Gaussian, which becomes quadratic after taking the logarithm). Squared features enable tree models to learn these nonlinear patterns more efficiently.
[0085] (d) Final feature vector (26 dimensions):
[0086] The original features, interaction features, and squared features are concatenated to obtain the final 26-dimensional feature vector. :
[0087] .
[0088] Before training the XGBoost model, Z-score normalization is performed on the 26-dimensional features to obtain normalized features. :
[0089] ,
[0090] in, The feature mean vector, is the feature standard deviation vector. Although XGBoost, as a tree model, is not sensitive to feature scale, standardization still helps improve the model's numerical stability and subsequent model interpretation and diagnostic processes.
[0091] This invention selects XGBoost (eXtreme Gradient Boosting) as the core machine learning algorithm for the surrogate model, mainly based on the following technical considerations:
[0092] (1) Prediction accuracy: XGBoost integrates a large number of regression trees through gradient boosting, exhibiting strong nonlinear fitting capabilities. In the benchmark comparison of this project, XGBoost performed better on the test set. MAE = 6.75, which is better than Gaussian process regression (GPR). MAE=9.24) and Support Vector Regression (SVR) (MAE=10.81), and Multilayer Perceptron (MLP, (MAE=9.45) performed similarly.
[0093] (2) Training efficiency: XGBoost uses second-order gradient approximation (Newton's method) for optimization, combined with column compression storage and CPU multi-threaded parallelism, achieving high efficiency with 10,000 samples. Training on a 26-dimensional feature dataset takes only a few seconds, far less than the minutes-level training time of MLP, which is especially important for online use cases that require frequent retraining.
[0094] (3) Robustness: XGBoost effectively controls overfitting risk through regularization, combined with early stopping mechanism and smooth loss function, and also through... , , Hyperparameters are used to further control model complexity and maintain stable generalization performance in 9-dimensional space.
[0095] (4) Interpretability: XGBoost provides feature importance ranking, which can be used to analyze which parameters have the greatest impact on beam quality, providing a reference for system debugging and subsequent optimization.
[0096] XGBoost uses an additive model to sum the predictions from K regression trees using weighted averages.
[0097] ,
[0098] in, The function space representing all regression trees. Here, K represents the beam quality value predicted by the surrogate model, K is the total number of regression trees, and Xnorm is the 26-dimensional feature vector normalized by Z-score. It is the first The structure of the tree (including the branch structure and leaf node weights).
[0099] The training process employs a forward stagewise algorithm, progressively minimizing the following objective function. :
[0100] ,
[0101] in, For a differentiable convex loss function, this invention uses squared loss. Here, represents the overall objective function value, n represents the total number of training samples, and s represents the sample index. This represents the true beam quality value for the s-th sample. This represents the cumulative predicted value from the first t-1 iterations. For the regression tree added in round t, Let Ω be the standardized 26-dimensional feature vector of the s-th sample, and Ω be the regularization term.
[0102] ,
[0103] For regularization terms:
[0104] ,
[0105] Where Ω(f) is the regularization term, This represents the number of leaf nodes in the tree. For the first The weight of each leaf, and This is the regularization hyperparameter. The first term penalizes the complexity of the tree (the more leaves, the greater the penalty), and the second term is the L2 regularization constraint on the leaf weights. Together, they prevent overfitting.
[0106] The expanded objective function is obtained by performing a second-order Taylor expansion on the loss function. :
[0107] ,
[0108] in,
[0109] ,
[0110] Let be the first derivative of the loss function with respect to the current predicted value of the s-th sample. The second derivative is represented by the diagonal elements of the Hessian matrix. By simultaneously utilizing gradient and Hessian information for optimal leaf weight calculation and tree structure scoring, XGBoost converges significantly faster than traditional gradient boosting methods that only use the first-order gradient.
[0111] Hyperparameter configuration and search;
[0112] XGBoost's optimal hyperparameters are automatically determined through Random Search and 3-fold cross-validation:
[0113] Search space: n_estimators (Default 500), max_depth (Default 6–8), learning_rate (Default 0.05–0.1), subsample (Default 0.8), colsample_bytree (Default 0.8). A total of 15 hyperparameter combinations are used, with 3-fold cross-validation performed on each combination. The optimal combination is automatically selected with the goal of minimizing the mean squared error (MSE) on the validation set. The model is then retrained on all training data using the optimal hyperparameters to obtain the final XGBoost surrogate model.
[0114] This automatic parameter tuning mechanism ensures that the XGBoost model can obtain near-optimal parameter configurations under different data distributions, avoiding the uncertainty of manual parameter tuning and the reliance on professional knowledge.
[0115] To verify the effectiveness of the XGBoost surrogate model, a comprehensive benchmark evaluation was conducted on the beam_quality_data.pkl test set, fairly comparing it with three mainstream regression models: MLP (Multilayer Perceptron), GPR (Gaussian Process Regression), and SVR (Support Vector Regression). All models used the same training data, feature engineering process, and evaluation metrics. The evaluation results are shown in Table 1 below:
[0116] Table 1
[0117]
[0118] As shown in the table, XGBoost ranks first in both R^2 and MAE: R^2 reaches 0.8143, which means that the surrogate model can explain 81.43% of the variance of the quality index in the parameter space; compared with MLP, XGBoost's R^2 is about 0.13% higher, while the training time is only about 1 / 26 of MLP (1 second vs. 26 seconds), which has a significant advantage in the comprehensive trade-off between accuracy and efficiency.
[0119] Furthermore, in step 3:
[0120] This invention selects JADE as the global optimizer, mainly based on its four core innovative mechanisms:
[0121] Mechanism 1: DE / current-to-pbest / 1 mutation strategy;
[0122] JADE proposes a new mutation strategy:
[0123] ,
[0124] in: Let q be the 9-dimensional parameter vector of the candidate. This is the scaling factor; Ranked among the top in the current population Randomly select one from the optimal individuals ( User-defined parameter, default value. ); From the current population Randomly selected from; From the current population External archives The results are randomly selected from the set. The improvement of this strategy over the standard DE / rand / 1 is:
[0125] (1) The term guides individuals toward the current optimal direction, accelerating the convergence speed;
[0126] (2) The term serves as a perturbation basis vector, ensuring local search capability;
[0127] (3) It can be obtained from external archives, which increases population diversity and effectively prevents premature convergence.
[0128] Mechanism 2: External Archive;
[0129] In each generation of population renewal, the parent individuals that are eliminated (i.e., the trial vectors) Failed to outperform the target vector At that time, it was retained ) was added to an external archive The archive size is limited to [number]. (Population size) When the population exceeds the limit, excess individuals are randomly removed to maintain archive capacity. Historical poorly performing solutions in the archive are used as... The candidate sources play two important roles: (1) they provide additional sources of diversity for the difference vectors; (2) the eliminated inferior solutions can still contribute their search direction information, further enhancing the algorithm's ability to escape local optima.
[0130] Mechanism 3: Adaptive parameter control.
[0131] This is JADE's most innovative mechanism. It uses a fixed... and Unlike other methods, JADE is for each individual. Independently generate scaling factor and crossover probability It adaptively adjusts its generation distribution parameters based on historical success records:
[0132] Crossover probability Generation:
[0133] ,
[0134] in, Sampling is based on a normal distribution. For the present The mean. In each generation, collect all those that successfully produced improvements. Values form a set Then update using Lehmer mean. :
[0135] ,
[0136] ,
[0137] in, Learning rate (default) ), As the Lehmer mean, a larger value is given. Higher weights make Preferring to perform better value.
[0138] scaling factor Generation:
[0139] ,
[0140] in, Sampling for Cauchy distribution, For the present The mean of the Cauchy distribution. Compared to the normal distribution, the Cauchy distribution has a wider tail, and therefore has a higher probability of generating larger values. This value is beneficial for maintaining population diversity in the early stages of the search. Successful collection occurs in each generation. Values form a set ,renew :
[0141] ,
[0142] ,
[0143] Advantages of parameter adaptive mechanism: (1) and The initial value setting is not sensitive to algorithm performance, which reduces the cost of parameter tuning; (2) and It automatically evolves with the optimization process, automatically biases towards large values in the early stage of the search to promote exploration, and automatically biases towards small values in the later stage to promote utilization; (3) It can adaptively adjust to a suitable parameter range for objective functions of different properties (single-peak / multi-peak, smooth / rugged, etc.).
[0144] Mechanism 4: Population Reinitialization.
[0145] When population diversity falls below a threshold (by detecting the standard deviation of each dimension in the population), JADE can automatically trigger the reinitialization of some individuals—randomly regenerating some individuals within the search space while retaining the optimal individuals. This mechanism further enhances the algorithm's ability to escape local optima.
[0146] Specific configuration of JADE in this invention:
[0147] Population size: ;
[0148] Maximum number of iterations: ;
[0149] Elite rate: (Selected from the top 5% of the best individuals) );
[0150] External archive size: ;
[0151] Learning rate: (control and (Update speed)
[0152] Initial mean: ;
[0153] Objective function: Beam quality predicted by the XGBoost surrogate model for 9-dimensional parameters value.
[0154] With this configuration, JADE requires approximately [amount missing] per generation. The XGBoost model prediction is performed in microseconds, and the entire global search process is usually completed within a few seconds (pure CPU computation) without involving any hardware movement.
[0155] Using XGBoost as a surrogate model, JADE was fairly compared with four optimizers: DE (Standard Difference Evolution), BO (Bayesian Optimization), CMA-ES (Covariance Matrix Adaptive Evolutionary Strategy), and PSO (Particle Swarm Optimization). Each optimizer was run three times (BO was only run twice due to its time consumption), with 100 generations evaluated each time. The results are shown in Table 2 below:
[0156] Table 2
[0157]
[0158] JADE significantly outperforms the comparable optimizers DE (516.66) and BO (514.01) with an average quality of 505.62 (lower is better) and an optimal quality of 504.93. Furthermore, it consistently converges to similar high-quality solutions (standard deviation 0.53) under different random seeds, demonstrating significantly better robustness than DE (standard deviation 2.40) and PSO (standard deviation 4.07). The experimental results fully validate the superiority of JADE in the specific 9-dimensional multimodal optimization problem of KB mirror calibration.
[0159] JADE's superior performance can be attributed to its adaptive parameter mechanism: BO faces difficulties in modeling Gaussian processes in high-dimensional spaces; CMA-ES fails to fully utilize the covariance matrix learning capability within 100 evaluations; PSO suffers from premature convergence due to the rapid decrease in particle velocity diversity in 9-dimensional space; and standard DE uses fixed parameters. It cannot adapt to the needs of different stages of the search process. Only JADE can adapt and adjust. and It automatically balances exploration and utilization at different stages of the search, achieving the most stable and high-quality global search performance within the limit of 100 iterations.
[0160] Furthermore, in step 4:
[0161] The optimal prediction obtained through JADE global search has an inherent bias between the predicted and actual values of the XGBoost surrogate model (although...). (Approximately 18.5% of the variance remains unexplained), indicating a slight offset between the solution and the true global optimum. To address this, this invention incorporates a local hill-climbing fine-tuning stage, moving the hardware to the vicinity of the predicted optimal position obtained from the JADE search, and performing an adaptive local search based on feedback from the real detector. The specific process is as follows:
[0162] Step 1 – Initialization: Receive the globally optimal solution output by JADE Read the current quality from the hardware Initialize step size (Each dimension's step size is initialized to approximately 1% of the parameter range), minimum step size threshold. Maximum number of consecutive failures .
[0163] Step 2 – Iterative Search: In the first step In each iteration, for each dimension ( Execute sequentially:
[0164] Positive perturbation: at the current value Increase step size based on ,have to ;
[0165] Negative perturbation: at the current value Reduce step size on the basis ,have to ;
[0166] Hardware measurement: The driver hardware moves sequentially to and Location, read the corresponding quality and (Note: After each movement, only the change in that dimension is read, while other dimensions remain unchanged to eliminate the effect of time drift.)
[0167] Update judgment: If ,Will Update to a better perturbation location, update ,at the same time (Increased step size, accelerated exploration);
[0168] Otherwise: Keep constant, (Reducing step size for a more refined search).
[0169] Step 3 – Termination Decision: When the step size of all 9 dimensions is less than [a certain value] , or continuous The next iteration did not improve. Terminate the search when the current time is reached. Output the current time. and corresponding As the final calibration parameter.
[0170] The design idea behind this adaptive step size strategy is as follows: when a better value is found in a certain dimension, it means that there is still room for improvement in that direction, and appropriately increasing the step size can accelerate convergence; when no improvement is found in a certain dimension, it means that a more refined search is needed, so the step size is reduced to accurately locate the optimal value. (Enlarged) and The asymmetric design of (shrinking) makes the step size decrease in the "enlarge-shrink" cycle, ensuring convergence while retaining a certain exploration capability.
[0171] In standard mode, the local fine-tuning stage typically requires 10–25 hardware moves, each taking approximately 1–2 seconds (including EPICS communication and hardware response time), for a total hardware time of approximately 20–50 seconds. Compared to the hundreds of hardware moves required for traditional manual calibration, the amount of hardware movement is reduced by more than 90%, and the calibration time is shortened by more than 95%.
[0172] To adapt to the needs of different calibration scenarios, this invention designs three selectable calibration modes, which are uniformly scheduled through the calibration main control module:
[0173] Quick Mode: Suitable for minor drift corrections during daily operation or rapid recovery after slight environmental changes. In this mode, the JADE global search phase is skipped, and local hill-climbing fine-tuning is performed directly from the current hardware location. Typical time consumption: Approximately 20 hardware moves, total time approximately 20-40 seconds.
[0174] Standard Mode: Suitable for routine full calibration tasks. It first performs one round of JADE global search (100 generations), then moves the hardware to the optimal solution position and performs local hill-climbing fine-tuning. This mode balances global search capability and fine-tuning efficiency and is the system's default recommended mode. Typical time consumption is JADE search (approximately 2-5 seconds, pure computation) + local fine-tuning (10-25 hardware moves, approximately 20-50 seconds), with a total consumption of less than 3 minutes.
[0175] Thorough Mode: Suitable for critical calibration tasks—such as the initial calibration after a light source restart, final optimization before important experiments, etc. It independently performs three rounds of JADE global search (100 generations per round, with different random seeds). After each round, the optimal solution is sent to hardware verification and local fine-tuning is performed. Finally, the results of the three rounds of verification are compared, and the solution with the highest quality is selected as the final output. Typical processing time: approximately 3 x (JADE search + local fine-tuning) = less than 10 minutes.
[0176] The two-stage optimization strategy of "XGBoost proxy model global search + hardware local fine-tuning" proposed in this invention works as follows:
[0177] Phase 1 – Global Search using the surrogate model: The entire search process of the JADE optimizer is performed entirely on the XGBoost surrogate model. The quality evaluation of candidate solutions can be completed solely through forward computation of XGBoost (in microseconds), without moving any hardware. The core advantages of this phase include: (1) 3000 function evaluations are completed within seconds (compared to several hours or more if using SRW physics simulation); (2) Zero hardware movement, completely avoiding mechanical wear and motor response delay; (3) JADE adaptive parameters ( It is continuously updated in each evaluation, quickly adapting to the objective function landscape.
[0178] The second stage—local hardware fine-tuning—involves moving the hardware to the globally optimal position predicted by the surrogate model and performing adaptive hill-climbing search using feedback from the real detector. This stage is necessary because there is an inherent bias between the XGBoost surrogate model's predictions and the actual values (even though...). This still means that approximately 18.5% of the variance remains unexplained. There may be a slight offset between the predicted and actual locations of the global optimum. The local fine-tuning stage eliminates this bias through a small number of real measurements, ensuring the absolute accuracy of the final calibration result.
[0179] The synergistic advantages of the two stages are reflected in the following: the global search of the surrogate model significantly compresses the search space—shrinking it from the entire 9-dimensional space to a minimal interval near the global optimum, effectively avoiding the risk of getting stuck in local extrema during the hardware fine-tuning stage; the local hardware fine-tuning compensates for the insufficient accuracy of the surrogate model, forming a complementary closed loop of "computation for hardware" and "hardware to compensate for computation," enabling the entire system to simultaneously achieve practicality in terms of accuracy, efficiency, and hardware lifespan. From an information theory perspective, XGBoost provides JADE with fast and accurate landscape prior information, which JADE uses to determine the most promising regions, while hardware fine-tuning supplements the most critical regions with real information.
[0180] In a second aspect, the present invention provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned synchrotron beamline self-calibration method based on an active learning agent model.
[0181] Thirdly, the present invention provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enable the processor to implement the aforementioned synchrotron beamline self-calibration method based on an active learning agent model.
[0182] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A synchrotron beamline self-calibration method based on an active learning surrogate model, characterized in that, include: Step 1: Collect multiple sets of original 9-dimensional control parameter combinations of the KB focusing system and the corresponding detector spot images. Divide the detector spot images into several sub-apertures and calculate the standard deviation of the centroid of each sub-aperture as a beam quality index. Step 2: Retain the original 9-dimensional control parameters, multiply the motor parameters with each slit parameter to construct interactive features, and calculate the squared terms for the original 9-dimensional control parameters to capture the squared features near the optimal solution. Concatenate the original 9-dimensional control parameters, interactive features, and squared features into a 26-dimensional feature vector and perform standardization processing. Train the XGBoost extreme gradient boosting model as a surrogate model. Step 3: Using the predicted value of the surrogate model as the fitness function, a global search is performed in the original 9-dimensional control parameter space using an adaptive differential evolution algorithm with optional external archive. The adaptive differential evolution algorithm independently generates scaling factors and crossover probabilities for each individual and follows a distribution controlled by the mean parameter that is adaptively updated based on historical success records. The fitness evaluation of all candidate solutions is completed on the surrogate model without moving any hardware devices during the entire search process. The predicted optimal solution is obtained after the search converges. Step 4: Move the hardware device to the predicted optimal solution position, use the actual measured value of the beam quality index as the feedback standard for local hill climbing fine adjustment, apply positive and negative perturbations in each dimension and adaptively adjust the step size according to the improvement of the actual measured value. When the step size of all dimensions is less than the preset threshold or the number of consecutive times without improvement reaches the upper limit, terminate the search and output the final calibration parameters.
2. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, In step 1, the 9-dimensional control parameters include: the tilt angle of the wavefront position monitor, the center position of the horizontal slit, the opening size of the horizontal slit, the center position of the vertical slit, the opening size of the vertical slit, the position of the lower slit, the position of the left slit, the position of the right slit, and the position of the upper slit.
3. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, In step 1: For each sub-aperture, the horizontal and vertical coordinates of the spot centroid are calculated using the gray values of all pixels within that sub-aperture, with the gray values as weights; the standard deviations of the horizontal coordinates and vertical coordinates of all sub-aperture centroids are calculated; and the average of the horizontal and vertical coordinate standard deviations is taken as the beam quality index.
4. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, The 26-dimensional feature vector in step 2 is specifically composed as follows: the first 9 dimensions are the original 9-dimensional control parameters; the middle 8 dimensions are the interactive features obtained by multiplying the motor parameters by the 8 slit parameters respectively; and the last 9 dimensions are the squared terms of the original 9-dimensional control parameters respectively.
5. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, In step 2, before training the XGBoost extreme gradient boosting model, a data augmentation method based on synchrotron radiation physics simulation software is used to expand the training samples: based on the collected original experimental data, systematic parameter sampling is performed in the feasible region of the 9-dimensional control parameter space, the sampled parameter combination is input into the synchrotron radiation physics simulation software for simulation and calculation of the corresponding beam quality index, and the effective data generated by the simulation is merged with the original experimental data to obtain the augmented training dataset.
6. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, In step 2, the hyperparameters of the XGBoost model are automatically determined by random search combined with K-fold cross-validation. The hyperparameter search space includes: the number of trees, maximum depth, learning rate, sample subsampling ratio, and feature subsampling ratio. The optimal combination of hyperparameters is selected with the goal of minimizing the mean square error of cross-validation, and the final XGBoost surrogate model is obtained by retraining on all training data using the optimal combination of hyperparameters.
7. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, In step 3, the adaptive differential evolution algorithm adopts the mutation strategy of the current optimal guidance, randomly selects one of the top individuals in the current population from the top specified percentage as the optimal guidance direction, and selects the source of the difference vector from the union of the current population and the external archive; the scaling factor follows a Cauchy distribution, and the crossover probability follows a normal distribution. The distribution mean parameters of both are updated based on the history of successful evolution using the Lymer mean method, so that the scaling factor and crossover probability are adaptively adjusted as the search process progresses.
8. The synchrotron beamline self-calibration method based on an active learning surrogate model according to claim 1, characterized in that, Three optional calibration modes are provided: in fast mode, the global search in step 3 is skipped, and the local hill-climbing fine-tuning in step 4 is performed directly from the current hardware position; in standard mode, the global search in step 3 is performed once, and then the local hill-climbing fine-tuning in step 4 is performed; in fine mode, the global search in step 3 is performed multiple times independently, and after each search, the hardware is moved to the corresponding predicted optimal solution and the local hill-climbing fine-tuning in step 4 is performed. The results of each verification are compared and the one with the best beam quality index is selected as the final output.
9. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When one or more programs are executed by the one or more processors, the one or more processors implement the synchrotron beamline self-calibration method based on an active learning agent model as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, It stores executable instructions that, when executed by a processor, enable the processor to implement the synchrotron beamline self-calibration method based on an active learning agent model as described in any one of claims 1-8.
