Optimization-based adaptive optics for optical coherence tomography