AI-Fuzzy

 view release on metacpan or  search on metacpan

lib/AI/Fuzzy/Axis.pm  view on Meta::CPAN



sub applicability {
    # this function should be called something else..
    # calculates to what degree $label applies to a $value

    my ($self, $value, $label) = @_;
    my $membership = 0;

    return $label->applicability($value) if ($label->can("applicability"));
    return undef unless ( exists $self->{labels}->{$label} );
    return $self->{labels}->{$label}->applicability($value);
}

sub label {
    # returns a label associated with this text
    my ($self, $name) = @_;

    return $self->{labels}->{$name};
}

lib/AI/Fuzzy/Axis.pm  view on Meta::CPAN

sub lessthan {
    my ($self, $labela, $labelb) = @_;

    if ( exists $self->{labels}->{$labela} and exists $self->{labels}->{$labelb} ) {
	my $la = $self->{labels}->{$labela};
	my $lb = $self->{labels}->{$labelb};

	return $la->lessthan($lb);

    } else {
	return undef;
    }
}
sub lessequal {
    my ($self, $labela, $labelb) = @_;

    if ( exists $self->{labels}->{$labela} and exists $self->{labels}->{$labelb} ) {
	my $la = $self->{labels}->{$labela};
	my $lb = $self->{labels}->{$labelb};
	
	return $la->lessequal($lb);
    } else {
	return undef;
    }
}

sub greaterthan {
    my ($self, $labela, $labelb) = @_;

    if ( exists $self->{labels}->{$labela} and exists $self->{labels}->{$labelb} ) {
	my $la = $self->{labels}->{$labela};
	my $lb = $self->{labels}->{$labelb};
	
	return $la->greaterthan($lb);
    } else {
	return undef;
    }
}
sub greaterequal {
    my ($self, $labela, $labelb) = @_;

    if ( exists $self->{labels}->{$labela} and exists $self->{labels}->{$labelb} ) {
	my $la = $self->{labels}->{$labela};
	my $lb = $self->{labels}->{$labelb};
	
	return $la->greaterequal($lb);
    } else {
	return undef;
    }
}

sub between {
    my ($self, $labela, $labelb, $labelc) = @_;

    if ( exists $self->{labels}->{$labela} and exists $self->{labels}->{$labelb} 
         and exists $self->{labels}->{$labelc} ) {
	my $la = $self->{labels}->{$labela};
	my $lb = $self->{labels}->{$labelb};
	my $lc = $self->{labels}->{$labelc};
	
	return $la->between($lb, $lc);
    } else {
	return undef;
    }
}
1;

lib/AI/Fuzzy/Set.pm  view on Meta::CPAN


sub complement {
    # returns a set that is the complement of us
    # requires that the set contain values from 0 to 1
    my $self = shift;

    my (%new);

    foreach my $member ($self->members) {
	my $comp = 1 - $self->membership($member); 
	return undef if ($comp < 0 || $comp >1);

	$new{$member} = $comp;
    }

    return new AI::Fuzzy::Set(%new);
}

sub support {
    # returns the support set.
    # defined as the set of all elements in our set with a non-zero membership.



( run in 2.893 seconds using v1.01-cache-2.11-cpan-d80b1682f3f )