fuzzylite

fuzzylite: a fuzzy logic control library in C++

https://github.com/fuzzylite/fuzzylite

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.5%) to scientific vocabulary

Keywords

artificial-intelligence c-plus-plus fuzzy-logic fuzzy-logic-control fuzzylite fuzzylite-libraries soft-computing
Last synced: 6 months ago · JSON representation ·

Repository

fuzzylite: a fuzzy logic control library in C++

Basic Info
  • Host: GitHub
  • Owner: fuzzylite
  • License: gpl-3.0
  • Language: C++
  • Default Branch: main
  • Homepage: https://fuzzylite.com
  • Size: 25.8 MB
Statistics
  • Stars: 307
  • Watchers: 15
  • Forks: 69
  • Open Issues: 8
  • Releases: 3
Topics
artificial-intelligence c-plus-plus fuzzy-logic fuzzy-logic-control fuzzylite fuzzylite-libraries soft-computing
Created over 11 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Funding License Citation

README.md

fuzzylite

fuzzylite 7.0.0

A Fuzzy Logic Control Library in C++

by Juan Rada-Vilela, PhD [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://opensource.org/license/gpl-3-0/) [![License: Paid](https://img.shields.io/badge/License-proprietary-blue)](mailto:sales@fuzzylite.com) [![Linux Build](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-linux.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-linux.yml) [![macOS Build](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-macos.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-macos.yml) [![Windows Build](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-windows.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/main-windows.yml) [![Linux Build (monthly)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-linux.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-linux.yml) [![macOS Build (monthly)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-macos.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-macos.yml) [![Windows Build (monthly)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-windows.yml/badge.svg)](https://github.com/fuzzylite/fuzzylite/actions/workflows/monthly-windows.yml) [![Coverage Status](https://coveralls.io/repos/github/fuzzylite/fuzzylite/badge.svg?branch=main)]( https://coveralls.io/github/fuzzylite/fuzzylite?branch=main)

FuzzyLite

The FuzzyLite Libraries for Fuzzy Logic Control refer to fuzzylite (C++), pyfuzzylite (Python), and jfuzzylite (Java).

The goal of the FuzzyLite Libraries is to easily design and efficiently operate fuzzy logic controllers following an object-oriented programming model with minimal dependency on external libraries.

License

fuzzylite is dual-licensed under the GNU GPL 3.0 and under a proprietary license for commercial purposes.

You are strongly encouraged to support the development of the FuzzyLite Libraries by purchasing a license of QtFuzzyLite.

QtFuzzyLite is the best graphical user interface available to easily design and directly operate fuzzy logic controllers in real time. Available for Windows, Mac, and Linux, its goal is to significantly speed up the design of your fuzzy logic controllers, while providing a very useful, functional and beautiful user interface. Please, download it and check it out for free at fuzzylite.com/downloads.

Documentation

Visit fuzzylite.com/documentation

Features

(6) Controllers: 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) Conjunction and Implication (T-Norms): Minimum, AlgebraicProduct, BoundedDifference, DrasticProduct, EinsteinProduct, HamacherProduct, NilpotentMinimum, LambdaNorm, FunctionNorm.

(11) Disjunction and Aggregation (S-Norms): 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.

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

(30+) Examples of Mamdani, Takagi-Sugeno, Tsukamoto, and Hybrid controllers from fuzzylite, Octave, and Matlab, each included in the following formats: C++, Java, fll, fld, R, fis, and fcl.

Example

FuzzyLite Language

```yaml

File: 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 ```

```cpp //File: ObstacleAvoidance.cpp

include

fl::Engine* engine = fl::FllImporter().fromFile("ObstacleAvoidance.fll"); ```

C++

```cpp //File: ObstacleAvoidance.cpp

include

using namespace fuzzylite;

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

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

Operation

```cpp using namespace fuzzylite;

std::string status; if (not engine->isReady(&status)) throw Exception("[engine error] engine is not ready:\n" + status, FL_AT);

InputVariable* obstacle = engine->getInputVariable("obstacle"); OutputVariable* steer = engine->getOutputVariable("steer");

for (int i = 0; i <= 50; ++i){ scalar location = obstacle->getMinimum() + i * (obstacle->range() / 50); obstacle->setValue(location); engine->process(); FL_LOG("obstacle.input = " << Op::str(location) << " => " << "steer.output = " << Op::str(steer->getValue())); } ```

Compile, Link, and Execute

Once you have an engine written in C++, you can compile it to create an executable file which links to the fuzzylite library. The linking can be either static or dynamic. Basically, the differences between static and dynamic linking are the following.

Static linking includes the fuzzylite library into your executable file, hence increasing its size, but the executable no longer needs to have access to the fuzzylite library files.

Dynamic linking does not include the fuzzylite library into your executable file, hence reducing its size, but the executable needs to have access to the fuzzylite shared library file. When using dynamic linking, make sure that the shared library files are either in the same directory as the executable, or are reachable via environmental variables:

posh rem Windows: set PATH="\path\to\fuzzylite\release\bin;%PATH%"

```bash

Unix:

export LDLIBRARYPATH="/path/to/fuzzylite/release/bin/:$LDLIBRARYPATH" ```

Windows

The commands to compile your engine in Windows are the following:

C++11 (default)

posh rem static linking: cl.exe ObstacleAvoidance.cpp fuzzylite-static.lib /Ipath/to/fuzzylite /EHsc /MD

posh rem dynamic linking: cl.exe ObstacleAvoidance.cpp fuzzylite.lib /Ipath/to/fuzzylite /DFL_IMPORT_LIBRARY /EHsc /MD

C++98

posh rem static linking: cl.exe ObstacleAvoidance.cpp fuzzylite-static.lib /Ipath/to/fuzzylite /DFL_CPP98=ON /EHsc /MD

posh rem dynamic linking: cl.exe ObstacleAvoidance.cpp fuzzylite.lib /Ipath/to/fuzzylite /DFL_IMPORT_LIBRARY /DFL_CPP98=ON /EHsc /MD

Unix

The commands to compile your engine in Unix are the following:

C++11 (default)

```bash

static linking

g++ ObstacleAvoidance.cpp -o ObstacleAvoidance -I/path/to/fuzzylite -L/path/to/fuzzylite/release/bin -lfuzzylite-static --std=c++11 ```

```bash

dynamic linking

g++ ObstacleAvoidance.cpp -o ObstacleAvoidance -I/path/to/fuzzylite -L/path/to/fuzzylite/release/bin -lfuzzylite ```

C++98

```bash

static linking

g++ ObstacleAvoidance.cpp -o ObstacleAvoidance -I/path/to/fuzzylite -L/path/to/fuzzylite/release/bin -lfuzzylite-static -DFL_CPP98=ON ```

```bash

dynamic linking

g++ ObstacleAvoidance.cpp -o ObstacleAvoidance -I/path/to/fuzzylite -L/path/to/fuzzylite/release/bin -lfuzzylite -DFL_CPP98=ON ```

CMake

Alternatively, you can use CMake to build your project linking to fuzzylite. Please, refer to the example application available at examples/application.

Building from Source

You can build the fuzzylite library from source using CMake (cmake.org).

Check .github/workflows for details.

Unix

bash cmake -B build/ -G"Unix Makefiles" . cmake --build build/ --parallel ctest --test-dir build/

Windows

bash cmake -B build/ -G"NMake Makefiles" . cmake --build build/ ctest --test-dir build/

Building Options

The following building options available:

-DFL_USE_FLOAT=ON builds the binaries using the fl::scalar data type as a float instead of double. By default, the binaries are built using -DFL_USE_FLOAT=OFF. If fuzzylite is built with -DFL_USE_FLOAT=ON, then the applications linking to fuzzylite also need to specify this compilation flag.

-DFL_CPP98=ON builds binaries using C++98 features instead of C++11. By default, the binaries are built using -DFL_CPP98=OFF. If you use C++98, you will not be able to benchmark the performance of your engine using the Benchmark class, and you will not be able to run any of the tests.

-DFL_BACKTRACE=OFF disables the backtrace information in case of errors. By default, the binaries are built using -DFL_BACKTRACE=ON. In Windows, the backtrace information requires the external library dbghelp, which is generally available in your system.

Documentation

The source code of fuzzylite is very well documented using doxygen formatting, and the documentation is available at fuzzylite.com/documentation. If you want to generate the documentation locally, you can produce the html documentation from the file Doxyfile using the command line: doxygen Doxyfile. The documentation will be created in the docs folder.

Binaries

After building from source, the following are the relevant binaries that will be created in Release mode. In Debug mode, the file names end with -debug (e.g., fuzzylite-debug.exe).

Windows

  • console application: fuzzylite.exe
  • shared library: fuzzylite.dll, fuzzylite.lib
  • static library: fuzzylite-static.lib

Linux

  • console application: fuzzylite
  • shared library: libfuzzylite.so
  • static library: libfuzzylite-static.a

Mac

  • console application: fuzzylite
  • shared library: libfuzzylite.dylib
  • static library: libfuzzylite-static.a

Console

The console application of fuzzylite allows you to import and export your engines. Its usage can be obtained executing the console binary. In addition, the console can be set in interactive mode. The FuzzyLite Interactive Console allows you to evaluate a given controller by manually providing the input values. The interactive console is triggered by specifying an input file and an output format. For example, to interact with the ObstacleAvoidance controller, the interactive console is launched as follows:

bash fuzzylite -i ObstacleAvoidance.fll -of fld

Contributing

All contributions are welcome, provided they follow the following guidelines:

  • Source code is consistent with standards in the library
  • Contribution is properly documented and tested, raising issues where appropriate
  • Contribution is licensed under the FuzzyLite License

Reference

If you are using the FuzzyLite Libraries, please cite the following reference in your article:

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

Or using bibtex:

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 Limited
jfuzzylite™ is a trademark of FuzzyLite Limited
pyfuzzylite™ is a trademark of FuzzyLite Limited
QtFuzzyLite™ is a trademark of FuzzyLite Limited

Owner

  • Name: FuzzyLite
  • Login: fuzzylite
  • Kind: organization
  • Email: sales@fuzzylite.com
  • Location: Australia

The FuzzyLite Libraries for Fuzzy Logic Control

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: fuzzylite
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Juan
    family-names: Rada-Vilela
    email: jcrada@fuzzylite.com
    affiliation: FuzzyLite Limited
repository-code: 'https://github.com/fuzzylite/fuzzylite'
url: 'https://fuzzylite.com'
abstract: >-
  The goal of the FuzzyLite Libraries is to easily design
  and efficiently operate fuzzy logic controllers following
  an object-oriented programming model with minimal
  dependency on external libraries.
keywords:
  - Artificial Intelligence
  - Fuzzy Logic
  - Control
  - Soft Computing
  - FuzzyLite
license: GPL-3.0

GitHub Events

Total
  • Issues event: 6
  • Watch event: 27
  • Delete event: 20
  • Issue comment event: 30
  • Push event: 79
  • Pull request event: 48
  • Fork event: 2
  • Create event: 24
Last Year
  • Issues event: 6
  • Watch event: 27
  • Delete event: 20
  • Issue comment event: 30
  • Push event: 79
  • Pull request event: 48
  • Fork event: 2
  • Create event: 24

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 56
  • Total pull requests: 52
  • Average time to close issues: 7 months
  • Average time to close pull requests: 20 days
  • Total issue authors: 16
  • Total pull request authors: 14
  • Average comments per issue: 2.16
  • Average comments per pull request: 1.42
  • Merged pull requests: 35
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 4
  • Average time to close issues: about 22 hours
  • Average time to close pull requests: 3 days
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 1.5
  • Average comments per pull request: 0.75
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jcrada (30)
  • josch (10)
  • pgarcia-dev (2)
  • ecksun (2)
  • mich-j (2)
  • ghost (2)
  • etam (1)
  • janisozaur (1)
  • seungjaemoon (1)
  • tom-i (1)
  • DilHem (1)
  • ieshaan12 (1)
  • susnux (1)
  • AMDmi3 (1)
  • minotaur-0 (1)
Pull Request Authors
  • jcrada (78)
  • sguazt (5)
  • janisozaur (4)
  • AMDmi3 (3)
  • josch (2)
  • ecksun (2)
  • vmarkovtsev (2)
  • 9468305 (2)
  • stefaj (1)
  • ArseniyShestakov (1)
  • cosmoiler (1)
  • mich-j (1)
  • ghost (1)
  • CJxD (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

examples/mamdani/octave/DESCRIPTION cran
  • octave >= 3.2.4 depends
examples/original/mamdani/octave/DESCRIPTION cran
  • octave >= 3.2.4 depends
examples/original/takagi-sugeno/octave/DESCRIPTION cran
  • octave >= 3.2.4 depends
examples/takagi-sugeno/octave/DESCRIPTION cran
  • octave >= 3.2.4 depends
.github/workflows/LinuxFullBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
.github/workflows/LinuxMediumBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
.github/workflows/LinuxQuickBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/cache/save v4 composite
  • actions/checkout v4 composite
.github/workflows/MacFullBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
.github/workflows/MacMediumBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
.github/workflows/MacQuickBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/cache/save v4 composite
  • actions/checkout v4 composite
.github/workflows/WindowsFullBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
  • ilammy/msvc-dev-cmd v1 composite
.github/workflows/WindowsMediumBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/checkout v4 composite
  • ilammy/msvc-dev-cmd v1 composite
.github/workflows/WindowsQuickBuild.yml actions
  • actions/cache/restore v4 composite
  • actions/cache/save v4 composite
  • actions/checkout v4 composite
  • ilammy/msvc-dev-cmd v1 composite