% Phase 3: Determination of the risk coefficient value using TOPSIS % Step1: Creating the decision matrix (9 hazards, 7 risk parameters) X = [ 0.0791 0.1827 0.0865 0.0798 0.0868 0.1622 0.1493; 0.1438 0.0490 0.1561 0.0533 0.0644 0.1096 0.1276; 0.1678 0.0286 0.1831 0.1572 0.1135 0.1427 0.0733; 0.2059 0.1824 0.2007 0.1686 0.1858 0.0922 0.1562; 0.1829 0.1157 0.1183 0.1642 0.1819 0.0758 0.0763; 0.0402 0.0653 0.0542 0.1359 0.1064 0.0572 0.0421; 0.0816 0.0586 0.1117 0.1171 0.1536 0.0102 0.0619; 0.0589 0.1427 0.0430 0.0831 0.0836 0.1310 0.1395; 0.0398 0.1751 0.0463 0.0408 0.0240 0.2192 0.1737; ]; % Risk Parameter Weights weights = [0.1445, 0.0481, 0.1195, 0.1762, 0.1558, 0.1573, 0.1987]; % Determining cost and benefit criteria % 1 = Benefit, -1 = Cost criteria_type = [1, 1, 1, -1, 1, 1, -1]; % Step 2: Creation of the weighted decision matrix V = zeros(size(X)); for j = 1:size(X, 2) V(:,j) = X(:,j) * weights(j); end % Step 3: Positive and negative ideal solutions values V_max = zeros(1, size(X, 2)); % Positive ideal solutions values V_min = zeros(1, size(X, 2)); % Negative ideal solutions values for j = 1:size(X, 2) if criteria_type(j) == 1 % Benefit criteria V_max(j) = max(V(:,j)); V_min(j) = min(V(:,j)); else % Cost criteria V_max(j) = min(V(:,j)); V_min(j) = max(V(:,j)); end end % Step 4: Determined of positive and negative distance values S_max = zeros(size(X, 1), 1); S_min= zeros(size(X, 1), 1); for i = 1:size(X, 1) S_max(i) = sqrt(sum((V(i,:) - V_max).^2)); S_min(i) = sqrt(sum((V(i,:) - V_min).^2)); end % Step 5: Calculate of closeness coefficient C = S_min ./ (S_max + S_min); % Normalization of closeness coefficient C_total = sum(C); C_normalized = C / C_total; % Step 6: Ranking of hazards [~, rank_indices] = sort(C_normalized, 'descend'); disp('Normalized closeness coefficient values (C) and rankings of hazards:'); for i = 1:size(X, 1) fprintf('Hazard %d: C = %.4f, Normalized C = %.4f, Rank: %d\n', i, C(i), C_normalized(i), find(rank_indices == i)); end disp('Ranked Hazards:'); disp(rank_indices');