人工智能導(dǎo)論產(chǎn)生式系統(tǒng)解讀_第1頁
人工智能導(dǎo)論產(chǎn)生式系統(tǒng)解讀_第2頁
人工智能導(dǎo)論產(chǎn)生式系統(tǒng)解讀_第3頁
人工智能導(dǎo)論產(chǎn)生式系統(tǒng)解讀_第4頁
已閱讀5頁,還剩4頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、( 北京)CHINA UNIVERSITY OF PETROLEUM人工智能導(dǎo)論產(chǎn)生式系統(tǒng)院系名稱:地球物理與信息工程學(xué)院專業(yè)名稱:計(jì)算機(jī)科學(xué)與技術(shù)學(xué)號(hào):姓名:完成日期2015年6月8日實(shí)驗(yàn)內(nèi)容:規(guī)則: (rule identify1(if (animal has hair)(then (animal is mammal)(rule identify2(if (animal gives milk)(then (animal is mammal)(rule identify3(if (animal has feathers)(then (animal is bird)(rule identify

2、4(if(animal flies)(animal lays eggs)(then (animal is bird)(rule identify5(if (animal eats meat)(then (animal is carnivore)(rule identify6(if (animal has pointed teeth)(animal has claws)(animal has forward eyes)(then (animal is carnivore)(rule identify7(if (animal is mammal) (animal has hoofs)(then (

3、animal is ungulate)(rule identify8(if(animal is mammal)(animal chews cud)(then (animal is ungulate)(even toed)(rule identify9(if(animal is mammal)(animal is carnivore)(animal has tawny color) (animal has dark spots)(then (animal is cheetah)(rule identify10(if (animal is mammal)(animal is carnivore)(

4、animal has tawny color) (animal has black stripes)(then (animal is tiger)(rule identify11(if (animal is ungulate) (animal has long neck)(animal has log legs) (animal has dark spots)(then (animal is giraffe)(rule identify12(if (animal is ungulate) (animal has black stripes)(then (animal is zebra) )(r

5、ule identify13(if (animal is bird)(animal does not fly)(animal has long neck) (animal has long legs)(animal is black and white)(then (animal is ostrich)(rule identify14(if(animal is bird)(animal does not fly)(animal swims) (animal is black and white)(then (animal is penguin)(rule identify15(if(anima

6、l is bird)(animal flys well)(then (animal is albatross)實(shí)驗(yàn)工具:VC+6.0設(shè)計(jì)思路:將每條語句按順序編號(hào),然后將規(guī)則存在R156數(shù)組中,在屏幕上輸入所擁有的條件數(shù)量并輸入規(guī)則編號(hào),余下的會(huì)自動(dòng)用 0 占位,將輸入的規(guī)則序號(hào)存入數(shù)組get20 中,然后遞歸調(diào)用 Contrast()函數(shù),得出結(jié)論,在 Contrast()函數(shù)中調(diào)用Comparison() 函數(shù)來比較每一條規(guī)則在輸入條件中是否存在,若存在則把條件替換成所含有規(guī)則的結(jié)論。最后當(dāng) get 數(shù)組中只含有最后一個(gè)非零語句編號(hào)時(shí),則為最終結(jié)論。詳細(xì)代碼:/ setq_fact.cpp

7、 : Defines the entry point for the console application.#include "stdafx.h"/語句數(shù)組 ruleschar rules3330="animal has hair","animal is mammal","animal gives milk","animal has feathers","animal is bird","animal flies","animal lays e

8、ggs","animal eats meat","animal is carnivore","animal has pointed teeth","animal has claws","animal has forward eyes","animal has hoofs","animal is ungulate","animal chews cud","even toed","animal has

9、 tawny color","animal has dark spots","animal ischeetah","animal has black stripes","animal is tiger","animal is ungulate","animal has long neck","animal is giraffe","animal is zebra","animal does not fly"

10、,"animal has long legs","animal is black and white","animal is ostrich","animal swims","animal is penguin","animal flys well","animal is albatross"/規(guī)則數(shù)組 RintR156=1,0,0,0,0,2,3,0,0,0,0,2,4,0,0,0,0,5,6,7,0,0,0,5,8,0,0,0,0,9,10,11,12

11、,0,0,9,2,13,0,0,0,14,2,15,0,0,0,14,2,9,17,18,0,19,2,9,17,20,0,21,14,18,22,23,0,24,14,20,0,0,0,25,5,22,26,27,28,29,5,26,28,30,0,31,5,32,0,0,0,33;/輸入存儲(chǔ)數(shù)組 getint get20;int all;/函數(shù)定義void Sort(); /數(shù)組排序void Contrast(); /數(shù)組對比int Comparison(int i,int j);/規(guī)則比較int main(int argc, char* argv)int i,j,m=100,n;/顯示

12、所有條件for(i=0;i<30;i+)printf("%d",i+1);for(j=0;j<30;j+)printf("%c",rulesij);printf("n");printf(" 輸入所擁有的條件數(shù) :");/請輸入條件數(shù)scanf("%d",&all);all-;printf("please put in your fact(change from 133):n");/請輸入條件printf("begin: ");i=0;w

13、hile(i<=all-1)/讀取輸入的條件在get 數(shù)組中scanf("%d",&m);geti=m;printf("go on: ");i+;scanf("%d",&m);getall=m;for(i=all+1;i<=19;i+)geti=0;Sort();/排序Contrast();/算法if(get0>=1&&get0<=33&&get1=0)/如果結(jié)果存在,輸出結(jié)論printf("The conclusion is: %d ",ge

14、t0);for(j=0;j<=29;j+)printf("%c",rulesget0-1j);else printf("NO Answer!");/不存在,提示沒有結(jié)果while(1);return 0;void Sort()/對 get數(shù)組內(nèi)部從小到大排序,相同的數(shù)字只保留一個(gè)int n;for(int i=0;i<=19;i+)for(int j=i+1;j<=all;j+)if(geti>getj)/排序n=geti;geti=getj;getj=n;else if(geti=getj&&getj!=0) /

15、相同非 0 數(shù)只保留一個(gè),其余取 0 getj=0;for(i=0;i<=all;i+)/把 0 放在數(shù)組末尾if(get0=0)for(int j=0;j<=all;j+)getj=getj+1;getall=0;void Contrast()/比照 R 數(shù)組和 get 數(shù)組int i;for(i=0;i<=14;i+)for(int j=0;j<=all;j+)if(Comparison(i,j)=1) Sort();Contrast();/比較每一條規(guī)則在 get 數(shù)組中是否存在,存在則簡化 get 數(shù)組 int Comparison(int i,int j)in

16、t m,n,count=0,k5,l5,a=0;for(n=0;n<=4;n+)kn=0;ln=0;for(n=0;n<=j;n+)for(m=0;m<=all;m+)if(Rin=getm)kn=getm; /把可能存在的規(guī)則條件存在k 數(shù)組中l(wèi)a+=m+1;/把 get數(shù)組中可能存在規(guī)則的位置記錄在l 數(shù)組中break;for(m=0;m<=4;m+)if(km=Rim)count+;if(count=5) /如果規(guī)則存在for(m=0;m<=4;m+)if(lm!=0)getlm-1=Ri5;/取出規(guī)則結(jié)果放在get 中return 1;elsereturn 0;運(yùn)行過程:讀書的好處1、行萬里路,讀萬卷書。2、書山有路勤為徑,學(xué)海無涯苦作舟。3、讀書破萬卷,下筆如有神。4、我所學(xué)到的任何有價(jià)值的知識(shí)都是由自學(xué)中得來的。 達(dá)爾文5、少壯不努力,老大徒悲傷。6、黑發(fā)不知勤學(xué)早,白首方悔讀書遲。 顏真卿7、寶劍鋒從磨礪出,梅花香自苦寒來。8、讀書要三到:心到、眼到、口到

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論