Optimal control of pathological locomotion