Rare events by constrained molecular dynamics