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

规则在 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);

 

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

 目前只使用5层递推功能

 

 

 

posted on 2008-12-29 20:14  feathersky  阅读(2076)  评论(3编辑  收藏  举报