Traditional Fuzzy Logic

 


Fuzzy Logic In 'C'


Below is a sample of what some typical 'C' code might look like to implement a small set of fuzzy logic rules:

if ((facing == LFT) && (position == SRP_LFT)) then

     angle = SRP_RT;

if ((facing == LFT) && (position == SLO_LFT)) then

     angle = SLO_RT;

if ((facing == LFT) && ((position == SLO_LFT) 

    || (position = STRT))) then

     angle = STRT;

if ((facing == LFT) && (position == SRP_RT)) then

     angle = SLO_LFT;

As you can see, the code can be confusing and error prone.  As a matter of fact there is one "bug" in the code above... not counting potential rule errors!

Where's the "bug"?  See the bottom of this page for the answer.

 

Fuzzy Logic With Spreadsheets


Spreadsheet style interfaces are often used to create and modify fuzzy logic rules.   These can be confusing and error prone - if you want to change all the rules involving a term in the first variable you need to jump around to change all of them.

Here's what a typical spreadsheet interface may look like:

Rule #

Position

Facing

Steering Angle

1

Right

Sharp Left

2

Right

Slow Left

3

Right

Straight

4

Right

Slow Right

5

Right

Sharp Right

6

Center

Sharp Left

7

Center

Slow Left

8

Center

Straight

9

Center

Slow Right

10

Center

Sharp Right

11

Left

Sharp Left

12

Left

Slow Left

13

Left

Straight

14

Left

Slow Right

15

Left

Sharp Right

With only 15 rules it's fairly manageable... when the number of rules increase - which they do quickly due to combinatorial explosion - creating and modifying rules can become a dreaded chore.

Where's The Bug?

The bug is in the 3rd "if-then" statement.  The rule:

if ((facing == LFT) && ((position == SLO_LFT) 

    || (position = STRT))) then

Should have a double equal sign in the last condition:

if ((facing == LFT) && ((position == SLO_LFT) 

    || (position == STRT))) then

 

 

 


Home | Mission | Spark! Fuzzy Logic Editor | Mailing List | Downloads | Around The Web | Privacy Policy


Copyright © 2005 Louder Than A Bomb! Software

Comments, Questions, or Problems?  Contact Our webmaster

Updated: September 28, 2005