Learn R Programming

fsr (version 1.0.0)

fsi_add_rules: Adding fuzzy rules to an FSI model

Description

This function adds the fuzzy rules set to a fuzzy spatial inference (FSI) model. A fuzzy rule must contain only linguistic variables and values employed by the added antecedent parts and consequent.

Usage

fsi_add_rules(fsi, rules, weights = rep(1, length(rules)))

Arguments

fsi

An FSI model instantiated with the function fsi_create.

rules

A character vector containing the rules defined by the user. It follows a specific format, as detailed below.

weights

A numeric vector of weight values for each rule. Default values are 1.

Value

An FSI model populated with fuzzy rules set.

Details

The definition of a fuzzy rule is user-friendly since users can write it by using the linguistic variables and linguistic values previously defined and added to the FSI model. A fuzzy rule has the format IF A THEN B, where A is called the antecedent and B the consequent of the rule such that A implies B. Further, A and B are statements that combine fuzzy propositions by using logical connectives like AND or OR. Each fuzzy proposition has the format LVar is LVal where LVal is a linguistic value in the scope of the linguistic variable LVar. To avoid possible contradictions keep in mind the following items when specifying the rules:

  • the order of the statements in the antecedent is not relevant;

  • each linguistic variable has to appear at most one time in each fuzzy rule;

Examples

Run this code
# NOT RUN {
# Creating the FSI model from an example implemented with the visitation function:
fsi <- visitation()

# Creating a vector of fuzzy rules; 
## note that we make use of the linguistic variables and linguistic values previously defined:
rules <- c(
  "IF accommodation review is reasonable AND food safety is low 
  THEN visiting experience is awful",
 "IF accommodation price is expensive AND accommodation review is reasonable 
   THEN visiting experience is awful",
 "IF accommodation price is affordable AND accommodation review is good AND food safety is medium 
   THEN visiting experience is average",
 "IF accommodation price is affordable AND accommodation review is excellent 
                                                                AND food safety is high 
   THEN visiting experience is great",
 "IF accommodation price is cut-rate AND accommodation review is excellent AND food safety is high 
   THEN visiting experience is great")

# Adding these rules to the FSI model previously instantiated:
fsi <- fsi_add_rules(fsi, rules)

# }

Run the code above in your browser using DataLab