Energy-Based Optimization