Last data update: 2014.03.03

R: From a set of rules, remove each rule for which another rule...
perceiveR Documentation

From a set of rules, remove each rule for which another rule exists that is more specific.

Description

Examine rules in a list and remove all of them for whose other more specific rules are present in the list. The specificity is determined by calling the is.specific function. This operation is a part of the pbld inference mechanism.

Usage

perceive(rules, 
         vars,
         specs,
         type=c('global', 'local'),
         fired=NULL)

Arguments

rules

A list of character vectors where each element is a fuzzy set name (a predicate) and thus each such vector forms a rule.

vars

A named (typically character) vector that determines which predicates originate from the same variable, i.e. which of them semantically deal with the same property. For that purpose, each value from any vector stored in the rules list must be present in names(vars). See also vars function of the fsets class.

specs

A square numeric matrix containing values from {0, 1}. It is a specificity matrix for which each row and column corresponds to an rules'es predicate specs[i][j] = 1 if and only if the i-th predicate is more specific (i.e. the corresponding fuzzy set is a subset of) than the j-th predicate (i.e. x[, j]). See also specs function of the fsets class.

type

The type of perception to use. It can be either "local" or "global" (default).

fired

If type=="global" then this argument can be NULL. If type is "local" then fired must be a numeric vector of values in the interval [0,1] indicating the truth values of all rules, i.e. the length of the vector must be equal to the number of rules in the rules argument.

Details

For each rule x in the rules list, it searches for another rule y such that is.specific(y, x) returns TRUE. If yes then x is removed from the list.

Value

A modified list of rules for which no other more specific rule exists. (Each rule is a vector.)

Author(s)

Michal Burda

See Also

is.specific, fsets, fcut, lcut

Examples

# prepare vars
v <- c(rep('a', 3),
       rep('b', 3),
       rep('c', 3),
       rep('d', 3))
names(v) <- paste(rep(c('VeSm', 'Sm', 'Bi'), times=4),
                  rep(c('a', 'b', 'c', 'd'), each=3),
                  sep='.')
print(v)

# prepare specs
s <- matrix(c(0,1,0, 0,0,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,

              0,0,0, 0,1,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,

              0,0,0, 0,0,0, 0,1,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,

              0,0,0, 0,0,0, 0,0,0, 0,1,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0,
              0,0,0, 0,0,0, 0,0,0, 0,0,0),
          byrow=TRUE,
          ncol=12)
colnames(s) = names(v)
rownames(s) = names(v)
print(s)

# run perceive function: (Sm.a, Bi.c) has
# more specific rule (VeSm.a, Bi.c)
perceive(list(c('Sm.a', 'Bi.c'), 
              c('VeSm.a', 'Bi.c'),
              c('Sm.b', 'Sm.d')),
         v, s)

Results