  Quantum Monte Carlo algorithms based on a world-line representation such as
the worm algorithm and the directed loop algorithm are among the most powerful
numerical techniques for the simulation of non-frustrated spin models and of
bosonic models. Both algorithms work in the grand-canonical ensemble and have a
non-zero winding number. However, they retain a lot of intrinsic degrees of
freedom which can be used to optimize the algorithm. We let us guide by the
rigorous statements on the globally optimal form of Markov chain Monte Carlo
simulations in order to devise a locally optimal formulation of the worm
algorithm while incorporating ideas from the directed loop algorithm. We
provide numerical examples for the soft-core Bose-Hubbard model and various
spin-S models.
