Public methods
Method new()
Create a new FuzzySet
object.
Usage
FuzzySet$new(
...,
elements = NULL,
membership = rep(1, length(elements)),
class = NULL
)
Arguments
...
Alternating elements and membership, see details.
elements
Elements in the set, see details.
membership
Corresponding membership of the elements, see details.
class
Optional string naming a class that if supplied gives the set the typed
property.
Details
FuzzySet
s can be constructed in one of two ways, either by supplying the elements and their
membership in alternate order, or by providing a list of elements to elements
and a list of
respective memberships to membership
, see examples. If the class
argument is non-NULL
,
then all elements will be coerced to the given class in construction, and if elements of a
different class are added these will either be rejected or coerced.
Returns
A new FuzzySet
object.
Method strprint()
Creates a printable representation of the object.
Usage
FuzzySet$strprint(n = 2)
Arguments
n
numeric. Number of elements to display on either side of ellipsis when printing.
Returns
A character string representing the object.
Method membership()
Returns the membership, i.e. value in [0, 1], of either the given element(s)
or all elements in the fuzzy set.
Usage
FuzzySet$membership(element = NULL)
Arguments
element
element or list of element in the set
, if NULL
returns membership of all elements
Details
For FuzzySet
s this is straightforward and returns the membership of the given element(s),
however in FuzzyTuple
s and FuzzyMultiset
s when an element may be duplicated, the function returns the membership of
all instances of the element.
Returns
Value, or list of values, in [0, 1].
Examples
f = FuzzySet$new(1, 0.1, 2, 0.5, 3, 1)
f$membership()
f$membership(2)
f$membership(list(1, 2))
Method alphaCut()
The alpha-cut of a fuzzy set is defined as the set
$$A_\alpha = \{x \epsilon F | m \ge \alpha\}$$
where \(x\) is an element in the fuzzy set, \(F\), and \(m\) is the corresponding membership.
Usage
FuzzySet$alphaCut(alpha, strong = FALSE, create = FALSE)
Arguments
alpha
numeric in [0, 1] to determine which elements to return
strong
logical, if FALSE
(default) then includes elements greater than or equal to alpha, otherwise only strictly greater than
create
logical, if FALSE
(default) returns the elements in the alpha cut, otherwise returns a crisp set of the elements
Returns
Elements in FuzzySet or a Set of the elements.
Examples
f = FuzzySet$new(1, 0.1, 2, 0.5, 3, 1)
# Alpha-cut
f$alphaCut(0.5)
# Strong alpha-cut
f$alphaCut(0.5, strong = TRUE)
# Create a set from the alpha-cut
f$alphaCut(0.5, create = TRUE)
Method support()
The support of a fuzzy set is defined as the set of elements whose membership
is greater than zero, or the strong alpha-cut with \(\alpha = 0\),
$$A_\alpha = \{x \epsilon F | m > 0\}$$
where \(x\) is an element in the fuzzy set, \(F\), and \(m\) is the corresponding
membership.
Usage
FuzzySet$support(create = FALSE)
Arguments
create
logical, if FALSE
(default) returns the support elements, otherwise returns a Set of the support elements
Returns
Support elements in fuzzy set or a Set of the support elements.
Examples
f = FuzzySet$new(0.1, 0, 1, 0.1, 2, 0.5, 3, 1)
f$support()
f$support(TRUE)
Method core()
The core of a fuzzy set is defined as the set of elements whose membership is equal to one,
or the alpha-cut with \(\alpha = 1\),
$$A_\alpha = \{x \epsilon F \ : \ m \ge 1\}$$
where \(x\) is an element in the fuzzy set, \(F\), and \(m\) is the corresponding membership.
Usage
FuzzySet$core(create = FALSE)
Arguments
create
logical, if FALSE
(default) returns the core elements, otherwise returns a Set of the core elements
Returns
Core elements in FuzzySet or a Set of the core elements.
Examples
f = FuzzySet$new(0.1, 0, 1, 0.1, 2, 0.5, 3, 1)
f$core()
f$core(TRUE)
Method inclusion()
An element in a fuzzy set, with corresponding membership \(m\), is:
Usage
FuzzySet$inclusion(element)
Arguments
element
element or list of elements in fuzzy set for which to get the inclusion level
Details
For FuzzySets this is straightforward and returns the inclusion level of the given element(s),
however in FuzzyTuples and FuzzyMultisets when an element may be duplicated, the function returns the inclusion level of
all instances of the element.
Returns
One of: "Included", "Partially Included", "Not Included"
Examples
f = FuzzySet$new(0.1, 0, 1, 0.1, 2, 0.5, 3, 1)
f$inclusion(0.1)
f$inclusion(1)
f$inclusion(3)
Method equals()
Tests if two sets are equal.
Usage
FuzzySet$equals(x, all = FALSE)
Arguments
x
Set or vector of Sets.
all
logical. If FALSE
tests each x
separately. Otherwise returns TRUE
only if all x
pass test.
Details
Two fuzzy sets are equal if they contain the same elements with the same memberships.
Infix operators can be used for:
Returns
If all
is TRUE
then returns TRUE
if all x
are equal to the Set, otherwise
FALSE
. If all
is FALSE
then returns a vector of logicals corresponding to each individual
element of x
.
Method isSubset()
Test if one set is a (proper) subset of another
Usage
FuzzySet$isSubset(x, proper = FALSE, all = FALSE)
Arguments
x
any. Object or vector of objects to test.
proper
logical. If TRUE
tests for proper subsets.
all
logical. If FALSE
tests each x
separately. Otherwise returns TRUE
only if all x
pass test.
Details
If using the method directly, and not via one of the operators then the additional boolean
argument proper
can be used to specify testing of subsets or proper subsets. A Set is a proper
subset of another if it is fully contained by the other Set (i.e. not equal to) whereas a Set is a
(non-proper) subset if it is fully contained by, or equal to, the other Set.
Infix operators can be used for:
Subset |
< |
Proper Subset |
<= |
Superset |
> |
Returns
If all
is TRUE
then returns TRUE
if all x
are subsets of the Set, otherwise
FALSE
. If all
is FALSE
then returns a vector of logicals corresponding to each individual
element of x
.
Method clone()
The objects of this class are cloneable with this method.
Usage
FuzzySet$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.