---
title: "Ranking of Alternatives with the RAFSI Method"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using the RAFSI Method}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```
# Introduction to the RAFSI Method

The RAFSI method is a multi-criteria decision-making technique developed by Malisa Zizovic in 2020. The `rafsi` package implements this method in R, allowing users to evaluate alternatives based on weighted criteria and generate a final ranking of alternatives.

## Example of Usage
In this example, we will use the RAFSI method to evaluate a set of alternatives based on specific criteria and calculate their final rankings.


```{r setup}
library(rafsi)

# Define the dataset (rows: alternatives, columns: criteria)
dataset <- matrix(c(
  180, 165, 160, 170, 185, 167,   # Criterion 1: Higher is better
  10.5, 9.2, 8.8, 9.5, 10, 8.9,   # Criterion 2: Lower is better
  15.5, 16.5, 14, 16, 14.5, 15.1, # Criterion 3: Lower is better
  160, 131, 125, 135, 143, 140,   # Criterion 4: Higher is better
  3.7, 5, 4.5, 3.4, 4.3, 4.1      # Criterion 5: Higher is better
), nrow = 6, ncol = 5, byrow = TRUE)

# Set names for the alternatives (A1 to A6)
rownames(dataset) <- c("A1", "A2", "A3", "A4", "A5", "A6")

# Define the weights for each criterion
weights <- c(0.35, 0.25, 0.15, 0.15, 0.10)

# Define the type of each criterion: 'max' for benefit, 'min' for cost
criterion_type <- c('max', 'min', 'min', 'max', 'max')

# Define the ideal values (best-case scenario) for each criterion
ideal <- c(200, 6, 10, 200, 8)

# Define the anti-ideal values (worst-case scenario) for each criterion
anti_ideal <- c(120, 12, 20, 100, 2)

# Number of criteria (n_i) and number of alternatives (n_k)
n_i <- 1
n_k <- 6

# Apply the RAFSI method
result <- rafsi_method(dataset, weights, criterion_type, ideal, anti_ideal, n_i, n_k)

# View the results
print(result)

```

Interpret the Results

The result provides the ranking of the alternatives based on their performance across all criteria, considering the weights and whether each criterion is treated as a benefit or a cost.

For more detailed information on the RAFSI method, you can refer to the original paper: https://doi.org/10.3390/math8061015.
