필터 지우기
필터 지우기

code of Best-worst Method?

조회 수: 4 (최근 30일)
Ali Naeemah
Ali Naeemah 2021년 10월 17일
답변: R 2023년 9월 30일
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
Jan
Jan 2021년 10월 17일
Okay. What is your question?
dpb
dpb 2021년 10월 17일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

R
R 2023년 9월 30일
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

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by