code of Best-worst Method?

7 Ansichten (letzte 30 Tage)
Ali Naeemah
Ali Naeemah am 17 Okt. 2021
Beantwortet: R am 30 Sep. 2023
Good day, ladies and gentlemen.
I need help to import data from excel to MATLAB to run the code for the Best-Worst method attached below. Actually, I have a problem running this code. I do not how to import data from excel to this code.
is there a specific procedure to follow it.
clc;clear;close all;
delete Data.mat
DATA = xlsread("Data.xlsx");
NumOfExperts = size(DATA , 1) / 2;
NumOfCriteria = size(DATA , 2);
BestData = DATA( 1:NumOfExperts , : );
WorstData = DATA( NumOfExperts + 1: end , :);
WorstData = WorstData';
ConsistencyIndex = [0 , .44 , 1 , 1.63 , 2.3 ,3 , 3.73 , 4.47 , 5.23];
DATA = struct;
for i = 1:NumOfExperts
IndexOfBest = find(BestData(i , :) == 0);
IndexOfWorst = find(WorstData(: , i) == 0);
BestData(i , IndexOfBest) = 1;
WorstData(IndexOfWorst , i) = 1;
DATA(i).Best = BestData(i , :);
DATA(i).Worst = WorstData(: , i);
DATA(i).BestIndex = IndexOfBest;
DATA(i).WorstIndex = IndexOfWorst;
end
clear BestData .. WorstData .. IndexOfBest .. IndexOfWorst;
MeanWeight = zeros(1 , NumOfCriteria);
for i = 1:NumOfExperts
Data = DATA(i);
save Data
EqualCoefftMat = ones(1 , NumOfCriteria);
InitialPoints = rand(1 , NumOfCriteria);
LowerBound = zeros(1 , NumOfCriteria);
UpperBound = ones(1 , NumOfCriteria);
options = optimoptions(@fmincon , 'Algorithm' , 'interior-point' , 'MaxFunctionEvaluations' , 50000 , 'MaxIterations' , 5000 );
[DATA(i).Weights , DATA(i).Ksi] = fmincon(@Epsilon , InitialPoints , [] , [] , EqualCoefftMat , 1 , LowerBound , UpperBound , [], options);
DATA(i).ConsistencyRatio = DATA(i).Ksi/ConsistencyIndex(max(max(DATA(i).Best) , max(DATA(i).Worst)));
MeanWeight = MeanWeight + DATA(i).Weights;
end
MeanWeight = MeanWeight/NumOfExperts;
bar(MeanWeight);
xlabel('Criterias');
ylabel('Weights');
title(['Mean Of Weights is: ', num2str(mean(MeanWeight))]);
[Result.Weights , Result.IndexOfWeight] = sort(MeanWeight , 'descend');
function Out = Epsilon(x)
load Data
for i = 1:NumOfCriteria
f(i) = abs(x(Data.BestIndex)/x(i) - Data.Best(i));
g(i) = abs(x(i)/x(Data.WorstIndex) - Data.Worst(i));
end
Out = (sum(f) + sum(g) - g(Data.BestIndex))*2/NumOfCriteria;
end
  2 Kommentare
Jan
Jan am 17 Okt. 2021
Okay. What is your question?
dpb
dpb am 17 Okt. 2021
DATA = xlsread("Data.xlsx");
NumOfExperts = size(DATA , 1) / 2;
NumOfCriteria = size(DATA , 2);
BestData = DATA( 1:NumOfExperts , : );
WorstData = DATA( NumOfExperts + 1: end , :);
...
The code has in it reading data from a presumed Excel workbook of a given name and format.
Follow that template.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

R
R am 30 Sep. 2023
Hi Please can someone tell me how I should enter the data in the data array. In my case I have 9 experts, how should I introduce the information for Running the program?
Thanks

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by