CODE:
% Economic Dispatch using Equal Incremental Cost Method - Sequential Adjustment Approach
% Define the incremental cost equations for each generator:
dF1 = @(P1) 0.8 * P1 + 10;
dF2 = @(P2) 0.7 * P2 + 5;
dF3 = @(P3) 0.94 * P3 + 15;
dF4 = @(P4) 0.64 * P4 + 8;
dF5 = @(P5) 0.8 * P5 + 12;
% Generation limits:
P1_min = 30; P1_max = 500;
P2_min = 30; P2_max = 500;
P3_min = 30; P3_max = 300;
P4_min = 30; P4_max = 400;
P5_min = 30; P5_max = 300;
% Load demand steps
load_steps = 150:100:2000; % Load demand from 150 MW to 2000 MW with 100 MW steps
% Store the optimal generation schedules
optimal_generation = zeros(length(load_steps), 5);
% Step size for power adjustment
step_size = 0.5;
% Loop through each load step
for i = 1:length(load_steps)
P_total = load_steps(i); % Current total load demand
% Initial guesses for P1, P2, P3, P4, P5 (evenly distributed)
P1 = P_total / 5;
P2 = P_total / 5;
P3 = P_total / 5;
P4 = P_total / 5;
P5 = P_total / 5;
% Enforce generation limits
P1 = max(min(P1, P1_max), P1_min);
P2 = max(min(P2, P2_max), P2_min);
P3 = max(min(P3, P3_max), P3_min);
P4 = max(min(P4, P4_max), P4_min);
P5 = max(min(P5, P5_max), P5_min);
% Calculate the initial lambda (average of the incremental costs)
lambda = mean([dF1(P1), dF2(P2), dF3(P3), dF4(P4), dF5(P5)]);
diff = Inf; % Initialize difference for the loop condition
% Iterate to balance the generation using sequential adjustment
while abs(diff) > 0.01
% Calculate incremental costs for the current power settings
IC1 = dF1(P1);
IC2 = dF2(P2);
IC3 = dF3(P3);
IC4 = dF4(P4);
IC5 = dF5(P5);
% Adjust powers based on the incremental cost differences with lambda
if IC1 > lambda
P1 = P1 - step_size;
else
P1 = P1 + step_size;
end
P1 = max(min(P1, P1_max), P1_min);
if IC2 > lambda
P2 = P2 - step_size;
else
P2 = P2 + step_size;
end
P2 = max(min(P2, P2_max), P2_min);
if IC3 > lambda
P3 = P3 - step_size;
else
P3 = P3 + step_size;
end
P3 = max(min(P3, P3_max), P3_min);
if IC4 > lambda
P4 = P4 - step_size;
else
P4 = P4 + step_size;
end
P4 = max(min(P4, P4_max), P4_min);
if IC5 > lambda
P5 = P5 - step_size;
else
P5 = P5 + step_size;
end
P5 = max(min(P5, P5_max), P5_min);
% Calculate the total power generation after adjustments
P_gen = P1 + P2 + P3 + P4 + P5;
% Calculate the difference from the desired total
diff = P_gen - P_total;
% Adjust lambda based on average of the updated incremental costs
lambda = mean([IC1, IC2, IC3, IC4, IC5]);
end
% Store the optimal generation for the current load step
optimal_generation(i, :) = [P1, P2, P3, P4, P5];
end
% Display the results
disp('Load Demand (MW) P1 (MW) P2 (MW) P3 (MW) P4 (MW) P5 (MW)');
for i = 1:length(load_steps)
fprintf('%8d %8.2f %8.2f %8.2f %8.2f %8.2f\n', ...
load_steps(i), optimal_generation(i, 1), optimal_generation(i, 2), ...
optimal_generation(i, 3), optimal_generation(i, 4), optimal_generation(i, 5));
end