Skip to content

Commit 71ca709

Browse files
authored
add sugeno inference system (#5)
* rename FuzzyInferenceSystem to MamdaniInferenceSystem * initial Sugeno inference system implementation * add plotting for sugeno membership functions * Update sugeno system - better API docs - differentiate between membership functions and sugeno outputs * add plotting tests and sugeno tutorial * fix typos
1 parent 3132e5a commit 71ca709

22 files changed

+619
-133
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using FuzzyLogic
3232
## Quickstart example
3333

3434
```julia
35-
fis = @fis function tipper(service, food)::tip
35+
fis = @mamfis function tipper(service, food)::tip
3636
service := begin
3737
domain = 0:10
3838
poor = GaussianMF(0.0, 1.5)

docs/make.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ generate_memberships()
101101
makedocs(;
102102
modules = [FuzzyLogic], authors = "Luca Ferranti",
103103
sitename = "FuzzyLogic.jl",
104-
doctest = false,
104+
doctest = false, checkdocs = :exports, strict = true,
105105
format = Documenter.HTML(;
106106
assets = [DocThemeIndigo.install(FuzzyLogic)],
107107
prettyurls = IS_CI, collapselevel = 1,
@@ -110,10 +110,17 @@ makedocs(;
110110
"Home" => "index.md",
111111
"Tutorials" => [
112112
"Build a Mamdani inference system" => "tutorials/mamdani.md",
113+
"Build a Sugeno inference system" => "tutorials/sugeno.md",
113114
],
114115
"API" => [
115-
"Inference system" => "api/fis.md",
116+
"Inference system API" => [
117+
"Types" => "api/fis.md",
118+
"Logical connectives" => "api/logical.md",
119+
"Aggregation methods" => "api/aggregation.md",
120+
"Defuzzification methods" => "api/defuzzification.md",
121+
],
116122
"Membership functions" => "api/memberships.md",
123+
"Reading/Writing" => "api/readwrite.md",
117124
],
118125
"Contributor's Guide" => "contributing.md",
119126
"Release notes" => "changelog.md",

docs/src/api/aggregation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Aggregation methods
2+
3+
```@autodocs
4+
Modules = [FuzzyLogic]
5+
Filter = t -> typeof(t) === DataType && t <: FuzzyLogic.AbstractAggregator
6+
```

docs/src/api/defuzzification.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Defuzzification methods
2+
3+
```@autodocs
4+
Modules = [FuzzyLogic]
5+
Filter = t -> typeof(t) === DataType && t <: FuzzyLogic.AbstractDefuzzifier
6+
```

docs/src/api/fis.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,15 @@
11
# Inference Systems
22

3-
## Inference systems
3+
## Mamdani inference system
44

55
```@docs
6-
FuzzyInferenceSystem
7-
@fis
6+
MamdaniFuzzySystem
87
```
98

10-
11-
## Inference system settings
12-
13-
### Conjuction methods
14-
15-
```@docs
16-
MinAnd
17-
ProdAnd
18-
```
19-
20-
### Disjunction methods
21-
22-
```@docs
23-
MaxOr
24-
ProbSumOr
25-
```
26-
27-
### Implication methods
28-
29-
```@docs
30-
MinImplication
31-
ProdImplication
32-
```
33-
34-
### Aggregation methods
35-
36-
```@docs
37-
MaxAggregator
38-
ProbSumAggregator
39-
```
40-
41-
### Defuzzification methods
9+
## Sugeno inference system
4210

4311
```@docs
44-
CentroidDefuzzifier
45-
BisectorDefuzzifier
12+
SugenoFuzzySystem
13+
ConstantSugenoOutput
14+
LinearSugenoOutput
4615
```

docs/src/api/logical.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Logical connectives
2+
3+
## Conjuction methods
4+
5+
```@autodocs
6+
Modules = [FuzzyLogic]
7+
Filter = t -> typeof(t) === DataType && t <: FuzzyLogic.AbstractAnd
8+
```
9+
10+
## Disjunction methods
11+
12+
```@autodocs
13+
Modules = [FuzzyLogic]
14+
Filter = t -> typeof(t) === DataType && t <: FuzzyLogic.AbstractOr
15+
```
16+
17+
## Implication methods
18+
19+
```@autodocs
20+
Modules = [FuzzyLogic]
21+
Filter = t -> typeof(t) === DataType && t <: FuzzyLogic.AbstractImplication
22+
```

docs/src/api/readwrite.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Reading / writing functionalities
2+
3+
## Parse Julia code
4+
5+
```@docs
6+
@mamfis
7+
@sugfis
8+
```

docs/src/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1515
- min and prod implication
1616
- max and probabilistic sum aggregation method
1717
- centroid and bisector defuzzifier
18+
- linear and constant output for Sugeno
1819
- initial plotting functionalities
1920
- plotting variables and membership functions
2021
- plotting rules of fuzzy inference system

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using FuzzyLogic
3232
## Quickstart example
3333

3434
```julia
35-
fis = @fis function tipper(service in 0:10, food in 0:10)::{tip in 0:30}
35+
fis = @mamfis function tipper(service in 0:10, food in 0:10)::{tip in 0:30}
3636
poor = GaussianMF(0.0, 1.5)
3737
good = GaussianMF(5.0, 1.5)
3838
excellent = GaussianMF(10.0, 1.5)

docs/src/literate/tutorials/mamdani.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ First, we need to load the library.
2424

2525
using FuzzyLogic
2626

27-
# The Mamdani inference system can be constructed with the [`@fis`](@ref) macro.
27+
# The Mamdani inference system can be constructed with the [`@mamfis`](@ref) macro.
2828
# We will first give a full example and then explain every step.
2929

30-
fis = @fis function tipper(service, food)::tip
30+
fis = @mamfis function tipper(service, food)::tip
3131
service := begin
3232
domain = 0:10
3333
poor = GaussianMF(0.0, 1.5)
@@ -61,7 +61,7 @@ fis = @fis function tipper(service, food)::tip
6161
end
6262

6363
#=
64-
As you can see, defining a fuzzy inference system with `@fis` looks a lot like writing
64+
As you can see, defining a fuzzy inference system with `@mamfis` looks a lot like writing
6565
Julia code. Let us now take a closer look at the components. The first line
6666
6767
```julia
@@ -133,14 +133,13 @@ and = ProdAnd
133133
are used to set the settings of the inference system. For a Mamdani inference system,
134134
the following settings are available
135135
136-
- `and`: algorithm to evaluate `&&`. Must be one of the available [Conjuction methods](@ref).
137-
- `or`: algorithm to evaluate `||`. Must be one of the available [Disjunction methods](@ref).
138-
- `implication`: algorithm to evalute `-->`. Must be one of the available [Implication methods](@ref).
139-
- `aggregato`: algorithm to perform outputs aggregation. Must be one of the available [Aggregation methods](@ref).
140-
- `defuzzifier`: algorithm to perform defuzzification. Must be one of the available [Defuzzification methods](@ref).
136+
- `and`: algorithm to evaluate `&&`. Must be one of the available [Conjuction methods](@ref). Default [`MinAnd`](@ref).
137+
- `or`: algorithm to evaluate `||`. Must be one of the available [Disjunction methods](@ref). Default [`MaxOr`](@ref)
138+
- `implication`: algorithm to evalute `-->`. Must be one of the available [Implication methods](@ref). Default [`MinImplication`](@ref).
139+
- `aggregato`: algorithm to perform outputs aggregation. Must be one of the available [Aggregation methods](@ref). Default [`MaxAggregator`](@ref).
140+
- `defuzzifier`: algorithm to perform defuzzification. Must be one of the available [Defuzzification methods](@ref). Default [`CentroidDefuzzifier`](@ref).
141141
142-
Each of the previous settings has a default value that will be used if the setting is not specified.
143-
The default values are listed in [`FuzzyInferenceSystem`](@ref) documentation.
142+
If one of the above settings is not specified, the corresponding default value is used.
144143
145144
Some of the above settings may have internal parameters.
146145
For example, [`CentroidDefuzzifier`](@ref) has an integer parameter `N`, the number of points used to perform numerical integration.

0 commit comments

Comments
 (0)