Similar Items: Optimization and Energy Management in Smart Grids