Fuzzy
This page is for GNUstep developers. It explains the Fuzzy Logic system for e.g. updating the GNUstep System such as drawing to screen. See the references immediately if you do not know anything about fuzzy logic systems. You should concur that you understand fuzzy logic before reading anything else on this page.
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.
The image displays the fuzzy logic function value increasing with temperature which is a linear algebraic function system. A function for cold would be f(x), for warm f(x*x) and for hot f(x*x*x). as f(X) increases the return value increases as does the temperature. Another solution would be to have the return value of a temperature fuzzy logic function increasing with temperature.
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.
Inference engines
Inference engines infere rules based on logic such as reasoning with not, and, or and combinations of these logical comparators. You can negate rules and infere less rules this way.
prolog
Prolog is a formal logic rule system which induces rules based on the logical input clauses and then reasons about them by parsing logic rules. You can ask the prolog interpreter questions about what he induced logically.
progol
Progol inferes the most specicic clause by using a graph searching algorithm. It parses e.g. by negation so that input clauses can be ruled out. Progol deduces i.e. makes the most general logical assumptions.
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];
}
You can change the fuzzy function parameter so that the threshold should not change.
The threading model of this code is multi-threaded so e.g. drawing to screen happens with interrupts and is managed by a threadpool object which alters the state of your GS windows. Threads can be used to let the fuzzy set parse and change nodes when doing other stuff.
references
external links
source code
author
`Enry the `Ermit <goon at yellowcouch dot org>