C# 简单专家系统中的推理机 大家可以定义自己的规则 使程序具有一定智能

 简单逻辑表达中 有 ->, ~, ^  即已完备 ,故我现在只引入了这几个

规则在 rules.txt中


目前只支持 if .... then .
then后只有一个项 不能用^

~ 表示否定

^ 表示并且

 

规则例子

if A1 then B1 ;
if ~ A1 then ~ B1 ;
if 干性皮肤 then 洗脸 ;
if 干性皮肤 then 防晒 ;
if 冬天 then ~ 防晒 ;
if 冬天 then 保湿 ;
if 冬天 ^ 干性皮肤 then 用大宝 ;

if 保湿 then 用大宝 ;

 

程序调用方法

expert.LoadRule("rules.txt");               //导入规则库 

 

           List<string> conditions = new List<string>();
            conditions.Add("冬天");
            conditions.Add("干性皮肤");         //前提

            List<int> conditionState = new List<int>();
            conditionState.Add(1);
            conditionState.Add(1);               // 1表示对应的前提确定成立 -1表示对应的前提确定不成立

            List<string> conclusions = new List<string>();   //保存结论
            List<int> conclusionState = new List<int>();     //判断结论是成立还是不成立


            expert.Deduce(conditions, conditionState, ref conclusions, ref conclusionState);

 

测试代码放在这里http://files.cnblogs.com/feathersky/ExpertSystemTest.rar,函数库可以随意使用,用于任何用途

 目前只使用5层递推功能

 

 

 

转载于:https://www.cnblogs.com/feathersky/archive/2008/12/29/1364763.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值