FluentFuzzy 0.1.0-d-2023-08-25-17-17-26
See the version list below for details.
dotnet add package FluentFuzzy --version 0.1.0-d-2023-08-25-17-17-26
NuGet\Install-Package FluentFuzzy -Version 0.1.0-d-2023-08-25-17-17-26
<PackageReference Include="FluentFuzzy" Version="0.1.0-d-2023-08-25-17-17-26" />
paket add FluentFuzzy --version 0.1.0-d-2023-08-25-17-17-26
#r "nuget: FluentFuzzy, 0.1.0-d-2023-08-25-17-17-26"
// Install FluentFuzzy as a Cake Addin #addin nuget:?package=FluentFuzzy&version=0.1.0-d-2023-08-25-17-17-26&prerelease // Install FluentFuzzy as a Cake Tool #tool nuget:?package=FluentFuzzy&version=0.1.0-d-2023-08-25-17-17-26&prerelease
FuzzyLogic
FuzzyLogic is a package for doing fuzzy logic in .NET with a natural fluent syntax.
FuzzyLogic is very much WIP and should be expected to be updated with breaking changes.
Contents
FuzzyLogic
contains the core fuzzy logic functionality.
FuzzyLogic.Visualization
has visualization for some FuzzyLogic
classes.
Using
After importing the Nuget package, using FuzzyLogic is a 2-step process.
Setting up input and output
FuzzyInput
s and FuzzyOutput
s can be set up in the following manner:
var health = new FuzzyInput(() => GetHealth());
var flee = new FuzzyOutput();
FuzzyInput
requires a Func<double>
to get the current crisp value of the input.
Setting up member functions
The next step is adding member functions to each input:
var low = 0;
var medium = 1;
var high = 2;
health.Set(low, new Trapezoid(0, 0, 25, 50));
health.Set(medium, new Triangle(25, 50, 75));
health.Set(high, new Trapezoid(50, 75, 100, 100));
Currently, the following membership functions have been implemented:
Triangle
defines a triangle.Trapezoid
defines a trapezoid.Line
defines a line.Value
defines a single value.AtLeast
defines a threshold value.
Custom membership functions can be created by implementing the IMembershipFunction
interface.
After the input functions, membership functions can be added to the FuzzyOutput
flee.Set(low, new Triangle(-0.25, 0, 0.25))
flee.Set(medium, new Triangle(0.25, 0.5, 0.75))
flee.Set(high, new Triangle(0.75, 1, 1.25))
The only currently supported defuzzification method is a version of the centroid method. As some of the membership functions, namely Line
, Value
and AtLeast
do not have useful centroids, these cannot be used as output member functions.
Custom output membership functions can be created by implementing the IHasCentroid
interface.
Setting up fuzzy rules
After setting up the fuzzy inputs and outputs, rules can be created to connect them.
Rules are created with a readable fluent syntax:
FuzzyRule.If(health.Is(high)).Then(flee.Is(low));
FuzzyRule.If(health.Is(medium)).Then(flee.Is(medium));
FuzzyRule.If(health.Is(low)).Then(flee.Is(high));
Evaluating an output
After creating the fuzzy ruleset, the output can be evaluated by calling the Evaluate
method on the output:
Console.Log($"flee(health: {health.Value}) = {flee.Evaluate()}")
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0-d-2023-08-25-18-02-55 | 81 | 8/25/2023 |
0.1.0-d-2023-08-25-18-01-56 | 75 | 8/25/2023 |
0.1.0-d-2023-08-25-18-01-40 | 76 | 8/25/2023 |
0.1.0-d-2023-08-25-17-31-34 | 80 | 8/25/2023 |
0.1.0-d-2023-08-25-17-24-55 | 79 | 8/25/2023 |
0.1.0-d-2023-08-25-17-17-26 | 72 | 8/25/2023 |
0.1.0-d-2023-08-25-15-51-04 | 73 | 8/25/2023 |
0.1.0-d-2023-08-25-13-37-22 | 76 | 8/25/2023 |
0.1.0-d-2023-08-25-13-36-05 | 80 | 8/25/2023 |
0.1.0-d-2023-08-25-13-33-48 | 79 | 8/25/2023 |
0.1.0-d-2023-08-24-09-51-42 | 74 | 8/24/2023 |
0.1.0-d-2023-08-24-09-45-42 | 84 | 8/24/2023 |
0.1.0-d-2023-08-24-00-26-55 | 76 | 8/24/2023 |
0.1.0-d-2023-08-23-18-00-51 | 80 | 8/23/2023 |
0.1.0-d-2023-08-23-17-54-36 | 75 | 8/23/2023 |
0.1.0-d-2023-08-23-17-51-51 | 77 | 8/23/2023 |