# An Application of Simulated Annealing in Compensation of Nonlinearity of Scanners
## 3 Results  
The optimization algorithm was implemented in LabVIEW on a quad core computer with 16 GB memory. We used 100 short ramps to reconstruct the triangular signal; each ramp was constructed using 2 samples. The typical frequency of the triangular signal input to the fast galvo-scanner was around 500 Hz. Therefore, we tested our optimization method at three frequencies: 862 Hz, 697 Hz, and 308 Hz. The reference shape of the triangular signal sent to the galvo scanner is shown in Figure 3a. The amplitude of the signal is 5-volt peak to peak.  
Figure 3: The reconstructed triangular signal with a frequency of 862 Hz (**a**) before optimization, (**b**) after optimization.  
In the first attempt, the frequency of the triangular signal was 862 Hz. The triangular signals before and after the optimization are given in Figure 3a,b, respectively. The corresponding FFT of these signals are shown in Figure 4a,b.  
The optimization algorithm improved the peak of the FFT signal during 10,000 iterations from 0.0035 to 0.029 V (-10 times). The peak amplitude of the FFT during the optimization was significantly improved, and the spectral width of the optimized signal became narrower. The graph showing the peak of FFT recorded during the optimization process as well as the improvement profile of the peak of the FFT, are given in Figure 5a,b, respectively. As shown in Figure 5a, during the global search loop of the optimization algorithm, the algorithm occasionally generates signals with low FFT signal amplitude. This part of the algorithm is similar to the Boltzmann loop [35; 36] in the simulated annealing algorithm which prevents the algorithm from being trapped into a local optimum.  
The compensation system was tested on two more triangular signals with frequencies of 697 Hz, and 308 Hz. The results are shown in Figures 6 and 7.  
We also tested using several ramps to reconstruct the triangular signal. The preliminary results showed an approximately two-fold increase when we used two samples per ramp instead of 10 (the number used in all the above experiments). The computation, however, became more expensive (it took four times longer).  
Figure 4: FFT of the photodetector signal while imaging the metal plate object, (**a**) before optimization, (**b**) after optimization. The frequency of the triangular signal was 862 Hz.  
Figure 5: Improvement in the amplitude of the FFT signal during the optimization process. (**a**) Variation of the FFT amplitude during the optimization process, (**b**) improvement profile of only “the improved FFT amplitudes” during the optimization process. The frequency of the triangular signal was 862 Hz.  
Figure 6: FFT of the photodetector signal while imaging the metal plate object, (**a**) before optimization and (**b**) after optimization. (**c**) The reconstructed triangular signal after the optimization process, (**d**) improvement profiles of only “the selected FFT component” during the optimization process. The frequency of the triangular signal was 697 Hz.  
Figure 7: FFT of the photodetector signal while imaging the metal plate object, (**a**) before optimization and (**b**) after optimization. (**c**) The reconstructed triangular signal after the optimization process, (**d**) improvement profile of only “the improved FFT amplitudes” during the optimization process. The frequency of the triangular signal was 308 Hz.