nrc.fuzzy
Class SimilarityByPossibilityOperator

java.lang.Object
  |
  +--nrc.fuzzy.SimilarityOperator
        |
        +--nrc.fuzzy.SimilarityByPossibilityOperator
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, SimilarityOperatorInterface

public class SimilarityByPossibilityOperator
extends SimilarityOperator
implements java.io.Serializable

A class that provides an operator to calculate the similarity between 2 fuzzy values. Given two fuzzy values, f1 and f2, similarity is defined as:

 similarity = if    necessity(f1,f2) > 0.5   
              then  possibility(f1,f2)   
              else  (necessity(f1,f2) + 0.5) * possibility(f1,f2) 

 where 

   necessity(f1,f2) = 1 - possibility(not f1,f2)

 and

   possibility(f1,f2) = max(min(u  (x),u  (x)) 
                         x       f1     f2  
 

The default similarity operator is the SimilarityByPossibilityOperator. This can be changed using the static setDefaultSimilarityOperator method of the FuzzyValue class.

See Also:
SimilarityOperator, SimilarityOperatorInterface, SimilarityByAreaOperator, Serialized Form

Constructor Summary
SimilarityByPossibilityOperator()
           
 
Method Summary
 double similarity(nrc.fuzzy.FuzzyValue fv1, nrc.fuzzy.FuzzyValue fv2)
          SIMILARITY: a method to calculate the similarity measure of two fuzzy sets Given two fuzzy values, f1 and f2, similarity is defined as:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimilarityByPossibilityOperator

public SimilarityByPossibilityOperator()
Method Detail

similarity

public double similarity(nrc.fuzzy.FuzzyValue fv1,
                         nrc.fuzzy.FuzzyValue fv2)
                  throws IncompatibleFuzzyValuesException
SIMILARITY: a method to calculate the similarity measure of two fuzzy sets Given two fuzzy values, f1 and f2, similarity is defined as:
 similarity = if    necessity(f1,f2) > 0.5   
              then  possibility(f1,f2)   
              else  (necessity(f1,f2) + 0.5) * possibility(f1,f2) 

 where 

   necessity(f1,f2) = 1 - possibility(not f1,f2)

 and

   possibility(f1,f2) = max(min(u  (x),u  (x)) 
                         x       f1     f2  
 

This version of a similarity function is useful in some cases but breaks down when there is some overlap but large parts not overlapping. For example if we have the fuzzy values with LeftLinearFuzzySet(0.499999, 0.500001) and RightLinearFuzzySet(0.499999, 0.500001) we'd expect a similarity to be close to 0.0 but it is 0.25 in this case. So if we are using triangular or trapezoid fuzzy sets this measure may be OK. This is a measure that was used in the FuzzyCLIPS system and a better approach might be to use the more useful measure, similarityByArea.

Note: we must check that the 2 fuzzy values have the same Fuzzy variable

Note: If the fuzzy values are the same (equals) then returns a 1.0

Specified by:
similarity in interface SimilarityOperatorInterface
Parameters:
fv1 -
fv2 -
Returns:
double that is the result of applying the operator to the 2 values (the similarity measure)
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done