% the data matrix should have 5 columns of fuel cost coefficients and plant  limits.
% 1.a ($/MW^2) 2. b $/MW 3. c ($) 4.lower lomit(MW) 5.Upper limit(MW)
% This Example system is taken from the book Power System Analysis  by Prof Haadi Sadaat Example 7.8
%no of rows denote the no of plants(n)
clear
clc;
format long;
global data B B0 B00 Pd
data=[0.008	7	200	10	85
0.009	6.3	180	10	80
0.007	6.8	140 10 70];
B=.01*[.0218 .0093 .0028;.0093 .0228 .0017;.0028 .0017 .0179];
 B0=0*[.0003 .0031 .0015];
 B00=100*.00030523;
 Pd=150;
 Pd=Pd+B00;
l=data(:,4)';
u=data(:,5)';
ran=[l' u'];
n=length(data(:,1));
Pdef = [100 100000 100 2 2 0.9 0.4 1500 1e-6 5000 NaN 0 0];
 [OUT]=pso_Trelea_vectorized('f6',n,1,ran,0,Pdef);
 out=abs(OUT)
 P=out(1:n)
  [F Pl]=f6(P')