Optimizing Energy of Electric Vehicles in Smart Cities