Computing The Optimal Path In Stochastic Dynamical Systems