A Complete Python Solution
Economic Load Dispatch (ELD) is a fundamental optimization problem in power systems engineering that aims to minimize the total fuel cost while satisfying the power demand and system constraints. Today, we’ll dive deep into this problem with a practical example and solve it using Python optimization techniques.
Problem Formulation
The economic load dispatch problem can be mathematically formulated as:
Objective Function:
$$\min \sum_{i=1}^{n} F_i(P_i)$$
Subject to:
$$\sum_{i=1}^{n} P_i = P_D + P_L$$
$$P_{i,\min} \leq P_i \leq P_{i,\max}$$
Where:
- $F_i(P_i)$ is the fuel cost function of generator $i$
- $P_i$ is the power output of generator $i$
- $P_D$ is the total power demand
- $P_L$ is the transmission loss
- $n$ is the number of generators
For this example, we’ll use quadratic cost functions:
$$F_i(P_i) = a_i P_i^2 + b_i P_i + c_i$$
1 | import numpy as np |
Detailed Code Explanation
Let me break down the key components of this comprehensive Economic Load Dispatch solution:
1. Class Structure and Initialization
The EconomicLoadDispatch class encapsulates all the necessary methods for solving the ELD problem. The constructor takes generator data (cost coefficients and limits), total demand, and optional transmission loss coefficients.
2. Cost Function Implementation
1 | def cost_function(self, power_output): |
This method calculates the total fuel cost using the quadratic cost function:
$$F_i(P_i) = a_i P_i^2 + b_i P_i + c_i$$
The quadratic nature reflects the decreasing efficiency of generators at higher outputs.
3. Transmission Loss Modeling
1 | def transmission_loss(self, power_output): |
Uses the B-coefficients method to approximate transmission losses:
$$P_{loss} = \sum_{i=1}^{n} B_{ii} P_i^2$$
This simplified model captures the quadratic relationship between power flow and losses.
4. Power Balance Constraint
1 | def power_balance_constraint(self, power_output): |
Enforces the fundamental power system constraint:
$$\sum_{i=1}^{n} P_i = P_D + P_L$$
5. Optimization Solver
The solve_eld() method uses SciPy’s Sequential Least Squares Programming (SLSQP) algorithm, which is well-suited for constrained optimization problems with both equality and inequality constraints.
6. Incremental Cost Calculation
1 | def calculate_lambda(self, power_output): |
Computes the incremental cost (marginal cost) for each generator:
$$\lambda_i = \frac{dF_i}{dP_i} = 2a_i P_i + b_i$$
At the optimal solution, all incremental costs should be approximately equal (economic dispatch principle).
Results Analysis and Interpretation
============================================================
ECONOMIC LOAD DISPATCH OPTIMIZATION
============================================================
Total Power Demand: 400 MW
Number of Generators: 4
Solving Economic Load Dispatch...
Optimization terminated successfully (Exit mode 0)
Current function value: 4034.8648980165035
Iterations: 14
Function evaluations: 71
Gradient evaluations: 14
============================================================
OPTIMIZATION RESULTS
============================================================
Optimization Status: Success
Total Generation Cost: $4034.86
Transmission Loss: 4.90 MW
Total Generation: 404.90 MW
Net Power to Load: 400.00 MW
DETAILED DISPATCH RESULTS:
--------------------------------------------------------------------------------
Generator Power Output (MW) Individual Cost ($) Incremental Cost ($/MWh) Capacity Utilization (%)
Generator 1 119.36 949.48 8.91 79.57
Generator 2 130.14 998.35 8.84 108.45
Generator 3 72.94 620.75 9.02 52.10
Generator 4 82.46 676.28 8.90 82.46
Optimality Check:
Average Incremental Cost: 8.919 $/MWh
Standard Deviation: 0.064533 $/MWh
(All incremental costs should be approximately equal for optimal dispatch)
Optimization terminated successfully (Exit mode 0)
Current function value: 3145.6282686781165
Iterations: 11
Function evaluations: 56
Gradient evaluations: 11
Optimization terminated successfully (Exit mode 0)
Current function value: 3237.027266204679
Iterations: 14
Function evaluations: 71
Gradient evaluations: 14
Optimization terminated successfully (Exit mode 0)
Current function value: 3328.942751660703
Iterations: 14
Function evaluations: 70
Gradient evaluations: 14
Optimization terminated successfully (Exit mode 0)
Current function value: 3421.37563329975
Iterations: 14
Function evaluations: 71
Gradient evaluations: 14
Optimization terminated successfully (Exit mode 0)
Current function value: 3514.326836020614
Iterations: 16
Function evaluations: 81
Gradient evaluations: 16
Optimization terminated successfully (Exit mode 0)
Current function value: 3607.797283671775
Iterations: 15
Function evaluations: 76
Gradient evaluations: 15
Optimization terminated successfully (Exit mode 0)
Current function value: 3701.787904367664
Iterations: 13
Function evaluations: 66
Gradient evaluations: 13
Optimization terminated successfully (Exit mode 0)
Current function value: 3796.299629058466
Iterations: 15
Function evaluations: 75
Gradient evaluations: 15
Optimization terminated successfully (Exit mode 0)
Current function value: 3891.333389578059
Iterations: 15
Fun
ECONOMIC MERIT ORDER ANALYSIS
Merit Order (Sorted by Average Cost):
Generator Average Cost ($/MW) Min Cost ($/MWh) Capacity (MW)
Generator 2 9.050 6.500 150
Generator 1 9.600 7.000 200
Generator 4 10.103 7.500 120
Generator 3 10.482 8.000 180
Note: The economic dispatch optimizes the total system cost,
which may differ from simple merit order due to transmission losses
and generator constraints.
Key Findings:
Optimal Dispatch: The algorithm determines the most economical power distribution among generators while respecting all constraints.
Incremental Cost Equality: The solution demonstrates the fundamental principle that optimal dispatch occurs when all generators operate at the same incremental cost.
Capacity Utilization: The visualization shows how efficiently each generator is being utilized relative to its maximum capacity.
Cost Sensitivity: The sensitivity analysis reveals how total system cost varies with demand changes, which is crucial for real-time operations.
Graphical Analysis:
- Power Dispatch Chart: Shows the optimal power output for each generator
- Cost Functions: Displays the quadratic cost curves with optimal operating points marked
- Incremental Costs: Verifies the optimality condition through nearly equal marginal costs
- Capacity Utilization: Indicates how close each generator operates to its maximum capacity
- 3D Surface Plot: Provides insight into the cost landscape for multi-generator systems
Practical Applications:
This solution methodology is directly applicable to:
- Real-time power system operations
- Day-ahead market scheduling
- Unit commitment optimization
- Renewable energy integration studies
The economic load dispatch forms the foundation for more complex power system optimization problems, including security-constrained dispatch, multi-area coordination, and electricity market operations.
This implementation provides a solid foundation that can be extended to include more sophisticated models such as valve-point effects, prohibited operating zones, and environmental constraints.









