"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
Algorithms for Graph Coloring Problem
1. Algorithms for Graph Coloring Problem
Wang Shengyi
National University of Singapore
November 6, 2014
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 1 / 24
2. Introduction Problem Description
Problem Description
• For a graph G = (V; E) and a color sequence c = (c0; c1; : : : ; cn), firstly
choose a node v 2 V and populate with c0
• Populate the rest of G in order of the rest of color sequence c such that only
new nodes connected to a previously populated node may be populated.
• Each populated G can be called a configuration, which can be seen as a
function f mapping node to color. We can calculate a reward value for such
a configuration f by the following formula:
H =
Σ
All filled (i;j)2E
1 (f(i); f(j)) where (x; y) =
{
0 x̸= y
1 x = y
• For any G and c, develop an algorithm to generate a configuration that gives
the maximum reward.
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 2 / 24
3. Introduction Data Set
Data Set
Set Number of Vertices Number of Edges Length of Color Sequences
01 10 29 10
02 153 5533 20
03 153 5533 130
04 590 658 400
05 2969 3372 4000
06 483 1358 400
07 11748 34716 9000
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 3 / 24
4. Introduction Data Set
Data Set
We can explore more…
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 4 / 24
5. Introduction Data Set
Graph Visualization: Graph 01
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 5 / 24
6. Introduction Data Set
Graph Visualization: Graph 02 03
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 6 / 24
7. Introduction Data Set
Graph Visualization: Graph 04
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 7 / 24
8. Introduction Data Set
Graph Visualization: Graph 05
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 8 / 24
9. Introduction Data Set
Graph Visualization: Graph 06
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 9 / 24
10. Introduction Data Set
Graph Visualization: Graph 07
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 10 / 24
11. Introduction Data Set
Color Sequence Visualization
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 11 / 24
12. Algorithms Representation
States
• Each state can be represented as a triple t = (
; p; )
•
is the subgraph which has not been populated.
• p is the set of all permitted choices.
• is a sequence of nodes which have been populated chronologically.
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 12 / 24
13. Algorithms Representation
State Transition Function: Transit
• Input: An old state (
; p; ) and n 2 p
• Output: An new state (
′; p′; ′)
•
′ =
removing n and related edges
• p′ = p [ neighbors of n in
fng
• ′ = :: n
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 13 / 24
14. Algorithms Randomized Algorithms
Search Component Generators: A Pentomino Style
• A search component S 2 S is a stochastic algorithm.
• Input: t = (
; p; ), Output: One or multiple final states t1; t2; : : : ; tm
• Before running, S would check the budget. For each final state, S compares
the reward with the best result so far and updates the budget.
• A search component generator : ! S
• Given a set of parameters 2 , () is a search component
• Simulate, Repeat, LookAhead, Step and Select
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 14 / 24
15. Algorithms Randomized Algorithms
Simulate
Parameters: Policy simu, mapping
from permitted set p to
choice n.
Algorithm: Repeatedly sampling
nodes according to simu
and performs transitions
Transit until reaching
the final state.
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 15 / 24
16. Algorithms Randomized Algorithms
Repeat
Parameters: A positive integer N 0,
a search component S
Algorithm: It repeats performing S
for N times.
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 16 / 24
17. Algorithms Randomized Algorithms
LookAhead
Parameters: A search component S
Algorithm: For each n 2 p, it
performs S on
Transit(t; n).
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 17 / 24
18. Algorithms Randomized Algorithms
Step
Parameters: A search component S
Algorithm: For each remaining steps
until the final state, it
performs S first. Then it
extracts the local best
choice nl and performs
transition
Transit(tstep; nl).
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 18 / 24
19. Algorithms Randomized Algorithms
Select
Parameters: A selection policy sel, a
search component S
Algorithm: It looks like Step. But in
each step, it chooses node
according to sel.
sel: UCB-1
C
s(t; c): Sum of rewards,from S
with Transit(t; c)
n(t; c): Number of times c was
selected in state t
n(t): Sum of n(t; c)
arg max
c2p
s(t; c)
n(t; c)
√
ln n(t)
n(t; c)
+ C
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 19 / 24
20. Algorithms Randomized Algorithms
Compisition
• Is = Step(Repeat(N; Simulate(random)))
• Nmc(0) = Simulate(random)
Nmc(l) = Step(LookAhead(Nmc(l 1)))
• Uct(C) = Step(Repeat(N; Select(UCB-1
C ; Simulate(random))))
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 20 / 24
21. Algorithms Greedy Algorithm
Greedy Strategy
arg max
c2p
Reward(fcg [ Neighbors(c; G))
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 21 / 24
22. Result
Results of Iterative Sampling (Is)
N set01 set02 set03 set04 set05 set06 set07
1 11 50 1981 129 1039 439 9721
10 16 58 2091 159 1107 473 9777
100 19 74 2127 167 1126 483 9878
1000 19 79 2147 167 1158 489 9938
4000 19 84 2181 175 1158 506 10006
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 22 / 24
23. Result
Result of Different Algorithms for Budget 1000
Algorithms set01 set02 set03 set04 set05 set06 set07
Is 19 79 2147 167 1158 489 9938
Nmc(2) 19 79 2171 171 1152 498 9953
Nmc(3) 18 75 2158 173 1145 503 9912
Uct(0:3) 19 98 2165 171 1141 504 9933
Uct(0:5) 19 98 2165 171 1141 500 9933
Greedy 19 156 2719 219 1473 737 16118
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 23 / 24
24. Thank you!
Wang Shengyi (NUS) Algorithms for Graph Coloring Problem November 6, 2014 24 / 24