实验报告之产生式系统_第1页
实验报告之产生式系统_第2页
实验报告之产生式系统_第3页
实验报告之产生式系统_第4页
实验报告之产生式系统_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实 验 报 告一、实验目的及要求1. 理解产生式系统的结构原理与实际应用。2. 掌握产生式规则表示及规则库组建的实现方法。3. 理解推理机的算法原理并掌握其编程实现方法。二、实验设备(环境)及方式1. 实验环境:PC机,Windows XP,VC(可自选);2. 实验方式:两人一组,开发某个产生式系统分别实现正向推理和反向推理,系统主题可自选。三、实验内容与要求运用所学知识,设计并编程实现一个简单的产生式系统(如三角形判定系统、动物识别系统、感冒诊断系统等)。1. 简单产生式系统的名称与推理方式名称:动物识别系统(正向)推理方式:正向使用规则,即问题的初始状态作为初始数据库,仅当数据库中的事实

2、满足某条规则的前提时,该规则才能被使用。2. 简单产生式系统的总体设计(系统组成模块及功能说明,包括人机交互模块、规则库存储及管理模块、综合数据库管理模块以及推理机制模块等)。人机交互模块:通过勾选系统给出的判别条件来输入判别信息。如图1,2所示:3. 简单产生式系统的详细设计(包括数据结构设计、参数设计、函数说明以及产生式规则集)数据结构设计: class Animal /定义实体存放规则 int a_id; public int A_id get return a_id; set a_id = value; private String a_condition; public String

3、 A_condition get return a_condition; set a_condition = value; private String a_result; public String A_result get return a_result; set a_result = value; 参数设计: int temp = new int50; / 存储当前所选择的的事实及推导出来的事实编号 string factInput = new string30; / 存储当前所选择的的事实及推导出来的事实内容 public static string factSelected = ne

4、w string 20; / 存储用户选择的事实,方便两个界面传递数据 public static int factLength; / 存储事实库中的实际数据个数 string resultList = new stringlength; / 存储规则库中所有后件 string conditionList = new stringlength; / 存储规则库中所有前件函数说明: public List<Animal> getAll(); / 取出规则库中的所有规则 public Animal getResultByID(int a_id); / 根据ID取出规则的后件 priva

5、te void Compare(string factInput,string conditionList,int j); / 匹配规则和已知事实库 private void InsertRules(Animal a); / 将匹配成功的规则显示在界面上4. 系统流程5. 源程序清单用户选择界面:Form1using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Te

6、xt;using System.Windows.Forms;using animal_IS.data;namespace animal_IS public partial class Form1 : Form int temp = new int50;/存?储洹?当獭?前°所ù选?择?的?实害?事?以?及°推?导?出?来?的?事?实害? public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) this.checkBox1.Checked

7、 = false; this.checkBox2.Checked = false; this.checkBox3.Checked = false; this.checkBox4.Checked = false; this.checkBox5.Checked = false; this.checkBox6.Checked = false; this.checkBox7.Checked = false; this.checkBox8.Checked = false; this.checkBox9.Checked = false; this.checkBox10.Checked = false; t

8、his.checkBox11.Checked = false; this.checkBox12.Checked = false; this.checkBox13.Checked = false; this.checkBox14.Checked = false; this.checkBox15.Checked = false; this.checkBox16.Checked = false; this.checkBox17.Checked = false; this.checkBox18.Checked = false; this.checkBox19.Checked = false; this

9、.checkBox20.Checked = false; this.checkBox21.Checked = false; this.checkBox22.Checked = false; for (int i = 0; i <Program.factSelected.Length; i+) Program.factSelectedi = null; /重?置?所ù有瓺选?项? private void button2_Click(object sender, EventArgs e) int factNum = new int 20; int k = 0; for (int

10、i = 1; i <= 22; i+) CheckBox che = (CheckBox)this.groupBox1.Controls.Find("checkBox"+i, true)0; if (che.Checked) factNumk = i; k+;/记?录?用?户§输?入?事?实害?的?编括?号? Program.factLength = k; for (int j = 0; j < factNum.Length; j+) DB data = new DB(); string sql = "select factContent f

11、rom fact where factID=" + factNumj; /根ù据Y编括?号?查é找ò出?规?则ò的?前°键ü的?内ú容,?显?示?在útextbox中D DataTable dt = data.query(sql); if (dt.Rows.Count > 0) Program.factSelectedj = dt.Rows00.ToString(); Form2 fr = new Form2(); fr.ShowDialog(); 结果显示界面:Form2using System;

12、using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using animal_IS.data;using animal_IS.business;using animal_IS.entity;namespace animal_IS public partial class Form2 : Form public Form2()

13、 InitializeComponent(); private void Form2_Load(object sender, EventArgs e) /*将?数簓据Y库a中D的?数簓据Y取?出?放?在ú二t维?数簓组哩?里?*/ List<Animal> ls = new List<Animal>(); AnimalOption aop = new AnimalOption(); ls = aop.getAll(); int length = ls.Count; string resultList = new stringlength; string con

14、ditionList = new stringlength; for (int i = 0; i < length; i+) resultListi = lsi.A_result; conditionListi = lsi.A_condition.Split(',?'); /*/ /*读á取?出?用?户§选?择?的?内ú容,?显?示?出?来?,?并放?入?数簓组哩actInput*/ string fact = null; string factInput = new string30; /定¨义?数簓组哩?,?用?来?存?储洹?用

15、?户§输?入?的?已?知a事?实害?库a for (int i = 0; i < Program.factSelected.Length; i+) fact += " " + Program.factSelectedi; factInputi = Program.factSelectedi; this.textBox3.Text = fact; /*/ string start = "/*推?理?开a始?*/rnrn" textBox1.Text = start; for (int j = 0; j < conditionList.

16、Length; j+) if (conditionListj != null) Compare(factInput, conditionList, j); if (this.textBox1.Text.Equals(start) this.textBox1.Text += "糟?糕a了?,?啥?也?没?推?出?。o(?)oTry Again?" if (factInputProgram.factLength-1.Equals("老?虎") this.textBox2.Text = "O(é_é)O老?虎" retu

17、rn; if (factInputProgram.factLength-1.Equals("豹繿子哩?) this.textBox2.Text = "O(é_é)O豹繿子哩?; return; if (factInputProgram.factLength-1.Equals("斑?马í") this.textBox2.Text = "O(é_é)O斑?马í" return; if (factInputProgram.factLength-1.Equals("长

18、64;颈±鹿1") this.textBox2.Text = "O(é_é)O长¤颈±鹿1" return; if (factInputProgram.factLength-1.Equals("海鸟?") this.textBox2.Text = "O(é_é)O海鸟?" return; if (factInputProgram.factLength-1.Equals("企ó鹅ì") this.textBox2.Te

19、xt = "O(é_é)O企ó鹅ì" return; if (factInputProgram.factLength-1.Equals("鸵?鸟?") this.textBox2.Text = "O(é_é)O鸵?鸟?" return; else this.textBox2.Text = "o_O? 小?的?才?疏酣?学§浅3没?见?过y这a动物?,?你?丫?上?火e星?找ò去?吧悒?!?" private void Compare(s

20、tring factInput,string conditionList,int j) int flag = 0; /将?匹¥配?标括?志?个?数簓 int width = conditionListj.Length; for(int k = 0; k<width; k+) for(int m=0; m<Program.factLength;m+) if(conditionListjk.Equals(factInputm) flag +; /一?旦?有瓺规?则ò前°键ü不?与?已?知a事?实害?库a匹¥配?的?,?匹¥配?标括?志?个?数簓加ó

21、;1 if(flag=width) /当獭?一?条?规?则ò中D的?所ù有瓺前°键ü都?匹¥配?时骸? Animal a = new Animal(); AnimalOption aop = new AnimalOption(); a = aop.getResultByID(j + 1); /获?取?该?条?规?则ò string result = a.A_result; /获?得?完?全?匹¥配?的?后ó键ü Program.factLength+; /已?知a事?实害?库afactInput的?非?空?位?数簓加ó1 factInputProgram.factLength

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论