Optimization-Based Estimation And Control Under Uncertainty