FuzzyLogic.jl
FuzzyLogic.jl copied to clipboard
Real- valued arguments desirable for membership functions
Would like membership functions to be defined on real- valued arguments. Presently only integer- valued arguments are possible. Thanks.
Hi there :wave: ,
thank you for your interest!
Could you clarify what you mean that currently only integers are possible? It should work with floating-point numbers without problems
julia> using FuzzyLogic
julia> mf = TriangularMF(1.0, 2.0, 3.0)
TriangularMF{Float64}(1.0, 2.0, 3.0)
julia> m2 = TriangularMF(1.1, 2.3, 4.5)
TriangularMF{Float64}(1.1, 2.3, 4.5)
julia> mf(1.1)
0.10000000000000009
julia> m2(1.1)
0.0
julia> m2(1.5)
0.3333333333333333
Hi
Thanks for the fast response. I've highlighted the place where Julia refused to let me give real values like what I've shown, and threw up Error.
I'll try to share a screenshot in 24h from the ide (vs code) , but I hope this screenshot might help.
Thanks again Vijay
On Sat, 27 May, 2023, 8:35 pm Luca Ferranti, @.***> wrote:
Hi there 👋 ,
thank you for your interest!
Could you clarify what you mean that currently only integers are possible? I dont think it's the case
julia> using FuzzyLogic
julia> mf = TriangularMF(1.0, 2.0, 3.0)TriangularMF{Float64}(1.0, 2.0, 3.0)
julia> m2 = TriangularMF(1.1, 2.3, 4.5)TriangularMF{Float64}(1.1, 2.3, 4.5)
julia> mf(1.1)0.10000000000000009
julia> m2(1.1)0.0
julia> m2(1.5)0.3333333333333333
— Reply to this email directly, view it on GitHub https://github.com/lucaferranti/FuzzyLogic.jl/issues/26#issuecomment-1565475555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP52V5SB3XOFLDDGPPAP2GLXIIJ2DANCNFSM6AAAAAAYQIT2ZM . You are receiving this because you authored the thread.Message ID: @.***>
Hi, yes a screen-shot would be very helpful.
Meanwhile, if I had to try to guess your issue, I would guess you encountered the following
julia> mf = TriangularMF(1, 2.1, 3.1)
ERROR: MethodError: no method matching TriangularMF(::Int64, ::Float64, ::Float64)
Closest candidates are:
TriangularMF(::T, ::T, ::T) where T<:Real
@ FuzzyLogic ~/.julia/dev/FuzzyLogic/src/membership_functions.jl:63
the problem here is that for many membership functions it expects all parameters to be of the same type, so either all integers or all floats. In that case, you would have to type
mf = TriangularMF(1.0, 2.1, 3.1)
this philosophy (all of the same type) is common in statically typed languages. There would be three possible fixes of this
- Leave it as is, and document better the inputs should either be all floats or all integer $^*$
- Support automatically promoting inputs, so that
TrinagularMF(1, 2.1 3.1)would automatically becomeTriangularMF(1.0, 2.1, 3.1) - Parametrize each membership function by the type of each parameter.
I can think of small drawbacks of each solution, so none is perfect.
$^*$ For completeness, there is an important exception where mixed types are supported, that is
julia> GeneralizedBellMF(1.0, 2, 3.0)
GeneralizedBellMF{Float64, Int64}(1.0, 2, 3.0)
The reason for this is the following: for other membership functions (triangular, gaussian, etc.) supporting mixed types is just a small short-cut, since one can always type TriangularMF(1.0, 2.1, 3.0) without any drawback. Indeed, it's very likely that the integer will be promoted to float at the first operation of the inference pipeline.
In the case of the Generalized Bell MF, however, the second parameter is significantly different from the others. The first and third are, respectively, a variance and a mean, while the second one is an exponent. It's much more reasonable to expect an exponent to be integer and also float ^ integer is much faster than float ^ float, which is why for the generalized bell membership function I chose from the beginning to support different types
(the close issue was a misclick, reopened ;) )
Hi
Yes, that's the error.
Have attached separate screenshots of the input to 'cheap' and 'average' and the error.
Thanks again for the prompt response. Vijay
Dr. B. V. Vijay 91-8073345633 @.***
[image: Screenshot 2023-05-28 at 8.12.16 PM.png]
[image: Screenshot 2023-05-28 at 8.12.42 PM.png]
On Sun, 28 May 2023 at 13:55, Luca Ferranti @.***> wrote:
Hi, yes a screen-shot would be very helpful.
Meanwhile, if I had to try to guess your issue, I would guess you encountered the following
julia> mf = TriangularMF(1, 2.0, 3.0) ERROR: MethodError: no method matching TriangularMF(::Int64, ::Float64, ::Float64)
Closest candidates are: TriangularMF(::T, ::T, ::T) where T<:Real @ FuzzyLogic ~/.julia/dev/FuzzyLogic/src/membership_functions.jl:63
— Reply to this email directly, view it on GitHub https://github.com/lucaferranti/FuzzyLogic.jl/issues/26#issuecomment-1565994091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP52V5QKW4QPDYZ4NXVMCYDXIMDW3ANCNFSM6AAAAAAYQIT2ZM . You are receiving this because you authored the thread.Message ID: @.***>
I don't see your attached screenshots unfortunately.
For now you should be able to overcome the problem by typing the integer as float (e.g. 1.0 instead of 1), does this get you unblocked?
I'll try to update the user interface to be more friendly and accept mixed inputs in the upcoming days.
---------- Forwarded message --------- From: Dr. B. V. Vijay @.> Date: Sun, 28 May, 2023, 8:24 pm Subject: Re: [lucaferranti/FuzzyLogic.jl] Real- valued arguments desirable for membership functions (Issue #26) To: lucaferranti/FuzzyLogic.jl < @.>
Hi
Yes, that's the error.
Have attached separate screenshots of the input to 'cheap' and 'average' and the error.
Thanks again for the prompt response. Vijay
Dr. B. V. Vijay 91-8073345633 @.***
[image: Screenshot 2023-05-28 at 8.12.16 PM.png]
[image: Screenshot 2023-05-28 at 8.12.42 PM.png]
On Sun, 28 May 2023 at 13:55, Luca Ferranti @.***> wrote:
Hi, yes a screen-shot would be very helpful.
Meanwhile, if I had to try to guess your issue, I would guess you encountered the following
julia> mf = TriangularMF(1, 2.0, 3.0) ERROR: MethodError: no method matching TriangularMF(::Int64, ::Float64, ::Float64)
Closest candidates are: TriangularMF(::T, ::T, ::T) where T<:Real @ FuzzyLogic ~/.julia/dev/FuzzyLogic/src/membership_functions.jl:63
— Reply to this email directly, view it on GitHub https://github.com/lucaferranti/FuzzyLogic.jl/issues/26#issuecomment-1565994091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP52V5QKW4QPDYZ4NXVMCYDXIMDW3ANCNFSM6AAAAAAYQIT2ZM . You are receiving this because you authored the thread.Message ID: @.***>
In an upcoming release, one will be able to automatically create membership functions with mixed precisions, like
GaussianMF(1, 2.0)
TriangularMF(2, 4.0, 5//1)
and the constructor will automatically handle the promotion for all membership functions. This however relies on new features of Julia 1.10, so will have to wait for it to be released. I will notify on this issue, once this is implemented.
Meanwhile, you can manually convert those to floats, e.g. writing GaussianMF(1.0, 2.5) instead of GaussianMF(1, 2.5)
Thanks for your mail. Looking forward to the new features.
On Sun, 26 Nov, 2023, 7:08 pm Luca Ferranti, @.***> wrote:
In an upcoming release, one will be able to automatically create membership functions with mixed precisions, like
GaussianMF(1, 2.0)TriangularMF(2, 4.0, 5//1)
and the constructor will automatically handle the promotion for all membership functions. This however relies on new features of Julia 1.10, so will have to wait for it to be released. I will notify on the issue, once this is implemented.
Meanwhile, you can manually convert those to floats, e.g. writing GaussianMF(1.0, 2.5) instead of GaussianMF(1, 2.5)
— Reply to this email directly, view it on GitHub https://github.com/lucaferranti/FuzzyLogic.jl/issues/26#issuecomment-1826787000, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP52V5QT6YT6JRKYTBYJ5NTYGNA4PAVCNFSM6AAAAAAYQIT2ZOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWG44DOMBQGA . You are receiving this because you authored the thread.Message ID: @.***>