davidgrupp / Fuzzy-Logic-Sharp

Fuzzy Logic Sharp for .NET
Apache License 2.0
44 stars 24 forks source link

FLS - Fuzzy Logic Sharp

What is Fuzzy Logic Sharp?

Fuzzy Logic Sharp is an open source library implementing a simple to use fuzzy logic system.

License: Apache License 2.0

Install via NuGet

Contributors

This project is looking for more contributors. If you have any interest in helping feel free to contact me or fork the project. We will make every effort to quickly evaluate and merge pull request that benefit the project.

Features

Usage

var water = new LinguisticVariable("Water");
var cold = water.MembershipFunctions.AddTrapezoid("Cold", 0, 0, 20, 40);
var warm = water.MembershipFunctions.AddTriangle("Warm", 30, 50, 70);
var hot = water.MembershipFunctions.AddTrapezoid("Hot", 50, 80, 100, 100);

var power = new LinguisticVariable("Power");
var low = power.MembershipFunctions.AddTriangle("Low", 0, 25, 50);
var high = power.MembershipFunctions.AddTriangle("High", 25, 50, 75);

IFuzzyEngine fuzzyEngine = new FuzzyEngineFactory().Default();

var rule1 = Rule.If(water.Is(cold).Or(water.Is(warm))).Then(power.Is(high));
var rule2 = Rule.If(water.Is(hot)).Then(power.Is(low));
fuzzyEngine.Rules.Add(rule1, rule2);

var result = fuzzyEngine.Defuzzify(new { water = 60 });

Road map

  1. FCL Support for saving and loading Fuzzy Systems.
  2. Additional defuzzification method implementations.
  3. Expand rule syntax and add additional operators.