Enhancing the performance of energy harvesting wireless communications using optimization and machine learning