Using Randomization to Find and Optimize Feasible Trajectories for Nonlinear Systems