using matchpairs when objects have different capacities
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Josue Ortega
el 25 de Mayo de 2023
Respondida: Steven Lord
el 25 de Mayo de 2023
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 comentarios
Respuesta aceptada
Steven Lord
el 25 de Mayo de 2023
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 comentarios
Más respuestas (1)
Matt J
el 25 de Mayo de 2023
Editada: Matt J
el 25 de Mayo de 2023
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 comentarios
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!