Network Loss Calculation and Demand Side Management: Optimization Problems for Cost Efficient Distribution System Operation