Dynamic resource allocation and optimization in wireless networks