Package fuzzy :: Module InputVariable
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.InputVariable

 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  """General instance of an input variable."""  
19  __revision__ = "$Id: InputVariable.py,v 1.9 2010-02-17 19:57:13 rliebscher Exp $" 
20   
21  from fuzzy.Variable import Variable 
22   
23 -class InputVariable(Variable):
24 """General instance of an input variable 25 The fuzzification is provided by special object for this purpose, 26 set as fuzzify param. 27 Also marker, so you can check if any variable is an (instance of) input variable 28 29 @ivar fuzzify: Fuzzification method. 30 @type fuzzify: L{fuzzy.fuzzify.Base.Base} 31 """ 32
33 - def __init__(self, fuzzify=None, *args, **keywords):
34 """Initialize this input variable with a fuzzification method. 35 36 @param fuzzify: Fuzzification method. 37 @type fuzzify: L{fuzzy.fuzzify.Base.Base} 38 """ 39 super(InputVariable, self).__init__(*args, **keywords) 40 self.fuzzify = fuzzify
41
42 - def setValue(self, value):
43 """Let adjectives calculate their membership values.""" 44 self.__value = self.fuzzify.setValue(self, value)
45
46 - def _repr_params(self, params):
47 """Helper for representation of instance. 48 49 Add all own params to given list in params. 50 """ 51 params.append(repr(self.fuzzify)) 52 super(InputVariable, self)._repr_params(params)
53