Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
sorting of products based on requirement
조회 수: 1 (최근 30일)
이전 댓글 표시
i have two set of objectives
actvites resources duration
mode 1 mode 2 mode 1 mode 2
A 5 4 10 6
B 7 3 7 9
C 3 7 5 11
D 8 8 4 7
E 9 6 9 4
if we choose a set randomly A from mode1, B from mode 2, C & D from mode 1 and E from mode 2.
total resources = 5*10+3*9+3*5+8*4+6*4 = 148,
like wise we have to choose a set R where total resource utilization from two modes in decendeing order
set D ( decereasing order of duaration)
how to write program for this in matlab
댓글 수: 2
Walter Roberson
2019년 10월 10일
"like wise we have to choose a set R where total resource utilization from two modes in decendeing order "
Sorry, I do not seem to understand what you are asking there?
It is easy to come up with an algorithm that would find the minimum possibility. If there are no constraints then each row can be considered independently.
답변 (1개)
Ganesh Regoti
2019년 11월 5일
Hi,
I presume that you need to pick the activities in descending order of duration and resources (first being the highest)
Here is the code which may help you
activity = 'ABCDE'; %The order of activities given
%Matrax of form NX4 where each column represents as follows:
%Resources,Duration,Mode,Activity Index
Activities = [5 10 1 1;
4 6 2 1;
7 7 1 2
3 9 2 2
3 5 1 3
7 11 2 3
8 4 1 4
8 7 2 4
9 9 1 5
6 4 2 5];
%Sorting based on Duration
[~,inx]=sort(Activities(:,2)); % Change the column number to 1 to get the values in sorted order of resources
out = Activities(inx,:);
num = 0;
den = 0;
str = '';
modes = [];
for i = 10:-1:1 %As we need descending, we need to start from end
if ~contains(str,activity(Activities(i,4)))
num = num + Activities(i,1)*Activities(i,2); % Sum of distribution
den = den + Activities(i,2);% Sum of duration
str = [str activity(Activities(i,4))]; % Final order of activities
modes = [modes, Activities(i,4)]; % Final order modes to respective activities
end
end
average = num/den; % This is average on descending order of duration
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!