This script launches the optimization of the figure of merit using the controlled random search and subplex routines from NLopt interface. The termination criteria are specified in the main text.

The pulse.dat file defines the initial pulse waveform. All pulses have the same duration and the microwave amplitudes are defined in MHz. The first column defines the x phase amplitude and the second column defines the y phase amplitude. Please keep the format as [numeric value][space][numeric value][endline], as the code may not handle exceptions very well.

The b1_inhom.dat includes microwave inhomogeneity. The first column defines the field strength prefactor and the second columns the corresponding weight. If the weights are not normalize, the code automatically normalizes the weights. The calculated FOM will then correspond to a weighted average. Please keep the format as [numeric value][space][numeric value][endline], as the code may not handle exceptions very well.

The par.dat file defines the optimization parameters. Please only change the numeric values and don't add additional lines, as the code may not handle exceptions very well.

To run, only modify the files and execute it with ./fom_nonlin_optimizer

Tested on Ubuntu 22.04.4 LTS
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
ldd (Ubuntu GLIBC 2.35-0ubuntu3.8) 2.35
This executable also requires NLOPT 
available on the Ubuntu repos libnlopt0 or
download from:  
github.com/stevengj/nlopt/archive/v2.7.1.tar.gz
Follow the instructions in 
nlopt.readthedocs.io/en/latest/NLopt_Installation/
and compile it as a shared library
