Skip to contents

fsi_add_rules() adds the fuzzy rules set to a fuzzy spatial inference (FSI) model. A fuzzy rule must contain only linguistic variables and values included in the antecedent parts and consequent.

Usage

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

Arguments

fsi

An FSI model instantiated with the fsi_create() function.

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 a fuzzy rules set.

Details

The fsi_add_rules() function adds fuzzy rules to an FSI model. 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 (via fsi_add_fsa() and fsi_add_cs()).

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.

  • only one kind of logical connective (i.e., AND or OR) must be used in the statements of the antecedent.

Examples

# Creating the FSI model from an example
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)