Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Poyasnitelnaya_zapiska.docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
352.16 Кб
Скачать

Заключение

Вывод: В рамках поставленной задачи требовалось создать экспертную систему по выбору программного обеспечения для ПК пользователя. Особенностью системы является возможность её работы с нечёткими входными данными. Знания эксперта так же могут допускать элементы нечёткости и недоопределённости.

Была выполнена следующая работа:

  • Создана программа консультирующей экспертной системы;

  • Создан модуль для обработки входных данных;

  • Выполнено несколько пробных запусков программы на основе базы

знаний величиной в 5 целей (по желанию можно добавлять цели), и 18 ПО (по желанию так же можно добавлять).

Список использованных источников и литературы

  1. Гаврилова Т. А., Хорошевский В. Ф. Базы знаний интеллектуальных систем. Учебник. — СПб.: Питер, 2000.

  2. Джозеф Джарратано, Гари Райли «Экспертные системы: принципы разработки и программирование» : Пер. с англ. — М. : Издательский дом «Вильямс», 2006. — 1152 стр. с ил.

  3. Гринберг С. Я. Обзор средств построения экспертных систем // Ротапринт ВЦ СО РАН, 1993г.

  4. А. Пегат., Нечеткое моделирование и управление, 2009 г.

Электронные источники

  1. http://market.yandex.ru/

  2. http://www.rusnauka.com/16_NPRT_2009/Informatica/47500.doc.htm

  3. http://ru.wikipedia.org

  4. http://otherreferats.allbest.ru/emodel/00015476_0.html

Приложения

Приложение А - Листинг программы

unit Unit1;

interface

uses

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

Dialogs, Menus, StdCtrls, DBCtrls, ExtCtrls, xpman, DB, ADODB, ComCtrls;

type

TForm1 = class(TForm)

Panel1: TPanel;

Label10: TLabel;

Label11: TLabel;

Label12: TLabel;

ComboBox6: TComboBox;

Label13: TLabel;

ComboBox7: TComboBox;

Label14: TLabel;

ComboBox8: TComboBox;

Label15: TLabel;

ComboBox9: TComboBox;

Label16: TLabel;

Edit2: TEdit;

Edit3: TEdit;

Button2: TButton;

Button3: TButton;

Panel2: TPanel;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Bevel1: TBevel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

DBLookupListBox1: TDBLookupListBox;

DBLookupListBox2: TDBLookupListBox;

ComboBox1: TComboBox;

ComboBox2: TComboBox;

ComboBox3: TComboBox;

ComboBox4: TComboBox;

Button1: TButton;

Edit1: TEdit;

ListBox1: TListBox;

PopupMenu1: TPopupMenu;

N1: TMenuItem;

N2: TMenuItem;

PopupMenu2: TPopupMenu;

MenuItem1: TMenuItem;

MenuItem2: TMenuItem;

DataSource1: TDataSource;

ADOQuery1: TADOQuery;

ADOConnection1: TADOConnection;

DataSource2: TDataSource;

ADOQuery2: TADOQuery;

ADOQueryINS: TADOQuery;

Label17: TLabel;

ComboBox5: TComboBox;

RichEdit1: TRichEdit;

procedure N1Click(Sender: TObject);

procedure N2Click(Sender: TObject);

procedure MenuItem1Click(Sender: TObject);

procedure MenuItem2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

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

procedure DBLookupListBox1Click(Sender: TObject);

procedure DBLookupListBox2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

const

processor_count = 12;

ram_count = 8;

video_count = 8;

other_count = 4;

priority_count = 5;

var

table_processor: array[1..processor_count, 1..processor_count] of byte;

table_ram: array[1..ram_count, 1..ram_count] of byte;

table_video: array[1..video_count, 1..video_count] of byte;

table_other: array[1..other_count, 1..other_count] of byte;

function get_processor_koeff(wehave, weneed: byte): real;

begin

get_processor_koeff := 1 / (processor_count * 2 - 1) * table_processor[processor_count - wehave + 1, weneed];

end;

function get_ram_koeff(wehave, weneed: byte): real;

begin

get_ram_koeff := 1 / (ram_count * 2 - 1) * table_ram[ram_count - wehave + 1, weneed];

end;

function get_video_koeff(wehave, weneed: byte): real;

begin

get_video_koeff := 1 / (video_count * 2 - 1) * table_video[video_count - wehave + 1, weneed];

end;

function get_other_koeff(wehave, weneed: byte): real;

begin

get_other_koeff := 1 / (other_count * 2 - 1) * table_other[other_count - wehave + 1, weneed];

end;

function get_priority_koeff(priority: byte): real;

begin

get_priority_koeff := 1 - 1 / (priority_count) * (priority - 1);

end;

procedure TForm1.N1Click(Sender: TObject);

var

str: string;

begin

str := inputbox('Новая цель использования ПК', 'Введите новую цель использования ПК', str);

if trim(str) = '' then

showmessage('Название цели не может быть пустым')

else

begin

adoqueryins.SQL.Text := 'insert into purpose (id_purpose, purpose) values ("' + formatdatetime('YYYYMMDDHHNNSS', now()) + '", "' + str + '")';

adoqueryins.ExecSQL;

adoquery1.Close;

adoquery1.Open;

end;

end;

procedure TForm1.N2Click(Sender: TObject);

begin

if dblookuplistbox1.KeyValue <> null then

begin

adoqueryins.SQL.Text := 'delete * from purpose where id_purpose = "' + dblookuplistbox1.KeyValue + '"';

adoqueryins.ExecSQL;

adoquery1.Close;

adoquery1.Open;

end;

end;

procedure TForm1.MenuItem1Click(Sender: TObject);

begin

if dblookuplistbox1.KeyValue <> null then

begin

edit2.Text := '';

combobox6.Text := '';

combobox7.Text := '';

combobox8.Text := '';

combobox9.Text := '';

edit3.Text := '';

combobox5.Text := '';

dblookuplistbox1.Enabled := false;

panel1.Visible := true;

end

else

showmessage('Выберите цель использования ПК!');

end;

procedure TForm1.MenuItem2Click(Sender: TObject);

begin

if dblookuplistbox2.KeyValue <> null then

begin

adoqueryins.SQL.Text := 'delete * from soft where id_soft = "' + dblookuplistbox2.KeyValue + '"';

adoqueryins.ExecSQL;

adoquery2.Close;

adoquery2.Open;

end;

end;

function allparamschoosed(p1: boolean): boolean;

var

apc: boolean;

begin

apc := true;

if p1 then

begin

if (trim(form1.Edit2.Text) = '') or

(form1.ComboBox6.ItemIndex = -1) or

(form1.ComboBox7.ItemIndex = -1) or

(form1.ComboBox8.ItemIndex = -1) or

(form1.ComboBox9.ItemIndex = -1) or

(form1.ComboBox5.ItemIndex = -1) or

(trim(form1.Edit2.Text) = '') then

apc := false;

end

else

begin

if (form1.ComboBox1.ItemIndex = -1) or

(form1.ComboBox2.ItemIndex = -1) or

(form1.ComboBox3.ItemIndex = -1) or

(form1.ComboBox4.ItemIndex = -1) or

(trim(form1.Edit1.Text) = '') then

apc := false;

end;

allparamschoosed := apc;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

i, count: byte;

mas: array[1..255, 1..3] of string;

stop: boolean;

max_koeff: double;

max_koeff_ind: byte;

rez: double;

begin

if dblookuplistbox1.KeyValue = null then

begin

showmessage('Выберите цель использования ПК!');

exit;

end;

if not allparamschoosed(false) then

begin

showmessage('Указаны не все поля!');

exit;

end;

if not trystrtofloat(edit1.Text, rez) then

begin

showmessage('Сумма введена неправильно!');

exit;

end;

// в нечеткой логике...

// дизъюнкция: x or y = x + y - x * y

// конъюнкция: x and y = x * y

// отрицание: not x = 1 - x

listbox1.Items.Clear;

adoquery2.First;

count := 0;

for i := 1 to adoquery2.RecordCount do

begin

if (adoquery2.Fields[2].AsFloat <= strtofloat(edit1.Text)) {and (adoquery2.Fields[2].AsFloat <> 0)} then

begin

count := count + 1;

mas[count, 1] := adoquery2.Fields[1].AsString;

mas[count, 2] := adoquery2.Fields[2].AsString;

mas[count, 3] := floattostr((get_processor_koeff(combobox1.ItemIndex + 1, adoquery2.Fields[3].AsInteger) *

get_ram_koeff(combobox2.ItemIndex + 1, adoquery2.Fields[4].AsInteger) *

get_video_koeff(combobox3.ItemIndex + 1, adoquery2.Fields[5].AsInteger) *

get_other_koeff(combobox4.ItemIndex + 1, adoquery2.Fields[6].AsInteger) +

get_priority_koeff(adoquery2.Fields[7].AsInteger) / 3) / 2);

end;

adoquery2.Next;

end;

stop := false;

rez := 0;

while not stop do

begin

max_koeff := 0;

max_koeff_ind := 0;

for i := 1 to count do

if mas[i, 3] <> '0' then

begin

max_koeff := strtofloat(mas[i, 3]);

max_koeff_ind := i;

break;

end;

if max_koeff_ind = 0 then

break;

for i := 1 to count do

begin

if (strtofloat(mas[i, 3]) > strtofloat(floattostr(max_koeff))) then

begin

max_koeff := strtofloat(mas[i, 3]);

max_koeff_ind := i;

end;

end;

if (rez + strtofloat(mas[max_koeff_ind, 2])) <= strtofloat(edit1.Text) then

begin

listbox1.Items.Add(floattostrf(strtofloat(mas[max_koeff_ind, 3]), fffixed, 5, 5) + ' ' + mas[max_koeff_ind, 1]);

rez := rez + strtofloat(mas[max_koeff_ind, 2]);

end;

mas[max_koeff_ind, 3] := '0';

if (rez >= strtofloat(edit1.Text)) and (rez <> 0) then

stop := true;

end;

end;

procedure TForm1.FormCreate(Sender: TObject);

var

i, j, n: byte;

begin

adoconnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + getcurrentdir() + '\db.mdb;Persist Security Info=False';

adoconnection1.Open;

adoquery1.Open;

n := (processor_count * 2) - 1;

for i := 1 to processor_count do

begin

for j := 1 to processor_count do

table_processor[i, j] := n - j + 1;

n := n - 1;

end;

n := (ram_count * 2) - 1;

for i := 1 to ram_count do

begin

for j := 1 to ram_count do

table_ram[i, j] := n - j + 1;

n := n - 1;

end;

n := (video_count * 2) - 1;

for i := 1 to video_count do

begin

for j := 1 to video_count do

table_video[i, j] := n - j + 1;

n := n - 1;

end;

n := (other_count * 2) - 1;

for i := 1 to other_count do

begin

for j := 1 to other_count do

table_other[i, j] := n - j + 1;

n := n - 1;

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

var

newid: string[14];

rez: double;

begin

if not allparamschoosed(true) then

begin

showmessage('Указаны не все поля!');

exit;

end;

if not trystrtofloat(edit3.Text, rez) then

begin

showmessage('Сумма введена неправильно!');

exit;

end;

newid := formatdatetime('YYYYMMDDHHNNSS', now());

adoqueryins.SQL.Text := 'insert into soft (id_soft, title, price, processor, ram, video, other, priority) values ("' + newid + '", "' + edit2.Text + '", ''' + edit3.Text + ''', ''' + inttostr(combobox6.ItemIndex + 1) + ''', ''' + inttostr(combobox7.ItemIndex + 1) + ''', ''' + inttostr(combobox8.ItemIndex + 1) + ''', ''' + inttostr(combobox9.ItemIndex + 1) + ''', ''' + inttostr(combobox5.ItemIndex + 1) + ''')';

adoqueryins.ExecSQL;

adoqueryins.SQL.Text := 'insert into soft_purpose (id_soft, id_purpose) values ("' + newid + '", "' + dblookuplistbox1.KeyValue + '")';

adoqueryins.ExecSQL;

adoquery2.SQL.Text := 'select soft.* from soft inner join soft_purpose on soft.id_soft = soft_purpose.id_soft where soft_purpose.id_purpose = "' + dblookuplistbox1.KeyValue + '" order by title';

adoquery2.Open;

panel1.Visible := false;

dblookuplistbox1.Enabled := true;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

panel1.Visible := false;

dblookuplistbox1.Enabled := true;

end;

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

begin

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

key := #0;

end;

procedure TForm1.DBLookupListBox1Click(Sender: TObject);

begin

adoquery2.SQL.Text := 'select soft.* from soft inner join soft_purpose on soft.id_soft = soft_purpose.id_soft where soft_purpose.id_purpose = "' + dblookuplistbox1.KeyValue + '" order by title';

adoquery2.Open;

end;

procedure TForm1.DBLookupListBox2Click(Sender: TObject);

begin

if dblookuplistbox2.KeyValue <> null then

begin

richedit1.Text := adoquery2.Fields[1].AsString + #13#13 +

'Системные требования:' + #13 +

'Процессор: ' + combobox6.Items[adoquery2.Fields[3].AsInteger - 1] + #13 +

'ОЗУ: ' + combobox7.Items[adoquery2.Fields[4].AsInteger - 1] + #13 +

'Видеопамять: ' + combobox8.Items[adoquery2.Fields[5].AsInteger - 1] + #13 +

'Мышь/колонки: ' + combobox9.Items[adoquery2.Fields[6].AsInteger - 1] + #13#13 +

combobox5.Items[adoquery2.Fields[7].AsInteger - 1] + #13 +

'Стоимость: ' + adoquery2.Fields[2].AsString + ' руб.';

end;

end;

end.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]