-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from phelipe/feature/plot-points
Feature - plot points
- Loading branch information
Showing
6 changed files
with
87 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Fuzzy" | ||
uuid = "a9166f1b-85e5-4df0-9c26-e06b441f12e8" | ||
authors = ["Phelipe Wesley <[email protected]> and contributors"] | ||
version = "0.3.0" | ||
version = "0.3.1" | ||
|
||
[compat] | ||
julia = "1.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
get_dots(membership_function::MF, input_point_vector::Union{StepRange,StepRangeLen}) = | ||
get_dots(membership_function, collect(input_point_vector)) | ||
|
||
function get_dots(membership_function::MF, input_point_vector::Vector{T}) where {T<:Number} | ||
return Real.(map(x -> Fuzzy.eval(membership_function, x), input_point_vector)) | ||
end | ||
|
||
chart_prepare(sets_dict::Dict{String,N}, input_point_vector::Union{StepRange,StepRangeLen}) where {N<:MF} = | ||
chart_prepare(sets_dict, collect(input_point_vector)) | ||
|
||
|
||
""" | ||
Create points | ||
eval_fis(sets_dict, input_point_vector) | ||
Parameters | ||
---------- | ||
`sets_dict` dictionary of membership functions | ||
`input_point_vector` array of points | ||
""" | ||
function chart_prepare(sets_dict::Dict{String,N}, input_point_vector::Vector{T}) where {T<:Number,N<:MF} | ||
names = String[] | ||
outputs = Array{T,1}[] | ||
for (name, membership_function) in sets_dict | ||
push!(names, name) | ||
push!(outputs, get_dots(membership_function, input_point_vector)) | ||
end | ||
return Dict("names" => reshape(names, 1, :), "values" => outputs) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,40 @@ | ||
module Fuzzy | ||
|
||
export TriangularMF, GaussianMF, BellMF, TrapezoidalMF, SigmoidMF | ||
export TriangularMF, GaussianMF, BellMF, TrapezoidalMF, SigmoidMF | ||
|
||
export Rule, FISMamdani, FISSugeno | ||
export Rule, FISMamdani, FISSugeno | ||
|
||
export mean_at, eval_fis | ||
export mean_at, eval_fis | ||
|
||
export minimum_value, algebraic_product, bounded_difference, drastic_product, einstein_product, hamacher_product | ||
export chart_prepare | ||
|
||
export maximum_value, algebraic_sum, bounded_sum, drastic_sum, einstein_sum, hamacher_sum | ||
export minimum_value, algebraic_product, bounded_difference, drastic_product, einstein_product, hamacher_product | ||
|
||
# T-Norm | ||
include("T-norm.jl") | ||
export maximum_value, algebraic_sum, bounded_sum, drastic_sum, einstein_sum, hamacher_sum | ||
|
||
# S-Norm | ||
include("S-norm.jl") | ||
export MFDict | ||
|
||
# Membership functions | ||
include("MF.jl") | ||
# T-Norm | ||
include("T-norm.jl") | ||
|
||
# Membership functions evaluations | ||
include("EvalMF.jl") | ||
# S-Norm | ||
include("S-norm.jl") | ||
|
||
# FIS | ||
include("FIS.jl") | ||
# Membership functions | ||
include("MF.jl") | ||
|
||
# Evaluation functions | ||
include("Eval.jl") | ||
# Membership functions evaluations | ||
include("EvalMF.jl") | ||
|
||
# FIS | ||
include("FIS.jl") | ||
|
||
# Evaluation functions | ||
include("Eval.jl") | ||
|
||
#Dots function | ||
include("DotsMF.jl") | ||
|
||
MFDict = Dict{String,MF} | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
l_vertex = 2. | ||
center = 5. | ||
r_vertex = 7. | ||
l_vertex = 2.0 | ||
center = 5.0 | ||
r_vertex = 7.0 | ||
|
||
mf = TriangularMF(l_vertex, center, r_vertex) | ||
|
||
# Evaluation tests | ||
@assert Fuzzy.eval(mf, center) == 1 | ||
@assert Fuzzy.eval(mf, l_vertex) == Fuzzy.eval(mf, r_vertex) == 0. | ||
@assert Fuzzy.eval(mf, (l_vertex + center) / 2.) == Fuzzy.eval(mf, (r_vertex + center) / 2.) == 0.5 | ||
@assert Fuzzy.eval(mf, l_vertex) == Fuzzy.eval(mf, r_vertex) == 0.0 | ||
@assert Fuzzy.eval(mf, (l_vertex + center) / 2.0) == Fuzzy.eval(mf, (r_vertex + center) / 2.0) == 0.5 | ||
|
||
# Mean finding tests | ||
@assert Fuzzy.mean_at(mf, 1.) == center | ||
@assert Fuzzy.mean_at(mf, 0.) == (l_vertex + r_vertex) / 2. | ||
@assert Fuzzy.mean_at(mf, 1.0) == center | ||
@assert Fuzzy.mean_at(mf, 0.0) == (l_vertex + r_vertex) / 2.0 |