basic fuzzy rules
Download
Skip this Video
Download Presentation
Basic Fuzzy Rules

Loading in 2 Seconds...

play fullscreen
1 / 21

Basic Fuzzy Rules - PowerPoint PPT Presentation


  • 54 Views
  • Uploaded on

Basic Fuzzy Rules. (Quick and Dirty?). Basic Functions. Define the four basic set functions. ( Code is on p. 198-199 of text.) Define the three logical operators. (Code is on p. 201 of text.)

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Basic Fuzzy Rules' - bruce-olson


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
basic fuzzy rules

Basic Fuzzy Rules

(Quick and Dirty?)

basic functions
Basic Functions
  • Define the four basic set functions. ( Code is on p. 198-199 of text.)
  • Define the three logical operators. (Code is on p. 201 of text.)
  • For hedges you can just use additional sets instead of modifiers. (You don’t have to do this. You can square etc. for hedges. If so, document your hedges.)
make sections for rules
Make Sections for Rules
  • Comment these sections clearly.
  • Values Section
    • This calculates fuzzy values for rules.
    • Has input and output values.
  • Rules Section
    • List rules in 2 parts.
  • Result Section
    • One line (weighted average).
procedure
Procedure
  • Decide on base variables.
    • (You will define fuzzy linguistic variables.)
  • Write the rules as comments using fuzzy values.
  • Define required fuzzy sets.
  • Write comments for the other sections.
  • Fill in rules then go back and fill in the other sections.
example deciding on a tip
Example: Deciding on a Tip
  • What are input variables?
  • Can we define base value for each variable we choose?
    • Taste of food?
    • Speed of service?
    • Price?
  • What is output?
    • Tip as percent of bill.
define rules as comments
Define rules as comments
  • If price is high and speed is slow then tip is lousy.
  • If taste is poor and speed is medium then tip is okay.
  • If price is very low or speed is high then tip is very good.
comments
Comments

// #1 If price is high and speed is slow

// then tip is lousy

  • Number rules and leave room for code.
  • Note this rule means we must define high price, slow speed, and lousy tip.
rules
// Rules

// #1 If price is high and speed is slow // then tip is lousy

// #2 if taste is poor and speed is not slow // then tip is okay

// #3 if price is low or speed is high // then tip is very good.

define fuzzy sets
Define Fuzzy Sets

double highPrice =

Fuz.grade( price, 8.5,10.0 );

  • highPrice will replace “price is high” in the rule. This is degree “price is high” is true.
  • price is base variable – value passed in.
  • Membership is 0 at 8.5 and rises to 1 at 10.0.
  • You may need to graph by hand to see if set is okay.
inputs
//Inputs

double highPrice =

Fuz.grade(price, 8.5, 10.0);

double lowPrice =

Fuz.reverseGrade(price, 2.0,2.5);

double slowSpeed =

Fuz.reverseGrade(speed,3.0, 5.0);

double mediumSpeed =

Fuz.Trapezoid(speed, 2.0, 4.0, 6.0, 8.0);

double highSpeed =

Fuz.grade(speed, 6.0, 8.0);

double poorTaste =

Fuz.reverseGrade(taste, 2.0, 3.0);

outputs
// Outputs

final double TIP_LOUSY = 5.0;

final double TIP_OKAY = 15.0;

final double TIP_VERY_GOOD = 20.0;

  • These are singleton outputs.
  • This is called the Sugeno Method.
rule 1
Rule 1

// #1 If price is high and speed is slow

double degree1 =

Fuz.and(highPrice,slowSpeed);

// then tip is lousy

double tip1 = TIP_LOUSY;

  • Use degree1 and tip1 for rule 1.
rule 2
Rule 2

// #2 if taste is poor and speed is not slow

double degree2 =

Fuz.and( poorTaste,Fuz.not(slowSpeed) );

// then tip is okay

double tip2 = TIP_OKAY;

rule 3
Rule 3

// #3 if price is low or speed is high

double degree3 =

Fuz.or( lowPrice,highSpeed );

// then tip is very good.

double tip3 = TIP_VERY_GOOD;

result
// Result

double result = ( degree1 * tip1 +

degree2 * tip2 +

degree3 * tip3 )

/ (degree1 + degree2 + degree3);

  • Note this is just weighted average.
another output method
Another Output Method
  • More complicated than singleton
  • Approximates continuous output method.
  • Demands uniform steps.
  • Exact if all fuzzy sets have straight lines between the specified values.
  • This is a simplified Mamdani Method.
method
Method
  • Define a scale.
  • Outputs are an array of values
  • Outputs are evenly spaced
  • For example with 5% scale:
    • TIP_LOUSY[0] is degree for 0% tip
    • TIP_LOUSY[1] is degree for 5% tip
    • TIP_LOUSY[2] is degree for 10% tip
    • Etc.
outputs each step is 5
Outputs, each step is 5%

final double scale = 5.0;

final double[] TIP_LOUSY =

{1.0, 1.0, 0.3,0.0, 0.0, 0.0};

final double[] TIP_OKAY =

{0.0, 0.0, 0.2,1.0, 0.5, 0.0 };

final double[] TIP_VERY_GOOD =

{0.0, 0.0, 0.0, 0.3, 1.0, 1.0 };

clipping of rule output
Clipping of Rule Output

// then tip is lousy (result of rule #1)

double[] tip1 =

Fuz.clip(degree1,TIP_LOUSY);

  • Output is a clipped array.
  • degree1 was used for clipping.
  • Thus output is weighted by degree rule is true.
results combine outputs
Results: Combine Outputs
  • Make an array with max of outputs.

double[] maxSet = new double[6];

Fuz.max(tip1,tip2,maxSet);

Fuz.max(tip3,maxSet,maxSet);

Fuz.max is basically:

for (int i=0; i< set1.length; i++){

theMax[i] = Math.max(set1[i],set2[i]);

}

results find centroid
Results: Find Centroid

double result = Fuz.centroid(scale, maxSet);

public static double centroid(double scale, double [] set){

//assumes set is not all zeros.

double sum = 0;

double weightedSum = 0;

for(int i=0; i< set.length; i++){

sum += set[i];

weightedSum += i * set[i];

}

return scale * (weightedSum)/sum;

ad