Adaptive model reduction to accelerate optimization problems governed by partial differential equations