# Conflicts with weights of the topsis method in R

Why can't I generate for the topsis method, choosing a w <- c(1, 0)? As far as I know it has to be the sum of the weights equal to 1. And it's weird that if I put w <- c(1, 1) it works. But why, since the sum of the weights must equal 1?

library(topsis)

df1 <- structure(list(n = c(2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
Coverage = c(0.0363201192049018, 0.0315198954715543,
0.112661460735583, 0.112661460735583, 0.112661460735583, 0.0813721071219816,
0.0862146652218061, 0.0697995564757394, 0.0599194966471805,
0.0507632014547115),
Production =
c(1635156.04305, 474707.64025, 170773.40775, 64708.312, 64708.312, 64708.312,
949.72635, 949.72635, 949.72635, 949.72635)),
class = "data.frame", row.names = c(NA,-10L))

df2 <- df1[c(2:3)]
df2<-data.matrix(df2)

w <- c(1, 0)
i <- c("+", "-")
topsis(df2, w, i)


Error in topsis(df2, w, i) : weights must be positive numbers

Normalizing the Weights. According to the topsis() documentation, the argument weights must be "[a] numeric vector with length equal to number of columns in decision matrix for weights of criterions" (sic) which clearly omits certain requirements based on your error message (namely that the weights be positive).

There does not appear to be a requirement for the weights to sum to 1 as the example in the documentation (copied below) uses c(1, 1, 2) to yield $$[1,\; 1,\; 2]$$ as weights.

The interpretation is that the third criterion is twice as important as the other two. This implies that weights [1 1 2], [0.25 0.25 0.50], and [2 2 4] are equivalent.

Clearly normalizing the weights (as seen here) isn't required for implementation.

# R Example
# Minimal Example for Demonstration
library(topsis)
set.seed(5)                   # Fixing the random seed for reproducibility
d <- matrix(rpois(12, 5), nrow = 4)
w <- c(1, 1, 2)               # Try a multiple of w to see for yourself
i <- c("+", "-", "+")
topsis(d, w, i)


This outputs the following:

  alt.row     score rank
1       1 0.7486787    1
2       2 0.1777717    4
3       3 0.3917848    2
4       4 0.3694949    3


Note that if you replace weights $$w$$ with any $$\alpha w$$ for $$\alpha > 0$$ you get the same output. For example, I used w <- c(3, 3, 6) and w <- c(0.25, 0.25, 0.5) and obtained the same results in each case.

Side Note. Using c(1,0) results in weights $$[0,\; 1]$$. Since the weights must be positive based on the function's error checking, zero may not satisfy that. Logically, why give something zero weight if you want to consider it for the objective? Just remove it.