How to model an assignment/ allocation problem?
4 views (last 30 days)
Show older comments
Dear experts,
If I have NS students from NA departments, and there is a ranking in each department. Now I want to allocate them into K different groups (where each group only has limited place) according to their in-department ranking.
For example, I can allocate students according to their relative position (relative position = student's rank in department/ number of students in the department). Students with lower relative postion will be assigned first.
While I have no idea how to use matlab to model this kind of problem, I was wondering if anyone could please give me some advice?
Many thanks!
2 Comments
Answers (1)
Divyanshu
on 20 Apr 2023
Here is a demo MATLAB script which allocates students to K groups. Few assumptions taken are:
- The number of places in each group is 3 and K = 3.
- Each department has same number of students.
- Total departments are 3 and each has 3 students.
depts = [1 2 3];
students = ["st1" "st2" "st3" "st4" "st5" "st6" "st7" "st8" "st9"];
dept_wise_rank = ["st2" "st3" "st1";"st4" "st6" "st5";"st7" "st8" "st9"];
% 2-D matrix ‘dept_wise_rank’ stores the students according to their relative rankings.
% Each row represents a department.
grp_matrix = [];
% The outer loop iterates over each department.
% The inner loop iterates over each student within a department.
for i=1:3
grp = [];
for j=1:3
grp = [grp dept_wise_rank(i,j)];
end
grp_matrix = [grp_matrix;grp];
end
% The grp_matrix is another 2-D matrix where each row represents a group.
grp_matrix
For more details about the concatenation operations on matrices and accessing of elements from a 2-D array, please go through the following documentations:
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!