User Guide

Introduction

This package is the R implementation of functions to manage a Fuzzy Inference System (FIS) provided by the open source software FisPro.
FisPro allows to create Fuzzy Inference Systems and to use them for reasoning purposes, especially for simulating a physical or biological system.
In this brief User Guide we describe how to build and use a FIS to infer input values.
See Fuzzy Logic Elementary Glossary for more details about Fuzzy Logic.

library(FisPro)

Build a FIS from a configuration file

The FIS configuration file can be designed using the FisPro open source software.

fis_file <- system.file("extdata", "test.fis", package = "FisPro")
fis <- NewFis(fis_file)

Build a FIS from scratch

Create a new empty FIS.
The design must be completed using the available functions to add inputs, outputs and rules before it can be used for inference.

fis <- NewFis()
fis$name <- "foo" Create inputs Add 2 inputs to the FIS. Create the first input with 2 MFs regular standardized fuzzy partition: fisin1 <- NewFisIn(2, 0, 1) fisin1$name <- "input1"
fis$add_input(fisin1) Create the second input with 3 MFs: fisin2 <- NewFisIn(0, 1) fisin2$name <- "input2"

mf1 <- NewMfTrapezoidalInf(0, 0.5)
mf1$label <- "Low" fisin2$add_mf(mf1)

mf2 <- NewMfTriangular(0, 0.5, 1)
mf2$label <- "Average" fisin2$add_mf(mf2)

mf3 <- NewMfTrapezoidalSup(0.5, 1)
mf3$label <- "High" fisin2$add_mf(mf3)

fis$add_input(fisin2) Create outputs Add 2 outputs to the FIS. Create a crisp output with range [0, 1]: fisout1 <- NewFisOutCrisp(0, 1) fisout1$name <- "output1"
fis$add_output(fisout1) Create a fuzzy output with 2 MFs regular standardized fuzzy partition in range [0, 1]: fisout2 <- NewFisOutFuzzy(2, 0, 1) fisout2$name <- "output2"

FIS inference

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 dataset: test_file <- system.file("extdata", "test_data.csv", package = "FisPro") dataset <- read.csv(test_file) inferred_dataset <- fis$infer(dataset)