Nesting of the lattice minimisation within the larger parameter estimation framework shown in Problem (PE) results in a bilevel programming problem: an inner level involving the rigid lattice energy minimisation of each structure with respect to Ω s and an outer level involving the T M F minimisation with respect to p. This bilevel structure presents a significant challenge to solving the parameter estimation problem for a number of reasons. One of the most challenging aspects of this optimisation problem is the calculation of derivatives of each merit function with respect to the parameter values. Gradients are typically obtained numerically using finite differences, such that the lattice energy minimisation problems must be re-solved for each finite difference step . For instance, using second-order centred finite differences, gradient calculations would require 2N P × N S lattice minimisations per set of gradient calculations, where N P is the number of parameters being optimised. This drastically increases the computational cost of the entire approach as N P and/or N S are increased. Finite differences are also subject to much more numerical noise than analytical calculations. This can lead to inaccuracies in the calculation of gradients and premature convergence or failure of typical optimisation algorithms.