Perl: the Markov chain saw PerlMonks

### RFC: A Beginners Guide to Fuzzy Rules-Based Systems

by lin0 (Curate)
 on Oct 12, 2006 at 05:51 UTC Need Help??

```IF “quality” IS bad AND “speed” IS slow THEN “award” IS minimum
IF “quality” IS good AND “speed” IS slow THEN “award” IS small
IF “quality” IS ok AND “speed” IS fast THEN  “award” IS good
IF “quality” IS excellent AND “speed” IS fast THEN “award” IS excellen
+t
```
```use AI::FuzzyInference;
```
```my \$fis = AI::FuzzyInference->new;
```
```\$fis->inVar('quality',      0, 10,
bad      =>  [ 0, 1, 2, 1, 4, 0 ],
...
good     =>  [ 4, 0, 6, 1, 8, 0 ],
excelent =>  [ 6, 0, 8, 1, 10, 1 ],
);
```
```    |
1.00|BBBB
...
|      B
|________B________________
0   2    4    6    8    10
```
```\$fis->outVar('award',         0, 100,
minimum   => [  0,1, 20,1,   40,0 ],
...
good      => [ 40,0, 60,1,   80,0 ],
excellent => [ 60,0, 80,1, 100,1 ],
);
```
```    |
1.00|MMMM
...
|      M
|_______M_____________________
0  20  40  60  80 100
```
```\$fis->addRule(
'quality=ok        & speed=slow' => 'award=minimum',
'quality=good      & speed=slow' => 'award=small',
'quality=excellent & speed=slow' => 'award=small',
```
```\$fis->compute( quality => \$quality_of_service,
speed   => \$speed_of_service);
```
```my \$award = \$fis->value('award');
```
```\$fis->operation( '&' );  #for the AND operation
\$fis->operation( '|' );  #for the OR operation
\$fis->implication();     #for the implication function
\$fis->aggregation();     #for the aggregation function
\$fis->defuzzification(); #for the defuzzification
```
```\$fis->operation( '&', 'difference');
\$fis->operation( '|', 'sum');
\$fis->implication( 'scale' );
```
```#!/usr/bin/perl
use warnings;
...
print "new values of | and implication\n";
print "| = ", \$fis->operation( '|' ),"\n";
print "implication = ", \$fis->implication(), "\n";
```

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://577755]
Approved by GrandFather
Front-paged by wfsp
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2018-03-20 11:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I think of a mole I think of:

Results (250 votes). Check out past polls.

Notices?