API Reference automatically collected with jazzy is published here with each new release.
FuzzySets Module
protocol FuzzySet
This abstraction requires a fuzzy set to provide a grade(forElement:) method which accepts a parameter of an associatedtype Universe and returns its membership Grade in the set. There are 3 provided concrete implementations in this module:
struct AnyFuzzySet - allows type erasure. It only stores a MembershipFunction and has non-mutable methods.
struct IterableFuzzySet - stores a MembershipFunction as well as a Sequence of elements of the associated type Universe. Implements Sequence so that it can easily be iterated over them. The elements of the iteration over an IterableFuzzySet are structs containing grade and element properties. It has non-mutable methods only. Includes support, core and height computed properties.
struct DiscreteMutableFuzzySet - it is “discrete” because it doesn’t stores a MembershipFunction but instead keeps its elements and their grade in a Dictionary, and it is “mutable” because it contains mutable equivalents of all other methods that operate over the set (including subscript). A default value of 0 is returned for the grade of an element that is not in the dictionary (a different default value can be provided as well). Includes support, core and height computed properties. A bonus feature is its debug print using Zadeh’s notation.
Convertions between the 3 types are easy and possible using the eraseToAnyFuzzySet, makeIterable and makeDiscreteMutable methods defined on them.
protocol FuzzySetOperations
All 3 concrete types implement it. It requires the following methods that operate on fuzzy sets:
FuzzyKit
Fuzzy sets and fuzzy logic theory implementations.
Example Usage
Modules
Using the Swift Package Manager, don’t forget to add the package as a dependency to your
Package.swift
file:To be able to use everything from this package, you can import everything at once using this helper module:
Or alternatively, import only the specific modules needed:
API Reference
API Reference automatically collected with
jazzy
is published here with each new release.FuzzySets
Moduleprotocol FuzzySet
This abstraction requires a fuzzy set to provide a
grade(forElement:)
method which accepts a parameter of anassociatedtype Universe
and returns its membershipGrade
in the set. There are 3 provided concrete implementations in this module:struct AnyFuzzySet
- allows type erasure. It only stores aMembershipFunction
and has non-mutable methods.struct IterableFuzzySet
- stores aMembershipFunction
as well as aSequence
of elements of the associated typeUniverse
. ImplementsSequence
so that it can easily be iterated over them. The elements of the iteration over anIterableFuzzySet
arestruct
s containinggrade
andelement
properties. It has non-mutable methods only. Includessupport
,core
andheight
computed properties.struct DiscreteMutableFuzzySet
- it is “discrete” because it doesn’t stores aMembershipFunction
but instead keeps its elements and their grade in aDictionary
, and it is “mutable” because it contains mutable equivalents of all other methods that operate over the set (includingsubscript
). A default value of0
is returned for the grade of an element that is not in the dictionary (a different default value can be provided as well). Includessupport
,core
andheight
computed properties. A bonus feature is its debug print using Zadeh’s notation.Convertions between the 3 types are easy and possible using the
eraseToAnyFuzzySet
,makeIterable
andmakeDiscreteMutable
methods defined on them.protocol FuzzySetOperations
All 3 concrete types implement it. It requires the following methods that operate on fuzzy sets:
alphaCut(_:alpha:)
complement(method:)
intersection(_:method:)
union(_:method:)
difference(_:method:)
symmetricDifference(_:method:)
power(_:n:)
appliedCustomFunction(_:function:)
License
MIT