Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by talexb (Canon)
on Oct 12, 2006 at 12:23 UTC ( #577820=note: print w/ replies, xml ) Need Help??


in reply to RFC: A Beginners Guide to Fuzzy Rules-Based Systems

Very interesting. A few comments: The $fis->addRule call in your code block above makes sense, but seems to be a huge blob of code that will just have to be parsed back to a (quality, speed) array of

[ [ qw/min min small small/ ], [ qw/min small small excellent/ ], [ qw/small good good excellent/ ], [ qw/small good good excellent/ ] ]
For clarity and teaching purposes, great. For maintainability and error prevention, not so good.

Also, what does this produce when you run it?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


Comment on Re: RFC: A Beginners Guide to Fuzzy Rules-Based Systems
Select or Download Code
Replies are listed 'Best First'.
Re^2: RFC: A Beginners Guide to Fuzzy Rules-Based Systems
by lin0 (Curate) on Oct 12, 2006 at 14:06 UTC

    Hi Alex

    Thank you for your comments.

    About your comment on the $fis->addRule, I am not sure if I understood it. Could you, please, rephrase it? Anyway, to give you a better description of the $fis->addRule: each line in the addRule represents a hash's element with the 'quality=bad & speed=slow' being a “key” of the hash (guaranteeing uniqueness of the antecedents) and the 'award=minimum' being the “value” for the key.

    About your comment on the output of the script, I just added a description just before the code.

    Cheers!

    lin0

        About your comment on the $fis->addRule, I am not sure if I understood it. Could you, please, rephrase it?

      Your OP contained the following chunk of code:

      $fis->addRule( 'quality=bad & speed=slow' => 'award=minimum', 'quality=ok & speed=slow' => 'award=minimum', 'quality=good & speed=slow' => 'award=small', 'quality=excellent & speed=slow' => 'award=small', 'quality=bad & speed=regular' => 'award=minimum', 'quality=ok & speed=regular' => 'award=small', 'quality=good & speed=regular' => 'award=small', 'quality=excellent & speed=regular' => 'award=excellent', 'quality=bad & speed=fast' => 'award=small', 'quality=ok & speed=fast' => 'award=good', 'quality=good & speed=fast' => 'award=good', 'quality=excellent & speed=fast' => 'award=excellent', 'quality=bad & speed=fastest' => 'award=small', 'quality=ok & speed=fastest' => 'award=good', 'quality=good & speed=fastest' => 'award=excellent', 'quality=excellent & speed=fastest' => 'award=excellent', );
      and I was wondering if that could be replaced with just an array (in my original post), for prevention of errors and maintainability.

      Just a thought.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        Hi talexb,

        Now, I got it!

        It will be hard to change that particular chunk of code for an array because of the way those statements are treated in the AI::FuzzyInference module (please, see the code below). However, I will think about your idea and see if I can suggest some improvements to the module

        thank you

        lin0


        # sub addRule() - public method. # # Adds fuzzy if-then inference rules. # # $obj->addRule('x=medium' => 'z = slow', # 'x=low & y=small' => 'z = fast', # 'x=high & y=tiny' => 'z=veryfast'); # spaces are optional. The characters [&=|] are special. sub addRule { my ($self, %rules) = @_; for my $k (keys %rules) { my $v = $rules{$k}; s/\s+//g for $v, $k; push @{$self->{RULES}} => [$k, $v]; } return 1; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://577820]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2015-07-08 06:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls