Title: | Fuzzy Inference System Design and Optimization |
---|---|
Description: | Fuzzy inference systems are based on fuzzy rules, which have a good capability for managing progressive phenomenons. This package is a basic implementation of the main functions to use a Fuzzy Inference System (FIS) provided by the open source software 'FisPro' <https://www.fispro.org>. 'FisPro' allows to create fuzzy inference systems and to use them for reasoning purposes, especially for simulating a physical or biological system. |
Authors: | Serge Guillaume [aut], Brigitte Charnomordic [aut], Jean-Luc Lablée [aut, cre], Hazaël Jones [ctb], Lydie Desperben [ctb], INRAE [cph] (National Research Institute for Agriculture, Food and Environment, France) |
Maintainer: | Jean-Luc Lablée <[email protected]> |
License: | CeCILL |
Version: | 1.1.4 |
Built: | 2024-11-28 06:56:26 UTC |
Source: | CRAN |
Class to manage a Fis "Fuzzy Inference System"
name
character vector, The name of the Fis
conjunction
character vector, The conjunction operator of rules in the Fis
Allowed values are: "min" (the default), "prod" or "luka"
Fis()
The default constructor to build an empty Fis
The Fis is initialized with "min" conjunction and empty name
The design must be completed using the available functions to add inputs, outputs and rules before it can be used for inference
Fis object
Fis(fis_file)
The constructor to build a Fis from a configuration file
The configuration file can be designed using the FisPro open source software
input_size()
integer value, The number of inputs in the Fis
add_input(input)
input
FisIn object, The input to add in the Fis
get_input(input_index)
get_inputs()
Get all inputs in the Fis
output_size()
integer value, The number of outputs in the Fis
add_output(output)
output
FisOut object, The output to add in the Fis
get_output(output_index)
get_outputs()
Get all outputs in the Fis
rule_size()
integer value, The number of rules in the Fis
add_rule(rule)
rule
Rule object, The rule to add in the Fis
get_rule(rule_index)
get_rules()
Get all rules in the Fis
infer(data)
Infers all outputs
data
numeric vector, matrix or data.frame, The input data or dataset to infer (the vector length or the number of columns must be equal to the number of inputs)
infer_output(data, output_index)
Infers a single output
data
numeric vector, matrix or data.frame, The input data or dataset to infer (the vector length or the number of columns must be equal to the number of inputs)
output_index
integer value, The index (1-based index) of the output to infer
numeric value or vector (in case of 2D input data)
Fuzzy Logic Elementary Glossary
# build a Fis from a configuration file fis_file <- system.file("extdata", "test.fis", package = "FisPro") fis <- NewFis(fis_file) # infers all outputs inferred <- fis$infer(c(0.25, 0.75)) # infers first output inferred_output1 <- fis$infer_output(c(0.25, 0.75), 1) # infers second output inferred_output2 <- fis$infer_output(c(0.25, 0.75), 2) # infers test_data dataset test_file <- system.file("extdata", "test_data.csv", package = "FisPro") dataset <- read.csv(test_file) inferred_dataset <- fis$infer(dataset) ######################################################################## # or build a Fis from scratch fis <- NewFis() fis$name <- "foo" # build the first input fisin1 <- NewFisIn(0, 1) fisin1$name <- "input1" fisin1$add_mf(NewMfTrapezoidalInf(0, 1)) fisin1$add_mf(NewMfTrapezoidalSup(0, 1)) fis$add_input(fisin1) # build the second input fisin2 <- NewFisIn(0, 1) fisin2$name <- "input2" fisin2$add_mf(NewMfTrapezoidalInf(0, 0.5)) fisin2$add_mf(NewMfTriangular(0, 0.5, 1)) fisin2$add_mf(NewMfTrapezoidalSup(0.5, 1)) fis$add_input(fisin2) # build an output fisout <- NewFisOutCrisp(0, 1) fisout$name <- "output" fis$add_output(fisout) # add rules to the Fis fis$add_rule(NewRule(c(1, 2), 0)) fis$add_rule(NewRule(c(2, 0), 1))
# build a Fis from a configuration file fis_file <- system.file("extdata", "test.fis", package = "FisPro") fis <- NewFis(fis_file) # infers all outputs inferred <- fis$infer(c(0.25, 0.75)) # infers first output inferred_output1 <- fis$infer_output(c(0.25, 0.75), 1) # infers second output inferred_output2 <- fis$infer_output(c(0.25, 0.75), 2) # infers test_data dataset test_file <- system.file("extdata", "test_data.csv", package = "FisPro") dataset <- read.csv(test_file) inferred_dataset <- fis$infer(dataset) ######################################################################## # or build a Fis from scratch fis <- NewFis() fis$name <- "foo" # build the first input fisin1 <- NewFisIn(0, 1) fisin1$name <- "input1" fisin1$add_mf(NewMfTrapezoidalInf(0, 1)) fisin1$add_mf(NewMfTrapezoidalSup(0, 1)) fis$add_input(fisin1) # build the second input fisin2 <- NewFisIn(0, 1) fisin2$name <- "input2" fisin2$add_mf(NewMfTrapezoidalInf(0, 0.5)) fisin2$add_mf(NewMfTriangular(0, 0.5, 1)) fisin2$add_mf(NewMfTrapezoidalSup(0.5, 1)) fis$add_input(fisin2) # build an output fisout <- NewFisOutCrisp(0, 1) fisout$name <- "output" fis$add_output(fisout) # add rules to the Fis fis$add_rule(NewRule(c(1, 2), 0)) fis$add_rule(NewRule(c(2, 0), 1))
Class to manage a Fis input
name
character vector, The name of the input
FisIn()
The default constructor to build an empty input with the default range [0, 1]
FisIn object
FisIn(minimum, maximum)
The constructor to build an empty input
FisIn(number_of_mfs, minimum, maximum)
The constructor to build an input with a regular standardized fuzzy partition
FisIn(breakpoints, minimum, maximum)
The constructor to build an input with an irregular standardized fuzzy partition
range()
numeric vector, The range of the input (min max values)
mf_size()
integer value, The number of Mfs in the input partition
add_mf(mf)
Add an Mf in the input partition
mf
Mf object, The Mf to add
get_mf(mf_index)
get_mfs()
Get all mfs in the input
is_standardized()
logical value, TRUE
if the input is a standardized fuzzy partition, FALSE
otherwise
Fuzzy Logic Elementary Glossary
input <- NewFisIn(0, 2) input$name <- "foo" input$add_mf(NewMfTrapezoidalInf(0, 1)) input$add_mf(NewMfTriangular(0, 1, 2)) input$add_mf(NewMfTrapezoidalSup(1, 2))
input <- NewFisIn(0, 2) input$name <- "foo" input$add_mf(NewMfTrapezoidalInf(0, 1)) input$add_mf(NewMfTriangular(0, 1, 2)) input$add_mf(NewMfTrapezoidalSup(1, 2))
The base class of Fis output (cannot be instantiate)
Use derived classes FisOutCrisp or FisOutFuzzy
name
character vector, The name of the output
range()
numeric vector, The range of the output (min max values)
Class to manage a Fis crisp output
defuzzification
character vector, The defuzzification operator of the crisp output
Allowed values are: "sugeno" (the default) or "MaxCrisp"
disjunction
character vector, The disjunction operator of the crisp output
Allowed values are: "max" (the default) or "sum"
FisOutCrisp class inherits all fields and methods of FisOut class
FisOutCrisp()
The default constructor to build a crisp output with the default range [0, 1]
FisOutCrisp object
FisOutCrisp(minimum, maximum)
The constructor to build a crisp output
minimum
numeric value, The minimum range value of the output
maximum
numeric value, The maximum range value of the output
FisOutCrisp object
Fuzzy Logic Elementary Glossary
output <- NewFisOutCrisp(0, 1) output$name <- "foo" output$defuzzification <- "sugeno" output$disjunction <- "max"
output <- NewFisOutCrisp(0, 1) output$name <- "foo" output$defuzzification <- "sugeno" output$disjunction <- "max"
Class to manage a Fis fuzzy output
defuzzification
character vector, The defuzzification operator of the fuzzy output
Allowed values are: "sugeno" (the default) "MeanMax", or "area"
disjunction
character vector, The disjunction operator of the fuzzy output
Allowed values are: "max" (the default) or "sum"
FisOutFuzzy class inherits all fields and methods of FisOut class
FisOutFuzzy()
The default constructor to build a fuzzy output with the default range [0, 1]
FisOutFuzzy object
FisOutFuzzy(minimum, maximum)
The constructor to build a fuzzy output
minimum
numeric value, The minimum range value of the output
maximum
numeric value, The maximum range value of the output
FisOutFuzzy object
FisOutFuzzy(number_of_mfs, minimum, maximum)
The constructor to build a fuzzy with a regular standardized fuzzy partition
number_of_mfs
integer value, The number of Mfs in the fuzzy partition
minimum
numeric value, The minimum range value of the output
maximum
numeric value, The maximum range value of the output
FisOutFuzzy object
FisOutFuzzy(breakpoints, minimum, maximum)
The constructor to build a fuzzy with an irregular standardized fuzzy partition
breakpoints
numeric vector, The breakpoint values (sorted in ascending order) of the Mfs in the fuzzy partition
minimum
numeric value, The minimum range value of the output
maximum
numeric value, The maximum range value of the output
FisOutFuzzy object
mf_size()
integer value, The number of Mfs in the output partition
add_mf(mf)
Add an Mf in the output partition
mf
Mf object, The Mf to add
get_mf(mf_index)
get_mfs()
Get all mfs in the output
is_standardized()
logical value, TRUE
if the output is a standardized fuzzy partition, FALSE
otherwise
Fuzzy Logic Elementary Glossary
output <- NewFisOutFuzzy(0, 2) output$name <- "foo" output$defuzzification <- "sugeno" output$disjunction <- "max" output$add_mf(NewMfTrapezoidalInf(0, 1)) output$add_mf(NewMfTriangular(0, 1, 2)) output$add_mf(NewMfTrapezoidalSup(1, 2))
output <- NewFisOutFuzzy(0, 2) output$name <- "foo" output$defuzzification <- "sugeno" output$disjunction <- "max" output$add_mf(NewMfTrapezoidalInf(0, 1)) output$add_mf(NewMfTriangular(0, 1, 2)) output$add_mf(NewMfTrapezoidalSup(1, 2))
This package is a basic implementation of the main functions to use a "Fuzzy Inference System" that can be used for reasoning purposes, especially for simulating a physical or biological system. It is derived from the FisPro open source software. Fuzzy inference systems are briefly described in the Fuzzy Logic Elementary Glossary. They are based on fuzzy rules, which have a good capability for managing progressive phenomenons. Fuzzy logic, since the pioneer work by Zadeh, has proven to be a powerful interface between symbolic and numerical spaces. One of the reasons for this success is the ability of fuzzy systems to incorporate human expert knowledge with its nuances, as well as to express the behaviour of the system in an interpretable way for humans. Another reason is the possibility of designing data-driven FIS to make the most of available data.
To design a fuzzy system that can be handled by this package the user can use the FisPro software. If needed, the package can be extended to other functions.
All the mentioned publications are available from the FisPro web site.
Enjoy FisPro!
FisPro Team [email protected]
Guillaume S, Charnomordic B (2011). “Learning interpretable Fuzzy Inference Systems with FisPro.” International Journal of Information Sciences, 181(20), 4409-4427. doi:10.1016/j.ins.2011.03.025, Special Issue on Interpretable Fuzzy Systems.
Guillaume S, Charnomordic B (2012). “Fuzzy Inference Systems: an integrated modelling environment for collaboration between expert knowledge and data using FisPro.” Expert Systems with Applications, 39(10), 8744-8755. doi:10.1016/j.eswa.2012.01.206.
The base class of all "membership function" classes (cannot be instantiate)
Use derived classes MfTriangular, MfTrapezoidal, MfTrapezoidalInf or MfTrapezoidalSup
label
character vector, The label of the membership function
degree(value)
Get the membership degree
Fuzzy Logic Elementary Glossary
Class to manage a trapezoidal membership function
MfTrapezoidal class inherits all fields and methods of Mf class
MfTrapezoidal(lower_support, lower_kernel, upper_kernel, upper_support)
lower_support
numeric lower value of support
lower_kernel
numeric lower value of kernel
upper_kernel
numeric upper value of kernel
upper_support
numeric upper value of support
MfTrapezoidal object
mf <- NewMfTrapezoidal(0, 1, 2, 3) mf$degree(0.5)
mf <- NewMfTrapezoidal(0, 1, 2, 3) mf$degree(0.5)
Class to manage a trapezoidal inf membership function
MfTrapezoidalInf class inherits all fields and methods of Mf class
MfTrapezoidalInf(upper_kernel, upper_support)
upper_kernel
numeric upper value of kernel
upper_support
numeric upper value of support
MfTrapezoidalInf object
mf <- NewMfTrapezoidalInf(0, 1) mf$degree(0.5)
mf <- NewMfTrapezoidalInf(0, 1) mf$degree(0.5)
Class to manage a trapezoidal sup membership function
MfTrapezoidalSup class inherits all fields and methods of Mf class
MfTrapezoidalSup(lower_support, lower_kernel)
lower_support
numeric lower value of support
lower_kernel
numeric lower value of kernel
MfTrapezoidalSup object
mf <- NewMfTrapezoidalSup(0, 1) mf$degree(0.5)
mf <- NewMfTrapezoidalSup(0, 1) mf$degree(0.5)
Class to manage a triangular membership function
MfTriangular
class inherits all fields and methods of Mf class
MfTriangular(lower_support, kernel, upper_support)
lower_support
numeric lower value of support
kernel
numeric value of kernel
upper_support
numeric upper value of support
MfTriangular object
mf <- NewMfTriangular(0, 1, 2) mf$degree(0.5)
mf <- NewMfTriangular(0, 1, 2) mf$degree(0.5)
Function to create object of class Fis
NewFis(...)
NewFis(...)
... |
arguments of Fis constructor |
Fis object
Function to create object of class FisIn
NewFisIn(...)
NewFisIn(...)
... |
arguments of FisIn constructor |
FisIn object
Function to create object of class FisOutCrisp
NewFisOutCrisp(...)
NewFisOutCrisp(...)
... |
arguments of FisOutCrisp constructor |
FisOutCrisp object
Function to create object of class FisOutFuzzy
NewFisOutFuzzy(...)
NewFisOutFuzzy(...)
... |
arguments of FisOutFuzzy constructor |
FisOutFuzzy object
Function to create object of class MfTrapezoidal
NewMfTrapezoidal(...)
NewMfTrapezoidal(...)
... |
arguments of MfTrapezoidal constructor |
MfTrapezoidal object
Function to create object of class MfTrapezoidalInf
NewMfTrapezoidalInf(...)
NewMfTrapezoidalInf(...)
... |
arguments of MfTrapezoidalInf constructor |
MfTrapezoidalInf object
Function to create object of class MfTrapezoidalSup
NewMfTrapezoidalSup(...)
NewMfTrapezoidalSup(...)
... |
arguments of MfTrapezoidalSup constructor |
MfTrapezoidalSup object
Function to create object of class MfTriangular
NewMfTriangular(...)
NewMfTriangular(...)
... |
arguments of MfTriangular constructor |
MfTriangular object
Function to create object of class Rule
NewRule(...)
NewRule(...)
... |
arguments of Rule constructor |
Rule object
Class to manage a Fis rule
premises
integer vector, The premises of the rule
A premise is the 1-based index of MF in the FisIn
0 means the input is not taken into account for this rule, i.e. the rule is incomplete
The vector length must be equal to the number of inputs in the Fis
conclusions
numeric vector, The conclusions of the rule
A conclusion is a numeric value for crisp output FisOutCrisp, or the 1-based index of MF in the fuzzy output FisOutFuzzy
The vector length must be equal to the number of outputs in the Fis
Rule()
The default constructor to build an empty rule
The rule is initialized with empty premises and conclusions
Rule object
Rule(premises, conclusions)
The constructor to build a rule
Fuzzy Logic Elementary Glossary
rule1 <- NewRule() rule1$premises <- c(1, 2, 0) rule1$conclusions <- c(1, 2) rule2 <- NewRule(c(2, 1, 1), c(2, 1))
rule1 <- NewRule() rule1$premises <- c(1, 2, 0) rule1$conclusions <- c(1, 2) rule2 <- NewRule(c(2, 1, 1), c(2, 1))