Towards ‘smart lasers’: self-optimisation of an ultrafast pulse source using a genetic algorithm

Short-pulse fibre lasers are a complex dynamical system possessing a broad space of operating states that can be accessed through control of cavity parameters. Determination of target regimes is a multi-parameter global optimisation problem. Here, we report the implementation of a genetic algorithm to intelligently locate optimum parameters for stable single-pulse mode- locking in a Figure-8 fibre laser, and fully automate the system turn-on procedure. Stable ultrashort pulses are repeatably achieved by employing a compound fitness function that monitors both temporal and spectral output properties of the laser. Our method of encoding photonics expertise into an algorithm and applying machine-learning principles paves the way to self-optimising ‘smart’ optical technologies.

Scientific RepoRts | 6:37616 | DOI: 10.1038/srep37616 optimisation can be efficiently implemented using machine learning principles. Genetic algorithms (GAs) are ideal for this task, applying concepts of natural selection from evolutionary biology to intelligently search for optimum parameters 16 . This technique has previously been applied in a number of optical contexts, such as pulse shaping 17 , optimisation of supercontinuum generation 18 , and the design of specialist optical fibres and amplifiers 19,20 . The application of GAs for extremum seeking in laser mode-locking was recently proposed theoretically 21,22 , and a basic implementation utilizing a singular fitness function to locate self-starting regimes in an NPE-mode-locked fibre laser was demonstrated 23,24 . It was observed, however, that coherent single-pulse mode-locking was not repeatable, and optimisation of the fitness function led to a tendency towards the emission of noise-like pulses, highlighting the need to implement a more sophisticated fitness function 25 .
Here, we experimentally demonstrate the first photonic application of a GA based on a compound fitness function to achieve optimised, reliable self-starting operation of an all-fibre ultrafast pulse source, paving the way towards fully automated 'smart lasers' . We show that the self-optimising scheme can rapidly explore a large multi-parameter space, locating and maintaining a global optimum in the presence of external disturbances.

Self-Optimising Laser Design
Operating States in Fibre Lasers. We consider a Figure-8 (F8) laser design: one of the earliest reported passively mode-locked laser schemes, employing a nonlinear amplifying loop mirror (NALM) as an artificial saturable absorber 4 , and currently receiving renewed interest as a flexible all-fibre ultrafast source [26][27][28][29][30][31][32] . F8 lasers consist of a unidirectional and bidirectional ring. The bidirectional ring forms a loop mirror that is imbalanced (either actively or passively) to induce a differential phase, and consequently a power-dependent reflectivity that mimics the action of a saturable absorber, promoting pulse generation in the main laser cavity. Polarisation control (PC) that acts as a phase bias is often included in the loop mirror to adjust the nonlinear transfer function of the NALM, and consequently the effective saturable absorber behaviour. Additional to polarisation control, the variable gain from an amplifier in the loop mirror, and influences from external disturbances (e.g. thermal and mechanical stresses) can affect the differential phase of the counter propagating waves and modify the nonlinear transfer function. Thus, to achieve stable self-starting operation in a target regime (e.g. single-pulse mode-locking), the phase bias must be carefully set and actively controlled.
The F8 laser setup is shown in Fig. 1 (see Methods section for details). The nonlinear amplifying loop mirror includes an electronic polarisation controller with four quarter waveplates (QWPs), providing full-wave control and the ability to traverse the entire surface of the Poincaré sphere. For a fixed pump power, the nonlinear transmission curve of the NALM is governed by the angle of the four waveplates, adjustment of which sweeps the laser operating regime through a wide range of states. To illustrate this variation, we represent a two-dimensional slice of the four-dimensional polarisation space: the pump power is held constant while two quarter waveplates are successively swept through all possible angles in 4.5 degree (0.025π rad) steps (Fig. 2). At each angle the output properties of the laser are evaluated and assigned a 'fitness score' quantifying the laser performance, which we discuss in detail later.
Localised regions of highest fitness indicate stable single-pulse continuous-wave mode-locking (CW-ML) at a repetition rate that matches the fundamental cavity frequency of 7.4 MHz. The lowest scores are assigned to non-lasing states and CW emission. Intermediate fitness values represent a wide variety of pulsating regimes, including Q-switching (QS) and unstable multiple-pulse or partial mode-locking (MP-ML). The characteristic output properties, evaluated in the optical and electrical spectral and temporal domains, that indicate operation in these regimes are summarised in the right-hand panels of Fig. 2. Evident from Fig. 2 is the sparseness of stable states, highlighting the need for an extremum seeking approach to quickly and efficiently find optimum regimes from any unknown initial state.
Genetic Algorithm Development. GAs are well-suited to the task of finding optimum solutions to a multi-parameter problem, where the quality of a solution is measured by a fitness function that is dependent on the value of selected system variables. In the nomenclature of GAs, each possible solution is known as an 'individual' and comprises a set of values for each parameter. Individual parameters are referred to as 'genes' 16 .  Figure 3 illustrates the core GA concept, which we now briefly explain. The process begins with a collection of individuals, each comprising a set of randomly assigned genes. This group (or 'population') becomes the first generation and represents the evolutionary epoch. The system output is measured for each individual in the generation-in our case by electronically setting cavity parameters based on the individual's genes. This output is evaluated by a fitness function (also known as a merit or objective function) and assigned a score.
The GA then creates the next generation by breeding individuals from the preceding generation, with the probability that an individual is selected to be a 'parent' based on their score ('roulette wheel' selection 16 ). Two children are produced from two parents by randomly distributing the parent's genes between the children. A mutation probability is also specified, which can randomly alter the children's genes. This process repeats until a steady state is reached, with a high probability of retaining good genes in the population, but permitting diversity to locate global maxima through breeding and mutation, while breeding out low quality genes which result in a low fitness score since they have low selection probability for breeding. The principle of 'elitism' is also employed, cloning the best individuals to the next generation to ensure their high-quality genes are preserved, increasing the speed of convergence 16 .  We find that a generation size of 30 individuals, each consisting of five genes (four waveplate angles and pump current), provides a suitable balance between genetic diversity and speed of convergence. The inclusion of pump current (that is proportional to pump power above the pump laser threshold) as a gene permits the full turn-on cycle and self-starting behaviour to be intelligently automated. The range of allowed pump currents is bounded: the upper limit prevents damage to integrated optical components and the pump laser itself (a 965 nm fibre-pigtailed diode laser); while the lower bound ensures the pump diode remains above threshold. A damped mutation is also applied, where an initial value of 25% is adaptively reduced as the algorithm progresses, to assist convergence. We also apply elitism by always cloning the best four individuals from each generation to the next. Our choice of GA parameters was empirically determined to give repeatable and reliable results; further optimisation to maximise the convergence rate is possible, but beyond the scope of this investigation 16 .

Choice of Fitness Function.
A critical factor to the success of a self-optimising laser implementation is the fitness function, which must return a higher value when the laser is operating closer to the target regime. In previous work, using local search algorithms, a variety of approaches have been considered to evaluate laser performance. Shen et al. 13 counted the optical pulses arriving on a photodiode to determine if the desired mode-locked repetition rate had been achieved. Olivier et al. 12 monitored the output polarisation state, detecting an abrupt change as a transition into mode-locking as cavity waveplate angles were swept. Radnatarov et al. 14 quantified high quality mode-locking by maximising the value of the fundamental radio frequency (RF) beat note in the electrical spectrum. To identify high-peak-power short-pulse regimes, nonlinear optical processes, including two-photon absorption (TPA) 11 and second-harmonic generation (SHG) 23 , have been employed. It has been found, however, that in isolation these singular fitness functions are unable to fully determine the laser output state and thus reliably enable self-optimisation, in particular when identifying single-pulse CW mode-locking. For instance, Q-switched mode-locked regimes can also produce high-peak-power pules leading to a high SHG signal 23 .
In practice, a specialist user assesses laser performance through a variety of diagnostics to confirm specific modes of operation, combing information from both the temporal and spectral domains. Therefore, we propose that a compound fitness function, including optical and electrical spectral, and temporal measurements, is required for reliable self-optimisation 25 . While this approach could be applied for a wide range of target output properties, here, we focus on ultrafast single-pulse CW mode-locking. Such pulse sources are an enabling tool in a wide range of applications including manufacturing, research and medical imaging, where pulse to pulse stability, and reliability of the system are of critical importance.
A stable train of mode-locked pulses incident on a photodiode induces a periodic electrical signal. Visualised on an oscilloscope, single-pulse mode-locking is characterised by pulses regularly spaced by the round-trip time of the laser cavity. Represented on an electrical spectrum analyser, the Fourier transform of the output exhibits bands appearing at the fundamental cavity frequency (f rep ), and harmonics thereafter (2f rep , 3f rep , etc). The magnitudes of these bands in the power spectrum monotonically decrease with the frequency response of the detection, while the signal-to-noise ratio (SNR) is a widely used metric for assessing the stability and quality of mode-locking 33 . Instabilities including Q-switched mode-locking and multiple pulsing reduce the peak to pedestal contrast or introduce lower frequency envelope modulations of the spectral power. In terms of their optical spectrum, Fourier transform limited pulses have a duration that is inversely proportional to their spectral bandwidth, thus ultrafast lasers are characterised by a broad spectrum on an optical spectrum analyser. In combination these three diagnostics provide a comprehensive picture of stable trains of ultrashort pulses in both the time and frequency domain.
We use this information to formulate a compound fitness function based on the following algorithm: • The temporal waveform of the laser output incident on a photodiode is measured on an oscilloscope with a time window sufficent to capture a complete period (or round-trip time) of the cavity. An 'oscilloscope score' is assigned by maximising the peak intensity of the signal. Fundamental mode-locking results in a single high-intensity pulse per round trip (i.e. two pulses appear in the time window, separated by the laser period), whereas multiple-pulsing regimes are readily identified by numerous lower intensity peaks in the time window. • The laser spectrum is recorded on an optical spectrum analyser with a span corresponding to the erbium gain band. An 'optical spectrum score' is allocated by maximising the full width at half maximum (FWHM) of the optical spectrum. • The electrical spectrum of the output is measured using a photodiode and RF spectrum analyser. A span of 500 MHz is chosen, balancing harmonic frequency coverage against aquisition speed and fundamental resolution. A peak detection routine is applied to identify the peak heights of all frequencies in the laser output. An 'electrical spectrum score' is determined by two factors of equal weighting: the magnitude of the fundamental frequency is maximised and the fluctuations of harmonic frequencies is minimised. Harmonic fluctuations are quantified as the mean of the deviation of each harmonic intensity from the peak harmonic value; if a harmonic is not detected (suggesting that the output is not stably mode-locked), it is assigned a value of 0 to yield a high fluctuation value and thus, a low electrical spectrum score.
The total fitness function of an individual is given by the sum of these three components, with equal weighting. Further optimisation could be possible by unequal weighting, which is a topic of ongoing work. We note that ultrafast temporal characterisation using an autocorrelator would provide additional information to enhance this score, however, the polarisation-sensitivity of the underlying nonlinear effect prohibits its application to lasers with a non-stationary output polarisation. The component contributions to the total fitness are shown in Fig. 4. It is clear that the composite fitness function provides highest contrast between stable and unstable pulsating regimes. In contrast the singular fitness functions fail to distinguish the subtleties between mode-locking regimes. The optical spectrum clearly distinguishes between lasing and non-lasing regions (i.e. when the NALM phase bias results in a very high cavity loss, or the pump power is too low), which is particularly important in the early GA evolution. The optical spectral width is also found to be a reliable metric for distinguishing between Q-switched and mode-locked regimes, although it fails to differentiate between multiple pulsing, Q-switched mode-locking and stable CW mode-locking, since they all yield broad spectra (noting that the optical spectrum analyser inherently averages over many consecutive pulses). Measurement of spectral harmonics in the electrical domain clearly highlights mode-locked regimes, although this alone has already been proven insufficient to preferentially locate stable single-pulse mode-locking 23 . The oscilloscope is therefore important for identifying and promoting fundamental, single-pulse mode-locking over multiple pulse mode-locking, but in isolation is a poor metric in the early stages of the evolution.
Adopting a thermodynamic picture, mode-locking can be viewed as a first-order phase transition that occurs at a critical 'temperature' or threshold power, where an initially long-lived, metastable CW regime finally transitions into the stationary mode-locked state 34 . This dynamic leads to a hysteresis behaviour exhibited by the system: mode-locking persists over a wider range of parameter space when already in the stable state, but not all mode-locked states yield self-starting behaviour. We explore the impact of this phenomenon by performing a 2D parameter sweep of the intra-cavity polarisation with (Fig. 2) and without (Fig. 4) resetting the laser state to a CW regime between each parameter adjustment. Firstly, we note that the fitness contours are highly repeatable for successive sweeps performed at near-constant ambient temperature. Lines of higher fitness can be seen extending vertically from the mode-locking region in Fig. 4 (the vertical lines are explained by the fact that the y-axis waveplate is stepped from 0 to π, followed by an increment of the x-axis waveplate; this process repeats across the two-dimensional parameter space), which are absent when we reset to a CW state between parameter cycles (Fig. 2). Although the hysteresis is evident, the effect is small and the macroscopic pattern of stable operation remains largely unchanged. In addition, while a high scoring regime may be identified that occurs due to hysteresis in the system, and as such does not represent a reliably self-starting state, the random dependence of the GA on the previous system state will ensure that the algorithm will favour states which are always long-term repeatable. Thus, in order to increase the speed of convergence, for the proceeding discussion we do not implement parameter resetting.

Results and Discussion
The compound fitness function-based GA is applied to the Figure-8 laser, initialised from a unique, randomised set of polarisation parameters, and a pump current corresponding to a sub-threshold power. The evolution is shown in Fig. 5(a), highlighting the fitness score of the best individual in the population over successive generations, as well as each generation's average. As expected, the average fitness of the initial random seed population is low, with the majority of individuals corresponding to non-lasing or CW states and fittest individuals resulting in Q-switched operation. Successive generations maintain the best individuals through elitism, while breeding new individuals with a high probability of inheriting high-quality genes. After ~5 generations the output appears to be converging towards a local maxima (with a score of ~0.25) corresponding to Q-switched operation. Due to mutation and crossover, however, during the evaluation of parameters in successive generations the GA locates an improved operating regime (represented by the sudden increase in 'best in generation' scores in generations 7 and 8). Through continued breeding and mutation, the optimum score gradually increases leading to the identification of a stable single-pulse mode-locked state. We emphasise that the complete turn-on cycle and tuning of cavity parameters to optimise stable, ultrashort pulse operation is thus fully automated.
We verify the repeatability of this approach by performing an ensemble of ten realisations, each from an initially 'off ' state. While each realisation resulted in a different evolution trajectory, due to random initial conditions and a probabilistic evolution, the final results are consistently similar, as shown in Fig. 5(b) and (c) highlighting each generation's best and average fitness. It is always observed that the laser converges towards a stable fundamentally mode-locked output, effectively optimising itself into the target operating regime. An average  (x and y axes are QWP1 and QWP2 angle, respectively, swept through 180 degrees). The data was recorded under the same conditions as Fig. 2, but without resetting the waveplates for each measurement (i.e. including hysteresis effects).
optimisation process requires ~20 generations [Fig. 5(c)] and completes in typically less than 30 minutes. The convergence time is dominated by a delay in remotely interfacing with the electronic polarisation controller, pump diode controller and the diagnostics, in addition to a short settling period allowing the cavity dynamics to stabilise in response to each new individual.
Despite the implementation of 'elitism' to copy the best genes directly across to subsequent generations, Fig. 5(b) shows that the maximum score occasionally decreases. This is explained by the existence of operating regimes that temporarily give a high-quality output, but are unstable on longer timescales, thus resulting in fitness score variation for repeat measurements. Additionally, as discussed earlier, hysteresis effects can have an impact in a small number of cases, whereby the score for a set of parameters depends on the previous system state. In such cases, the genetic algorithm can find a regime and award it a high-score, yet on repeat measurement (i.e. when using the same parameters in the next generation, but approached from a different previous system state) the performance is very different. Therefore, it is not unexpected that the maximum score shows occasional reductions in an otherwise monotonic increase towards an optimum due to the elitism principle. We stress, however, that the genetic algorithm overcomes such instability inherent to mode-locked laser parameter space: while an unstable regime may instantaneously give a high score, the poor repeatability will result in these low-quality genes being bred out in favour of long-term stable regimes with a repeatably high score.
Suppressing the tendency towards noise-burst and multi-pulsing operation is a common challenge in mode-locked fibre laser design, as highlighted by Andral et al. using an evolutionary algorithm with a single-diagnostic fitness function 23,24 . We observe similar unstable multi-pulsing behaviour when the GA is executed with only a singular fitness function as described in ref. 23. By using a compound fitness function integrating multiple diagnostics, however, the system repeatability generates stable pulses with sub-picosecond durations (shown by outputs from consecutive realisations in Fig. 6(a) and (b), where the autocorrelation is not included in the fitness function but is used to independently verify ultrashort coherent pulse generation). Variation in the output pulse duration on the order of ~150 fs is noted between realisations. This is due to the bandwidth limits of our fitness function diagnostics that prohibit real-time ultrafast characterisation and hence, pulse duration optimisation. Despite this, we show that the compound fitness function approach is a reliable solution to global optimisation of the laser operating state. This highlights the improvement from employing multiple diagnostic measurements, albeit at the cost of greater system complexity. Further progress is therefore possible by integrating femtosecond timescale diagnostics into the fitness function which remains a topic for future work.
Additionally, we demonstrate the benefit of online monitoring of the laser output to ensure optimum performance by intentionally disturbing the fibre laser during mode-locked operation. Figure 6(c) shows a typical evolution from turn-on; in the 23rd generation we mechanically perturb the cavity which alters the fibre birefringence and thus the phase bias of the NALM. This disturbance changes the cavity dynamics that the GA has previously 'learned' how to optimise, and mode-locking is lost. The subsequent sharp fall in fitness score increases the mutation rate (which was damped when stably operating) permitting the GA to explore a wider parameter space to diversify the population, identifying and ultimately converging towards new optimum parameter settings for stable mode-locking.
Finally, we comment on the outlook for practical implementations of 'smart' mode-locked lasers. While our results demonstrate that genetic algorithms with a compound fitness function are a promising approach towards self-optimising laser designs, the requirement for real-time monitoring using multiple diagnostic devices is a practical limitation. It is noted, however, that the development of miniaturised, cost-effective laser diagnostic tools for online monitoring is an area of active research and development 35 which will enable further progress in this area. Additionally, simplifications are possible using novel measurement techniques and a single oscilloscope: in addition to measuring the standard trace, the RF spectrum of the output could be extracted by a Fast Fourier Transform (FFT) of the temporal intensity signal and the optical spectrum could be obtained via a dispersive Fourier transform (exploiting strong chromatic dispersion in a length of fibre to map the spectrum to a temporal waveform 36 ). Finally, we note that additional metrics for the quality of a mode-locked pulse train, such as quantifying jitter and energy fluctuations, could be obtained from analysis of the electrical spectrum 33 , which represents an additional topic of future work that may further improve the fitness function enabling simpler allocation of a fitness score, while minimising pulse to pulse variation.

Conclusion
We have demonstrated a self-optimising ultrafast Figure-8 fibre laser by employing a compound fitness function based genetic algorithm. Through exploration of various nonlinear cavity dynamics, which can be accessed by automated control of power and polarisation, we have shown that a compound fitness function, assessing both the temporal and spectral output properties of the laser, is required to obtain an accurate 'score' for quantifying laser performance. This score is maximised by the GA to obtain optimum performance, targeting the generation of stable mode-locked ultrashort pulses.
This approach also opens new opportunities for exploring nonlinear cavity dynamics in laser systems where the vast parameter space makes systematic exploration impracticable, yet ideally suited to optimisation by a genetic algorithm. Emerging laser designs such as all-normal-dispersion 37 and long-cavity 38,39 lasers exhibit such complex cavity dynamics which could be efficiently explored to potentially yield new regimes of operation with improved output properties (higher pulse energies, shorter pulses etc.), as recently shown by theoretical studies 21 . Additionally, with a suitably tailored fitness function, the genetic algorithm approach could help to experimentally identify parameters that result in novel nonlinear wave phenomena, such as soliton explosions 9 , which are studied in mode-locked fibre lasers that provide an ideal platform for exploring the dynamics of complex nonlinear systems. While the genetic algorithm concept presented here is ideally suited to mode-locked lasers that employ an artificial saturable absorber, where the nonlinear transfer function can be dynamically controlled electronically, this technique could also benefit pulsed lasers that include real saturable absorbers, where polarisation and power are still critical parameters affecting stable operation, despite the restricted space of operating regimes due to the fixed nonlinear transfer function of the saturable absorber.
To further improve the self-optimising laser design, we expect that the convergence time for the GA could be reduced through careful optimisation of the algorithm parameters (population size, mutation rate etc.) or even by the implementation of automated GA parameter tuning 16 . The delay in remote interfacing of diagnostic hardware could also be minimised by electronic integration and consideration of novel measurement techniques could further simplify the system by reducing the number of required diagnostic devices. Finally, we believe the genetic algorithm approach including a compound fitness function could be widely applicable to photonic device technology, leading to a new generation of intelligent self-optimising systems.  Fig. 1(a)] includes a passive unidirectional ring and an active bidirectional loop (known as a nonlinear amplifying loop mirror, NALM). The passive ring comprises of an isolator and 10% output coupler, while the NALM contains a 2.3 m length of ytterbium-erbium co-doped fibre, diode-pumped at 965 nm through a wavelength division multiplexer, and an electronic polarisation controller (EPC). Our EPC is formed of four stepper motor-controlled fibre-loop quarter waveplates (with 0.18 degree rotation resolution), enabling complete traversal of the Poincaré sphere by stress-induced birefringence. The total cavity length is ~28 m, resulting in a cavity group delay dispersion of ~− 0.6 ps 2 , indicating that soliton pulse shaping is expected. The cavity output is split using fibre couplers to deliver the GA-stabilised laser output in addition to signals for the diagnostic devices for evaluation of the fitness function, including an oscilloscope and electrical spectrum analyser (with photodiodes), and an optical spectrum analyser.