Olve.Fuzzy 0.63.2

dotnet add package Olve.Fuzzy --version 0.63.2
                    
NuGet\Install-Package Olve.Fuzzy -Version 0.63.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Olve.Fuzzy" Version="0.63.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Olve.Fuzzy" Version="0.63.2" />
                    
Directory.Packages.props
<PackageReference Include="Olve.Fuzzy" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Olve.Fuzzy --version 0.63.2
                    
#r "nuget: Olve.Fuzzy, 0.63.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Olve.Fuzzy@0.63.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Olve.Fuzzy&version=0.63.2
                    
Install as a Cake Addin
#tool nuget:?package=Olve.Fuzzy&version=0.63.2
                    
Install as a Cake Tool

Olve.Fuzzy

NuGet Docs

Fuzzy logic with a fluent rule syntax: inputs with member functions, rules that read like sentences, and centroid defuzzification of the outputs.

Olve.Fuzzy is the core of FluentFuzzy (MIT, Oliver Vea), moved into Olve.Utilities.


Installation

dotnet add package Olve.Fuzzy

Overview

Type Description
FuzzyInput An input variable: a crisp value read through a Func<double>, and member functions keyed by int.
FuzzyOutput An output variable: member functions keyed by int, and the rules attached to them. Evaluate() defuzzifies.
FuzzyRule Entry point of the fluent rule syntax: If(...).And(...).Or(...).Then(...).And(...).Else(...).ElseIf(...).
Triangle, Trapezoid Member functions usable for inputs and outputs.
Line, Value, AtLeast Member functions for inputs only (they have no useful centroid).
IMemberFunction Implement for a custom input member function.
IHasCentroid Implement for a custom output member function.

Usage

Inputs and outputs

A FuzzyInput takes a Func<double> that returns its current crisp value. The function is called on every evaluation.

// ../../tests/Olve.Fuzzy.Tests/ReadmeDemo.cs#L10-L12

var healthValue = 35.0;
var health = new FuzzyInput(() => healthValue);
var flee = new FuzzyOutput();

Member functions

Each input gets a member function per antecedent, keyed by an int:

// ../../tests/Olve.Fuzzy.Tests/ReadmeDemo.cs#L14-L20

const int low = 0;
const int medium = 1;
const int 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));

Outputs take member functions that implement IHasCentroid, as defuzzification uses a version of the centroid method. Line, Value and AtLeast have no useful centroid, so they are input-only.

// ../../tests/Olve.Fuzzy.Tests/ReadmeDemo.cs#L22-L24

flee.Set(low, new Triangle(-0.5, 0, 0.5));
flee.Set(medium, new Triangle(0, 0.5, 1));
flee.Set(high, new Triangle(0.5, 1, 1.5));

Rules

Rules connect input conditions to output consequents:

// ../../tests/Olve.Fuzzy.Tests/ReadmeDemo.cs#L26-L28

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));

And takes the minimum, Or the maximum, and IsNot/Else the negation (1 - truth).

Evaluating

// ../../tests/Olve.Fuzzy.Tests/ReadmeDemo.cs#L30-L30

var result = flee.Evaluate(); // ≈ 0.78

Rule sets and threads

Inputs read their values through a Func<double>, and rules attach to the outputs. An output therefore holds its rule set, and every rule you build adds to it. Build the inputs, outputs and rules per evaluation context (e.g. per roll, per actor), and don't share them across threads.


Documentation

Full API reference: https://olivervea.github.io/Olve.Utilities/api/Olve.Fuzzy.html


License

MIT License © OliverVea

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • 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.63.2 59 11/13/2026