  We introduce a variational algorithm to estimate the likelihood of a rare
event within a nonequilibrium molecular dynamics simulation through the
evaluation of an optimal control force. Optimization of a control force within
a chosen basis is made possible by explicit forms for the gradients of a cost
function in terms of the susceptibility of driven trajectories to changes in
variational parameters. We consider probabilities of time-integrated dynamical
observables as characterized by their large deviation functions, and find that
in many cases the variational estimate is quantitatively accurate.
Additionally, we provide expressions to exactly correct the variational
estimate that can be evaluated directly. We benchmark this algorithm against
the numerically exact solution of a model of a driven particle in a periodic
potential, where the control force can be represented with a complete basis. We
then demonstrate the utility of the algorithm in a model of repulsive particles
on a line, which undergo a dynamical phase transition, resulting in singular
changes to the form of the optimal control force. In both systems, we find fast
convergence and are able to evaluate large deviation functions with significant
increases in statistical efficiency over alternative Monte Carlo approaches.
