net.sourceforge.fuzzyservices.beans
Class MembershipFunction

java.lang.Object
  extended by net.sourceforge.fuzzyservices.beans.MembershipFunction
All Implemented Interfaces:
Serializable, Cloneable

public class MembershipFunction
extends Object
implements Cloneable, Serializable

The membership function f(x) is defined by a setDegreeOfMembership of points. Every point marks a relationship between a value x and its degree of membership. All points clamp a traverse. If the degree of membership of a value is not defined by a point exactly it will be calculated by interpolation. This class offers methods for manipulating the membership function, in general. For calculation the pointed membership function is iterated in a certain increment defined in fuzzy manager of this system.

Since:
1.0
Author:
Uwe Weng
See Also:
MembershipFunctionPoint, FuzzySet, FuzzyNumber, FuzzyLRNumber, FuzzyInterval, FuzzyLRInterval, Serialized Form

Field Summary
static String DEGREE_OF_MEMBERSHIP_PROPERTY
          Bound property name for newDegreeOfMembership.
 
Constructor Summary
MembershipFunction()
          Creates a membership function with f(x) = 0.
MembershipFunction(float x, float spread)
          Creates a membership function looks like an isosceles triangle.
MembershipFunction(float plateau1, float plateau2, float alpha, float beta)
          Creates a membership function looks like a trapezium.
MembershipFunction(MembershipFunctionPoint[] newPoints)
          Creates a membership function with already existing points.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a VetoableChangeListener to the listener list.
 void clear()
          Reset the membership function to f(x) = 0.0.
 Object clone()
           
 void concentrate()
          Concentrates the membership function.
 void dilate()
          Dilates the membership function.
 boolean equals(Object obj)
           
 float getAlpha()
          Returns the spread on the left falling edge.
 float getBeta()
          Returns the spread on the right falling edge.
 float getDegreeOfMembership(float x)
          Returns the degree of membership to a x value.
 float getGranularity(MembershipFunction membershipFunction)
          Calculates the increment when combining this membership function with membershipFunction.
 float getHeight()
          Returns the height of the membership function.
 int getId()
          Returns the technical identifier (e.g. within a database).
 float getMaxDefinedX()
          Gets the maximal value which is defined on the x axis by the set of points.
 float getMinDefinedX()
          Gets the minimal value which is defined on the x axis by the set of points.
 int getNumSteps(MembershipFunction membershipFunction)
          Calculates the number of steps when combining this membership function with membershipFunction.
 float[] getXValues()
          Returns an array of all x values which define the membership function.
 int hashCode()
           
 void invert()
          Creates the inverse of the membership function.
 boolean isConvex()
          Checks whether the membership function is convex.
 boolean isDefined()
          Checks if the membership function is defined by at least one point.
 boolean isNormalized()
          Checks whether the membership function is normalized.
 Iterator<Float> iterator()
          Returns an iterator of all x values which define the membership function.
 void negate()
          Negates the membership function.
 void normalize()
          Normalizes the membership function.
 void reciproce()
          Creates the complementary membership function (f(x) = 1-f(x)).
 void reduce()
          Reduces the number of points without changing the appearance of the membership function.
 void remove(float x)
          Sets the degree of membership at x to 0.0.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes a VetoableChangeListener from the listener list.
 void setDegreeOfMembership(float x, float newDegreeOfMembership)
          Defines at x a new degree of membership.
 int size()
          Returns the number of points specifying the membership function.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEGREE_OF_MEMBERSHIP_PROPERTY

public static final String DEGREE_OF_MEMBERSHIP_PROPERTY
Bound property name for newDegreeOfMembership.

See Also:
Constant Field Values
Constructor Detail

MembershipFunction

public MembershipFunction()
Creates a membership function with f(x) = 0.


MembershipFunction

public MembershipFunction(MembershipFunctionPoint[] newPoints)
Creates a membership function with already existing points.

Parameters:
newPoints - an array of X/Degree of Membership Pairs.

MembershipFunction

public MembershipFunction(float x,
                          float spread)
Creates a membership function looks like an isosceles triangle.

Parameters:
x - the x value with degree of membership of 1.0
spread - the spread to x x with degree of membership 0.0

MembershipFunction

public MembershipFunction(float plateau1,
                          float plateau2,
                          float alpha,
                          float beta)
Creates a membership function looks like a trapezium. The degree of membership between plateau1 and plateau2 is 1.0.

Parameters:
plateau1 - coming from left at this point the membership is 1.0 the first time.
plateau2 - coming from right at this point the membership is 1.0 the first time.
alpha - the spread of the left trailing edge
beta - the spread of the right trailing edge
Method Detail

getId

public int getId()
Returns the technical identifier (e.g. within a database).

Returns:
the ID

setDegreeOfMembership

public final void setDegreeOfMembership(float x,
                                        float newDegreeOfMembership)
                                 throws PropertyVetoException
Defines at x a new degree of membership.

Parameters:
x - the x coordinate
newDegreeOfMembership - the new degree of membership at x
Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

remove

public final void remove(float x)
                  throws PropertyVetoException
Sets the degree of membership at x to 0.0.

Parameters:
x - the x coordinate
Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

clear

public final void clear()
                 throws PropertyVetoException
Reset the membership function to f(x) = 0.0.

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

getAlpha

public final float getAlpha()
Returns the spread on the left falling edge. It is the so-called alpha value.

Returns:
the spread alpha

getBeta

public final float getBeta()
Returns the spread on the right falling edge. It is the so-called beta value.

Returns:
the spread beta

getHeight

public final float getHeight()
Returns the height of the membership function. It is the maximum defined degree of membership.

Returns:
the maximum degree of membership as height

isNormalized

public final boolean isNormalized()
Checks whether the membership function is normalized. A membership function is normalized if its height is 1.0.

Returns:
true if membership function is normalized false, otherwise
See Also:
getHeight()

normalize

public final void normalize()
                     throws PropertyVetoException
Normalizes the membership function. Afterwards the degree of membership is alwalys in [0,1].

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener
See Also:
isNormalized()

reciproce

public final void reciproce()
                     throws PropertyVetoException
Creates the complementary membership function (f(x) = 1-f(x)).

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

dilate

public final void dilate()
                  throws PropertyVetoException
Dilates the membership function.

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

concentrate

public final void concentrate()
                       throws PropertyVetoException
Concentrates the membership function.

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener

isConvex

public final boolean isConvex()
Checks whether the membership function is convex. A membership function is convex if there is only one change of sign from + to -.

Returns:
true if membership function is convex false, otherwise

iterator

public final Iterator<Float> iterator()
Returns an iterator of all x values which define the membership function.

Returns:
an iterator of Float objects which are the x values of the membership function

getXValues

public final float[] getXValues()
Returns an array of all x values which define the membership function.

Returns:
an array of Float objects which are the x values of the membership function

size

public final int size()
Returns the number of points specifying the membership function.

Returns:
the number of specified x values

isDefined

public final boolean isDefined()
Checks if the membership function is defined by at least one point.

Returns:
true if a point exists false, otherwise

getDegreeOfMembership

public final float getDegreeOfMembership(float x)
Returns the degree of membership to a x value.

Parameters:
x - the x value
Returns:
the degree of membership function to x

getNumSteps

public int getNumSteps(MembershipFunction membershipFunction)
Calculates the number of steps when combining this membership function with membershipFunction.

Parameters:
membershipFunction - the membership function for combining
Returns:
the number of steps

getGranularity

public float getGranularity(MembershipFunction membershipFunction)
Calculates the increment when combining this membership function with membershipFunction.

Parameters:
membershipFunction - the membershipFunction for combining
Returns:
the so-called granularity

reduce

public void reduce()
Reduces the number of points without changing the appearance of the membership function.


getMinDefinedX

public final float getMinDefinedX()
Gets the minimal value which is defined on the x axis by the set of points.

Returns:
the minimal defined x value. Float.NaN if set is empty.

getMaxDefinedX

public final float getMaxDefinedX()
Gets the maximal value which is defined on the x axis by the set of points.

Returns:
the maximal defined x value. Float.NaN if set is empty.

negate

public final void negate()
                  throws PropertyVetoException
Negates the membership function.

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener
See Also:
FuzzyNumber, FuzzyLRNumber, FuzzyInterval, FuzzyLRInterval

invert

public final void invert()
                  throws PropertyVetoException
Creates the inverse of the membership function. Due to mathematical restrictions it is impossible to calculate the inverse at x = 0, because there is a definition lack.

Throws:
PropertyVetoException - when the attempt to set the property is vetoed by a listener
See Also:
FuzzyNumber, FuzzyLRNumber, FuzzyInterval, FuzzyLRInterval

addVetoableChangeListener

public final void addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list. The listener is registered for all properties.

Parameters:
listener - the VetoableChangeListener to be added

removeVetoableChangeListener

public final void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered for all properties.

Parameters:
listener - the VetoableChangeListener to be removed

addPropertyChangeListener

public final void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired in response to setting a bound property.

Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public final void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - the PropertyChangeListener to be removed

clone

public Object clone()
Overrides:
clone in class Object

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2012 Fuzzy Services. All Rights Reserved.