Optimizing the Advanced Metering Infrastructure Architecture in Smart Grid