Efficient Energy Optimization For Smart Grid And Smart Community