Optimal design of the Barker proposal and other locally-balanced Metropolis-Hastings algorithms