# fire: Compute truth-degrees of rules on data In lfl: Linguistic Fuzzy Logic

## Description

Given data in the form of membership degrees to fuzzy sets, compute the truth value of given list of rules.

## Usage

 ```1 2 3 4 5``` ```fire(x, rules, tnorm=c("goedel", "goguen", "lukasiewicz"), onlyAnte=TRUE, parallel=FALSE) ```

## Arguments

 `x` Data for the rules to be evaluated on. Could be either a numeric matrix or numeric vector. If matrix is given then the rules are evaluated on rows. Each value of the vector or column of the matrix represents a predicate - it's numeric value represents the truth values (values in the interval [0, 1]). `rules` Either an object of class "farules" or list of character vectors where each vector is a rule with consequent being the first element of the vector. Elements of the vectors (predicate names) must correspond to the `x`'s names (of columns if `x` is a matrix). `tnorm` A character string representing a triangular norm to be used (either `"goedel"`, `"goguen"`, or `"lukasiewicz"`) or an arbitrary function that takes a vector of truth values and returns a t-norm computed of them. `onlyAnte` TRUE if only antecedent-part of a rule should be evaluated. Antecedent-part of a rule are all predicates in rule vector starting from the 2nd position. (First element of a rule is the consequent - see above.) If FALSE, then the whole rule will be evaluated (antecedent part together with consequent). `parallel` Whether the processing should be run in parallel or not. Parallelization is implemented using the `foreach` package. The parallel environment must be set properly in advance, e.g. with the `registerDoMC()` function of the `doMC` package.

## Details

The aim of this function is to compute the truth value of each rule in a list on given data. Each rule in the `rules` list is represented as a character vector of predicates with the first element being considered as a rule's consequent.

`x` is data either in a form of a numeric vector or numeric matrix. If vector is given then `names(x)` must correspond to the predicate names in `rules`. If `x` is a matrix then each column represents a predicate and thus `colnames(x)` must correspond to the predicate names in `rules`.

Values of either an input vector or matrix are interpreted as truth values. If matrix is given, the resulting truth values are computed row-wisely.

The type of conjunction to be used can be specified with the `tnorm` argument.

## Value

If `x` is a vector then the result of this function is a list with a truth value of each rule. If `x` is a matrix, then a list of vectors of truth values is returned with truth values of the rules being computed row-wisely.

## Author(s)

Michal Burda

`aggregateConsequents`, `defuzz` `perceive`, `pbld`, `fcut`, `lcut`, `farules`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20``` ```# fire whole rules on a vector x <- 1:10 / 10 names(x) <- letters[1:10] rules <- list(c('a', 'c', 'e'), c('b'), c('d', 'a'), c('c', 'a', 'b')) fire(x, rules, tnorm='goguen') # fire antecedents of the rules on a matrix x <- matrix(1:20 / 20, nrow=2) colnames(x) <- letters[1:10] rules <- list(c('a', 'c', 'e'), c('b'), c('d', 'a'), c('c', 'a', 'b')) fire(x, rules, tnorm='goedel', onlyAnte=TRUE) # the former command should be equal to fire(x, antecedents(rules), tnorm='goedel') ```