1   
 2   
 3   
 4   
 5   
 6   
 7   
 8   
 9   
10   
11   
12   
13   
14   
15   
16   
17   
18   
19  """Not a real defuzzification. 
20  Just stores the adjective memberships in a dictionary for output.""" 
21   
22  __revision__ = "$Id: Dict.py,v 1.9 2010-03-28 18:40:33 rliebscher Exp $" 
23   
24  from fuzzy.defuzzify.Base import Base 
25   
27      """Not a real defuzzification. 
28         Just stores the adjective memberships 
29         in a dictionary for output. 
30         You should use in the adjectives instances of Set itself. 
31          
32         What can be done with this? 
33          
34         For example: 
35          
36         You want help with buying a car. 
37          
38         Input are your preferences:: 
39          speed, payload (1-10), ... 
40         (map to "very important, important, doesn't matter, not wanted, never" ;-) 
41          
42         Output are choices: 
43         cars with adjectives: ferrari, truck, ... 
44          
45         rules are as follows:: 
46          if speed->very_important && payload->never then car->ferrari 
47          if payload->very_important then car->truck 
48         ... and so on 
49          
50         Then you use this as follows:: 
51          input variables  
52          { speed:3, payload:1, ...}  
53          ==>  
54          output_variables 
55          { car: { 
56                   ferrari:0.1, 
57                   truck: 1.0, 
58                   ... 
59                 } 
60          } 
61         """ 
64   
66          """no defuzzification just return membership values""" 
67          temp = {} 
68          for name, adjective in variable.adjectives.items(): 
69               
70              temp[name] = adjective.getMembership() 
71          return temp 
  72