A Survey of Optimization-based Task and Motion Planning: From Classical To Learning Approaches