Смекни!
smekni.com

Использование нечеткой искусственной нейронной сети TSK Takagi Sugeno Kanga в задаче прогнозирования (стр. 11 из 14)

22.2536 21.9127 0.3409 21.7846 0.4690

22.0466 22.2549 -0.2083 21.9200 0.1266

21.8129 22.0556 -0.2427 22.2480 -0.4351

21.7667 21.7951 -0.0284 22.0365 -0.2698

21.7741 21.7667 0.0074 21.8182 -0.0441

21.6546 21.7820 -0.1274 21.7672 -0.1126

21.6826 21.6586 0.0240 21.7694 -0.0868

21.8987 21.6780 0.2207 21.6626 0.2361

21.6999 21.9017 -0.2018 21.6932 0.0067

21.6952 21.7088 -0.0136 21.8991 -0.2039

21.7220 21.6800 0.0420 21.6940 0.0280

21.6809 21.7288 -0.0479 21.7043 -0.0234

21.8536 21.6829 0.1707 21.7192 0.1344

21.7135 21.8491 -0.1356 21.6767 0.0368

21.7306 21.7227 0.0079 21.8602 -0.1296

21.7001 21.7189 -0.0188 21.7077 -0.0076

21.5347 21.7062 -0.1715 21.7347 -0.2000

21.7213 21.5353 0.1860 21.6988 0.0225

22.3503 21.7145 0.6358 21.5328 0.8175

22.1375 22.3556 -0.2181 21.7303 0.4072

22.2133 22.1547 0.0586 22.3443 -0.1310

22.2000 22.1802 0.0198 22.1193 0.0807

22.1959 22.2098 -0.0139 22.2216 -0.0257

22.2089 22.1930 0.0159 22.1855 0.0234

22.3387 22.2090 0.1297 22.1822 0.1565

22.2055 22.3378 -0.1323 22.2138 -0.0083

22.3327 22.2111 0.1216 22.3364 -0.0037

22.2445 22.3215 -0.0770 22.2016 0.0429

22.2404 22.2549 -0.0145 22.3369 -0.0965

22.3905 22.2327 0.1578 22.2386 0.1519

22.5251 22.3917 0.1334 22.2413 0.2838

22.5495 22.5289 0.0206 22.3928 0.1567

22.5518 22.5480 0.0038 22.5179 0.0339

22.8039 22.5471 0.2568 22.5472 0.2567

22.8440 22.7997 0.0443 22.5491 0.2949

22.8138 22.8520 -0.0382 22.7983 0.0155

23.2884 22.8057 0.4827 22.8319 0.4565

23.8456 23.2796 0.5660 22.8115 1.0341

23.2653 23.8562 -0.5909 23.2863 -0.0210

23.7359 23.2730 0.4629 23.8229 -0.0870

23.8394 23.6877 0.1517 23.2456 0.5938

24.0390 23.8758 0.1632 23.7494 0.2896

23.9227 24.0229 -0.1002 23.8057 0.1170

24.0392 23.9260 0.1132 24.0271 0.0121

24.1458 24.0258 0.1200 23.9257 0.2201

24.1932 24.1526 0.0406 24.0291 0.1641

23.7148 24.1920 -0.4772 24.1370 -0.4222

23.7680 23.7178 0.0502 24.1856 -0.4176

23.6412 23.7489 -0.1077 23.7148 -0.0736

23.5967 23.6631 -0.0664 23.7794 -0.1827

23.5723 23.5918 -0.0195 23.6368 -0.0645

23.6716 23.5759 0.0957 23.6052 0.0664

23.7189 23.6715 0.0474 23.5859 0.1330

24.0997 23.7228 0.3769 23.6726 0.4271

24.5946 24.0929 0.5017 23.7195 0.8751

25.2590 24.5996 0.6594 24.0995 1.1595

25.4215 25.2530 0.1685 24.5815 0.8400

26.0587 25.4222 0.6365 25.2390 0.8197

25.8549 26.0297 -0.1748 25.3932 0.4617

26.5626 25.8715 0.6911 26.0366 0.5260

25.9180 26.5219 -0.6039 25.8128 0.1052

25.4944 25.9567 -0.4623 26.5490 -1.0546

25.7561 25.4503 0.3058 25.8832 -0.1271

26.2157 25.7622 0.4535 25.5003 0.7154

25.9854 26.2369 -0.2515 25.7680 0.2174

25.5189 25.9946 -0.4757 26.1966 -0.6777

26.1437 25.4982 0.6455 25.9919 0.1518

27.0949 26.1282 0.9667 25.5339 1.5610

27.6867 27.1234 0.5633 26.1471 1.5396

28.4523 27.6887 0.7636 27.0656 1.3867

29.5029 28.4250 1.0779 27.6661 1.8368

28.8115 29.4914 -0.6799 28.4364 0.3751

27.8928 28.8248 -0.9320 29.4492 -1.5564

27.9722 27.8378 0.1344 28.7438 -0.7716

27.2098 27.9647 -0.7549 27.8895 -0.6797

27.3991 27.2589 0.1402 27.9709 -0.5718

27.7549 27.3694 0.3855 27.1890 0.5659

27.2280 27.7866 -0.5586 27.4531 -0.2251

27.9749 27.2407 0.7342 27.7730 0.2019

28.0640 27.9336 0.1304 27.2229 0.8411

28.7574 28.1083 0.6491 28.0096 0.7478

28.2074 28.7240 -0.5166 28.0310 0.1764

28.2438 28.2328 0.0110 28.7503 -0.5065

28.3721 28.1973 0.1748 28.1895 0.1826

28.3514 28.3919 -0.0405 28.2402 0.1112

28.9328 28.3557 0.5771 28.3612 0.5716

28.9594 28.9200 0.0394 28.3353 0.6241

29.0392 28.9795 0.0597 28.9474 0.0918

28.3951 29.0165 -0.6214 28.9378 -0.5427

28.8022 28.4034 0.3988 29.0344 -0.2322

28.8345 28.7721 0.0624 28.3861 0.4484

28.9675 28.8730 0.0945 28.8077 0.1598

29.5156 28.9524 0.5632 28.8204 0.6952

30.2278 29.5114 0.7164 28.9714 1.2564

30.0163 30.2327 -0.2164 29.5233 0.4930

30.0846 30.0216 0.0630 30.1985 -0.1139

30.4830 30.0477 0.4353 29.9897 0.4933

29.8649 30.4873 -0.6224 30.0806 -0.2157

30.3308 29.8838 0.4470 30.4582 -0.1274

30.0762 30.2883 -0.2121 29.8354 0.2408

30.2365 30.1185 0.1180 30.3554 -0.1189

30.8580 30.2089 0.6491 30.0552 0.8028

30.6614 30.8650 -0.2036 30.2410 0.4204

30.5844 30.6793 -0.0949 30.8639 -0.2795

31.1065 30.5541 0.5524 30.6314 0.4751

31.4369 31.1040 0.3329 30.5948 0.8421

31.3143 31.4542 -0.1399 31.0978 0.2165

31.4791 31.3069 0.1722 31.4058 0.0733

31.4058 31.4590 -0.0532 31.3088 0.0970

31.6801 31.4165 0.2636 31.4785 0.2016

31.7325 31.6681 0.0644 31.3829 0.3496

32.0790 31.7438 0.3352 31.6750 0.4040

32.3305 32.0660 0.2645 31.7249 0.6056

32.5779 32.3367 0.2412 32.0734 0.5045

32.5723 32.5699 0.0024 32.3177 0.2546

33.7905 32.5703 1.2202 32.5613 1.2292

34.3755 33.7654 0.6101 32.5583 1.8172

35.1092 34.4098 0.6994 33.7782 1.3310

35.1681 35.0729 0.0952 34.3259 0.8422

36.2071 35.1673 1.0398 35.0818 1.1253

36.1219 36.1668 -0.0449 35.1289 0.9930

36.2668 36.1547 0.1121 36.1652 0.1016

36.8864 36.2215 0.6649 36.0635 0.8229

36.3872 36.8851 -0.4979 36.2481 0.1391

36.8653 36.4090 0.4563 36.8680 -0.0027

37.2193 36.8180 0.4013 36.3402 0.8791

37.0266 37.2496 -0.2230 36.8814 0.1452

36.7194 37.0234 -0.3040 37.1931 -0.4737

37.2455 36.7018 0.5437 37.0038 0.2417

38.4723 37.2354 1.2369 36.7328 1.7395

39.6802 38.4878 1.1924 37.2391 2.4411

39.6877 38.4484

38.4399

39.6406


Приложение 2

Текст программы

unitUnit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Grids;

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

Button3: TButton;

Button4: TButton;

Button5: TButton;

Button6: TButton;

Button7: TButton;

Button8: TButton;

Button9: TButton;

Button10: TButton;

Button11: TButton;

OpenData: TOpenDialog;

OpenNNS: TOpenDialog;

SaveData: TSaveDialog;

SaveNNS: TSaveDialog;

StringGrid1: TStringGrid;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Edit1: TEdit;

Label7: TLabel;

Edit2: TEdit;

Label8: TLabel;

Label9: TLabel;

Edit3: TEdit;

Edit4: TEdit;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

Edit8: TEdit;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

procedure Button11Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure FormResize(Sender: TObject);

procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);

procedure StringGrid1GetEditText(Sender: TObject; ACol, ARow: Integer;

var Value: String);

procedure Button4Click(Sender: TObject);

procedure Button8Click(Sender: TObject);

procedure Button9Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

const nns=54321;

mM=20;

mN=20;

u=0.8;

v=1.25;

var

Form1: TForm1;

s1: string;

i,j,k,n,m,OnSettings:integer;//m - количество правил

a,ap,ap3: array[1..2000]of real;

f,f1,f2,f3,f4:TextFile;

t,Nst,Nac,Neps,Nrp:integer;

w3,w: array[1..20]of real;

sign:array[1..20] of integer;

c:array[1..20]of real;

h:array[1..250,1..mM]of real;

myu0,myu03:array[1..mM]of real;//пересечение правил

myu,myu3,cen,cen3,b,b3:array[1..mM,1..mN]of real; // нелинейные параметры

sigma,sigma3:array[1..mM,1..mN]of real; // нелинейные параметры

// b:array[1..mM,1..mN]of real; // нелинейные параметры

gc,gs,gb:real;//шаг градиентного спуска

p,p3:array[1..mM,0..mN]of real; // Линейные параметры

input,output:array[1..20]of real;

eps,skoS,sko3S,skoP,sko3P,ms,mp,ms3,mp3,sappS,sapp3S,sappP,sapp3p:real;

fname:string;

nnit:longint;

implementation

uses Unit2, Unit3, Unit4, matrices;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

//загрузить данные

var i:integer;

s:string;

begin

for i:=1 to n+10 do

begin

StringGrid1.cells[0,i]:='';

StringGrid1.cells[1,i]:='';

StringGrid1.cells[2,i]:='';

StringGrid1.cells[3,i]:='';

StringGrid1.cells[4,i]:='';

end;

OpenData.InitialDir:='D:\CW';

OpenData.DefaultExt:='txt';

if OpenData.Execute then

begin

s:=OpenData.FileName;

StringGrid1.RowCount:=1;

for i:=1 to n do

begin

StringGrid1.cells[0,i]:='';

end;

fname:=s;

AssignFile(f1,s);

reset(f1);

readln(f1,n);

nst:=trunc(n/10);

StringGrid1.RowCount:=0;

for i:=1 to n do

begin

readln(f1,s);

{ str(a[i]:8:4,s);}

for j:=1 to length(s) do

if(s[j]='.') or(s[j]=',')then s[j]:=decimalseparator;

StringGrid1.Cells[0,i]:=s;

StringGrid1.RowCount:=StringGrid1.RowCount+1;

a[i]:=strToFloat(s);

end;

StringGrid1.RowCount:=StringGrid1.RowCount+10;

StringGrid1.LeftCol:=0;

StringGrid1.TopRow:=1;

if n-10>0 then

StringGrid1.TopRow:=n-10;

CloseFile(f1);

end;

end;//Загрузить данные (Конец)

procedure TForm1.Button2Click(Sender: TObject);//Загрузить нейросеть

var nn:integer;

begin

OpenNNS.InitialDir:='D:\CW';

OpenNNS.DefaultExt:='nns';

if OpenNNS.Execute then

begin

s:=OpenNNS.FileName;

AssignFile(f1,s);

reset(f1);

readln(f1,nn);

if nn<>nns then

begin

messagedlg('Ошибка ввода начальных данных!',mtError,[mbOk],0);

end

else

begin

readln(f1,nac);

readln(f1,m);

for i:=1 to m do

for j:=1 to nac do

readln(f1,cen[i,j]);

for i:=1 to m do

for j:=1 to nac do

readln(f1,sigma[i,j]);

for i:=1 to m do

for j:=1 to nac do

readln(f1,b[i,j]);

for i:=1 to m do

for j:=0 to nac do

if j<=nac then

readln(f1,p[i,j]);

for i:=1 to m do

for j:=1 to nac do

readln(f1,cen3[i,j]);

for i:=1 to m do

for j:=1 to nac do

readln(f1,sigma3[i,j]);

for i:=1 to m do

for j:=1 to nac do

readln(f1,b3[i,j]);

for i:=1 to m do

for j:=0 to nac do

if j<=nac then

readln(f1,p3[i,j]);

end;

CloseFile(f1);

end;

end;//Загрузить нейросеть (конец)

procedure TForm1.Button7Click(Sender: TObject);

//Сохранить данные

var i:integer;

begin

SaveData.InitialDir:='D:&bsol;CW';

SaveData.DefaultExt:='txt'; i:=1;

while (stringGrid1.cells[0,i]<>'')and(i<10000) do

begin

i:=i+1;

end;

n:=i-1;

if SaveData.Execute then

begin

fname:=SaveData.FileName;

AssignFile(f3,SaveData.FileName);

Rewrite(f3);

writeln(f3,n);

for i:=1 to n do

begin

writeln(f3,stringGrid1.cells[0,i]);

end;

CloseFile(f3);

end;

end; //Сохранить данные (конец)

procedure TForm1.Button11Click(Sender: TObject);

begin // Закрыть форму 1

AssignFile(f3,'1.txt');

Rewrite(f3);

writeln(f3,skoS:10:8);

writeln(f3,sko3S:10:8);

writeln(f3,skoP:10:8);

writeln(f3,sko3P:10:8);

writeln(f3,ms:10:8);

writeln(f3,mp:10:8);

writeln(f3,ms3:10:8);

writeln(f3,mp3:10:8);

for i:=nst to n+3 do

begin

write(f3,stringGrid1.cells[0,i]);

write(f3,stringGrid1.cells[1,i]);

write(f3,stringGrid1.cells[2,i]);

write(f3,stringGrid1.cells[3,i]);

writeln(f3,stringGrid1.cells[4,i]);

end;

CloseFile(f3);

Form1.close;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin //Открыть форму "Настройки"

form2.Show;

end; //Открыть форму "Настройки" (конец)

procedure TForm1.Button5Click(Sender: TObject);

begin

if (stringGrid1.cells[0,1]<>'')and(stringGrid1.cells[0,3]<>'') then

form3.show; // Открыть форму график КВ

end;

procedure TForm1.Button6Click(Sender: TObject);

begin

if (stringGrid1.cells[0,1]<>'')and(stringGrid1.cells[0,3]<>'') then

form4.show; // Открыть форму график пргноза на 3 шага вперед

end;

procedure TForm1.FormCreate(Sender: TObject);

// Создание формы 1

var a:integer;

begin

a:=6;

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';

edit4.Text:='';

edit5.Text:='';

edit6.Text:='';

edit7.Text:='';

edit8.Text:='';

Nst:=0; Nac:=4;Neps:=10;Nrp:=80;m:=5;

end; //Конец создания формы 1

procedure TForm1.FormResize(Sender: TObject);

//Изменение размеров формы 1

var a:integer;

begin

if Form1.Width<500 then

Form1.Width:=500;

if Form1.Height<550 then

Form1.Height:=550;

StringGrid1.Width:=Form1.Width-Button1.Width-80;

StringGrid1.Height:=Form1.Height-280;

a:=6;

StringGrid1.Top:=Form1.ClientHeight-StringGrid1.Height-216;

StringGrid1.Left:=Form1.ClientWidth-StringGrid1.Width-24;

StringGrid1.ColWidths[0]:=trunc(StringGrid1.Width*0.2)-a;

StringGrid1.ColWidths[1]:=trunc(StringGrid1.Width*0.2)-a;

StringGrid1.ColWidths[2]:=trunc(StringGrid1.Width*0.2)-a;

StringGrid1.ColWidths[3]:=trunc(StringGrid1.Width*0.2)-a;

StringGrid1.ColWidths[4]:=trunc(StringGrid1.Width*0.2)-a;

end; // Конец изменения формы 1

procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);

begin

if not (Key in [#8,'0'..'9',decimalSeparator])then

Key:=#0

end;

procedure TForm1.StringGrid1GetEditText(Sender: TObject; ACol,

ARow: Integer; var Value: String);

var i:integer;

begin

i:=1;

while (stringgrid1.cells[0,i]<>'')do

i:=i+1;

StringGrid1.RowCount:=i+10;

n:=i;

end;

function adjust():boolean;

var wrong,q,r:integer;

//f:boolean;

prognoz,realynoe:real;

begin

wrong:=0;

for q:=nac+2 to nst-1 do

begin

eps:=Neps*a[q]/1000;

realynoe:=a[q+1]-a[q];

prognoz:=0;

for r:=1 to nac do

prognoz:=prognoz+(a[q-nac+r-1]-a[q-nac+r-2])*w[r];

if abs(prognoz-realynoe)<eps then

wrong:=wrong+1;

end;

if wrong/(nst-(nac+2))<(100-Nrp)/100 then

adjust:=true

else

adjust:=false;

end;//adjust

procedure ns(i,j:integer;var a,b,c:real);

const eps=0.01;

begin a:=eps*i/j;b:=eps*i/i;c:=i/j;

end;

procedure adjust_csb3(num:integer;vihod:real);

const eps=0.00001;

var lxj,mxj,mxjs,sum:real;

r,k,j,l,bb,d,delta:integer;

p1,p2,p5,p4:real; // Произведения при вычислении dw/d(cen)(sigma)(b)

s1,sc,ss,sb,dec,deb,des,dwc,dwb,dws:real; // dw/d(cen)(sigma)(b)

begin

for j:=1 to nac do

begin

for k:=1 to m do

begin

lxj:=1;

for l:=1 to nac do

lxj:=lxj*myu3[k,j];

mxj:=1;

for bb:=1 to m do

begin

mxjs:=0;

for d:=1 to nac do

mxjs:=mxjs+myu3[bb,d];

mxj:=mxj*mxjs;

end;

if mxj<eps then

mxj:=eps;

if lxj<eps then

lxj:=eps;

// Изменняем cen

sc:=0;

ss:=0;

sb:=0;

for r:=1 to m do

begin

//dw/d(cen)

p1:=1;

for i:=1 to m do

if i<>j then

p1:=p1*(2*b3[k,j]/sigma3[k,j])*