Largest Candidate Rule
1 次查看(过去 30 天)
显示 更早的评论
I have to write a program for assembly line balancing utilizing the Largest Candidate rule. Basically that is taking a series of elements with an associated time, then reordering the elements in descending order by time, ie the longest time first. Then I must group the elements into work stations by observing other constraints. Any suggestions. I am still pretty new to Matlab so my knowledge is still pretty basic.
I am having a hard time visualizing how to group the elements into work stations. There is a time cycle which the sum of the time of the grouped elements cannot exceed. There are also precedence factors which dictate which station certain elements can be in. I just cannot figure out how to account for all of it. It seems to me there would be an overwhelming amount of "if" statements in this code.
0 个评论
采纳的回答
UJJWAL
2011-9-27
Hi Jason,
Ok. I am assuming some things. I assume that you are a very basic and new user of MATLAB. So The code which I am giving is an extremely basic code just to give you a feel of the steps. There can be more optimized and complicated and slick codes but I have made this basic code for you for your understanding.
a(:,1) = randi(1000,[1,100]); % Suppose it denotes the time taken
a(:,2) = randi(5000,[1,100]); % Suppose it denotes constraint A
a(:,3)= randi(20000,[1,100]); % Suppose it denotes constraint B
[p,q] = sort(a(:,1),'descend'); % Please look the syntax up in the help file
a(:,[1:end]) = a(q,[1:end]); % What I have done is that I have just arranged the observations in the order of their decreasing time
work1 = []; % Suppose I have 3 workstations and I have declared three vectors to store the elements to work on them
work2=[];
work3=[];
for i = 1: size(a,1)
if a(i,2)+a(i,3)>2000; % IF the sum of constraints A and B is more than 2000 then work at workstation 1
work1= horzcat(work1,a(i,1));
else
if a(i,2)+a(i,3)<2000 && a(i,2)+a(i,3)>1000 % Similarly the two conditions
work2 = horzcat(work2,a(i,1));
else
work3=horzcat(work3,a(i,1));
end
end
end
Of Course the number of if statements involved would be large depending upon the constraints and their inter-relationships. In Pattern Recognition also we work on large number of constraints and in many cases it is impossible to escape the if-else statements. Dont be afraid of them. In some cases you may reduce the number of if-else statements but it takes luck and conditions. I hope this code would give you an idea of the problem. I hope I have captured ur problem and given u an apt reply. If you need more help, mail back
Happy to Help
UJJWAL
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!