Fuzzy

From GNUstepWiki
Revision as of 13:24, 16 December 2014 by Bubble.rogue (talk | contribs)
Jump to navigation Jump to search

This page is for GNUstep developers. It explains the Fuzzy Logic system for e.g. updating the GNUstep System such as drawing to screen.

What is Fuzzy Logic ?

A fuzzy system is a rule-based systems with inputs and outputs. Each fuzzy rule is associated with a mathematical function. The system is a greedy decision tree algorithm. The rules of a fuzzy system are more random than a decision tree so that it is faster. A decision tree traverses at O(log(n)), the depth of the tree and O(n*log(n)) for a n-ary tree approximately.

As the name fuzzy suggests it uses more general information systems. The functions of the fuzzy logic are most important. For example "extremely" associates with the value x * x * x where x is a floating point number. "a little bit" is associated with sqrt(x) / 1.3 and so on. The fuzzy rules are parsed in succession and yield a value for each natural language word. Thus you can reason as a human what the fuzzy logic should do after a fuzzy function is successful e.g. against some threshold, if x=0 then the "extremely" function i 0 * 0 * 0 = 0 and is smaller than threshold 0.001. The threshold is from Artificial Neural Networks for calculating success of the extremum sought by the network.

Fuzzy Networks

If you implement all rules in a seperate graph node you can reason your way around a graph.

Distributed fuzzy networks

The same as a fuzzy network but with a node for each fuzzy logic set or system of nodes of a fuzzy network.

How does it apply to GNUstep ?

You can reason about what or how to draw to an X11/Xquartz window or GS subelement in the window such as a view, a button or a bitmap. You would use a fuzzy paint node which is in a distributed node system. If you switch nodes you either paint or wait (for example with an idle node) or reason (e.g. with an interrupt you must redraw your app screen) and so on. e.g. a mouse node would reason if you are about to click a button and access the region the mouse is in to reason further about what the painting algorithm of the window or rootwindow should do.

gnustep-fuzzy

gnustep-fuzzy uses a paint node which reasons about when it should paint. It can idle for seconds (or milliseconds) if you like and inferes the rules of the paint node this way. There is a fuzzy function associated with each rule string and a rule associated with a drawing function e.g. paintOn: or paintIdle1Second:. This system can be further distributed from a fuzzy set to a fuzzy node for each rule.

rule system code example

This is portable C and Objective-C :


void makePaintRules(OpalFuzzyPaintRuleSystem* sys) // sys is a node with a fuzzy set (or network in it) {

       /*sys contains a canvas called _painter and adds here a rule
         which redraws the screen, this method is paintOn: with the
         canvas as an argument. There are 3 adapters inside sys : self,   painter  and parser
       */
       [sys addRule:"paint extremely fast" : paintOn:];
      
       /* f is a functor object which contains the "extremely" reasoning fuzzy function, implemented as return (x*x*x); where x is initialized to 0.0 thereunder. You change the x not the threshold in sys, so if you have a threshold of 0.001, f(x)==0 < threshold, and the rule gets matched by sys.

The fuzzy parser of rules is now still simple. I mean the non-fuzzy function part.

       */
       OpalFuzzyFunction *f = [OpalFuzzyFunctionExtremely new];
       [f x:.0];
       [sys addFunction:"paint extremely" : f];
       /* here's the same thing the paint thread of e.g. Xquartz event handling sleeps for 1 second */
       [sys addRule:"paint not for 1 second" : paintIdle1SecondOn:];
       f = [OpalFuzzyFunctionIdle new];
       [f x:.0];
       [sys addFunction:"paint not for 1 second" : f];

}

references

source code

File:Gnustep-fuzzy-0.1.tar.gz

author

`Enry the `Ermit <johan at yellowcouch dot org>