Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
sorting of products based on requirement
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 10 Okt. 2019
"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.
Antworten (1)
Ganesh Regoti
am 5 Nov. 2019
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 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!