po-lung chen (dont block me) d092: irobot 2010/03/26 (1) d092: irobot po-lung chen team dont block...

9
Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Upload: georgina-dean

Post on 19-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1)

d092: iRobot

Po-Lung Chen

Team Dont Block Me, National Taiwan University

March 26, 2010

Page 2: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (2)

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 M iRobots and M cells of mineral in the maze. Minimize the total number of steps that each iRobot collect distinct cells of mineral.

Page 3: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (3)

Example

R R

M

M

Answer: 18

Page 4: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (4)

Solution (1/2)

• This is a minimum cost maximum matching problem.

Page 5: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (5)

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.

Page 6: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (6)

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?

Page 7: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (7)

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.

Page 8: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (8)

Related Problems

• There are some problems for min/max-cost maximum matching problems in PTC.– d022: Course Enrollments– d072: On Sale– d094: Shipping Containers

Page 9: Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (1) d092: iRobot Po-Lung Chen Team Dont Block Me, National Taiwan University March 26, 2010

Po-Lung Chen (Dont block me) d092: iRobot 2010/03/26 (9)

Finally…

Thanks for your attention!