I was trying to get the top n optimal solution sets for a multi objective optimization using pymoo==0.6.0.1
and pymcdm
.
First I optimized 5 objectives f1,f2,f3,f4, and f5 to get the result
in pymoo
. All objectives are to be minimized except f2 which is to be maximized. After that I have tried to sort the result of optimization using TOPSIS algorithm in pymcdm
. Then I plot the top 3 solutions. The top 3 solutions are not as expected in parallel coordinate plots (PCP).
Ideally the Solution 1(shown in red) should be having lowest value for objectives f1,f3,f4,and f5 amongst the solutions 1,2,and 3; while it should be having maximum value for f2 amongst solutions 1,2, and 3. This is clearly not the case in my PCP plot. Solution 3(shown in green) is actually a better individual as compared to Solution 1 as per the plot. Does rrankdata not guarantee any order to output of Topsis? What am I doing wrong ?
from pymoo.visualization.pcp import PCP
from pymcdm.normalizations import minmax_normalization
from pymcdm.methods import TOPSIS
from pymcdm.helpers import rrankdata
# .......optimization using pymoo code
# f2 needs maximizing(profit), all other objectives are to be minimized(cost as per pymcdm notion)
type_of_criteria = [-1,1,-1,-1,-1]
topsis = TOPSIS(minmax_normalization)
prefs = topsis(np.absolute(result.F), weights, type_of_criteria)
ranks = rrankdata(prefs)
# convert rank to index
sorted_row_index = ranks -1
# sort the objective values obtained from pymoo
sorted_F = np.absolute(result.F[sorted_row_index,:])
# Normalize and multiply by weights
norm_sorted_F = np.empty(sorted_F.shape)
for i, tpl in enumerate(zip(sorted_F.T, type_of_criteria)):
col,cost_type = tpl
if cost_type == -1:
cost_type = False
norm_col = minmax_normalization(col,cost=cost_type)
norm_sorted_F[:,i] = norm_col
weighted_norm_sorted_F = norm_sorted_F * weights[np.newaxis,:]
plot = PCP(title=("Run_test", {'pad': 30}),
n_ticks=10,
legend=(True, {'loc': "upper left"}),
labels=["f1", "f2", "f3", "f4", "f5"]
)
plot.set_axis_style(color="grey", alpha=1)
# plot all values
plot.add(weighted_norm_sorted_F, color="grey", alpha=0.3)
#plot top 3 values
plot.add(weighted_norm_sorted_F[0], linewidth=2, color="red", label="Solution 1")
plot.add(weighted_norm_sorted_F[1], linewidth=2, color="blue", label="Solution 2")
plot.add(weighted_norm_sorted_F[2], linewidth=2, color="green", label="Solution 3")
plot.show()
Now I understand a bit more about TOPSIS. This algorithm calculates a score for each solution based on the following formula
Based on this score, TOPSIS ranks individual solutions obtained from a multiobjective optimization. It is not ranking based on the distance from best ideal solution which I was assuming earlier. Hence the output from PCP is correct.
Parallel coordinate plot in my case is not telling me which solution is best. It is just showing me where my top 3 solutions are lying in the overall solution set.