๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ5: ๐’ฆ๐‘œ๐“‡๐‘’๐’ถ ๐’ฐ๐“ƒ๐’พ๐“‹/Artificial Intelligence(COSE361)

[์ธ๊ณต์ง€๋Šฅ] 6. Constraint Satisfaction Problems

1. Problem Formulation as a CSP

 : ๋ฌธ์ œ ์ƒํ™ฉ์„ ํ‘œํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ• ์ค‘์—์„œ๋Š” factored represetation์ด ์žˆ๋‹ค. ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์–ด๋–ค ์ œํ•œ์‚ฌํ•ญ, ์กฐ๊ฑด๋“ค(Constraint)๋ฅผ ๋งŒ์กฑ์‹œ์ผœ์•ผ ํ’€๋ฆฐ๋‹ค๊ณ  ํ•ด๋ณด์ž. Factored representation์€ ๊ฐ states๋ฅผ variable์„ ํ™œ์šฉํ•ด ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์ด๊ณ (goal state ๋˜ํ•œ ๊ทธ๋ ‡๋‹ค), ์ด variable์— ํ• ๋‹น๋œ value๊ฐ’์ด constraint์„ ๋งŒ์กฑํ•˜๋Š” ๊ฐ’์ผ ๋•Œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ๋‹ค๊ณ  ๋งํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

  ์ฆ‰, ์–ด๋–ค ๊ฐ’์„ ํ• ๋‹นํ•  ์ˆ˜ ์žˆ๋Š” variable๊ณผ ๋…ผ๋ฆฌ์—ฐ์‚ฐ์ž๋ฅผ ์ด์šฉํ•ด ์–ด๋–ค ๋ฌธ์ œ ์ƒํ™ฉ์„ ํ‘œํ˜„ํ•œ๋‹ค๊ณ  ํ•  ๋•Œ, ์ด๋Ÿฐ ๋ฌธ์ œ๋“ค์„ Constraint Satisfaction Problem์ด๋ผ๊ณ  ํ•œ๋‹ค. 

 ( ์ง€๊ธˆ๊นŒ์ง€๋Š” autonomic representation์„ ์‚ฌ์šฉํ–ˆ์—ˆ๋Š”๋ฐ, ์ด์ œ๋ถ€ํ„ฐ๋Š” state์˜ ๋‚ด๋ถ€๋ฅผ ๋“ค์—ฌ๋‹ค ๋ด ๋‚ด๋ถ€ ์ •๋ณด์— ์ ‘๊ทผํ•  ๊ฒƒ์ด๋‹ค.)

 

   CSP search algorithms์€ structure of states์—์„œ ์ด์ ์„ ๊ฐ€์ง€๊ณ , ๋ฌธ์ œ๋ณ„๋กœ ๋‹ค๋ฅธ heuristic์„ ์‚ฌ์šฉํ•˜๋Š” ๋Œ€์‹  ์ผ๋ฐ˜์ ์ธ general heuristics์„ ์‚ฌ์šฉํ•ด ๋ณต์žกํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค. constraints๋ฅผ ๋งŒ์กฑํ•˜์ง€ ์•Š๋Š” variable/value ์˜ ์กฐํ•ฉ๋“ค์„ ์•Œ์•„๋‚ด, search space์˜ ๋งŽ์€ ๋ถ€๋ถ„์„ ํ•œ๊บผ๋ฒˆ์— pruningํ•˜์—ฌ ์—†์•ฐ์œผ๋กœ์จ search space๋ฅผ ํ•œ ๋ฒˆ์— ํ™• ์ค„์ผ ์ˆ˜ ์žˆ๋‹ค. 

 

 

CSP์˜ components์—๋Š” X, D, C๊ฐ€ ์žˆ๋‹ค

 โ‘  X๋Š” ๋ณ€์ˆ˜๋“ค variables์˜ ์ง‘ํ•ฉ์ด๋‹ค. {X1, X2, ... , XN}

 โ‘ก D๋Š” ๊ฐ ๋ณ€์ˆ˜๋“ค๋งˆ๋‹ค ์ •์˜๋˜๋Š” domains์˜ ์ง‘ํ•ฉ์ด๋‹ค.(์ •์˜์—ญ) {D1, D2, ... , DN}

    ํ•œ ๋ณ€์ˆ˜๋Š” Domain ์•ˆ์˜ ๊ฐ’๋“ค ์ค‘์—์„œ ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

 โ‘ข C๋Š” constraints์˜ ์ง‘ํ•ฉ์œผ๋กœ, ํ—ˆ์šฉ ๊ฐ€๋Šฅํ•œ value๋“ค์˜ ์กฐํ•ฉ์„ ๋งํ•œ๋‹ค. ์ฆ‰ ๋ณ€์ˆ˜๋“ค์ด ์–ด๋–ค ๊ฐ’์„ ๊ฐ€์ ธ์•ผ ํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์กฐ๊ฑด์„ ๋งํ•œ๋‹ค.

    constraint๋Š” <Scope, rel> ์˜ ํ•œ ์Œ์œผ๋กœ ์ด๋ฃจ์–ด์ง€๋Š”๋ฐ, scope ๋Š” ์กฐ๊ฑด์„ ๊ตฌ์„ฑํ•˜๋Š” ๋ณ€์ˆ˜๋“ค์˜ ์ง‘ํ•ฉ์ด๊ณ , rel์€ ๊ทธ ๋ณ€์ˆ˜๋“ค์ด ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ๊ฐ’๋“ค์ด ์–ด๋–ค ๊ด€๊ณ„๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š”์ง€์— ๋Œ€ํ•œ relation ์ด๋‹ค. ์ฆ‰ ์กฐ๊ฑด์ด๋‹ค. 

  ex) <(X1,X2) , X1 = X2 >

 

๋Œ€ํ‘œ์ ์ธ CSP๋Š” ๋ฐ”๋กœ ์ด ์ƒ‰์น  ๋ฌธ์ œ์ด๋‹ค. (b) ๊ทธ๋ž˜ํ”„์—์„œ ์ธ์ ‘ํ•œ ๋‘ ์ •์ ์—๋Š” ์„œ๋กœ ๋‹ค๋ฅธ value๋ฅผ ํ• ๋‹นํ•˜๋Š” ๋ฌธ์ œ์ธ ๊ฒƒ์ด๋‹ค. 

CSP๋ฌธ์ œ๋Š” constraint graph๋กœ ๋ณด๊ธฐ ํŽธํ•˜๊ฒŒ ๋ฐ”๊พธ๊ณค ํ•œ๋‹ค. node๊ฐ€ ๊ฐ๊ฐ problem์˜ variable์ด ๋˜๊ณ , ๊ฐ„์„ ์€ constraint์— ์กด์žฌํ•˜๋Š” ๋‘ variable์„ ์ด์–ด์ค€๋‹ค.

 

์œ„ ๋ฌธ์ œ๋ฅผ CSP๋กœ ๋‚˜ํƒ€๋‚ด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

 

X = { WA, SA, V, NSW, Q, NT, T }

D = { D1, ..., D7 } , Di = {red, green, blue} // ๊ฐ variable์€ red, green, blue์˜ ๊ฐ’์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿฐ variable์ด ์ด 7๊ฐœ

C = { SA ≠ WA , SA ≠ NT ..., NSW ≠V} // ์ธ์ ‘ํ•œ ๋‘ ์ •์ ์€ ์ƒ‰์ด ๋‹ฌ๋ผ์•ผ ํ•œ๋‹ค

 

๊ทธ๋ž˜์„œ ๊ฐ Variable์— ์–ด๋– ํ•œ value๋ฅผ ํ• ๋‹นํ•˜๋Š” ๊ฒƒ์ด CSP์—์„œ์˜ state์ด๋‹ค. 

 ex) {Xi = vi , Xj = vj , ... }

 

์ด๋ ‡๊ฒŒ ๋ชจ๋“  variable์— ๊ฐ’์ด ํ• ๋‹น๋˜์—ˆ๋‹ค๋ฉด complete assignment, variable์˜ ์ผ๋ถ€์—๋งŒ value๊ฐ’์ด ํ• ๋‹น๋˜์—ˆ๋‹ค๋ฉด partial assignment๋ผ๊ณ  ํ•œ๋‹ค. ๋˜ํ•œ assignment๊ฐ€ ์–ด๋– ํ•œ constraints๋„ ์–ด๊ธฐ์ง€ ์•Š์•˜๋‹ค๋ฉด ์ด๊ฒƒ์„ consistent ๋˜๋Š” Legal assignment๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. ๋”ฐ๋ผ์„œ CSP์—์„œ์˜ solution์€ consistentํ•˜๊ณ  complete ํ•œ asignment๊ฐ€ ๋œ๋‹ค. 

๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๋Š” ๋ฌธ์ž๋กœ ๋œ ๋ฌธ์ œ๋ฅผ CSP๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์–ด์•ผ ํ•œ๋‹ค.

 

EX) ์ฐจ์˜ ๋ถ€ํ’ˆ์„ ๊ฒฐํ•ฉํ•˜์ž : ์•ž , ๋’ค ๋ฐ”ํ€ด ์ถ•์„ ๋‹ฌ๊ณ , ๋„ค๊ฐœ์˜ ๋ฐ”ํ€ด๋ฅผ ๊ณ ์ •์‹œํ‚ค๊ณ , ๊ฐ ๋ฐ”ํ€ด์˜ ๋„ˆํŠธ๋ฅผ ๊ณ ์ •์‹œํ‚ค๊ณ , ๋งˆ๊ฐ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰์œผ๋กœ ์ž˜ ํ•ฉ์ณ์กŒ๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•œ๋‹ค. ์ถ•์„ ๋‹ค๋Š”๋ฐ๋Š” 10๋ถ„, ๋ฐ”ํ€ด๋‹ค๋Š”๋ฐ๋Š” 1๋ถ„, ๋‚˜์‚ฌ์กฐ์ด๋Š”๋ฐ๋Š” 2๋ถ„์ด ๊ฑธ๋ฆฌ๊ณ  ๋งˆ๊ฐ์—” 3๋ถ„์ด ๊ฑธ๋ฆฐ๋‹ค. ๋˜ํ•œ ์ถ•->๋ฐ”ํ€ด->๋‚˜์‚ฌ->๋งˆ๊ฐ ์ˆœ์œผ๋กœ ์ง„ํ–‰๋˜์–ด์•ผ ํ•œ๋‹ค. 30๋ถ„ ์•ˆ์— ์กฐ๋ฆฝํ•ด๋ณด์ž.

 

X = { axles_f, axles_b, wheel_fr, wheel_fl, wheel_br, wheel_bl, nut_fr, nut_fl, nut_br, nut_bl, cap_fl, cap_fr, cap_bl, cap_br, inspect }

 

D = { D1, D2, ... , D15 } , Di = { 1, ... ,27 } // ๋งˆ์ง€๋ง‰ 3๋ถ„์€ ์ ๊ฒ€ํ•˜๋Š”๋ฐ ์จ์•ผํ•ด์š” ๋”ฐ๋ผ์„œ ์•ž ๋‹จ๊ณ„๊นŒ์ง€ 27๋ถ„ ์ปท ํ•ด์•ผํ•จ

 

C =  {

axles_f + 10 <= wheel_fr, axles_f + 10 <= wheel_fl,

(๋ฐ”ํ€ด ์„ค์น˜ํ•˜๊ธฐ ์‹œ์ž‘ํ•˜๋Š” ์‹œ๊ฐ„์€ ์ฐจ์ถ• ์„ค์น˜ํ•˜๊ณ  ๋‚˜์„œ ์ตœ์†Œํ•œ 10๋ถ„์ด ํ๋ฅธ ๋’ค์–ด์•ผ ํ•จ)

axles_b + 10 <= wheel_br, axles_b + 10 <= wheel_bl, 

wheel_fr + 1 <= nut_fr, wheel_fl +1 <= nut_fl, wheel_br +1 <= nut_br, wheel_bl + 1 <= nut_bl,

nut_fr + 2 <= cap_fr,...

(axles_f + 10 <= axles_b) or (axles_b + 10 <= axles_f)}

∩ {X != Inspect | X + dx <= inspect }

 

 

๋˜ํ•œ ์ˆซ์ž ์•”ํ˜ธ ์—ญ์‹œ CSP๋กœ ํ’€ ์ˆ˜ ์žˆ๋‹ค.

X = { F, T, U, W, R, O, C3, C2, C1}

D = {D1,...,D9}, Di = {0,...9}

C = { F!=T!=U!=W!=R, O+O = 10*C1 + R, W+W+C1 = U + 10*C2, T+T+C2 = O+10*C3, C3 = F, F != 0 }

 

 

์ด ์™ธ์—๋„ Sudoku, 8-queens ๋ฌธ์ œ ๋“ฑ์„ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

Advantage of CSP

 - CSP๋Š” ๋งค์šฐ ๋‹ค์–‘ํ•˜๊ณ  ๋งŽ์€ ๋ฌธ์ œ๋“ค์„ ์ž์—ฐ์–ด์ฒ˜๋Ÿผ naturalํ•˜๊ฒŒ ํ‘œํ˜„ํ•   ์ˆ˜ ์žˆ๋‹ค.

 - ๊ทธ๋ž˜์„œ ๋‹ค๋ฅธ search technique์„ ์‚ฌ์šฉํ•ด ์„ค๊ณ„ํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ๋ฌธ์ œ ์ž์ฒด๋ฅผ ํ™œ์šฉํ•ด ํ•ด๊ฒฐํ•˜๋Š” ๊ฒƒ์ด ๋” ์‰ฌ์šด ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

 - CSP๋กœ ๋ฌธ์ œ๋ฅผ ํ’€๋ฉด ๋‹ค๋ฅธ state-space searchers๋ณด๋‹ค ํ›จ์”ฌ ๋น ๋ฅด๋‹ค. ์™œ๋ƒ๋ฉด CSP ๋Š” generalํ•œ ๋ฌธ์ œํ’€์ด ๋ฐฉ๋ฒ•์ด ์žˆ์–ด์„œ search space๋ฅผ ๋น ๋ฅด๊ฒŒ ์—†์•  ๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. CSP๋ฅผ ํ†ตํ•ด solution์ด ์•„๋‹Œ ๊ฒƒ, ์ฆ‰ constraint๋ฅผ ์œ„๋ฐฐํ•˜๋Š” partial assignment๋“ค์€ ๋น ๋ฅด๊ฒŒ pruning ํ•ด๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๋‹ค!