Measurement-Based Control for Minimizing Energy Functions in Quantum Systems