# ms_optimize

`boulderopal.ions.ms_optimize(drives, duration, lamb_dicke_parameters, relative_detunings, target_phases, sample_count=128, robust=False, **optimization_kwargs)`

Find optimal pulses to perform a target Mølmer–Sørensen-type operation on a system composed of ions.

This function builds a graph describing the Mølmer–Sørensen operation and calls boulderopal.run_optimization to minimize the target cost.

### Parameters

**drives**(*list**[**OptimizableDrive**]*) – A list of optimizable drives addressing the ions. Each ion can only be addressed by a single drive, but there may be ions not addressed by any drive.**duration**(*float*) – The duration, in seconds, of the dynamics to be optimized, $T$**lamb_dicke_parameters**(*np.ndarray*) – The laser-ion coupling strength, $\{\eta_{jkl}\}$`(3, N, N)`

, where the dimensions indicate, respectively, axis, collective mode, and ion.**relative_detunings**(*np.ndarray*) – The difference $\{\delta_{jk} = \nu_{jk} - \delta\}$ (in Hz) between each motional mode frequency and the laser detuning from the qubit transition frequency $\omega_0$`(3, N)`

, where the dimensions indicate, respectively, axis and collective mode.**target_phases**(*np.ndarray**or**None**,**optional*) – The target total relative phases between ion pairs, $\{\Psi_{ln}\}$`(N, N)`

. $\Psi_{ln}$ with $l > n$ indicates the relative phase between ions $l$ and $n$, while $\Psi_{ln} = 0$ for $l \leq n$**sample_count**(*int**,**optional*) – The number of times $T$**robust**(*bool**,**optional*) – If set to False, the cost corresponds to the infidelity at the end of the gate. If set to True, the cost is the final infidelity plus a dephasing-robust cost term. Defaults to False.`\*\*optimization_kwargs`

– Additional parameters to pass to boulderopal.run_optimization.

### Returns

The result of the run_optimization call.
Its `output`

item is a dictionary containing information about
the optimized drive and the evolution of the system, with the following keys:

optimized drives : The piecewise-constant optimized drives implementing the gate. The keys are the names of the drives provided to the function.

`sample_times`

: The times at which the evolution is sampled, as an array of shape`(T,)`

.

`phases`

: Acquired phases $\{\Phi_{ln}(t_i) = \phi_{ln}(t_i) + \phi_{nl}(t_i)\}$ for each sample time and for all ion pairs, as a strictly lower triangular matrix of shape`(T, N, N)`

. $\Phi_{ln}(t_i)$ with $l > n$ indicates the relative phase between ions $l$ and $n$, while $\Phi_{ln}(t_i) = 0$ for $l \leq n$.

`displacements`

: Displacements $\{\eta_{jkl}\alpha_{jkl}(t_i)\}$ for all mode-ion combinations, as an array of shape`(T, 3, N, N)`

, where the dimensions indicate, respectively, time, axis, collective mode, and ion.

`infidelities`

: A 1D array of length`T`

with the operational infidelities of the Mølmer–Sørensen gate at each sample time, $\mathcal{I}(t_i)$.

### Return type

dict

### SEE ALSO

`boulderopal.ions.ComplexOptimizableDrive`

: Class describing a piecewise-constant complex-valued optimizable drive.

`boulderopal.ions.RealOptimizableDrive`

: Class describing a piecewise-constant real-valued optimizable drive.

`boulderopal.ions.ms_simulate`

: Simulate a Mølmer–Sørensen-type operation on a trapped ions system.

`boulderopal.ions.obtain_ion_chain_properties`

: Calculate the properties of an ion chain.

## Notes

See the notes of `boulderopal.ions.ms_simulate`

for the main equations and definitions.

You can use the robust flag to construct a Mølmer–Sørensen gate that is
robust against dephasing noise. This imposes a symmetry ^{1} in the optimizable
ion drives and aims to minimize the time-averaged positions of the phase-space
trajectories,

This is achieved by adding an additional term to the cost function, consisting of the sum of the square moduli of the time-averaged positions multiplied by the corresponding Lamb–Dicke parameters. That is to say,

$C_\text{robust} = \mathcal{I} + \sum_{j=1}^{3} \sum_{k=1}^{N} \sum_{l=1}^{N} \left| \eta_{jkl} \langle \alpha_{jkl} \rangle \right|^2 .$