Package fuzzy :: Package fuzzify :: Module Dict
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.fuzzify.Dict

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2009  Rene Liebscher 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify it under 
 6  # the terms of the GNU Lesser General Public License as published by the Free  
 7  # Software Foundation; either version 3 of the License, or (at your option) any 
 8  # later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, but WITHOUT  
11  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
12  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
13  # details. 
14  #  
15  # You should have received a copy of the GNU Lesser General Public License 
16  # along with this program; if not, see <http://www.gnu.org/licenses/>.  
17  # 
18   
19  """Fuzzification which sets adjectives values according the values in given dictionary.""" 
20   
21  __revision__ = "$Id: Dict.py,v 1.8 2010-10-29 19:24:41 rliebscher Exp $" 
22   
23  from fuzzy.fuzzify.Base import Base 
24   
25   
26 -class Dict(Base): # pylint: disable=R0903
27 """Fuzzification method which gets adjective memberships 28 in a dictionary instead of values to fuzzify. 29 You should use in the adjectives instances of Set itself. 30 31 Q : What can be done with this? 32 33 A : Break complexity, by divide big and heavy fuzzy 34 systems into small ones :: 35 36 input1 ----> ******* 37 input2 ----> * FIS * 38 input3 ----> * * ------> output 39 input4 ----> ******* 40 41 should be:: 42 43 input1 ----> ******* 44 input2 ----> *FIS 1* ----+ 45 ******* | 46 +--> ******* 47 input3 ----> ******* -------> *FIS 3* ----> output 48 input4 ----> *FIS 2* ******* 49 ******* 50 51 Q : Why don't defuzzify outputs of FIS1 and FIS2 ? 52 53 A : Defuzzification mean data loss. 54 55 """ 56
57 - def __init__(self, *args, **keywords):
58 super(Dict, self).__init__(*args, **keywords)
59
60 - def setValue(self, variable, value):
61 """Do not let adjectives calculate their membership values. 62 Instead use the provided values from dictionary. 63 64 @param variable: variable which adjective to set 65 @type variable: L{fuzzy.Variable.Variable} 66 @param variable: values to set the adjectives 67 @type: dict 68 """ 69 for adjective_key in value: 70 variable.adjectives[adjective_key].membership = value[adjective_key] 71 return None
72