Optimization of Dynamic Objective Functions Using Path integrals