# pyfuzzylite 8.0.2
<img src="https://fuzzylite.github.io/pyfuzzylite/image/fuzzylite.svg" align="left" alt="fuzzylite">
## A Fuzzy Logic Control Library in Python
by [**Juan Rada-Vilela, PhD**](https://fuzzylite.com/about)
<br>
<br>
[![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)
[![Coverage Status](
https://coveralls.io/repos/github/fuzzylite/pyfuzzylite/badge.svg?branch=main)](
https://coveralls.io/github/fuzzylite/pyfuzzylite?branch=main)
[![Build](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/build.yml/badge.svg)](
https://github.com/fuzzylite/pyfuzzylite/actions/workflows/build.yml)
[![Test](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/test.yml/badge.svg)](
https://github.com/fuzzylite/pyfuzzylite/actions/workflows/test.yml)
[![Publish](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/publish.yml/badge.svg)](
https://github.com/fuzzylite/pyfuzzylite/actions/workflows/publish.yml)
## <a name="fuzzylite">FuzzyLite</a>
**The FuzzyLite Libraries for Fuzzy Logic Control** refer to [`fuzzylite`](https://github.com/fuzzylite/fuzzylite/)
(C++), [`pyfuzzylite`](https://github.com/fuzzylite/pyfuzzylite/) (Python),
and [`jfuzzylite`](https://github.com/fuzzylite/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.
## <a name="license">License</a>
`pyfuzzylite` is dual-licensed under the [**GNU GPL 3.0**](https://opensource.org/license/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`](https://fuzzylite.com/downloads).
[`QtFuzzyLite`](https://fuzzylite.com/downloads/) 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](https://fuzzylite.com/downloads).
## <a name="install">Install</a>
```commandline
pip install pyfuzzylite
```
## <a name="features">Features</a>
**Documentation**: [fuzzylite.github.io/pyfuzzylite/](https://fuzzylite.github.io/pyfuzzylite/)
**(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`. With `fuzzylite`: Fuzzy Inference System `fis`, Fuzzy Control
Language `fcl`.
**(7) Exporters**: `Python`, FuzzyLite Language `fll`, FuzzyLite Dataset `fld`. With `fuzzylite`: `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: `py`, `fll`, `fld`. With `fuzzylite`: `C++`, `Java`, `R`, `fis`, and `fcl`.
## <a name="examples">Examples</a>
### FuzzyLite Language
```yaml
# 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
```
```python
# Python
import fuzzylite as fl
engine = fl.FllImporter().from_file("examples/mamdani/ObstacleAvoidance.fll")
```
### Python
```python
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"),
],
)
],
)
```
### `float` and vectorization
```python
# single `float` operation
engine.input_variable("obstacle").value = 0.5
engine.process()
print("y =", engine.output_variable("mSteer").value)
# > y = 0.5
print("ỹ =", engine.output_variable("mSteer").fuzzy_value())
# > ỹ = 0.500/left + 0.500/right
# vectorization
engine.input_variable("obstacle").value = fl.array([0, 0.25, 0.5, 0.75, 1.0])
engine.process()
print("y =", repr(engine.output_variable("mSteer").value))
# > y = array([0.6666665 , 0.62179477, 0.5 , 0.37820523, 0.3333335 ])
print("ỹ =", repr(engine.output_variable("mSteer").fuzzy_value()))
# > ỹ = array(['0.000/left + 1.000/right',
# '0.250/left + 0.750/right',
# '0.500/left + 0.500/right',
# '0.750/left + 0.250/right',
# '1.000/left + 0.000/right'], dtype='<U26')
```
Please refer to the documentation for more
information: [**fuzzylite.github.io/pyfuzzylite/**](https://fuzzylite.github.io/pyfuzzylite/)
## <a name="contributing">Contributing</a>
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
## <a name="reference">Reference</a>
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 <br>
jfuzzylite™ is a trademark of FuzzyLite Limited <br>
pyfuzzylite™ is a trademark of FuzzyLite Limited <br>
QtFuzzyLite™ is a trademark of FuzzyLite Limited <br>
Raw data
{
"_id": null,
"home_page": "https://github.com/fuzzylite/pyfuzzylite.git",
"name": "pyfuzzylite",
"maintainer": "Juan Rada-Vilela, PhD",
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": "jcrada@fuzzylite.com",
"keywords": "fuzzy logic control, soft computing, artificial intelligence",
"author": "Juan Rada-Vilela, PhD",
"author_email": "jcrada@fuzzylite.com",
"download_url": "https://files.pythonhosted.org/packages/3b/ff/59181d92947a61d8e93e684b566b9d569da264af869b56d6abdd6b8a4a1a/pyfuzzylite-8.0.2.tar.gz",
"platform": null,
"description": "# pyfuzzylite 8.0.2\n\n<img src=\"https://fuzzylite.github.io/pyfuzzylite/image/fuzzylite.svg\" align=\"left\" alt=\"fuzzylite\">\n\n## A Fuzzy Logic Control Library in Python\n\nby [**Juan Rada-Vilela, PhD**](https://fuzzylite.com/about)\n\n<br>\n<br>\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://opensource.org/license/gpl-3-0/)\n[![License: Paid](https://img.shields.io/badge/License-proprietary-blue)](mailto:sales@fuzzylite.com)\n[![Coverage Status](\nhttps://coveralls.io/repos/github/fuzzylite/pyfuzzylite/badge.svg?branch=main)](\nhttps://coveralls.io/github/fuzzylite/pyfuzzylite?branch=main)\n[![Build](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/build.yml/badge.svg)](\nhttps://github.com/fuzzylite/pyfuzzylite/actions/workflows/build.yml)\n[![Test](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/test.yml/badge.svg)](\nhttps://github.com/fuzzylite/pyfuzzylite/actions/workflows/test.yml)\n[![Publish](https://github.com/fuzzylite/pyfuzzylite/actions/workflows/publish.yml/badge.svg)](\nhttps://github.com/fuzzylite/pyfuzzylite/actions/workflows/publish.yml)\n\n## <a name=\"fuzzylite\">FuzzyLite</a>\n\n**The FuzzyLite Libraries for Fuzzy Logic Control** refer to [`fuzzylite`](https://github.com/fuzzylite/fuzzylite/)\n(C++), [`pyfuzzylite`](https://github.com/fuzzylite/pyfuzzylite/) (Python),\nand [`jfuzzylite`](https://github.com/fuzzylite/jfuzzylite/) (Java).\n\nThe **goal** of the FuzzyLite Libraries is to **easily** design and **efficiently** operate fuzzy logic controllers\nfollowing an **object-oriented** programming model with minimal dependency on external libraries.\n\n## <a name=\"license\">License</a>\n\n`pyfuzzylite` is dual-licensed under the [**GNU GPL 3.0**](https://opensource.org/license/gpl-3-0/) and under a\n**proprietary license for commercial purposes**.\n\nYou are **strongly** encouraged to support the development of the FuzzyLite Libraries by purchasing a license\nof [`QtFuzzyLite`](https://fuzzylite.com/downloads).\n\n[`QtFuzzyLite`](https://fuzzylite.com/downloads/) is the best graphical user interface available to easily design and\ndirectly operate fuzzy logic controllers in real time. Available for Windows, Mac, and Linux, its goal is to\nsignificantly **speed up** the design of your fuzzy logic controllers, while providing a very **useful**, **functional**\nand **beautiful** user interface.\nPlease, download it and check it out for free at [fuzzylite.com/downloads](https://fuzzylite.com/downloads).\n\n## <a name=\"install\">Install</a>\n\n```commandline\npip install pyfuzzylite\n```\n\n## <a name=\"features\">Features</a>\n\n**Documentation**: [fuzzylite.github.io/pyfuzzylite/](https://fuzzylite.github.io/pyfuzzylite/)\n\n**(6) Controllers**: Mamdani, Takagi-Sugeno, Larsen, Tsukamoto, Inverse Tsukamoto, Hybrid\n\n**(25) Linguistic terms**: (5) *Basic*: Triangle, Trapezoid, Rectangle, Discrete, SemiEllipse.\n(8) *Extended*: Bell, Cosine, Gaussian, GaussianProduct, PiShape, SigmoidDifference, SigmoidProduct, Spike.\n(7) *Edges*: Arc, Binary, Concave, Ramp, Sigmoid, SShape, ZShape.\n(3) *Functions*: Constant, Linear, Function. (2) *Special*: Aggregated, Activated.\n\n**(7) Activation methods**: General, Proportional, Threshold, First, Last, Lowest, Highest.\n\n**(9) Conjunction and Implication (T-Norms)**: Minimum, AlgebraicProduct, BoundedDifference, DrasticProduct,\nEinsteinProduct, HamacherProduct, NilpotentMinimum, LambdaNorm, FunctionNorm.\n\n**(11) Disjunction and Aggregation (S-Norms)**: Maximum, AlgebraicSum, BoundedSum, DrasticSum, EinsteinSum,\nHamacherSum, NilpotentMaximum, NormalizedSum, UnboundedSum, LambdaNorm, FunctionNorm.\n\n**(7) Defuzzifiers**: (5) *Integral*: Centroid, Bisector, SmallestOfMaximum, LargestOfMaximum, MeanOfMaximum.\n(2) *Weighted*: WeightedAverage, WeightedSum.\n\n**(7) Hedges**: Any, Not, Extremely, Seldom, Somewhat, Very, Function.\n\n**(3) Importers**: FuzzyLite Language `fll`. With `fuzzylite`: Fuzzy Inference System `fis`, Fuzzy Control\nLanguage `fcl`.\n\n**(7) Exporters**: `Python`, FuzzyLite Language `fll`, FuzzyLite Dataset `fld`. With `fuzzylite`: `C++`, `Java`,\nFuzzyLite Language `fll`, FuzzyLite Dataset `fld`, `R` script, Fuzzy Inference System `fis`, Fuzzy Control\nLanguage `fcl`.\n\n**(30+) Examples** of Mamdani, Takagi-Sugeno, Tsukamoto, and Hybrid controllers from `fuzzylite`, Octave, and Matlab,\neach included in the following formats: `py`, `fll`, `fld`. With `fuzzylite`: `C++`, `Java`, `R`, `fis`, and `fcl`.\n\n## <a name=\"examples\">Examples</a>\n\n### FuzzyLite Language\n\n```yaml\n# File: examples/mamdani/ObstacleAvoidance.fll\nEngine: ObstacleAvoidance\nInputVariable: obstacle\n enabled: true\n range: 0.000 1.000\n lock-range: false\n term: left Ramp 1.000 0.000\n term: right Ramp 0.000 1.000\nOutputVariable: mSteer\n enabled: true\n range: 0.000 1.000\n lock-range: false\n aggregation: Maximum\n defuzzifier: Centroid 100\n default: nan\n lock-previous: false\n term: left Ramp 1.000 0.000\n term: right Ramp 0.000 1.000\nRuleBlock: mamdani\n enabled: true\n conjunction: none\n disjunction: none\n implication: AlgebraicProduct\n activation: General\n rule: if obstacle is left then mSteer is right\n rule: if obstacle is right then mSteer is left\n```\n\n```python\n# Python\nimport fuzzylite as fl\n\nengine = fl.FllImporter().from_file(\"examples/mamdani/ObstacleAvoidance.fll\")\n```\n\n### Python\n\n```python\nimport fuzzylite as fl\n\nengine = fl.Engine(\n name=\"ObstacleAvoidance\",\n input_variables=[\n fl.InputVariable(\n name=\"obstacle\",\n minimum=0.0,\n maximum=1.0,\n lock_range=False,\n terms=[fl.Ramp(\"left\", 1.0, 0.0), fl.Ramp(\"right\", 0.0, 1.0)],\n )\n ],\n output_variables=[\n fl.OutputVariable(\n name=\"mSteer\",\n minimum=0.0,\n maximum=1.0,\n lock_range=False,\n lock_previous=False,\n default_value=fl.nan,\n aggregation=fl.Maximum(),\n defuzzifier=fl.Centroid(resolution=100),\n terms=[fl.Ramp(\"left\", 1.0, 0.0), fl.Ramp(\"right\", 0.0, 1.0)],\n )\n ],\n rule_blocks=[\n fl.RuleBlock(\n name=\"mamdani\",\n conjunction=None,\n disjunction=None,\n implication=fl.AlgebraicProduct(),\n activation=fl.General(),\n rules=[\n fl.Rule.create(\"if obstacle is left then mSteer is right\"),\n fl.Rule.create(\"if obstacle is right then mSteer is left\"),\n ],\n )\n ],\n)\n```\n\n### `float` and vectorization\n\n```python\n# single `float` operation\nengine.input_variable(\"obstacle\").value = 0.5\nengine.process()\nprint(\"y =\", engine.output_variable(\"mSteer\").value)\n# > y = 0.5\nprint(\"\u1ef9 =\", engine.output_variable(\"mSteer\").fuzzy_value())\n# > \u1ef9 = 0.500/left + 0.500/right\n\n# vectorization\nengine.input_variable(\"obstacle\").value = fl.array([0, 0.25, 0.5, 0.75, 1.0])\nengine.process()\nprint(\"y =\", repr(engine.output_variable(\"mSteer\").value))\n# > y = array([0.6666665 , 0.62179477, 0.5 , 0.37820523, 0.3333335 ])\nprint(\"\u1ef9 =\", repr(engine.output_variable(\"mSteer\").fuzzy_value()))\n# > \u1ef9 = array(['0.000/left + 1.000/right',\n# '0.250/left + 0.750/right',\n# '0.500/left + 0.500/right',\n# '0.750/left + 0.250/right',\n# '1.000/left + 0.000/right'], dtype='<U26')\n```\n\nPlease refer to the documentation for more\ninformation: [**fuzzylite.github.io/pyfuzzylite/**](https://fuzzylite.github.io/pyfuzzylite/)\n\n## <a name=\"contributing\">Contributing</a>\n\nAll contributions are welcome, provided they follow the following guidelines:\n\n- Source code is consistent with standards in the library\n- Contribution is properly documented and tested, raising issues where appropriate\n- Contribution is licensed under the FuzzyLite License\n\n## <a name=\"reference\">Reference</a>\n\nIf you are using the FuzzyLite Libraries, please cite the following reference in your article:\n\n> Juan Rada-Vilela. The FuzzyLite Libraries for Fuzzy Logic Control, 2018. URL https://fuzzylite.com.\n\nOr using `bibtex`:\n\n```bibtex\n@misc{fl::fuzzylite,\n author={Juan Rada-Vilela},\n title={The FuzzyLite Libraries for Fuzzy Logic Control},\n url={https://fuzzylite.com},\n year={2018}\n}\n```\n\n***\n\nfuzzylite® is a registered trademark of FuzzyLite Limited <br>\njfuzzylite™ is a trademark of FuzzyLite Limited <br>\npyfuzzylite™ is a trademark of FuzzyLite Limited <br>\nQtFuzzyLite™ is a trademark of FuzzyLite Limited <br>\n\n",
"bugtrack_url": null,
"license": "Proprietary",
"summary": "a fuzzy logic control library in Python",
"version": "8.0.2",
"project_urls": {
"Bug Tracker": "https://github.com/fuzzylite/pyfuzzylite/issues",
"Documentation": "https://fuzzylite.github.io/pyfuzzylite/",
"Homepage": "https://github.com/fuzzylite/pyfuzzylite.git",
"Repository": "https://github.com/fuzzylite/pyfuzzylite.git",
"Source Code": "https://github.com/fuzzylite/pyfuzzylite"
},
"split_keywords": [
"fuzzy logic control",
" soft computing",
" artificial intelligence"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5175fa27656bab22022dc0926200be8ca4f89ecdd25389f01121274b095e587",
"md5": "cff51baf2ad13dafb81bcc6a9a608e5b",
"sha256": "410edee2f7c58f9b1478c809aaa9f8975db05e6a95a1ffd5b98266a0fa999479"
},
"downloads": -1,
"filename": "pyfuzzylite-8.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cff51baf2ad13dafb81bcc6a9a608e5b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 740266,
"upload_time": "2024-04-26T03:53:41",
"upload_time_iso_8601": "2024-04-26T03:53:41.985127Z",
"url": "https://files.pythonhosted.org/packages/d5/17/5fa27656bab22022dc0926200be8ca4f89ecdd25389f01121274b095e587/pyfuzzylite-8.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3bff59181d92947a61d8e93e684b566b9d569da264af869b56d6abdd6b8a4a1a",
"md5": "8a3dc7970b5ffc907fd1980963b4c505",
"sha256": "40e78bea498562a4323ea4d603f8ae0b6d796d770f20184848d3dd97bf51e6d9"
},
"downloads": -1,
"filename": "pyfuzzylite-8.0.2.tar.gz",
"has_sig": false,
"md5_digest": "8a3dc7970b5ffc907fd1980963b4c505",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 702024,
"upload_time": "2024-04-26T03:53:43",
"upload_time_iso_8601": "2024-04-26T03:53:43.626642Z",
"url": "https://files.pythonhosted.org/packages/3b/ff/59181d92947a61d8e93e684b566b9d569da264af869b56d6abdd6b8a4a1a/pyfuzzylite-8.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-26 03:53:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fuzzylite",
"github_project": "pyfuzzylite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "nox",
"specs": [
[
"~=",
"2023.4.22"
]
]
},
{
"name": "poetry",
"specs": [
[
"~=",
"1.7.1"
]
]
}
],
"lcname": "pyfuzzylite"
}