Online Model-based Estimation for Automated Optical System Alignment and Phase Retrieval Algorithm