50151

Нечеткая логика

Лабораторная работа

Информатика, кибернетика и программирование

Согласно заданным вариантам разработать программу на любом алгоритмическом языке, способную: А. Различать степени изменения лингвистической переменной в трех степенях – «Очень – Нормально – Слабо» Б. Изменять порог чувствительности. Улитка без ноги – медленно – быстро (о скорости)

Русский

2014-01-16

67.5 KB

2 чел.

Системы искусственного интеллекта

Лабораторная работа №1

Нечеткая логика

Цель работы: создание простейшей системы нечеткой логики, реализованной на языке высокого уровня.

Задание

Согласно заданным вариантам разработать программу на любом алгоритмическом языке, способную:

А. Различать степени изменения лингвистической переменной в трех степенях – «Очень – Нормально – Слабо»

Б. Изменять порог чувствительности.

  1.  Улитка без ноги – медленно – быстро (о скорости)

unit Unit1;

interface

uses

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

 Dialogs, ComCtrls, StdCtrls,math, TeEngine, Series, ExtCtrls, TeeProcs,

 Chart;

type

 TForm1 = class(TForm)

   Chart1: TChart;

   Series1: TLineSeries;

   Series2: TLineSeries;

   Series3: TLineSeries;

   Series4: TBarSeries;

   TrackBar1: TTrackBar;

   Label1: TLabel;

   Label5: TLabel;

   Edit1: TEdit;

   Edit2: TEdit;

   Edit3: TEdit;

   Label6: TLabel;

   Label2: TLabel;

   Label3: TLabel;

   Label4: TLabel;

   Label7: TLabel;

   TrackBar2: TTrackBar;

   procedure TrackBar1Change(Sender: TObject);

   procedure TrackBar2Change(Sender: TObject);

   procedure FormCreate(Sender: TObject);

 private

   { Private declarations }

 public

   { Public declarations }

 end;

var

 Form1: TForm1;

 acc:integer;

implementation

{$R *.dfm}

procedure TForm1.TrackBar1Change(Sender: TObject);

var a,b,c,aq:double;

   i:integer;

begin

 label2.Caption:='';

 label3.Caption:='';

 label4.Caption:='';

 label1.Caption:=inttostr(trackbar1.position);

 a:=(1/(1+power(((trackbar1.Position-10+acc)/12),22)));

 b:=(1/(1+power(((trackbar1.Position-35+acc)/12),8)));

 c:=(1/(1+power(((trackbar1.Position-60+acc)/12),12)));

 if a<0.2 then label2.Caption:='Совсем не '+edit1.Text;

 if (a<0.4) and (a>0.2) then label2.Caption:='Чуть-чуть не '+edit1.Text;

 if (a<0.6) and (a>0.4) then label2.Caption:='Немного '+edit1.Text;

 if (a<0.8) and (a>0.6) then label2.Caption:='Весьма '+edit1.Text;

 if (a<1) and (a>0.8) then label2.Caption:='Абсолютно '+edit1.Text;

 if b<0.2 then label3.Caption:='Совсем не '+edit2.Text;

 if (b<0.4) and (b>0.2) then label3.Caption:='Чуть-чуть не '+edit2.Text;

 if (b<0.6) and (b>0.4) then label3.Caption:='Немного '+edit2.Text;

 if (b<0.8) and (b>0.6) then label3.Caption:='Весьма '+edit2.Text;

 if (b<1) and (b>0.8) then label3.Caption:='Абсолютно '+edit2.Text;

 if c<0.2 then label4.Caption:='Совсем не '+edit3.Text;

 if (c<0.4) and (c>0.2) then label4.Caption:='Чуть-чуть не '+edit3.Text;

 if (c<0.6) and (c>0.4) then label4.Caption:='Немного '+edit3.Text;

 if (c<0.8) and (c>0.6) then label4.Caption:='Весьма '+edit3.Text;

 if (c<1) and (c>0.8) then label4.Caption:='Абсолютно '+edit3.Text;

 aq:=a+b+c;

 label2.Caption:=label2.Caption+' '+inttostr(round(a/aq*100))+'%'+edit1.Text;

 label3.Caption:=label3.Caption+' '+inttostr(round(b/aq*100))+'%'+edit2.Text;

 label4.Caption:=label4.Caption+' '+inttostr(round(c/aq*100))+'%'+edit3.Text;

 series4.Clear;

 for i:=1 to 100 do if i<>trackbar1.Position then

   series4.Add(0) else series4.Add(1);

end;

procedure TForm1.TrackBar2Change(Sender: TObject);

var a,b,c:double;

   i:integer;

begin

 acc:=trackbar2.Position;

 series1.Clear;

 series2.Clear;

 series3.Clear;

 series4.Clear;

 for i:=1 to 100 do begin

   a:=(1/(1+power(((i-10+acc)/12),22)));

   series1.Add(a);

   b:=(1/(1+power(((i-35+acc)/12),8)));

   series2.Add(b);

   c:=(1/(1+power(((i-60+acc)/12),12)));

   series3.Add(c);

 end;

end;

procedure TForm1.FormCreate(Sender: TObject);

var a,b,c:double;

   i:integer;

begin

 acc:=0;

 series1.Clear;

 series2.Clear;

 series3.Clear;

 series4.Clear;

 for i:=1 to 100 do begin

   a:=(1/(1+power(((i-10+acc)/12),22)));

   series1.Add(a);

   b:=(1/(1+power(((i-35+acc)/12),8)));

   series2.Add(b);

   c:=(1/(1+power(((i-60+acc)/12),12)));

   series3.Add(c);

 end;

end;

end.

Вывод: научились создавать простейшую системы нечеткой логики, реализованной на языке высокого уровня.


 

А также другие работы, которые могут Вас заинтересовать

11231. THE ETHICAL AND CULTURAL HERITAGE OF THE BIBLE: CHRISTIAN VIRTUES SA DESCRIBED IN THE BIBLE AND THEIR ETERNAL VALUE 24 KB
  THE ETHICAL AND CULTURAL HERITAGE OF THE BIBLE: CHRISTIAN VIRTUES SA DESCRIBED IN THE BIBLE AND THEIR ETERNAL VALUE. To become a real Christian you must obtain certain qualities of mind and heart which are called Christian virtues. The main virtues are: love hope faith humility patience meekness selfcontrol. Love is surely the most important of all Christian qualities. Firstly a man must love God with all his heart soul mind and strength. Secondly a man should love his neig...
11232. THE ETHICAL AND CULTURAL HERITAGE OF THE BIBLE: SINS AND STRUGGLE WITH THEM AS DESCRIBED IN THE BIBLE 24 KB
  THE ETHICAL AND CULTURAL HERITAGE OF THE BIBLE: SINS AND STRUGGLE WITH THEM AS DESCRIBED IN THE BIBLE. To start with I should say that there are some sins called deadly sins because they are especially ruinous for one’s soul. They are pride covetousness lust envy gluttony anger sloth other sins are idle talk filthy language slander bribery sponging murder magic and witchcraft adultery fornication violation incest and cruelty. All of them are originated from the 7 ...
11233. TALK ABOUT THE MAIN IDEAS AND CHARACTERS OF THE BOOK YOU’VE READ AND DISCUSSED IN CLASS 24.5 KB
  TALK ABOUT THE MAIN IDEAS AND CHARACTERS OF THE BOOK YOU’VE READ AND DISCUSSED IN CLASS. Oscar Wilde was an Irish playwright poet and author of numerous stories and one novel. Known for his biting wit he became one of the most successful playwrights of the late Victorian era in London and one of the greatest celebrities of his day. Wilde suffered a dramatic downfall and was imprisoned for two years; after Wilde was released from prison he set sail for Dieppe by the night ferry. He nev...
11234. TALK ABOUT UNFORTUNATE EXPERIENCEOF A HOLIDAY ARRANGED THOUGH A TRAVEL AGENCY 24.5 KB
  TALK ABOUT UNFORTUNATE EXPERIENCEOF A HOLIDAY ARRANGED THOUGH A TRAVEL AGENCY. First of all I’d like to say that traveling is necessary for all of us as it’s a kind of relaxation and a good opportunity to relax your body renew your energy and refresh your spirits. Many people adore visiting beautiful places and look forward to going on holiday just to escape daily grind of work and daytoday pressures and get away from their usual sources of stress. Sometimes you need a change and...
11235. GIVE A COMPARATIVE DESCRIPTION OF SOME ANCIENT ENGLISH TOWNS 26 KB
  GIVE A COMPARATIVE DESCRIPTION OF SOME ANCIENT ENGLISH TOWNS. To start with I should say that Britain is a fabulous country a country of startling beauty and diversity it’s really worth exploring visiting and living in. It’s packed with exiting places to go and interesting place to discover. Everyone who comes to England is fascinated by its magnificent picturesque breathtaking and inviting towns where past and present exist side by side. Some of the ancient towns in England are Sa...
11236. Describe a journey that went wrong for some reason 24 KB
  Describe a journey that went wrong for some reason First of all I’d like to say that travelling is necessary for all of us as it’s a kind of relaxation and a good opportunity to relax your body renew your mind and refresh the spirit. Many people are keen on travelling and they look forward to going on a holiday just to escape a daily grind of work daytoday pressures and get away from usual sources of stress. But journey is not always a fun. Sometimes it can even t...
11237. Talk about a short trip to Edinburgh and what you can see there 24 KB
  Talk about a short trip to Edinburgh and what you can see there. Traveling is necessary for all of us as it is a kind of relaxation and a good opportunity to relax your body broadens our mind as well. Many people like visiting beautiful places and look forward to going on a holiday just to escape from their daily routine even if their trip will be very short. There are many fascinating cities all over the world. And Edinburgh is one of them. A coach tour of this city will ta...
11238. Предприятие - основное звено экономики 77 KB
  1 Предприятие – основное звено экономики 1.1 Предприятие – основное звено экономики. Предприятие в рыночной среде. 1.2 Классификация предприятий. 1.3 Организационноправовые формы предприятий. 1.4 Производственная структура. 1.1 Предприятие – основное звено экономи...