fsi_add_cs {fsr} | R Documentation |
Add the consequent to an FSI model
Description
fsi_add_cs()
adds the consequent to a fuzzy spatial inference (FSI) model. It consists of a set of membership functions labeled with linguistic values.
Usage
fsi_add_cs(fsi, lvar, lvals, mfs, bounds)
Arguments
fsi |
The FSI model instantiated with the |
lvar |
A character value that represents a linguistic variable of the consequent. |
lvals |
A character vector that contains linguistic values of the linguistic variable of the consequent. |
mfs |
A vector of membership functions (see examples below). |
bounds |
A numeric vector that represents the lower and upper bounds of the consequent domain. |
Details
The fsi_add_cs()
function adds the consequent to an FSI model.
Each linguistic value defined in lvals
has a corresponding membership function defined in mfs
.
Thus, these two parameters must have the same length.
For instance, the first value of lvals
defines the linguistic value of the first membership function in mfs
.
In bounds
, the lower and upper values correspond to the first and second parameter, respectively.
Value
An FSI model populated with a consequent.
References
Underlying concepts and formal definitions of FSI models are introduced in:
Examples
# Defining two different types of membership functions
trap_mf <- function(a, b, c, d) {
function(x) {
pmax(pmin((x - a)/(b - a), 1, (d - x)/(d - c), na.rm = TRUE), 0)
}
}
trim_mf <- function(a, b, c) {
function(x) {
pmax(pmin((x - a)/(b - a), (c - x)/(c - b), na.rm = TRUE), 0)
}
}
# Creating the FSI model
fsi <- fsi_create("To visit or not to visit, that is the question",
default_conseq = trim_mf(10, 30, 60))
# Creating the vector with the linguistic values of the linguistic variable "visiting experience"
lvals_visiting_exp <- c("awful", "average", "great")
# Defining the membership function for each linguistic value
awful_mf <- trim_mf(0, 0, 20)
average_mf <- trim_mf(10, 30, 60)
great_mf <- trap_mf(40, 80, 100, 100)
# Adding the consequent to the FSI model
fsi <- fsi_add_cs(fsi, "visiting experience", lvals_visiting_exp,
c(awful_mf, average_mf, great_mf), c(0, 100))