simpful


Namesimpful JSON
Version 2.12.0 PyPI version JSON
download
home_pagehttps://github.com/aresio/simpful
SummaryA user-friendly Python library for fuzzy logic
upload_time2024-02-27 12:56:10
maintainer
docs_urlNone
authorMarco S. Nobile
requires_python
licenseLICENSE.txt
keywords fuzzy logic sugeno mamdani reasoner python modeling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Python package](https://github.com/aresio/simpful/workflows/Python%20package/badge.svg?branch=master)
[![Documentation Status](https://readthedocs.org/projects/simpful/badge/?version=latest)](https://simpful.readthedocs.io/en/latest/?badge=latest)

# simpful
A Python library for fuzzy logic reasoning, designed to provide a simple and lightweight API, as close as possible to natural language.
Simpful supports Mamdani and Sugeno reasoning of any order, parsing any complex fuzzy rules involving AND, OR, and NOT operators, using arbitrarily shaped fuzzy sets.
For more information on its usage, try out the example scripts in this repository or check our [online documentation](https://simpful.readthedocs.io/en/latest/).

## Installation

`pip install simpful`

## Citing Simpful

If you find Simpful useful for your research, please cite our work as follows:

Spolaor S., Fuchs C., Cazzaniga P., Kaymak U., Besozzi D., Nobile M.S.: Simpful: a user-friendly Python library for fuzzy logic, International Journal of Computational Intelligence Systems, 13(1):1687–1698, 2020
[DOI:10.2991/ijcis.d.201012.002](https://doi.org/10.2991/ijcis.d.201012.002)

## Usage example 1: controlling a gas burner with a Takagi-Sugeno fuzzy system

This example shows how to specify the information about the linguistic variables, fuzzy sets, fuzzy rules, and input values to Simpful. The last line of code prints the result of the fuzzy reasoning.


```
import simpful as sf

# A simple fuzzy model describing how the heating power of a gas burner depends on the oxygen supply.

FS = sf.FuzzySystem()

# Define a linguistic variable.
S_1 = sf.FuzzySet( points=[[0, 1.],  [1., 1.],  [1.5, 0]],          term="low_flow" )
S_2 = sf.FuzzySet( points=[[0.5, 0], [1.5, 1.], [2.5, 1], [3., 0]], term="medium_flow" )
S_3 = sf.FuzzySet( points=[[2., 0],  [2.5, 1.], [3., 1.]],          term="high_flow" )
FS.add_linguistic_variable("OXI", sf.LinguisticVariable( [S_1, S_2, S_3] ))

# Define consequents.
FS.set_crisp_output_value("LOW_POWER", 0)
FS.set_crisp_output_value("MEDIUM_POWER", 25)
FS.set_output_function("HIGH_FUN", "OXI**2")

# Define fuzzy rules.
RULE1 = "IF (OXI IS low_flow) THEN (POWER IS LOW_POWER)"
RULE2 = "IF (OXI IS medium_flow) THEN (POWER IS MEDIUM_POWER)"
RULE3 = "IF (NOT (OXI IS low_flow)) THEN (POWER IS HIGH_FUN)"
FS.add_rules([RULE1, RULE2, RULE3])

# Set antecedents values, perform Sugeno inference and print output values.
FS.set_variable("OXI", .51)
print (FS.Sugeno_inference(['POWER']))
```

## Usage example 2: tipping with a Mamdani fuzzy system 

This second example shows how to model a FIS using Mamdani inference. It also shows some facilities 
that make modeling more concise and clear: automatic Triangles (i.e., pre-baked linguistic variables 
with equally spaced triangular fuzzy sets) and the automatic detection of the inference method.

```
from simpful import *

FS = FuzzySystem()

TLV = AutoTriangle(3, terms=['poor', 'average', 'good'], universe_of_discourse=[0,10])
FS.add_linguistic_variable("service", TLV)
FS.add_linguistic_variable("quality", TLV)

O1 = TriangleFuzzySet(0,0,13,   term="low")
O2 = TriangleFuzzySet(0,13,25,  term="medium")
O3 = TriangleFuzzySet(13,25,25, term="high")
FS.add_linguistic_variable("tip", LinguisticVariable([O1, O2, O3], universe_of_discourse=[0,25]))

FS.add_rules([
	"IF (quality IS poor) OR (service IS poor) THEN (tip IS low)",
	"IF (service IS average) THEN (tip IS medium)",
	"IF (quality IS good) OR (service IS good) THEN (tip IS high)"
	])

FS.set_variable("quality", 6.5) 
FS.set_variable("service", 9.8) 

tip = FS.inference()
```
## Additional examples

Additional example scripts are available in the [examples folder](https://github.com/aresio/simpful/tree/master/examples) of this GitHub and in our [Code Ocean capsule](https://codeocean.com/capsule/2230971/tree).

## Further info
Created by Marco S. Nobile at the Eindhoven University of Technology and Simone Spolaor at the University of Milano-Bicocca. 

If you need further information, please write an e-mail at: marco.nobile@unive.it.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aresio/simpful",
    "name": "simpful",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "fuzzy logic,sugeno,mamdani,reasoner,python,modeling",
    "author": "Marco S. Nobile",
    "author_email": "marco.nobile@unive.it",
    "download_url": "https://files.pythonhosted.org/packages/4f/29/eb3887c0627366d4121aae0c546dc0d7a5287dc64e6c1a00ced3645a813b/simpful-2.12.0.tar.gz",
    "platform": null,
    "description": "![Python package](https://github.com/aresio/simpful/workflows/Python%20package/badge.svg?branch=master)\n[![Documentation Status](https://readthedocs.org/projects/simpful/badge/?version=latest)](https://simpful.readthedocs.io/en/latest/?badge=latest)\n\n# simpful\nA Python library for fuzzy logic reasoning, designed to provide a simple and lightweight API, as close as possible to natural language.\nSimpful supports Mamdani and Sugeno reasoning of any order, parsing any complex fuzzy rules involving AND, OR, and NOT operators, using arbitrarily shaped fuzzy sets.\nFor more information on its usage, try out the example scripts in this repository or check our [online documentation](https://simpful.readthedocs.io/en/latest/).\n\n## Installation\n\n`pip install simpful`\n\n## Citing Simpful\n\nIf you find Simpful useful for your research, please cite our work as follows:\n\nSpolaor S., Fuchs C., Cazzaniga P., Kaymak U., Besozzi D., Nobile M.S.: Simpful: a user-friendly Python library for fuzzy logic, International Journal of Computational Intelligence Systems, 13(1):1687\u20131698, 2020\n[DOI:10.2991/ijcis.d.201012.002](https://doi.org/10.2991/ijcis.d.201012.002)\n\n## Usage example 1: controlling a gas burner with a Takagi-Sugeno fuzzy system\n\nThis example shows how to specify the information about the linguistic variables, fuzzy sets, fuzzy rules, and input values to Simpful. The last line of code prints the result of the fuzzy reasoning.\n\n\n```\nimport simpful as sf\n\n# A simple fuzzy model describing how the heating power of a gas burner depends on the oxygen supply.\n\nFS = sf.FuzzySystem()\n\n# Define a linguistic variable.\nS_1 = sf.FuzzySet( points=[[0, 1.],  [1., 1.],  [1.5, 0]],          term=\"low_flow\" )\nS_2 = sf.FuzzySet( points=[[0.5, 0], [1.5, 1.], [2.5, 1], [3., 0]], term=\"medium_flow\" )\nS_3 = sf.FuzzySet( points=[[2., 0],  [2.5, 1.], [3., 1.]],          term=\"high_flow\" )\nFS.add_linguistic_variable(\"OXI\", sf.LinguisticVariable( [S_1, S_2, S_3] ))\n\n# Define consequents.\nFS.set_crisp_output_value(\"LOW_POWER\", 0)\nFS.set_crisp_output_value(\"MEDIUM_POWER\", 25)\nFS.set_output_function(\"HIGH_FUN\", \"OXI**2\")\n\n# Define fuzzy rules.\nRULE1 = \"IF (OXI IS low_flow) THEN (POWER IS LOW_POWER)\"\nRULE2 = \"IF (OXI IS medium_flow) THEN (POWER IS MEDIUM_POWER)\"\nRULE3 = \"IF (NOT (OXI IS low_flow)) THEN (POWER IS HIGH_FUN)\"\nFS.add_rules([RULE1, RULE2, RULE3])\n\n# Set antecedents values, perform Sugeno inference and print output values.\nFS.set_variable(\"OXI\", .51)\nprint (FS.Sugeno_inference(['POWER']))\n```\n\n## Usage example 2: tipping with a Mamdani fuzzy system \n\nThis second example shows how to model a FIS using Mamdani inference. It also shows some facilities \nthat make modeling more concise and clear: automatic Triangles (i.e., pre-baked linguistic variables \nwith equally spaced triangular fuzzy sets) and the automatic detection of the inference method.\n\n```\nfrom simpful import *\n\nFS = FuzzySystem()\n\nTLV = AutoTriangle(3, terms=['poor', 'average', 'good'], universe_of_discourse=[0,10])\nFS.add_linguistic_variable(\"service\", TLV)\nFS.add_linguistic_variable(\"quality\", TLV)\n\nO1 = TriangleFuzzySet(0,0,13,   term=\"low\")\nO2 = TriangleFuzzySet(0,13,25,  term=\"medium\")\nO3 = TriangleFuzzySet(13,25,25, term=\"high\")\nFS.add_linguistic_variable(\"tip\", LinguisticVariable([O1, O2, O3], universe_of_discourse=[0,25]))\n\nFS.add_rules([\n\t\"IF (quality IS poor) OR (service IS poor) THEN (tip IS low)\",\n\t\"IF (service IS average) THEN (tip IS medium)\",\n\t\"IF (quality IS good) OR (service IS good) THEN (tip IS high)\"\n\t])\n\nFS.set_variable(\"quality\", 6.5) \nFS.set_variable(\"service\", 9.8) \n\ntip = FS.inference()\n```\n## Additional examples\n\nAdditional example scripts are available in the [examples folder](https://github.com/aresio/simpful/tree/master/examples) of this GitHub and in our [Code Ocean capsule](https://codeocean.com/capsule/2230971/tree).\n\n## Further info\nCreated by Marco S. Nobile at the Eindhoven University of Technology and Simone Spolaor at the University of Milano-Bicocca. \n\nIf you need further information, please write an e-mail at: marco.nobile@unive.it.\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "A user-friendly Python library for fuzzy logic",
    "version": "2.12.0",
    "project_urls": {
        "Homepage": "https://github.com/aresio/simpful"
    },
    "split_keywords": [
        "fuzzy logic",
        "sugeno",
        "mamdani",
        "reasoner",
        "python",
        "modeling"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d0eaebc2fb0b0f481994179b2ee2b8e6bbf0894d971594688c018375e7076ea",
                "md5": "dde62f784842165ac0c48fcf8478b3f7",
                "sha256": "333b5ec7daa199f9b87839d845f5f0aa318a98c4066e7e3b7e66e4beb18ff95e"
            },
            "downloads": -1,
            "filename": "simpful-2.12.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dde62f784842165ac0c48fcf8478b3f7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 24692,
            "upload_time": "2024-02-27T12:56:08",
            "upload_time_iso_8601": "2024-02-27T12:56:08.072173Z",
            "url": "https://files.pythonhosted.org/packages/9d/0e/aebc2fb0b0f481994179b2ee2b8e6bbf0894d971594688c018375e7076ea/simpful-2.12.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f29eb3887c0627366d4121aae0c546dc0d7a5287dc64e6c1a00ced3645a813b",
                "md5": "616fbc3733c6d0d99d7bf513f066de76",
                "sha256": "9c1290f0ad1b6674cb1567df055a809535924c714a6830f0a4aa0a8a3d60dddb"
            },
            "downloads": -1,
            "filename": "simpful-2.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "616fbc3733c6d0d99d7bf513f066de76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 27032,
            "upload_time": "2024-02-27T12:56:10",
            "upload_time_iso_8601": "2024-02-27T12:56:10.324011Z",
            "url": "https://files.pythonhosted.org/packages/4f/29/eb3887c0627366d4121aae0c546dc0d7a5287dc64e6c1a00ced3645a813b/simpful-2.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 12:56:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aresio",
    "github_project": "simpful",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "simpful"
}
        
Elapsed time: 0.19656s