Skip to content

fuzzylite

The FuzzyLite Libraries for Fuzzy Logic Control

by Juan Rada-Vilela, PhD



The objective of the FuzzyLite Libraries is to easily design and efficiently operate fuzzy logic controllers
using object-oriented programming with minimal reliance on external libraries.


License

The FuzzyLite Libraries are dual-licensed under:

Please contact sales@fuzzylite.com for more information.

Repositories

fuzzylite (C++)

fuzzylite/fuzzylite - GitHub

pyfuzzylite (Python)

fuzzylite/pyfuzzylite - GitHub

jfuzzylite (Java)

fuzzylite/jfuzzylite - GitHub

help

fuzzylite/help - GitHub

Examples

# File: examples/mamdani/ObstacleAvoidance.fll
Engine: ObstacleAvoidance
InputVariable: obstacle
  enabled: true
  range: 0.000 1.000
  lock-range: false
  term: left Ramp 1.000 0.000
  term: right Ramp 0.000 1.000
OutputVariable: mSteer
  enabled: true
  range: 0.000 1.000
  lock-range: false
  aggregation: Maximum
  defuzzifier: Centroid 100
  default: nan
  lock-previous: false
  term: left Ramp 1.000 0.000
  term: right Ramp 0.000 1.000
RuleBlock: mamdani
  enabled: true
  conjunction: none
  disjunction: none
  implication: AlgebraicProduct
  activation: General
  rule: if obstacle is left then mSteer is right
  rule: if obstacle is right then mSteer is left
// C++
#include "fl/Headers.h"

fl::Engine* engine = fl::FllImporter().fromFile("examples/mamdani/ObstacleAvoidance.fll");
# Python
import fuzzylite as fl

engine = fl.FllImporter().from_file("examples/mamdani/ObstacleAvoidance.fll")
// Java
import com.fuzzylite.*;

Engine engine = new FllImporter().fromFile("examples/mamdani/ObstacleAvoidance.fll");
#include "fl/Headers.h"

using namespace fl;

Engine* engine = new Engine;
engine->setName("ObstacleAvoidance");

InputVariable* obstacle = new InputVariable;
obstacle->setName("obstacle");
obstacle->setDescription("");
obstacle->setEnabled(true);
obstacle->setRange(0.000, 1.000);
obstacle->setLockValueInRange(false);
obstacle->addTerm(new Ramp("left", 1.000, 0.000));
obstacle->addTerm(new Ramp("right", 0.000, 1.000));
engine->addInputVariable(obstacle);

OutputVariable* mSteer = new OutputVariable;
mSteer->setName("mSteer");
mSteer->setDescription("");
mSteer->setEnabled(true);
mSteer->setRange(0.000, 1.000);
mSteer->setLockValueInRange(false);
mSteer->setAggregation(new Maximum);
mSteer->setDefuzzifier(new Centroid(100));
mSteer->setDefaultValue(fl::nan);
mSteer->setLockPreviousValue(false);
mSteer->addTerm(new Ramp("left", 1.000, 0.000));
mSteer->addTerm(new Ramp("right", 0.000, 1.000));
engine->addOutputVariable(mSteer);

RuleBlock* mamdani = new RuleBlock;
mamdani->setName("mamdani");
mamdani->setDescription("");
mamdani->setEnabled(true);
mamdani->setConjunction(fl::null);
mamdani->setDisjunction(fl::null);
mamdani->setImplication(new AlgebraicProduct);
mamdani->setActivation(new General);
mamdani->addRule(Rule::parse("if obstacle is left then mSteer is right", engine));
mamdani->addRule(Rule::parse("if obstacle is right then mSteer is left", engine));
engine->addRuleBlock(mamdani);
import fuzzylite as fl

engine = fl.Engine(
    name="ObstacleAvoidance",
    input_variables=[
        fl.InputVariable(
            name="obstacle",
            minimum=0.0,
            maximum=1.0,
            lock_range=False,
            terms=[fl.Ramp("left", 1.0, 0.0), fl.Ramp("right", 0.0, 1.0)],
        )
    ],
    output_variables=[
        fl.OutputVariable(
            name="mSteer",
            minimum=0.0,
            maximum=1.0,
            lock_range=False,
            lock_previous=False,
            default_value=fl.nan,
            aggregation=fl.Maximum(),
            defuzzifier=fl.Centroid(resolution=100),
            terms=[fl.Ramp("left", 1.0, 0.0), fl.Ramp("right", 0.0, 1.0)],
        )
    ],
    rule_blocks=[
        fl.RuleBlock(
            name="mamdani",
            conjunction=None,
            disjunction=None,
            implication=fl.AlgebraicProduct(),
            activation=fl.General(),
            rules=[
                fl.Rule.create("if obstacle is left then mSteer is right"),
                fl.Rule.create("if obstacle is right then mSteer is left"),
            ],
        )
    ],
)
import com.fuzzylite.*;

Engine engine = new Engine();
engine.setName("ObstacleAvoidance");

InputVariable obstacle = new InputVariable();
obstacle.setName("obstacle");
obstacle.setDescription("");
obstacle.setEnabled(true);
obstacle.setRange(0.000, 1.000);
obstacle.setLockValueInRange(false);
obstacle.addTerm(new Ramp("left", 1.000, 0.000));
obstacle.addTerm(new Ramp("right", 0.000, 1.000));
engine.addInputVariable(obstacle);

OutputVariable mSteer = new OutputVariable();
mSteer.setName("mSteer");
mSteer.setDescription("");
mSteer.setEnabled(true);
mSteer.setRange(0.000, 1.000);
mSteer.setLockValueInRange(false);
mSteer.setAggregation(new Maximum());
mSteer.setDefuzzifier(new Centroid(100));
mSteer.setDefaultValue(Double.NaN);
mSteer.setLockPreviousValue(false);
mSteer.addTerm(new Ramp("left", 1.000, 0.000));
mSteer.addTerm(new Ramp("right", 0.000, 1.000));
engine.addOutputVariable(mSteer);

RuleBlock mamdani = new RuleBlock();
mamdani.setName("mamdani");
mamdani.setDescription("");
mamdani.setEnabled(true);
mamdani.setConjunction(null);
mamdani.setDisjunction(null);
mamdani.setImplication(new AlgebraicProduct());
mamdani.setActivation(new General());
mamdani.addRule(Rule.parse("if obstacle is left then mSteer is right", engine));
mamdani.addRule(Rule.parse("if obstacle is right then mSteer is left", engine));
engine.addRuleBlock(mamdani);

Features

6 Controller Types

Mamdani, Takagi-Sugeno, Larsen, Tsukamoto, Inverse Tsukamoto, Hybrid.

25 Linguistic Terms

5 Basic: Triangle, Trapezoid, Rectangle, Discrete, SemiEllipse.

8 Extended: Bell, Cosine, Gaussian, GaussianProduct, PiShape, SigmoidDifference, SigmoidProduct, Spike.

7 Edges: Arc, Binary, Concave, Ramp, Sigmoid, SShape, ZShape.

3 Functions: Constant, Linear, Function.

2 Special: Aggregated, Activated.

7 Activation methods

General, Proportional, Threshold, First, Last, Lowest, Highest.

9 T-Norms for Conjunction and Implication

Minimum, AlgebraicProduct, BoundedDifference, DrasticProduct, EinsteinProduct, HamacherProduct, NilpotentMinimum, LambdaNorm, FunctionNorm.

11 S-Norms for Disjunction and Aggregation

Maximum, AlgebraicSum, BoundedSum, DrasticSum, EinsteinSum, HamacherSum, NilpotentMaximum, NormalizedSum, UnboundedSum, LambdaNorm, FunctionNorm.

7 Defuzzifiers

5 Integral: Centroid, Bisector, SmallestOfMaximum, LargestOfMaximum, MeanOfMaximum.

2 Weighted: WeightedAverage, WeightedSum.

7 Hedges

Any, Not, Extremely, Seldom, Somewhat, Very, Function.

3 Importers

FuzzyLite Language (fll), Fuzzy Inference System (fis), Fuzzy Control Language (fcl).

8 Exporters

Python, C++, Java, FuzzyLite Language (fll), FuzzyLite Dataset (fld), R script, Fuzzy Inference System (fis), Fuzzy Control Language (fcl).

30+ Examples

Mamdani, Takagi-Sugeno, Tsukamoto, and Hybrid controllers from fuzzylite, Octave, and Matlab.

Examples in C++, Python, Java, fll, fld, R, fis, and fcl.

Flexibility

Easily extend the library by adding your own linguistic terms, activation methods, T-Norms and S-Norms, defuzzifiers, and hedges.

Reference

If you are using the FuzzyLite Libraries, please cite our article as follows:

Juan Rada-Vilela. The FuzzyLite Libraries for Fuzzy Logic Control, 2018. URL https://fuzzylite.com.

Or using bibtex:

@misc{
    fl::fuzzylite,
    author={Juan Rada-Vilela},
    title={The FuzzyLite Libraries for Fuzzy Logic Control},
    url={https://fuzzylite.com},
    year={2018}
}

fuzzylite® is a registered trademark of FuzzyLite
pyfuzzylite™ is a trademark of FuzzyLite
jfuzzylite™ is a trademark of FuzzyLite
QtFuzzyLite™ is a trademark of FuzzyLite