Learn R Programming

frbs (version 1.0-0)

rulebase: The rule checking function

Description

This function checks the consistency of a rule definition (given by the user). The rulebase consists of several fuzzy IF-THEN rules.

Usage

rulebase(type.model, rule, func.tsk = NULL)

Arguments

type.model
a value determining the type of model to use. Here, 1 and 2 mean Mamdani and Takagi Sugeno Kang model, respectively.
rule
a matrix or list of rules.
func.tsk
a matrix representing the consequent parts of rules in Takagi Sugeno Kang formulation.

Value

  • fuzzy IF-THEN rule base

Details

For rules of the Mamdani model, there are 2 parts in each rule, the antecedent and the consequent part, which are separated by "->".

For example: r1 <- c("a1","and","b1","->", "c1")

Here, ("a1", "and", "b1") is the antecedent, with "a1" and "b1" being fuzzy terms, and ("c1") is the consequent part.

A fuzzy IF-THEN rule base with several rules is defined in the following way:

r1 <- c("not a1","and","b1", "->", "c1")

r2 <- c("a2","or","b2", "->", "c2")

r3 <- c("a3","or","b2", "->", "c3")

rule <- list(r1,r2,r3)

For rules of the Takagi Sugeno Kang model, the rules are at first defined without the consequent part, e.g.:

r1 <- c("a1",1,"b1","->")

r2 <- c("a2",2,"b2", "->")

r3 <- c("a3","2","b2", "->")

rule <- list(r1,r2,r3)

The consequences are defined then as a matrix fun_tsk, which contains the linear equations of the consequences of the rules. The dimension of this matrix is [, + 1]. The matrix has one extra column for the constants. If there is no constant, a zero is put.

So, for example, if we have 3 rules and 2 fuzzy variables (A, B), the matrix fun_tsk has dim(3,3), as in:

func.tsk <- matrix(c(1, 1, 5, 2, 1, 3, 1, 2, 2), nrow=3, ncol=3, byrow = TRUE)

Furthermore, we can represent linguistic hedge within the rules. The kinds of hedges used are

  • "extremely" reduces the truth value. For example, "extremely a1" means membership function a1 = miu(a1)^3
  • "very" reduces the truth value. For example, "very a1" means membership function a1 = miu(a1)^2
  • "somewhat" increases the truth value. For example, "somewhat a1" means membership function a1 = miu(a1)^0.5
  • "slightly" increases the truth value. For example, "slightly a1" means membership function a1 = miu(a1)^0.33

An example of fuzzy IF-THEN rules using linguistic hedge is:

r1 <- c("very a1","and","b1","->","c1")

r2 <- c("a2",2,"b2", "->", "c2")

r3 <- c("a3","2","slightly b2", "->", "c3")

rule <- list(r1,r2,r3)

Furthermore, the following is an example in order to give names to the fuzzy terms in the input and output variables.

varinput.1 <- c("a1", "a2", "a3")

varinput.2 <- c("b1", "b2")

names.varinput <- c(varinput.1, varinput.2)

names.varoutput <- c("c1", "c2", "c3")

Note that the names of the fuzzy terms must be unique and if we are using the learning methods, the fuzzy IF-THEN rules will be generated automatically as the outputs of frbs.learn.

See Also

defuzzifier, inference, and fuzzifier