First off, I don't have any experience with TOPSIS but the code of that function explains what is going on and matches the description of TOPSIS. You can see the code by typing topsis
.
matrix d
in this example is a 4x3 matrix. Each row represents one alternative (for instance , a model of car available in the market) while each column represents a criterion on which these alternatives are to be judged (for instance , you might use cost, efficiency, torque and ground clearance to select a car)
The + and - just show how that particular criteria(column) impacts the outcome. For instance, cost of a car might be a -ve while torque will be +ve.
The algorithm uses these impact signs to come to a Positive Ideal solution and a Negative(worst) Ideal solution .
Positive Ideal solution is derived by using the max value of +ve columns and the min value of the -ve columns. Here's the relevant line from the code.
u <- as.integer(impacts == "+") * apply(V, 2, max) + as.integer(impacts ==
"-") * apply(V, 2, min)
Negative ideal is the opposite.
From thereon the code proceeds to find distance of each of our alternatives with these best and worst outcomes and ranks them.