class OutputVariable(Variable): '''An output varible such as Health or Tip. Defines a linguistic variable for output. Attributes: default: a float value to assume by default if there is no output. defuzzifier: an instance of a defuzzifier method. output: a Cumulative term to which Output terms will be appended. ''' def __init__(self, name, default = None): Variable.__init__(self, name) self.default = default self.defuzzifier = None self.output = Cumulative('output') def configure(self, fop): Variable.configure(self, fop) self.defuzzifier = fop.defuzzifier self.output.accumulation = fop.accumulation def defuzzify(self): '''Returns a single float value representing the defuzzified output.''' if self.output.is_empty(): return self.default return self.defuzzifier.defuzzify(self.output)
def __init__(self, name, default = None): Variable.__init__(self, name) self.default = default self.defuzzifier = None self.output = Cumulative('output')