ulowa 1.1.0
Library for ULOWA operations, given fuzzy numbers
License: MIT

## ULOWA MODULE 
Please, read carefully before using this library.

This module implements the ULOWA aggregation operator: Unbalanced Linguistic Ordered Weighted Average. 
Aggregation operators for linguistic variables usually assume uniform and symmetrical distribution of 
the linguistic terms that define the variable. However, there are some problems where an unbalanced set 
of linguistic terms is more appropriate to describe the objects. ULOWA accepts a set of linguistic labels 
defined with unbalanced fuzzy sets. The fuzzy sets must define a fuzzy partition on the set of reference values. 
They can be defined by trapezoidal or triangular membership functions.



This module has been made for academic purposes. If you want to use it, cite the author.

### 1. Installation
First, you can simpy install it by using the pip comand: `pip install ulowa`
### 2. Usage
#### 2.1. ULOWA

The aggregation operator works with a fuzzy linguistic scale.
First, it is necessary to define the set of labels (vocabulary) and their corresponding fuzzy sets.
Labels must be ordered increasingly, from the worst value to the best.
`labels = ["VL", "L", "M", "AH", "H", "VH", "P"]`

Fuzzy sets will be trapezoidal and so each one is defined by four 4 points on a numerical scale of reference, e.g:
`fuzzySets = [[0.0, 0.0, 1.0, 2.0], [1.0, 2.0, 4.0, 5.0], [4.0, 5.0, 5.0, 6.0], [5.0, 6.0, 6.0, 7.0],
                [6.0, 7.0, 8.0, 8.5], [8.0, 8.5, 9.0, 9.5], [9.0, 9.5, 10.0, 10.0]]`

*Note that the scale may vary, it isn't compulsory to be from 0 to 10*

ULOWA also needs a vector of weights that define the aggregation policy (from conjunctive to disjunctive).
Weights are not importances for the criteria, but for the values on each rank position, e.g:
`weights = [0.6, 0.2, 0.2, 0.0, 0.0]`

*Note that the weights must sum up to 1*

The labels to be aggregated will be also introduced as a vector of lables. They do not need to be in any order. 
`values = ["VL", "VL", "L", "M", "L"]`

To call to the ULOWA function is the following:
`ulowa(values, weights, fuzzySets, labels)`

The output will be one of the linguistic labels of the vocabulary.

#### 2.2. Defuzzification
To transform the output of ULOWA into a number, one can use defuzzification opeations.
There are three methods implemented in this package: 
`defuzzifyCOG(fuzzyNumbers, labels, tag)` that is the method of Center of Gravity
`defuzzifyCOM(fuzzyNumbers, labels, tag)` that is the method of Center of Maximum
`defuzzifyOrdinal(labels, tag)` that is a method that returns the position of the tag in the vocabulary

#### 2.3. Specificity and Fuzziness
This module also allows you to calculate the specificity and fuzziness of a given fuzzy set.
The function needs the position of the label in the vocabulary and the min and max of the reference numerical scale.
For example:
```
a = fuzzySets[0][0]
b = fuzzySets[len(fuzzySets) - 1][3]
order=1
for i in fuzzySets:
    print(f"\nThe specificity of the {order} fuzzy set is: {specificity(i, a, b)}")
    print(f"\nThe fuzziness of the {order} fuzzy set is: {fuzziness(i, a, b)}")
    order = order + 1
```


#### 2.4. Plotting fuzzy sets
The package also provides a method to plot the fuzzy sets of the linguistic scale: `plotFuzzySets(fuzzySets, labels)`. 
Here you have an example for a specific set of fuzzy numbers and labels:
```
fuzzySets = [[0.0, 0.0, 1.0, 2.0], [1.0, 2.0, 2.0, 3.0], [2.0, 3.0, 3.0, 4.0], [3.0, 4.0, 4.0, 5.0],
                [4.0, 5.0, 5.0, 6.0], [5.0, 6.0, 6.0, 7.0], [6.0, 7.0, 7.0, 8.0], [7.0, 8.0, 8.0, 9.0],
                [8.0, 9.0, 10.0, 10.0]]
labels = ["N", "VL", "L", "AM", "M", "AH", "H", "VH", "P"]

plotFuzzySets(fuzzySets, labels)
```
You should get an image like the one showed below:
![fuzzy sets example](https://deim.urv.cat/~itaka/imatges/fuzzysets.png)

**Author:** Universitat Rovira i Virgili (URV) - [ITAKA research group](https://deim.urv.cat/~itaka/itaka2/index.html) (Ignacio Miguel Rodríguez)

**Reference:** A. Valls, The Unbalanced Linguistic Ordered Weighted Averaging Operator, In: Proc. IEEE International Conference on Fuzzy Systems, FUZZ-IEEE 2010, IEEE Computer Society, Barcelona, Catalonia, 2010, pp. 3063-3070. [ULOWA article](https://ieeexplore.ieee.org/document/5584199)

**Contact:** [Send e-mail](mailto:aida.valls@urv.cat)