![]() |
|||||||||||
|
|||||||||||
|
1. FuzzyClassThis page describes the Pyro Fuzzy class.
You create a fuzzy value using the following code: import pyrobot.brain.fuzzy fuzvariable = Fuzzy(SMALLVALUE, BIGGERVALUE)But that only creates the range of the Fuzzy variable. To fuzzify a value, do this: Fuzzy(SMALLVALUE, BIGGERVALUE) << VALUEor Fuzzy(SMALLVALUE, BIGGERVALUE) >> VALUEwhere the double arrows point uphill. Consider the following statement from a behavior based brain: self.IF(Fuzzy(SMALLVALUE, BIGGERVALUE) << VALUE, 'translate', 0) This IF statement applies to all VALUEs; however, it will only effect translate if it is somewhat true. That is, if Fuzzy(SMALLVALUE, BIGGERVALUE) << VALUE is above zero, then it could effect translate. The more true the fuzzy expression is, the more it will influence translate. Here, "influence translate" means that it will try to stop it. Of course, what actually happens depends on the other behaviors wishes, too. Recall, this is behavior blending. Because this fuzzy expression uses <<, it becomes more true by having smaller VALUEs. To the left is uphill, so on the graph values that are equal to or less than SMALLVALUE will be 100% true. Values greater than or equal to BIGGERVALUE will be 100% false. Values in between will have varying degrees of truth. In general: self.IF(TRUTHVALUE, CONTROL, DESIRE)
Does the Fuzzy command just give the strength of its response to 'translate'? To see exactly what happens, you can look at the code in
1.1. Fuzzy ConnectivesConsider:
Fuzzy(a, b) >> varWill result in the following truth-graph:
F |
1| * * *
u | *
| *
z | *
| *
z | *
| *
y | *
---*-*-|-------------|---------
a b
Var
Fuzzy(a, b) << varWill result in this following truth-graph:
F |
1|* * *
u | *
| *
z | *
| *
z | *
| *
y | *
-------|---------------|-*-*---
a b
Var
To 'and' two fuzzy variables, simply use & or |, i.e. (Fuzzy(1, 2) << a) & (Fuzzy(3, 4) << b) To interactively explore Fuzzy values, try:
[dblank@cesario dblank]$ python2 Python 2.1.1 (#1, Aug 13 2001, 19:37:40) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-96)] on linux2 Type "copyright", "credits" or "license" for more information. >>> from pyrobot.brain.fuzzy import * >>> f1 = Fuzzy(0, 1) >> .5 >>> f1 <pyrobot.brain.fuzzy.Fuzzy instance at 0x81cc4a4> However, you probably want to see the value. We can see the value by converting it to a float, or by printing it directly (print is overloaded too):
>>> float(f1) 0.5 >>> print f1 <Fuzzy instance value = 0.5 min = 0 max = 1> Performing an & gives MAX, while | gives MIN (use single ampersand and bar operators):
>>> float((Fuzzy(0, 1) >> .25) & (Fuzzy(0, 1) << .25)) 0.75 >>> float((Fuzzy(0, 1) >> .75) & (Fuzzy(0, 1) << .75)) 0.75 >>> float((Fuzzy(0, 1) >> .25) | (Fuzzy(0, 1) << .25)) 0.25 >>> float((Fuzzy(0, 1) >> .75) | (Fuzzy(0, 1) << .75)) 0.25 The parentheses are not necessary. --Evan Moses and Sharon Rose Alterman
Related topics: Go here for full search functions ViewWiki | EditWiki | Webmaster@wiki.cs |