using matchpairs when objects have different capacities
7 次查看(过去 30 天)
显示 更早的评论
I am using the matchpairs function to determine the assignment of objects to people that minimizes the total cost.
It takes as input a matrix where element i,j indicates the cost of assigning object i to agent j.
However, the solution implies that each object can only be assigned to one person. What if object j can be asisgned to k persons?
0 个评论
采纳的回答
Steven Lord
2023-5-25
You could duplicate rows or columns in the matrix you pass to matchpairs to reflect that "multiple copies" of the object to be matched are available. Adapting the "Assign Flight with Minimal Cost" example on the matchpairs documentation page:
people = ["Fred"; "Beth"; "Sue"; "Greg"];
cities = ["Dallas"; "Chicago"; "New York City"; "St. Louis"];
C = [600 670 960 560
900 280 970 540
310 350 950 820
325 290 600 540];
C(:, 5) = C(:, 2); % Two people can go to Chicago
cities(5) = cities(2);
M = matchpairs(C, 1000);
for n = 1:height(M)
fprintf("Person %s is going to %s.\n", people(M(n, 1)), cities(M(n, 2)))
end
No one is going to New York City, which makes sense since it has the most expensive flights. Greg is going to Chicago in this modified example, where in the original example Greg went to NYC.
0 个评论
更多回答(1 个)
Matt J
2023-5-25
编辑:Matt J
2023-5-25
Then you are not seeking pairings. Therefore, matchpairs will not apply. But you can probably use minL1intlin from this FEX download,
to solve your more general problem. You can imitate what is done in "Example 2: Optimal Reordering of Points" under the examples tab. Except, though, you would drop the constraint,
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!