1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
| unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CheckLst, Math;
type
TForm2 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit4: TEdit;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Label12: TLabel;
Label14: TLabel;
Label15: TLabel;
Edit7: TEdit;
Edit8: TEdit;
Label13: TLabel;
Button1: TButton;
GroupBox1: TGroupBox;
Button2: TButton;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Edit9: TEdit;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
Label33: TLabel;
Label34: TLabel;
Label35: TLabel;
Label36: TLabel;
Label37: TLabel;
Label38: TLabel;
Label39: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
a: array [1..4] of Real;
i_: Integer;
implementation
uses Unit1;
{$R *.dfm}
function Exit_obj(u1:real;u2:real): real;
begin
Exit_obj:=a[1]+a[2]*u1+a[3]*u2+a[4]*u1*u2;
end;
function Pomeha(D:real): real;
var
m: real;
begin
m:=0;
Pomeha:=RandG(m,D);
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
i_ := 1;
end;
procedure TForm2.Button2Click(Sender: TObject);
var i,j,l:Integer;
u:array[1..2] of Real;
experim_u:array[1..9,1..2] of Real;
delta_u:array[1..2] of Real;
Dh,sum,sig1,sig2,m_oz,h,fisher,f:Real;
matrix_plan:array[1..9,1..8] of Real;
y:array[1..9] of Real;
y_dop:array[1..9] of Real;
b:array[1..7] of Real;
a_ots:array[1..7] of Real;
begin
// Считывание данных с клавиатуры
a[1]:=StrToFloat(Edit1.Text);
a[2]:=StrToFloat(Edit2.Text);
a[3]:=StrToFloat(Edit3.Text);
a[4]:=StrToFloat(Edit9.Text);
u[1]:=StrToFloat(Edit7.Text);
u[2]:=StrToFloat(Edit8.Text);
Dh:=StrToFloat(Edit4.Text);
delta_u[1]:=StrToFloat(Edit5.Text);
delta_u[2]:=StrToFloat(Edit6.Text);
matrix_plan[1,1]:=1; matrix_plan[1,2]:=1; matrix_plan[1,3]:=1; matrix_plan[1,4]:=1; matrix_plan[1,5]:=1; matrix_plan[1,6]:=1; matrix_plan[1,7]:=0.333; matrix_plan[1,8]:=0.333;
matrix_plan[2,1]:=1; matrix_plan[2,2]:=-1; matrix_plan[2,3]:=1; matrix_plan[2,4]:=-1; matrix_plan[2,5]:=1; matrix_plan[2,6]:=1; matrix_plan[2,7]:=0.333; matrix_plan[2,8]:=0.333;
matrix_plan[3,1]:=1; matrix_plan[3,2]:=1; matrix_plan[3,3]:=-1; matrix_plan[3,4]:=-1; matrix_plan[3,5]:=1; matrix_plan[3,6]:=1; matrix_plan[3,7]:=0.333; matrix_plan[3,8]:=0.333;
matrix_plan[4,1]:=1; matrix_plan[4,2]:=-1; matrix_plan[4,3]:=-1; matrix_plan[4,4]:=1; matrix_plan[4,5]:=1; matrix_plan[4,6]:=1; matrix_plan[4,7]:=0.333; matrix_plan[4,8]:=0.333;
matrix_plan[5,1]:=1; matrix_plan[5,2]:=1; matrix_plan[5,3]:=0; matrix_plan[5,4]:=0; matrix_plan[5,5]:=1; matrix_plan[5,6]:=0; matrix_plan[5,7]:=0.333; matrix_plan[5,8]:=-0.666;
matrix_plan[6,1]:=1; matrix_plan[6,2]:=-1; matrix_plan[6,3]:=0; matrix_plan[6,4]:=0; matrix_plan[6,5]:=1; matrix_plan[6,6]:=0; matrix_plan[6,7]:=0.333; matrix_plan[6,8]:=-0.666;
matrix_plan[7,1]:=1; matrix_plan[7,2]:=0; matrix_plan[7,3]:=1; matrix_plan[7,4]:=0; matrix_plan[7,5]:=0; matrix_plan[7,6]:=1; matrix_plan[7,7]:=-0.666; matrix_plan[7,8]:=0.333;
matrix_plan[8,1]:=1; matrix_plan[8,2]:=0; matrix_plan[8,3]:=-1; matrix_plan[8,4]:=0; matrix_plan[8,5]:=0; matrix_plan[8,6]:=1; matrix_plan[8,7]:=-0.666; matrix_plan[8,8]:=0.333;
matrix_plan[9,1]:=1; matrix_plan[9,2]:=0; matrix_plan[9,3]:=0; matrix_plan[9,4]:=0; matrix_plan[9,5]:=0; matrix_plan[9,6]:=0; matrix_plan[9,7]:=-0.666; matrix_plan[9,8]:=-0.666;
// Расчеты выхода модели
for i:=1 to 4 do begin
for j:=1 to 2 do begin
experim_u[i,j]:=(matrix_plan[i,j+1]*delta_u[j]+u[j]-u[j])/delta_u[j];
end;
y[i]:=Exit_obj(experim_u[i,1],experim_u[i,2])+Pomeha(Dh);
end;
// Расчеты параметров модели
sum:=0;
for j:=1 to 4 do begin
for i:=1 to 4 do begin
sum:=sum+matrix_plan[i,j]*y[i]
end;
b[j]:=sum/4;
sum:=0;
end;
a_ots[1]:=b[1];
a_ots[2]:=b[2]/delta_u[1];
a_ots[3]:=b[3]/delta_u[2];
a_ots[4]:=b[4]/(delta_u[1]*delta_u[2]);
// Оценка линейной модели
Label26.Caption:=FloatToStr(a_ots[1]);
Label27.Caption:=FloatToStr(a_ots[2]);
Label28.Caption:=FloatToStr(a_ots[3]);
Label29.Caption:=FloatToStr(a_ots[4]);
sig1:=0;
for i:=1 to 4 do begin
h:=y[i]-(a_ots[2]*experim_u[i,1]+a_ots[3]*experim_u[i,2]+a_ots[4]*experim_u[i,1]*experim_u[i,2]+a_ots[1]);
sig1:=sig1+sqr(h);
end;
//Находим мат.ожидание выхода модели
m_oz:=0;
for i:=1 to 4 do begin
y_dop[i]:=Exit_obj(u[1],u[2])+Pomeha(Dh);
m_oz:=m_oz+y_dop[i];
end;
m_oz:=m_oz/4;
// Находим дисперсию выхода модели
sig2:=0;
for i:=1 to 4 do begin
sig2:=sig2+sqr(y_dop[i]-m_oz);
end;
sig2:=sig2/3;
f:=sig1/sig2;
fisher:=216;
if (f<=fisher) then begin
Label19.Caption:='Линейная модель адекватна';
end
else begin
Label19.Caption:='Линейная модель неадекватна';
end;
// 2.Расчеты для неполной квадратичной модели
// Расчеты выхода модели
m_oz:=0;
for i:=1 to 9 do begin
for j:=1 to 2 do begin
experim_u[i,j]:=(matrix_plan[i,j+1]*delta_u[j]+u[j]-u[j])/delta_u[j];
end;
y[i]:=Exit_obj(experim_u[i,1],experim_u[i,2])+Pomeha(Dh);
y_dop[i]:=Exit_obj(u[1],u[2])+Pomeha(Dh);
m_oz:=m_oz+y_dop[i];
end;
m_oz:=m_oz/9;
// Расчеты параметров модели
sum:=0;
for j:=1 to 6 do begin
for i:=1 to 9 do begin
sum:=sum+matrix_plan[i,j]*y[i]
end;
b[j]:=sum/9;
sum:=0;
end;
a_ots[1]:=b[1];a_ots[2]:=b[2]/delta_u[1];a_ots[3]:=b[3]/delta_u[2];a_ots[4]:=b[4]/(delta_u[1]*delta_u[2]);a_ots[5]:=b[5]/(delta_u[1]*delta_u[1]);
a_ots[6]:=b[6]/(delta_u[2]*delta_u[2]);
// Оценка линейной модели
//Квадратичная
Label34.Caption:=FloatToStr(a_ots[1]);
Label35.Caption:=FloatToStr(a_ots[2]);
Label36.Caption:=FloatToStr(a_ots[3]);
Label37.Caption:=FloatToStr(a_ots[4]);
Label38.Caption:=FloatToStr(a_ots[5]);
Label39.Caption:=FloatToStr(a_ots[6]);
sig1:=0;
for i:=1 to 9 do begin
h:=y[i]-(a_ots[2]*experim_u[i,1]+a_ots[3]*experim_u[i,2]+a_ots[4]*experim_u[i,1]*experim_u[i,2]+a_ots[5]*sqr(experim_u[i,1])+a_ots[6]*sqr(experim_u[i,2])+a_ots[1]);
sig1:=sig1+sqr(h);
end;
sig1:=sig1/6;
// Находим дисперсию выхода модели
sig2:=0;
for i:=1 to 9 do begin
sig2:=sig2+sqr(y_dop[i]-m_oz);
end;
sig2:=sig2/8;
f:=sig1/sig2;
fisher:=19.4;
if (f<=fisher) then begin
Label20.Caption:='Квадратичная модель адекватна';
end
else begin
Label20.Caption:='Квадратичная модель неадекватна';
end;
i_:=i_+1;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
close();
end;
end. |