AI-ExpertSystem-Advanced
view release on metacpan or search on metacpan
Inspired in AI::ExpertSystem::Simple but with additional features:
* Uses backward, forward and mixed algorithms.
* Offers different views, so user can interact with the expert system
via a terminal or with a friendly user interface.
* The knowledge database can be stored in any format such as YAML, XML
or databases. You just need to choose what driver to use and you are
done.
* Uses certainty factors.
SYNOPSIS
An example of the mixed algorithm:
use AI::ExpertSystem::Advanced;
use AI::ExpertSystem::Advanced::KnowledgeDB::Factory;
my $yaml_kdb = AI::ExpertSystem::Advanced::KnowledgeDB::Factory->new('yaml',
{
filename => 'examples/knowledge_db_one.yaml'
});
my $ai = AI::ExpertSystem::Advanced->new(
viewer_class => 'terminal',
knowledge_db => $yaml_kdb,
initial_facts => ['I'],
verbose => 1);
$ai->mixed();
$ai->summary();
Attributes
initial_facts
A list/set of initial facts the algorithms start using.
During the forward algorithm the task is to find a list of goals
caused by these initial facts (the only data we have in that
moment).
Lets imagine your knowledge database is about symptoms and diseases.
You need to find what diseases are caused by the symptoms of a
patient, these first symptons are the initial facts.
Initial facts as also asked and inference facts can be negative or
positive. By default the initial facts are positive.
Keep in mind that the data contained in this array can be the IDs or
the name of the fact.
This array will be converted to initial_facts_dict. And all the data
(ids or or names) will be made of only IDs.
my $ai = AI::ExpertSystem::Advanced->new(
viewer_class => 'terminal',
knowledge_db => $yaml_kdb,
initial_facts => ['I', ['F', '-'], ['G', '+']);
As you can see if you want to provide the sign of a fact, just
*encapsulate* it in an array, the first item should be the fact and
the second one the sign.
initial_facts_dict
This dictionary (see AI::ExpertSystem::Advanced::Dictionary has the
sasme data of initial_facts but with the additional feature(s) of
proviing iterators and a quick way to find elements.
goals_to_check
my $ai = AI::ExpertSystem::Advanced->new(
viewer_class => 'terminal',
knowledge_db => $yaml_kdb,
goals_to_check => ['J']);
When doing the backward() algorithm it's required to have at least
one goal (aka hypothesis).
This could be pretty similar to initial_facts, with the difference
that the initial facts are used more with the causes of the rules
and this one with the goals (usually one in a well defined knowledge
database).
The same rule of initial_facts apply here, you can provide the sign
of the facts and you can provide the id or the name of them.
From our example of symptoms and diseases lets imagine we have the
hypothesis that a patient has flu, we don't know the symptoms it
has, we want the expert system to keep asking us for them to make
sure that our hypothesis is correct (or incorrect in case there's
not enough information).
goals_to_check_dict
Very similar to goals_to_check (and indeed of initial_facts_dict).
We want to make the job easier.
It will be a dictionary made of the data of goals_to_check.
inference_facts
Inference facts are basically the core of an expert system. These
are facts that are found and copied when a set of facts (initial,
inference or asked) match with the causes of a goal.
inference_facts is a AI::ExpertSystem::Advanced::Dictionary, it will
store the name of the fact, the rule that caused these facts to be
copied to this dictionary, the sign and the algorithm that triggered
it.
knowledge_db
The object reference of the knowledge database
AI::ExpertSystem::Advanced is using.
asked_facts
During the backward() algorithm there will be cases when there's no
clarity if a fact exists. In these cases the backward() will be
asking the user (via automation or real questions) if a fact exists.
Going back to the initial_facts example of symptoms and diseases.
Imagine the algorithm is checking a rule, some of the facts of the
rule make a match with the ones of initial_facts or inference_facts
but some wont, for these *unsure* facts the backward() will ask the
user if a symptom (a fact) exists. All these asked facts will be
stored here.
( run in 0.575 second using v1.01-cache-2.11-cpan-39bf76dae61 )