Last data update: 2014.03.03

R: Determine whether the first set of predicates is more...
is.specificR Documentation

Determine whether the first set of predicates is more specific (or equal) than the other.

Description

Take two character vectors of predicates and determine whether x is more specific (or equal w.r.t. the specificity) than y. The specificity relation is fully determined with the values of vars vector and specs incidence matrix.

Usage

is.specific(x, y, vars, specs)

Arguments

x

The first character vector of predicates.

y

The second character vector of predicates.

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 of x or y 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 rows and columns represent predicates. 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.

Details

Let x_i, y_j represent any predicate of the vectors x, y. Function assumes that each vector x and y does not contain two or more predicates with the same value of vars.

This function returns TRUE iff all of the following conditions hold:

  • for any y_j there exists x_i such that vars[y_j] = vars[x_i];

  • for any x_i there either does not exist y_j such that vars[x_i] = vars[y_j] or x_i = y_j or specs[x_i, y_j] = 1.

x

Value

TRUE or FALSE (see above).

Author(s)

Michal Burda

See Also

perceive, pbld, vars, specs

Examples

    # create vars (v) and specs (s)
    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='.')

    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)

    # returns TRUE
    is.specific(c('VeSm.a', 'Bi.c'), 
                c('VeSm.a', 'Bi.c'),
                v, s)

    # returns TRUE (x and y swapped return FALSE)
    is.specific(c('VeSm.a', 'Bi.c', 'Sm.d'),
                c('Sm.a', 'Bi.c', 'Sm.d'),
                v, s)

    # returns TRUE (x and y swapped return FALSE)
    is.specific(c('VeSm.a', 'Bi.c', 'Sm.d'),
                c('VeSm.a', 'Bi.c'),
                v, s)

    # returns TRUE (x and y swapped return FALSE)
    is.specific(c('VeSm.a', 'Bi.c', 'Sm.d'),
                NULL,
                v, s)

    # returns FALSE
    is.specific(c('Sm.a'), c('Bi.c'), v, s)

    # returns FALSE
    is.specific(c('VeSm.a', 'Sm.c'),
                c('Sm.a', 'Bi.c'),
                v, s)

Results