net.sourceforge.jfl.core
Class DoubleInterpolatedFuzzySet

java.lang.Object
  extended by net.sourceforge.jfl.core.DoubleInterpolatedFuzzySet
All Implemented Interfaces:
IFuzzySet<java.lang.Double>

public class DoubleInterpolatedFuzzySet
extends java.lang.Object
implements IFuzzySet<java.lang.Double>

This class implements the IFuzzySet interface over Double typa members. This implementation not allows null element.

It implements the set backed by and array. The membership funtion is a linear interpolation of elements into the set.

Add an element into the set means add a point to the intorpolated membership function.

Call m the min element present into the set, all x < m has a memebrship value = u(m).
Call M the max element present into the set, all x > M has a membership value = u(M).

Author:
arons777@users.sourceforge.net

Field Summary
protected  boolean complementary
           
protected static int DEFAULT_ARRAY_INCREMENT
           
protected  java.lang.String label
           
protected  double[] membership
           
protected  int size
           
protected  double[] support
           
 
Constructor Summary
DoubleInterpolatedFuzzySet()
           
DoubleInterpolatedFuzzySet(int initialCapacity)
          Initialize the set with the passed capacity.
 
Method Summary
 void addAllElement(java.util.Set<java.lang.Double> elements, double membershipValue)
           
 void addElement(java.lang.Double element, double membershipValue)
           
 DoubleInterpolatedFuzzySet and(IFuzzySet<java.lang.Double> anotherSet)
          Performs a fuzzy logic and between this fuzzy set and the given one
 DoubleInterpolatedFuzzySet complement()
          Return a fuzzy set represents the complentary of the set.
protected  void extend()
          Extend the array by default value.
protected  void extend(int incrementSize)
          Extend the array by passed value.
 java.lang.String getLabel()
          Returns the label of this fuzzy set.
 double getMembership(java.lang.Double element)
          returns the membership value of the provided element to this IFuzzySet.
 java.util.Set<java.lang.Double> getSupport()
          Gets the fuzzy set support or, in other words, all the elements with non zero membership value.
 java.util.Set<Interval> getSupportIntervals()
          Gets the fuzzy set support or, in other words, all the elements with non zero membership value.
protected  void insert(double element, double membershipValue)
          Insert the passed element with the passed memebership value.
protected  void insert(double element, double membershipValue, int index)
           
protected  double membership(double element)
          Retrieve membership
 DoubleInterpolatedFuzzySet or(IFuzzySet<java.lang.Double> anotherSet)
          Performs a fuzzy logic or between this fuzzy set and the given one
protected  double remove(double element)
          Remove a point of interpolation from the set.
 double removeElement(java.lang.Double element)
           
protected  int searchLess(double element)
          Return index of the first element less than passed.
 void setLabel(java.lang.String label)
          Sets this fuzzy set label.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ARRAY_INCREMENT

protected static final int DEFAULT_ARRAY_INCREMENT
See Also:
Constant Field Values

label

protected java.lang.String label

support

protected double[] support

membership

protected double[] membership

size

protected int size

complementary

protected boolean complementary
Constructor Detail

DoubleInterpolatedFuzzySet

public DoubleInterpolatedFuzzySet()

DoubleInterpolatedFuzzySet

public DoubleInterpolatedFuzzySet(int initialCapacity)
Initialize the set with the passed capacity.

Parameters:
initialCapacity -
Method Detail

setLabel

public void setLabel(java.lang.String label)
Description copied from interface: IFuzzySet
Sets this fuzzy set label. A fuzzy set label is just an human readable name for the fuzzy set.

Specified by:
setLabel in interface IFuzzySet<java.lang.Double>
Parameters:
label - the label to set

getLabel

public java.lang.String getLabel()
Description copied from interface: IFuzzySet
Returns the label of this fuzzy set.

Specified by:
getLabel in interface IFuzzySet<java.lang.Double>
Returns:
the label of this fuzzy set.

addAllElement

public void addAllElement(java.util.Set<java.lang.Double> elements,
                          double membershipValue)

addElement

public void addElement(java.lang.Double element,
                       double membershipValue)

removeElement

public double removeElement(java.lang.Double element)

getMembership

public double getMembership(java.lang.Double element)
Description copied from interface: IFuzzySet
returns the membership value of the provided element to this IFuzzySet.

Specified by:
getMembership in interface IFuzzySet<java.lang.Double>
Parameters:
element - the element of which we want the membership value for this IFuzzySet
Returns:
the membership value of the queried element

getSupport

public java.util.Set<java.lang.Double> getSupport()
Description copied from interface: IFuzzySet
Gets the fuzzy set support or, in other words, all the elements with non zero membership value.

Specified by:
getSupport in interface IFuzzySet<java.lang.Double>
Returns:
the fuzzy set support, null if is not possible to return the support as a set.

getSupportIntervals

public java.util.Set<Interval> getSupportIntervals()
Description copied from interface: IFuzzySet
Gets the fuzzy set support or, in other words, all the elements with non zero membership value.

Specified by:
getSupportIntervals in interface IFuzzySet<java.lang.Double>
Returns:
the fuzzy set support intervals, null if is not possible to return the support as interval.

complement

public DoubleInterpolatedFuzzySet complement()
Description copied from interface: IFuzzySet
Return a fuzzy set represents the complentary of the set.

Specified by:
complement in interface IFuzzySet<java.lang.Double>
Returns:
the fuzzy set represents the complentary of the set.

membership

protected double membership(double element)
Retrieve membership

Parameters:
element -
Returns:

searchLess

protected int searchLess(double element)
Return index of the first element less than passed. TODO (arons): change in a better algorithm.

Parameters:
d -
Returns:
index, -1 if all elements are greather of the one passet.

insert

protected void insert(double element,
                      double membershipValue)
Insert the passed element with the passed memebership value.

Parameters:
element -
membership -

insert

protected void insert(double element,
                      double membershipValue,
                      int index)
Parameters:
element -
membership -
index - index of element after insert the new one.

remove

protected double remove(double element)
Remove a point of interpolation from the set.

Parameters:
element - to be removed
Returns:
previous membership value.

extend

protected void extend()
Extend the array by default value.


extend

protected void extend(int incrementSize)
Extend the array by passed value.

Parameters:
incrementSize - increment size

and

public DoubleInterpolatedFuzzySet and(IFuzzySet<java.lang.Double> anotherSet)
Description copied from interface: IFuzzySet
Performs a fuzzy logic and between this fuzzy set and the given one

Specified by:
and in interface IFuzzySet<java.lang.Double>
Parameters:
anotherSet - the fuzzy set to perform the fuzzy logic and with
Returns:
the fuzzy set resulting from the and between this fuzzy set and the given one.

or

public DoubleInterpolatedFuzzySet or(IFuzzySet<java.lang.Double> anotherSet)
Description copied from interface: IFuzzySet
Performs a fuzzy logic or between this fuzzy set and the given one

Specified by:
or in interface IFuzzySet<java.lang.Double>
Parameters:
anotherSet - the fuzzy set to perform the fuzzy logic or with
Returns:
the fuzzy set resulting from the or between this fuzzy set and the given one.


Copyright © 2000 Dummy Corp. All Rights Reserved.