Fuzzy Logic Class Prototype

I plan on supporting both the FCL file definitions and also objects that do the same thing. The FCL file reader object will use the other objects, so that each would complement each other.

// Variables
Ai_FuzzyLogic_Variable_Abstract();
Ai_FuzzyLogic_Variable_Input(); // Extends Ai_FuzzyLogic_Variable_Abstract
Ai_FuzzyLogic_Variable_Output(); // Extends Ai_FuzzyLogic_Variable_Abstract

Well, anything further will have to wait for experimentation, but I do have some plans as to how the execution will be.

// Rule 0;
$rule0 =Ai_FuzzyLogic_Rule
                   ->if($term)
                   ->and($term)
                   ->then($term);

Ai_FuzzyLogic::addRule($rule0);

// Rule 1;
$rule1 = Ai_FuzzyLogic_Rule
                   ->if($term)
                   ->and($term)
                   ->and($term)
                   ->or($term)
                   ->then($term);

Ai_FuzzyLogic::addRule($rule1);

I do know that the rule can be better served with this method since it has a limited set of methods that can be used together. The rest of the pieces will take a lot of thought and testing to finalize, but I think I can work out a good first API for which the user will use. I can then refactor the back end later when I think of a better method.

Possibly Related Posts:


2 Comments.

  1. So, does this just make using if:then statements easier to conduct, or what is the purpose? Is it just like using PEAR?

  2. No, I would rather use the core conditional statements, but it would be a bad idea to override the core to be fuzzified.

    The purpose is that the rules are set up for the eventual defuzzification of the terms. Which means you first set it up and then you use it.

    After the rules set:

    Ai_FuzzyLogic::setValue($inputTerm, $value);
    Ai_FuzzyLogic::setValue($inputTerm, $value);
    
    $output = Ai_FuzzyLogic::execute() // get defuzzification value.
    

    1. The variables are set up to define what value it can be.
    2. Next step is to define the terms of which the variables can take.
    3. Define the rules for which to calculate the output variable.

    I wish I could give an example, but I can’t. When I’m finish with the library, I’ll post a better example for how to use it.

    The purpose of Fuzzy Logic is to make better (human) decisions based on the input. So say, you have the choice of going to the movies, the mall, or to pick up your mother.

    You would have a rule saying that if your mother is in need of being picked up that there would be a great chance of you doing so. However, if you mom didn’t need to be picked up, then you would choose between the mall and the movies. You may be more inclined to go to the movies, however, if you needed something important then that might not be the case.

    Fuzzy logic tries to find the value of how much would you, instead of the straight boolean, would or wouldn’t you. In this way, given the input allowing better decisions based on the input to be taken.

    In this way, it is easy to fake Fuzzy Logic, but would take more lines to do so.