Критерии принытия решений

Страница: 7/8

SpeedButton3: TSpeedButton;

Memo1: TMemo;

SpeedButton4: TSpeedButton;

SpeedButton5: TSpeedButton;

SpeedButton6: TSpeedButton;

Image1: TImage;

procedure FormCreate(Sender: TObject);

procedure SpeedButton6Click(Sender: TObject);

procedure SpeedButton5Click(Sender: TObject);

procedure SpeedButton4Click(Sender: TObject);

procedure SpeedButton1Click(Sender: TObject);

procedure SpeedButton2Click(Sender: TObject);

procedure SpeedButton3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.DFM}

const

M = 4;

rajon: array [1 5] of string = (

'Панинский',

'Петропавловский',

'Поворинский',

'Подгоренский',

'Рамонский');

data: array [1 5, 1 4] of real = (

(19.73, 7.9, 20.95, 1040.95),

(14.66, 8.08, 19.63, 644.75),

(18.89, 7.16, 18.39, 1125.9),

(18.59, 7.38, 18.12, 846.05),

(21.82, 6.44, 23.29, 1140.85));

var

E: array [1 10, 1 10] of real;

R: array [1 10] of string;

N: integer;

procedure TForm1.FormCreate(Sender: TObject);

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

var

s: string;

i: integer;

begin

StringGrid1.RowCount := 5;

n := 5;

for i := 1 to n do

begin

Str(i, s);

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

StringGrid1.Cells[1, i - 1] := rajon[i];

Str(data[i, 1]:3:1, s);

StringGrid1.Cells[2, i - 1] := s;

Str(data[i, 2]:3:1, s);

StringGrid1.Cells[3, i - 1] := s;

Str(data[i, 3]:3:1, s);

StringGrid1.Cells[4, i - 1] := s;

Str(data[i, 4]:3:1, s);

StringGrid1.Cells[5, i - 1] := s;

end;

end;

procedure TForm1.SpeedButton6Click(Sender: TObject);

//выход

begin

Close;

end;

procedure TForm1.SpeedButton5Click(Sender: TObject);

//загрузка тестового примера

var

s: string;

i: integer;

begin

StringGrid1.RowCount := 5;

n := 5;

for i := 1 to n do

begin

Str(i, s);

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

StringGrid1.Cells[1, i - 1] := rajon[i];

Str(data[i, 1]:3:1, s);

StringGrid1.Cells[2, i - 1] := s;

Str(data[i, 2]:3:1, s);

StringGrid1.Cells[3, i - 1] := s;

Str(data[i, 3]:3:1, s);

StringGrid1.Cells[4, i - 1] := s;

Str(data[i, 4]:3:1, s);

StringGrid1.Cells[5, i - 1] := s;

end;

end;

procedure TForm1.SpeedButton4Click(Sender: TObject);

//приведение матрицы

var

E1: array [1 10, 1 10] of real;

Xsr: array [1 10] of real;

k, i, j: integer;

c: real;

s1: string;

begin

N := StringGrid1.RowCount;

for i := 1 to N do

begin

R[i] := StringGrid1.Cells[1, i - 1];

Val(StringGrid1.Cells[2, i - 1], E1[i, 1], k);

Val(StringGrid1.Cells[3, i - 1], E1[i, 2], k);

Val(StringGrid1.Cells[4, i - 1], E1[i, 3], k);

Val(StringGrid1.Cells[5, i - 1], E1[i, 4], k);

end;

// формирование безразмерной матрицы

for j := 1 to M do

begin

Xsr[j] := 0;

for i := 1 to N do

Xsr[j] := Xsr[j] + E1[i, j];

Xsr[j] := Xsr[j] / N;

end;

for j := 1 to M do

begin

c := 0;

for i := 1 to N do

c := c + Sqr(E1[i, j] - Xsr[j]);

c := Sqrt(c) / 5;

for i := 1 to N do

E[i, j] := (E1[i, j] - Xsr[j]) / c;

end;

GroupBox1.Enabled := True;

// вывод безразмерной матрицы

for i := 1 to N do

for j := 1 to M do

begin

Str(E[i, j]:7:3, s1);

StringGrid1.Cells[j + 1, i - 1] := s1;

end;

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);

// критерий произведений

var

c: real;

j, imin, imax, k, i: integer;

min, max: real;

s1, s: string;

begin

for i := 1 to N do

begin

min := E[i, 1];

imin := 1;

for j := 1 to N do

if E[i, j] < min then

begin

min := E[i, j];

imin := j;

end;

E[i, imin] := E[i, imin] + Abs(min) + 1;

end;

for i := 1 to N do

begin

E[i, 5] := 1;

for j := 1 to M do

E[i, 5] := E[i, 5] * E[i, j];

end;

imax := 1;

max := E[1, 5];

imin := 1;

min := E[1, 5];

for i := 1 to N do

begin

if E[i, 5] > max then

begin

max := E[i, 5];

imax := i;

end;

if E[i, 5] < min then

begin

min := E[i, 5];

imin := i;

end;

end;

Memo1.Lines.Add('Критерий произведений');

Memo1.Lines.Add('Наилучший объект');

Memo1.Lines.Add(R[imax]);

Str(max:5:3, s);

Memo1.Lines.Add('Значение: ' + s);

Memo1.Lines.Add('Наихудший объект');

Memo1.Lines.Add(R[imin]);

Str(min:5:3, s);

Memo1.Lines.Add('Значение: ' + s);

end;

procedure TForm1.SpeedButton2Click(Sender: TObject);

Реферат опубликован: 12/02/2009