Chorus-Expert
view release on metacpan or search on metacpan
lib/Chorus/Sample/Cursors.pm view on Meta::CPAN
Each rule is tested with a combinaison of scope(s) of one or more parameters.
The knowledge of the system is modelized with Chorus::Frame objects. This is not necessary
since a rule can combinate any array given in its parameter _SCOPE but, the usage of the function fmatch(),
combinated with grep, can be an efficient way to reduce and optimize the scopes of rules parameters by
looking for elements of knowledge having certain properties.
In the same time, any invocation of the frame methods get() & set(), can take advantage of the presence
of the slot _NEEDED or _AFTER, to respectively try to realize conditions (backward chaining) before providing
an information on a frame or/and propagate (~ forward chaining) a modification to the system - See Chorus::Frame documentation.
In this example, the system is composed of 100 cursors (frames), each one having a slot 'level'
with a random value (from 1 to 10).
The goal is to move the system until the average distance of 'level' to the medium value 5
is lower than 0.5.
Rule 1 : display the state of the system
Rule 2 : check if the target is reached (will declare the system as solved)
Rule 3 : decrease levels if > 5
Rule 4 : increase levels if < 5
Of course, such a system doesn't need an expert system to be solved but it can illustrate how Chorus::Expert works.
( run in 0.237 second using v1.01-cache-2.11-cpan-4d50c553e7e )