90 likes | 241 Views
d092: iRobot. Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010. Problem Description. Dr. John build some mazes to test some newly designed robots, called iRobots , whether they have the ability to collect the minerals cooperatively.
E N D
d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010
Problem Description • Dr. John build some mazes to test some newly designed robots, called iRobots, whether they have the ability to collect the minerals cooperatively. • In a maze with rows and columns, every iRobot can move on 4 directions in 1 step. • They can move onto an open cell (including cells that contain mineral or another iRobot.) • Now, there are MiRobots and M cells of mineral in the maze. Minimize the total number of steps that each iRobot collect distinct cells of mineral.
Example R R M M Answer: 18
Solution(1/2) • This is a minimum cost maximum matching problem.
Solution (2/2) • We can use the Hungarian Algorithm to solve this problem, see • http://en.wikipedia.org/wiki/Hungarian_algorithm • But this algorithm is difficult to implement well in short period of time (i.e. during the contest.) • Better to prepare it in your own toolbox. • The number of iRobots is no more than 20. • The graph is small, so we can run a simple shortest path algorithm for augmenting.
The Algorithm (1/2) • We first construct the graph, set each directed edge has capacity 1, flow 0, and cost to be the minimum distance from an iRobot to a mineral cell. • If an iRobot cannot move to a certain mineral cell, do not construct this edge. • Then for each augment iteration, we find the min-cost augmenting path using the shortest path algorithm (such as the Floyd-Warshall’s or Bellman-Ford’s). • Why No Dijkstra’s? • Why So Serious?
The Algorithm (2/2) • After found a shortest path, we invert the direction of each edge on this path and set their weights to be negative (or positive, if the weight on an edge is negative.) • Then add the cost to the answer. • After M iterations we then have found the minimum cost to the problem.
Related Problems • There are some problems for min/max-cost maximum matching problems in PTC. • d022: Course Enrollments • d072: On Sale • d094: Shipping Containers
Finally… Thanks for your attention!