AI-Fuzzy
    
    
  
  
  
view release on metacpan or search on metacpan
Revision history for Perl extension AI::Fuzzy.
0.05 Sat Jan  4 10:20:29 EST 2003
	- found problem with stringifycation in Set.pm
	- fixed warning messages due to not checking "exists" for hash 
	  values in Set.pm (union,intersection).  Thanks to Richard Jelinek
	  for pointing this out, and a problem in the code in the docs.
	
0.04 Fri Dec  6 13:49:55 EST 2002
        - replaced current AI::Fuzzy::Label with a new AI::Fuzzy::Axis (a container for label objects)
          and changed AI::Fuzzy::Label to be concerned only about label data.  This
          will allow us to add new AI::Fuzzy::Label{Spline, Trapezoid, etc.} subclasses
          of labels to the now independent Axis class.  Axis will defer to the Label
          itself to decide applicability, >,<,>=,<=, and the like.
        - changed test.pl to work with the new setup
        - added functions: greaterthan, greaterequal, lessthan, lessequal, and between
          to AI::Fuzzy::Label
        - added overriding of >,>=,<,<=, and <=> in AI::Fuzzy::Label.
0.03 Wed Oct  9 18:07:34 EDT 2002
	- added functions: support, core, height, is_normal, is_subnormal
	  to AI::Fuzzy::Set
0.02 Wed Oct  9 16:41:29 EDT 2002
	- ownership transfering to Tom Scanlan <tscanlan@openreach.com>
note that labels can overlap, and that the
mid number isn't always in the exact center, so the slope
of the two sides may vary...
$fl = new AI::Fuzzy::Label ( "hot", 77, 80, 100 );
$fx = new AI::Fuzzy::Label ( "cold", 0, 10, 200 );
    # what I consider hot. :) (in Farenheit, of course!)
if ( $fl->lessthan($fx) ) {
    print "the laws of nature have changed\n";
}
# there is a lessthan, greaterthan, lessequal, greaterequal, and between 
#  that functions as above or using <,>,<=,>=
$a = $fl->applicability($value);
    # $a is now the degree to which this label applies to $value
=head2 Fuzzy Axis
lib/AI/Fuzzy/Label.pm view on Meta::CPAN
    # calculates to what degree this label applies to a $value
    my ($self, $value) = @_;
    my $membership = 0;
    # if the low and mid points are same as value, full membership
    # same if mid and high are same as value
    if ($self->{mid} == $self->{low} && $value == $self->{low}) { return 1 };  
    if ($self->{high} == $self->{mid} && $value == $self->{high}) { return 1 };  
    # m = slope of the line.. (change in y/change in x) 
    #     change in y is 1 as membership increases, -1 as it decreases
    my $mIncreasing =  1 / ($self->{mid} - $self->{low});
    my $mDecreasing = -1 / ($self->{high} - $self->{mid});
    # reject values that are "out of bounds"
    return ($membership = 0)
	if ($value <= $self->{low} ) or ($value >= $self->{high} );
    # now calculate membership:
    # y=mx+b , just like in algebra
    if ($value < $self->{mid}) {
( run in 0.354 second using v1.01-cache-2.11-cpan-c333fce770f )