Skip to content

Inference Engines and Defuzzification Types

david grupp edited this page Aug 31, 2014 · 2 revisions

Inference Engines and Defuzzification Types

Inference Engines

The package comes with two inferences engines. There is a Center of Gravity engine and Middle of Maximum Engine.

Using Default (CoG) Engine:

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

fuzzyEngine.Rules.If(water.Is(cold)).Then(power.Is(low));
fuzzyEngine.Rules.If(water.Is(hot)).Then(power.Is(high));

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

If you want to use a different defuzzification method you can pass that type into the engine factory. Example using MoM Engine:

IFuzzyEngine fuzzyEngine = new FuzzyEngineFactory().Create(new MoMDefuzzification());

fuzzyEngine.Rules.If(water.Is(cold)).Then(power.Is(low));
fuzzyEngine.Rules.If(water.Is(hot)).Then(power.Is(high));

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

Adding Custom Inference Engines

Creating a custom inference engine is easy but remember in most cases you may want to create a custom defuzzification and pass it into the fuzzy engine factory.

public class MyFuzzyEngine : IFuzzyEngine
{
     public Double Defuzzify(Object inputValues)
     {
         ...
     }

     public FuzzyRuleCollection Rules { get; set; }
}

Defuzzification

Adding Custom Defuzzification Type

public class MyDefuzzification : IDefuzzification
{
    public Double Defuzzify(List<IMembershipFunction> functions)
    {
        ...
    }
}