Your SlideShare is downloading. ×
Ai ch5 (madsg.com)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ai ch5 (madsg.com)

173
views

Published on

Published in: Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
173
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. ‫ﺋ‬‫ﻣﺤﺪودﻳﺖ‬ ‫ارﺿﺎء‬ ‫ﻣﺴﺎﺋﻞ‬ (CSP)(CSP) ‫ﭘﻨﺠﻢ‬ ‫ﻓﺼﻞ‬ ‫رﺿﻮي‬ ‫ﻧﺎﺻ‬ ‫ﺪ‬ ‫ﺳ‬‫رﺿﻮي‬ ‫ﻧﺎﺻﺮ‬ ‫ﺳﻴﺪ‬ razavi@Comp.iust.ac.irEmail: 1384 ‫ﻣﻘﺪﻣﻪ‬‫ﻣﻘﺪﻣﻪ‬ •‫ﻨﺪ‬‫ﺜﺎل‬‫از‬‫ﺎﺋﻞ‬‫ﺿﺎ‬ ‫ا‬‫ﺖ‬ ‫ﺪ‬ •‫ﭼﻨﺪ‬‫ﻣﺜﺎل‬‫از‬‫ﻣﺴﺎﺋﻞ‬‫ارﺿﺎء‬‫ﻣﺤﺪودﻳﺖ‬ •‫ﻛﺎرﺑﺮد‬General Search‫در‬‫ﺣﻞ‬CSP ‫ﻞ‬ •‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬(backtracking)‫ﺑﺮاي‬CSP ‫ل‬ ‫ﻛ‬‫ﻠ‬(f d h ki ) •‫ﻛﻨﺘﺮل‬‫روﺑﻪ‬‫ﺟﻠﻮ‬(forward checking) •‫اﺳﺘﻔﺎده‬‫از‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﺎ‬‫در‬CSP‫ﻫﺎ‬ ‫ﻴ‬ ‫ﻳ‬ ‫ﻴﻮ‬ •‫ﺟﺴﺘﺠﻮي‬‫ﻣﺤﻠﻲ‬‫ﺑﺮاي‬‫ﻣﺴﺎﺋﻞ‬‫ارﺿﺎء‬‫ﻣﺤﺪودﻳﺖ‬ N. Razavi - AI course - 2005 2 ‫ﻣﺤﺪودﻳﺖ‬ ‫ارﺿﺎ‬ ‫ﻣﺴﺎﺋﻞ‬‫ﻣﺤﺪودﻳﺖ‬ ‫ارﺿﺎء‬ ‫ﻣﺴﺎﺋﻞ‬ •‫ﻣﺴﺄﻟﻪ‬‫ﺟﺴﺘﺠﻮي‬‫اﺳﺘﺎﻧﺪارد‬ –‫ﺣﺎﻟﺖ‬‫ﻳﻚ‬“‫ﺟﻌﺒﻪ‬‫ﺳﻴﺎه‬”‫اﺳﺖ‬–‫ﻫﺮ‬‫ﺳﺎﺧﺘﺎر‬‫داده‬‫اي‬‫ﻛﻪ‬‫از‬‫ﺗﺎﺑﻊ‬‫ﺣﺎﻻت‬،‫ﺑﻌﺪي‬‫ﺗﺎﺑﻊ‬ ‫ﻳ‬‫ﺒ‬ ‫ﺟ‬‫ﻴ‬‫ﺮ‬‫ر‬‫ي‬‫ز‬‫ﺑﻊ‬‫ي‬ ‫ﺑ‬‫ﺑﻊ‬ ‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫و‬‫ﺗﺴﺖ‬‫ﻫﺪف‬‫ﭘﺸﺘﻴﺒﺎﻧﻲ‬‫ﻛﻨﺪ‬. •CSP: –‫ﺣﺎﻟﺖ‬‫ﺗﻮﺳﻂ‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﻣﺘﻐﻴﺮﻫﺎي‬Xi‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬‫ﺷﻮد‬‫ﻛﻪ‬‫ﻫﺮ‬‫ﻳﻚ‬‫ﻣﻘﺎدﻳﺮﺷﺎن‬‫را‬‫از‬‫ﻳﻚ‬‫داﻣﻨﻪ‬ Di‫اﺧﺘﻴﺎر‬‫ﻣﻲ‬‫ﻛﻨﻨﺪ‬. ‫ف‬‫ا‬‫ا‬‫ﺎ‬‫ﺎ‬‫ﺎ‬‫ﻛ‬‫ﺎ‬ ‫ﻛ‬‫ﺎ‬‫ﻘﺎ‬‫ا‬ ––‫ﺗﺴﺖ‬‫ﻫﺪف‬‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫ﻫﺎ‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬‫ﻛﻪ‬‫ﺗﺮﻛﻴﺒﺎت‬‫ﻣﺠﺎز‬‫ﻣﻘﺎدﻳﺮ‬‫ﺑﺮاي‬ ‫زﻳﺮﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫را‬‫ﻣﺸﺨﺺ‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •‫ﻣﺜﺎل‬‫ﺳﺎده‬‫اي‬‫از‬‫ﻳﻚ‬‫زﺑﺎن‬‫زﺑﺎن‬‫ﺑﺎزﻧﻤﺎﻳﻲ‬‫ﺑﺎزﻧﻤﺎﻳﻲ‬‫رﺳﻤﻲ‬‫رﺳﻤﻲ‬ ••‫ﻜﺎن‬ ‫ا‬‫ﺘﻔﺎ‬ ‫ا‬‫از‬‫ﺘ‬ ‫اﻟﮕ‬‫ﺎ‬‫ﻪ‬‫ﻪ‬‫ﻨﻈ‬‫ﻨﻈ‬‫ﻛﻪ‬‫ﺖ‬ ‫ﻧ‬‫ﻪ‬‫ﺘ‬ ‫اﻟﮕ‬‫ﺎ‬ ••‫اﻣﻜﺎن‬‫اﺳﺘﻔﺎده‬‫از‬‫اﻟﮕﻮرﻳﺘﻢ‬‫ﻫﺎي‬‫ﻫﻤﻪ‬‫ﻫﻤﻪ‬‫ﻣﻨﻈﻮره‬‫ﻣﻨﻈﻮره‬‫ﻛﻪ‬‫ﻧﺴﺒﺖ‬‫ﺑﻪ‬‫اﻟﮕﻮرﻳﺘﻢ‬‫ﻫﺎي‬ ‫اﺳﺘﺎﻧﺪارد‬‫ﻗﺪرت‬‫ﺑﻴﺸﺘﺮي‬‫دارﻧﺪ‬. N. Razavi - AI course - 2005 3 ‫ﻣﺜﺎل‬:‫ﻧﻘﺸﻪ‬ ‫آﻣﻴﺰي‬ ‫رﻧﮓ‬ ‫ﻣﺜﺎل‬:‫ﻧﻘﺸﻪ‬ ‫آﻣﻴﺰي‬ ‫رﻧﮓ‬ •‫ﻣﺘﻐﻴﺮﻫﺎ‬:WA, NT, Q, NSW, V, SA, T •‫داﻣﻨﻪ‬‫ﻫﺎ‬:{red, green, blue} •‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬:‫ﻧﻮاﺣﻲ‬‫ﻫﻤﺴﺎﻳﻪ‬‫ﺑﺎﻳﺪ‬‫رﻧﮓ‬‫ﻣﺘﻔﺎوﺗﻲ‬‫داﺷﺘﻪ‬‫ﺑﺎﺷﻨﺪ‬ ‫ﻲ‬‫ﻲ‬ ‫ﻣﺜﻼ‬:WA ≠ NT،‫ﺑﻪ‬‫ﺑﻴﺎن‬‫دﻳﮕﺮ‬: {(red green) (red blue) (green red) (green blue) (blue red) (blue green)} N. Razavi - AI course - 2005 4 {(red, green), (red, blue), (green, red), (green, blue), (blue, red), (blue, green)}
  • 2. ‫ﻣﺜﺎل‬:‫ﻧﻘﺸﻪ‬ ‫آﻣﻴﺰي‬ ‫رﻧﮓ‬ ‫ﻣﺜﺎل‬:‫ﻧﻘﺸﻪ‬ ‫آﻣﻴﺰي‬ ‫رﻧﮓ‬ ‫ﻛ‬‫ﻛ‬‫ﮔ‬‫ﮔ‬ •‫راه‬‫ﺣﻞ‬‫ﻫﺎ‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻛﺎﻣﻞ‬‫ﻛﺎﻣﻞ‬‫و‬‫ﺳﺎزﮔﺎر‬‫ﺳﺎزﮔﺎر‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. •‫ﻣﺜﺎل‬:‫ﻣﺜﺎل‬: {WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green} N. Razavi - AI course - 2005 5 ‫ﻣﺤﺪودﻳﺖ‬ ‫ﮔﺮاف‬‫ﻣﺤﺪودﻳﺖ‬ ‫ﮔﺮاف‬ ••‫ﮔﺮاف‬‫ﮔﺮاف‬‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬:: ‫ﮔ‬‫ﺎ‬‫ﺎ‬‫ﺎ‬ -‫ﮔﺮه‬‫ﻫﺎ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫را‬‫ﻧﺸﺎن‬‫ﻣﻲ‬‫دﻫﻨﺪ‬. -‫ﻳﺎﻟﻬﺎي‬‫ﮔﺮاف‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫ي‬‫ﺑﻴﻦ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫را‬‫ﻧﺸﺎن‬‫ﻣﻲ‬‫دﻫﻨﺪ‬. ‫ي‬ ‫ﻬ‬ ‫ﻳ‬‫ﺮ‬‫ﻳ‬ ‫و‬‫ي‬‫ﺑﻴﻦ‬‫ﻴﺮ‬‫ر‬‫ﻲ‬ N. Razavi - AI course - 2005 6 ‫ﺻﻮرت‬ ‫ﺑﻪ‬ ‫ﻣﺴﺄﻟﻪ‬ ‫ﺑﻴﺎن‬ ‫ﻣﺰاﻳﺎي‬CSP ‫ﺻﻮرت‬ ‫ﺑﻪ‬ ‫ﻣﺴﺄﻟﻪ‬ ‫ﺑﻴﺎن‬ ‫ﻣﺰاﻳﺎي‬CSP ‫ﻟ‬‫ﻟ‬) •‫ﺑﻪ‬‫دﻟﻴﻞ‬‫ﻧﻤﺎﻳﺶ‬‫اﺳﺘﺎﻧﺪارد‬‫ﺣﺎﻟﺖ‬‫ﻫﺎ‬)‫ﻣﺠﻤﻮﻋﻪ‬‫ﻣﺘﻐﻴﺮﻫﺎﻳﻲ‬‫ﺑﺎ‬ ‫ﻣﻘﺪارﺷﺎن‬(،‫ﻣﻲ‬‫ﺗﻮان‬‫ﺗﺎﺑﻊ‬‫ﺗﺎﺑﻊ‬SuccessorSuccessor‫و‬‫آزﻣﻮن‬‫آزﻣﻮن‬‫ﻫﺪف‬‫ﻫﺪف‬‫را‬‫ﺑﻪ‬ ‫ن‬ ‫ر‬(،‫ﻲ‬‫ن‬ ‫ﻮ‬‫ﺑﻊ‬‫ﺑﻊ‬SuccessoSuccesso‫و‬‫ﻮن‬ ‫ز‬‫ﻮن‬ ‫ز‬‫ف‬‫ف‬‫ر‬‫ﺑ‬ ‫ﺷﻜﻞ‬‫ﻛﻠﻲ‬‫ﻧﻮﺷﺖ‬‫ﺑﻪ‬‫ﻃﻮرﻳﻜﻪ‬‫ﺑﺮاي‬‫ﻫﺮ‬CSP‫ﻗﺎﺑﻞ‬‫اﻋﻤﺎل‬‫ﺑﺎﺷﺪ‬. ••‫ﻣ‬‫ان‬ ‫ﺗ‬‫ﻚ‬ ‫ﺘ‬ ‫ﻳ‬ ‫ﻫ‬‫ﻚ‬ ‫ﺘ‬ ‫ﻳ‬ ‫ﻫ‬‫ﻫﺎي‬‫ﻫﺎي‬‫ﻛﻠ‬‫ﻛﻠ‬‫و‬‫و‬‫اﻳ‬ ‫ﻛﺎ‬‫اﻳ‬ ‫ﻛﺎ‬‫اﻳﺠﺎد‬‫د‬ ‫ﻛ‬‫ﻛﻪ‬‫ﺎز‬ ‫ﻧ‬‫ﺑﻪ‬ ••‫ﻣﻲ‬‫ﺗﻮان‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﺎي‬‫ﻫﺎي‬‫ﻛﻠﻲ‬‫ﻛﻠﻲ‬‫و‬‫و‬‫ﻛﺎراﻳﻲ‬‫ﻛﺎراﻳﻲ‬‫اﻳﺠﺎد‬‫ﻛﺮد‬‫ﻛﻪ‬‫ﻧﻴﺎز‬‫ﺑﻪ‬ ‫ﺗﺨﺼﺺ‬‫اﺿﺎﻓﻲ‬‫در‬‫داﻣﻨﻪ‬‫ﺧﺎص‬‫ﻣﺴﺄﻟﻪ‬‫ﻧﺪاﺷﺘﻪ‬‫ﺑﺎﺷﻨﺪ‬. N. Razavi - AI course - 2005 7 ‫ﻣﺴﺎﺋﻞ‬ ‫اﻧﻮاع‬CSP ‫ﻣﺴﺎﺋﻞ‬ ‫اﻧﻮاع‬CSP •‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﮔﺴﺴﺘﻪ‬ –‫داﻣﻨﻪ‬‫ﻫﺎي‬‫ﻣﺤﺪود‬: •n،‫ﻣﺘﻐﻴﺮ‬‫اﻧﺪازه‬‫ﻫﺮ‬‫داﻣﻨﻪ‬d‫ﺗﻌﺪاد‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻛﺎﻣﻞ‬O(dn) •‫ﻣﺜﺎل‬:CSP‫ﻫﺎي‬‫ﺑﻮﻟﻴﻦ‬،n-‫وزﻳﺮ‬،‫رﻧﮓ‬‫آﻣﻴﺰي‬‫ﻧﻘﺸﻪ‬‫و‬... ‫ا‬‫ﺎ‬‫ﺎ‬ –‫داﻣﻨﻪ‬‫ﻫﺎي‬‫ﻧﺎﻣﺤﺪود‬: •‫اﻋﺪاد‬،‫ﺻﺤﻴﺢ‬‫رﺷﺘﻪ‬‫ﻫﺎ‬‫و‬... •‫ﻣﺜﺎل‬:‫زﻣﺎﻧﺒﻨﺪي‬‫ﻛﺎرﻫﺎ‬-،‫ﻣﺘﻐﻴﺮﻫﺎ‬‫زﻣﺎن‬‫ﺷﺮوع‬/‫ﭘﺎﻳﺎن‬‫ﻫﺮ‬‫ﻛﺎر‬‫ﻫﺴﺘﻨﺪ‬ ‫ﻣﺜﺎل‬:‫زﻣﺎﻧﺒﻨﺪي‬‫ﻛﺎرﻫﺎ‬،‫ﻣﺘﻐﻴﺮﻫﺎ‬‫زﻣﺎن‬‫ﺷﺮوع‬/‫ﭘﺎﻳﺎن‬‫ﻫﺮ‬‫ﻛﺎر‬‫ﻫﺴﺘﻨﺪ‬. •‫ﻧﺒﺎز‬‫ﺑﻪ‬‫زﺑﺎن‬‫ﻣﺤﺪودﻳﺖ‬‫دارﻧﺪ‬.‫ﻣﺜﺎل‬:StartJob1 + 5 ≤ StartJob3 •‫ﺎ‬ ‫ﻐ‬ •‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﭘﻴﻮﺳﺘﻪ‬ –‫ﻣﺜﺎل‬:‫زﻣﺎن‬‫ﻫﺎي‬‫ﺷﺮوع‬‫و‬‫ﭘﺎﻳﺎن‬‫ﻣﺸﺎﻫﺪات‬‫ﺗﻠﺴﻜﻮپ‬‫ﻓﻀﺎﻳﻲ‬‫ﻫﺎﺑﻞ‬ ‫ﺎ‬‫ﻄ‬‫ﻛ‬‫ﻂ‬‫ﻧﺎ‬‫ﻄ‬‫ﻞ‬‫ﻗﺎ‬‫ﻞ‬‫ﺎن‬ ‫ز‬‫ﻠ‬‫ا‬ –‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎي‬‫ﺧﻄﻲ‬‫ﻛﻪ‬‫ﺗﻮﺳﻂ‬‫ﺑﺮﻧﺎﻣﻪ‬‫رﻳﺰي‬‫ﺧﻄﻲ‬‫ﻗﺎﺑﻞ‬‫ﺣﻞ‬‫در‬‫زﻣﺎن‬‫ﭼﻨﺪﺟﻤﻠﻪ‬‫اي‬ ‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. N. Razavi - AI course - 2005 8
  • 3. ‫ﻫﺎ‬ ‫ﻣﺤﺪودﻳﺖ‬ ‫اﻧﻮاع‬‫ﻫﺎ‬ ‫ﻣﺤﺪودﻳﺖ‬ ‫اﻧﻮاع‬ •‫ﻳﻜﺎﻧﻲ‬(Unary):‫روي‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬،‫ﺷﻮد‬ –‫ﻣﺜﺎل‬:SA ≠ green •‫دودوﻳﻲ‬(Binary):‫ﻣﺤﺪودﻳﺖ‬‫ﺷﺎﻣﻞ‬‫ﻳﻚ‬‫زوج‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﻣﻲ‬،‫ﺑﺎﺷﺪ‬ –‫ﻣﺜﺎل‬:SA ≠ WA •‫ﻪ‬ ‫ﺗ‬‫ﺎﻻﺗ‬(Higher order)‫ﺖ‬ ‫ﺪ‬‫ﻞ‬ ‫ﺷﺎ‬‫ﺎ‬‫ﺸ‬‫ﻐ‬‫ﺖ‬ ‫ا‬ •‫ﻣﺮﺗﺒﻪ‬‫ﺑﺎﻻﺗﺮ‬(Higher-order):‫ﻣﺤﺪودﻳﺖ‬‫ﺷﺎﻣﻞ‬‫ﺳﻪ‬‫ﻳﺎ‬‫ﺑﻴﺸﺘﺮ‬‫ﻣﺘﻐﻴﺮ‬،‫اﺳﺖ‬ –‫ﻣﺜﺎل‬:‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎي‬‫ﻣﻮﺟﻮد‬‫در‬‫ﺳﺘﻮن‬‫ﻫﺎي‬‫ﻣﺴﺎﺋﻞ‬‫رﻳﺎﺿﻴﺎت‬‫رﻣﺰي‬ –‫در‬‫ﺻﻮرت‬‫ﻣﺘﻨﺎﻫﻲ‬‫ﺑﻮدن‬،‫داﻣﻨﻪ‬‫ﻣﻲ‬‫ﺗﻮاﻧﺪ‬‫ﺑﻪ‬‫ﺗﻌﺪادي‬‫ﻣﺤﺪودﻳﺖ‬‫دودﻳﻲ‬‫ﻛﺎﻫﺶ‬‫ﻳﺎﺑﺪ‬. ‫ر‬‫ﻮر‬‫ﻲ‬‫ﺑﻮ‬‫ﻲ‬‫ﻮ‬‫ﺑ‬‫ي‬‫ﻳ‬ ‫و‬‫ﻳﻲ‬ ‫و‬‫ﺶ‬‫ﺑ‬ ‫ﻳ‬ •‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎي‬‫ﻣﺜﺎل‬‫ﻫﺎي‬‫ﺑﺎﻻ‬‫ﻫﻤﮕﻲ‬‫از‬‫ﻧﻮع‬‫ﻣﻄﻠﻖ‬‫ﻣﻄﻠﻖ‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬.‫ﻧﻘﺾ‬‫ﻳﻚ‬‫ﻣﺤﺪودﻳﺖ‬ ‫ﻄﻠ‬‫ﺎ‬‫ﺬف‬‫ﻚ‬‫ا‬‫ﻞ‬‫ﺎﻟﻘ‬‫ﺎﺷ‬ ‫ع‬ ‫ﻣﻄﻠﻖ‬‫ﺑﻪ‬‫ﻣﻌﻨﺎي‬‫ﺣﺬف‬‫ﻳﻚ‬‫راه‬‫ﺣﻞ‬‫ﺑﺎﻟﻘﻮه‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬. ‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬‫اوﻟﻮﻳﺖ‬‫اوﻟﻮﻳﺖ‬‫دار‬‫دار‬))‫ﻧﺮم‬‫ﻧﺮم‬((:: ‫ﺜﻼ‬‫ﻗ‬‫ﺖ‬ ‫ا‬‫ا‬‫اﻏﻠ‬‫ﻠ‬‫ﻧﻈ‬‫ﻓ‬ ‫ﮔ‬‫ا‬‫ﺎ‬ ‫اﻧ‬‫ﺎ‬ ‫ﻐ‬ ،‫ﻣﺜﻼ‬‫ﻗﺮﻣﺰ‬‫ﺑﺮ‬‫ﺳﺒﺰ‬‫ارﺟﺤﻴﺖ‬‫دارد‬.‫اﻏﻠﺐ‬‫ﺑﻮﺳﻴﻠﻪ‬‫در‬‫ﻧﻈﺮ‬‫ﮔﺮﻓﺘﻦ‬‫ﻫﺰﻳﻨﻪ‬‫ﺑﺮاي‬‫اﻧﺘﺴﺎب‬‫ﻣﺘﻐﻴﺮﻫﺎ‬ ‫ﻗﺎﺑﻞ‬‫ﺑﺎزﻧﻤﺎﻳﻲ‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬.Constraint Optimization Problem N. Razavi - AI course - 2005 9 ‫ﻣﺜﺎل‬‫رﻣﺰي‬ ‫رﻳﺎﺿﻴﺎت‬ ‫ﻣﺜﺎل‬:‫رﻣﺰي‬ ‫رﻳﺎﺿﻴﺎت‬ • Variables:FTUW R O X1 X2 X31 2 3 • Domains: {0,1,2,3,4,5,6,7,8,9} • Constraints: Alldiff (F,T,U,W,R,O)( , , , , , ) • – O + O = R + 10 · X11 – – X1 + W + W = U + 10 · X2 N. Razavi - AI course - 2005 10 – – X2 + T + T = O + 10 · X3 X F T ≠ 0 F ≠ 0 ‫ﻣﺜﺎل‬4‫ﻋﻨﻮان‬ ‫ﺑﻪ‬ ‫وزﻳﺮ‬CSP ‫ﻣﺜﺎل‬:4-‫ﻋﻨﻮان‬ ‫ﺑﻪ‬ ‫وزﻳﺮ‬CSP ‫در‬‫ﻫﺮ‬‫ﺳﺘﻮن‬‫ﻳﻚ‬‫وزﻳﺮ‬‫ﻓﺮض‬‫ﻛﻨﻴﺪ‬. ‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬:Q1, Q2, Q3, Q4 ‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬:Q1, Q2, Q3, Q4 ‫داﻣﻨﻪ‬‫داﻣﻨﻪ‬‫ﻫﺎ‬‫ﻫﺎ‬:1, 2, 3, 4}{=Di ‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫ﻫﺎ‬:: ‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫ﻫﺎ‬:: Qi ≠ Qj)‫دو‬‫وزﻳﺮ‬‫ﻧﻤﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫در‬‫ﻳﻚ‬‫ﺳﻄﺮ‬‫ﻗﺮار‬‫ﺑﮕﻴﺮﻧﺪ‬ |Q Q | ≠ |i j|)‫ﺎ‬‫ﻚ‬‫ﻗﻄ‬( |Qi – Qj| ≠ |i – j|)‫ﻳﺎ‬‫در‬‫ﻳﻚ‬‫ﻗﻄﺮ‬( ‫ﻫﺮ‬‫ﻣﺤﺪودﻳﺖ‬‫ﺑﻪ‬‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬‫ﺑﺮاي‬‫ﻣﺘﻐﻴﺮﻫﺎﻳﺶ‬‫ﺗﺮﺟﻤﻪ‬‫ﻣﻲ‬،‫ﺷﻮد‬ ‫ﻼ‬‫ﻼ‬‫ﻣﺜ‬: ‫ﻣﻘﺎدﻳﺮ‬(Q1, Q2)‫ﻣﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫ﻣﺎﻧﻨﺪ‬‫زﻳﺮ‬‫ﺑﺎﺷﻨﺪ‬: (1, 3), (1, 4), (2, 4), (3, 1), (4, 1), (4, 2) N. Razavi - AI course - 2005 11 ‫واﻗﻌ‬ ‫دﻧﻴﺎي‬ ‫در‬ ‫ﻣﺤﺪودﻳﺖ‬ ‫ارﺿﺎ‬ ‫ﻣﺴﺎﺋﻞ‬‫واﻗﻌﻲ‬ ‫دﻧﻴﺎي‬ ‫در‬ ‫ﻣﺤﺪودﻳﺖ‬ ‫ارﺿﺎء‬ ‫ﻣﺴﺎﺋﻞ‬ •‫ﻣﺴﺎﺋﻞ‬‫اﻧﺘﺴﺎﺑﻲ‬(assignment) –،‫ﺜﻼ‬‫ﭼﻪ‬‫ﻛ‬‫ﭼﻪ‬‫ﻛﻼ‬‫ا‬‫د‬‫دﻫﺪ‬ –،‫ﻣﺜﻼ‬‫ﭼﻪ‬‫ﻛﺴﻲ‬‫ﭼﻪ‬‫ﻛﻼﺳﻲ‬‫را‬‫درس‬‫ﻣﻲ‬‫دﻫﺪ‬. •‫ﻣﺴﺎﺋﻞ‬‫ﺗﻌﻴﻴﻦ‬‫ﺟﺪول‬‫زﻣﺎﻧﺒﻨﺪي‬(Timetabling) –،‫ﻣﺜﻼ‬‫ﻛﺪام‬،‫ﻛﻼس‬‫ﻛﺠﺎ‬‫وﻛﻲ‬‫اراﺋﻪ‬‫ﻣﻲ‬‫ﺷﻮد؟‬ •‫زﻣﺎﻧﺒﻨﺪي‬‫ﺣﻤﻞ‬‫و‬‫ﻧﻘﻞ‬(transportation) ‫زﻣﺎﻧﺒﻨﺪي‬‫ﺣﻤﻞ‬‫و‬‫ﻧﻘﻞ‬(transportation) •‫زﻣﺎﻧﺒﻨﺪي‬‫ﻛﺎرﺧﺎﻧﻪ‬(factory scheduling) •‫ﺗﻮﺟﻪ‬:‫ﺑﺴﻴﺎري‬‫از‬‫ﻣﺴﺎﺋﻞ‬‫در‬‫دﻧﻴﺎي‬‫واﻗﻌﻲ‬‫ﺷﺎﻣﻞ‬‫ﻣﺘﻐﻴﺮﻫﺎﻳﻲ‬‫ﺑﺎ‬‫ﻣﻘﺎدﻳﺮ‬‫ﺣﻘﻴﻘﻲ‬ ‫ﺗﻮﺟﻪ‬:‫ﺑﺴﻴﺎري‬‫از‬‫ﻣﺴﺎﺋﻞ‬‫در‬‫دﻧﻴﺎي‬‫واﻗﻌﻲ‬‫ﺷﺎﻣﻞ‬‫ﻣﺘﻐﻴﺮﻫﺎﻳﻲ‬‫ﺑﺎ‬‫ﻣﻘﺎدﻳﺮ‬‫ﺣﻘﻴﻘﻲ‬ ‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. N. Razavi - AI course - 2005 12
  • 4. ‫ﺘﺎﻧﺪارد‬ ‫ا‬ ‫ﻮي‬ ‫ﺘ‬ ‫ﺎزي‬ ‫ﻓﺮﻣﻮﻟﻪ‬)‫اﻓﺰاﻳﺸ‬( ‫اﺳﺘﺎﻧﺪارد‬ ‫ﺟﺴﺘﺠﻮي‬ ‫ﺳﺎزي‬ ‫ﻓﺮﻣﻮﻟﻪ‬)‫اﻓﺰاﻳﺸﻲ‬( •‫ﺎﻻت‬‫ﻂ‬ ‫ﺗ‬‫ي‬ ‫ﻘﺎد‬‫ﻛﻪ‬‫ﺗﺎ‬‫ن‬ ‫ﻛﻨ‬‫ﺎ‬ ‫اﻧﺘ‬‫ﺎﻓﺘﻪ‬‫اﻧﺪ‬‫ﻒ‬ ‫ﺗ‬‫ﻧﺪ‬ ‫ﺷ‬ •‫ﺣﺎﻻت‬‫ﺗﻮﺳﻂ‬‫ﻣﻘﺎدﻳﺮي‬‫ﻛﻪ‬‫ﺗﺎ‬‫ﻛﻨﻮن‬‫اﻧﺘﺴﺎب‬‫ﻳﺎﻓﺘﻪ‬،‫اﻧﺪ‬‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬‫ﺷﻮﻧﺪ‬. •‫ﺣﺎﻟﺖ‬‫اوﻟﻴﻪ‬:‫ﺗﻤﺎم‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺑﺪون‬،‫ﻣﻘﺪار‬‫ﻳﻌﻨﻲ‬‫اﻧﺘﺴﺎب‬‫ﺗﻬﻲ‬{} •‫ﻫﺎ‬ ‫ﻠﮕ‬ ‫ﻋ‬‫ﻫﺎ‬ ‫ﻠﮕ‬ ‫ﻋ‬::‫ﺎب‬ ‫اﻧﺘ‬‫ﻣﻘﺪار‬‫ﺑﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐ‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﻪ‬‫ري‬ ‫ﻃ‬‫ﻛﻪ‬‫ﺑﺎ‬‫ﺎب‬ ‫اﻧﺘ‬‫ﻓﻌﻠ‬‫ي‬ ‫درﮔ‬‫اﻳﺠﺎد‬ •‫ﻋﻤﻠﮕﺮﻫﺎ‬‫ﻋﻤﻠﮕﺮﻫﺎ‬::‫اﻧﺘﺴﺎب‬‫ﻣﻘﺪار‬‫ﺑﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﻪ‬‫ﻃﻮري‬‫ﻛﻪ‬‫ﺑﺎ‬‫اﻧﺘﺴﺎب‬‫ﻓﻌﻠﻲ‬‫درﮔﻴﺮي‬‫اﻳﺠﺎد‬ ‫ﻧﻜﻨﺪ‬.‫در‬‫ﺻﻮرت‬‫ﻋﺪم‬‫وﺟﻮد‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻣﺠﺎز‬‫ﺷﻜﺴﺖ‬‫ﻣﻲ‬‫ﺧﻮرد‬. ••‫ﺗﺴﺖ‬‫ﺗﺴﺖ‬‫ﻫﺪف‬‫ﻫﺪف‬::‫اﻧﺘﺴﺎب‬‫ﻓﻌﻠﻲ‬‫ﻛﺎﻣﻞ‬‫ﺑﺎﺷﺪ‬. ‫ب‬‫ﻲ‬‫ﻞ‬‫ﺑ‬ ••‫ﻫﺰﻳﻨﻪ‬‫ﻫﺰﻳﻨﻪ‬‫ﻣﺴﻴﺮ‬‫ﻣﺴﻴﺮ‬::‫ﻫﺰﻳﻨﻪ‬‫ﻳﻜﺴﺎن‬‫ﺑﺮاي‬‫ﺗﻤﺎم‬‫ﻣﺮاﺣﻞ‬ 1(‫ﺑﺮاي‬‫ﺗﻤﺎم‬CSP‫ﻫﺎ‬‫ﻳﻜﺴﺎن‬‫اﺳﺖ‬! 2(‫ﻫﺮ‬‫ﭘﺎﺳﺦ‬‫در‬‫ﻋﻤﻖ‬n‫ﺑﺎ‬n‫ﻣﺘﻐﻴﺮ‬‫ﻇﺎﻫﺮ‬‫ﻣﻲ‬‫ﺷﻮد‬.‫اﺳﺘﻔﺎده‬‫از‬‫ﺟﺴﺘﺠﻮي‬‫ﻋﻤﻘﻲ‬ ‫ﺮ‬‫ﺦ‬ ‫ﭘ‬‫ﺑ‬‫ﺮ‬‫ﺮ‬‫ﻲ‬‫ﻮ‬‫ﻮ‬‫ﻲ‬ 3(‫در‬‫ﻋﻤﻖ‬l،‫ﻓﺎﻛﺘﻮر‬‫اﻧﺸﻌﺎب‬(b)‫ﺑﺮاﺑﺮ‬‫اﺳﺖ‬‫ﺑﺎ‬(n-l)*d. ‫ﺑﻨﺎﺑﺮاﻳﻦ‬‫ﺗﻌﺪاد‬‫ﺑﺮﮔﻬﺎي‬‫درﺧﺖ‬‫ﺟﺴﺘﺠﻮ‬‫ﺑﺮاﺑﺮ‬‫اﺳﺖ‬‫ﺑﺎ‬n! * dn!!!! (nd) * [(n-1)d] * [(n-2)d] * … d = n!dn ‫در‬ ‫ﻣﺜﻼ‬8-‫وزﻳﺮ‬:8!88 N. Razavi - AI course - 2005 13 ‫ﺳﺎزي‬ ‫ﭘﻴﺎده‬‫ﺳﺎزي‬ ‫ﭘﻴﺎده‬ datatype CSP-STATE components: UNASSIGNED, a list of variables not yet assignedcomponents: UNASSIGNED, a list of variables not yet assigned ASSIGNED, a list of variable that have value datatype CSP-VAR components: NAME, for i/o purposecomponents: NAME, for i/o purpose DOMAIN, a list of possible values VALUE current value (if any)VALUE, current value (if any) •‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫را‬‫ﻣﻲ‬‫ﺗﻮان‬‫ﺑﻪ‬‫دو‬‫روش‬‫ﻧﻤﺎﻳﺶ‬‫داد‬: ––‫ﺻﺮﻳﺢ‬‫ﺻﺮﻳﺢ‬::‫ﺑﻪ‬‫ﻋﻨﻮان‬‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﻘﺎدﻳﺮ‬،‫ﻣﺠﺎز‬‫ﻳﺎ‬ ––‫ﺿﻤﻨﻲ‬‫ﺿﻤﻨﻲ‬::‫ﺑﻮﺳﻴﻠﻪ‬‫ﺗﺎﺑﻌﻲ‬‫ﻛﻪ‬‫ارﺿﺎء‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫را‬‫ﺑﺮرﺳﻲ‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. N. Razavi - AI course - 2005 14 ‫رﻫﻴﺎﻓﺖ‬ ‫اﻳﻦ‬ ‫ﭘﻴﭽﻴﺪﮔ‬‫رﻫﻴﺎﻓﺖ‬ ‫اﻳﻦ‬ ‫ﭘﻴﭽﻴﺪﮔﻲ‬ •‫ﺣﺪاﻛﺜﺮ‬‫ﻋﻤﻖ‬‫ﻓﻀﺎ‬)m(=‫؟؟‬n)‫ﺗﻌﺪاد‬‫ﻣﺘﻐﻴﺮﻫﺎ‬( •‫ﻋﻤﻖ‬‫ﺣﺎﻟﺖ‬‫ﭘﺎﺳﺦ‬(d)=‫؟؟‬n)‫ﺗﻤﺎم‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﻣﻘﺪار‬‫دارﻧﺪ‬( ‫ﻖ‬‫ﺦ‬ ‫ﭘ‬( )‫م‬‫ﻴﺮ‬‫ر‬‫ر‬ •‫اﻟﮕﻮرﻳﺘﻢ‬‫ﺟﺴﺘﺠﻮ؟؟‬‫ﺟﺴﺘﺠﻮي‬‫اول‬-‫ﻋﻤﻖ‬ •‫ﻓﺎﻛﺘﻮر‬‫اﻧﺸﻌﺎب‬b‫؟؟‬Σi|Di|)‫در‬‫ﺑﺎﻻي‬‫درﺧﺖ‬( ‫ﻓﺎﻛﺘﻮر‬‫اﻧﺸﻌﺎب‬b‫؟؟‬Σi|Di|)‫در‬‫ﺑﺎﻻي‬‫درﺧﺖ‬( •‫اﻳﻦ‬‫ﻫﺎ‬‫ﻣ‬‫ﺗﻮاﻧﻨﺪ‬‫ﺑﺎ‬‫ﺗﻮﺟﻪ‬‫ﺑﻪ‬‫ﻧﻜﺎت‬‫زﻳ‬‫ﺑﻬﺒﻮد‬‫ﻳﺎﺑﻨﺪ‬: ‫اﻳﻦ‬‫ﻫﺎ‬‫ﻣﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫ﺑﺎ‬‫ﺗﻮﺟﻪ‬‫ﺑﻪ‬‫ﻧﻜﺎت‬‫زﻳﺮ‬‫ﺑﻬﺒﻮد‬‫ﻳﺎﺑﻨﺪ‬: 1(‫ﺗﺮﺗﻴﺐ‬‫اﻧﺘﺴﺎب‬‫ﻣﻘﺎدﻳﺮ‬‫ﺑﻪ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫اﻫﻤﻴﺖ‬،‫ﻧﺪارد‬‫ﭘﺲ‬‫ﺑﺴﻴﺎري‬‫از‬‫ﻣﺴﻴﺮﻫﺎ‬‫ﻣﻌﺎدل‬‫ﻳﻜﺪﻳﮕﺮ‬ ‫ﻣ‬‫ﺑﺎﺷﻨﺪ‬)‫در‬8-‫وزﻳﺮ‬‫اﻧﺪازه‬‫ﻓﻀﺎي‬‫ﺣﺎﻟﺖ‬‫از‬8!88‫ﺑﻪ‬88‫ﻛﺎﻫﺶ‬‫ﻣ‬‫ﻳﺎﺑﺪ‬( ‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬.)‫در‬8‫وزﻳﺮ‬‫اﻧﺪازه‬‫ﻓﻀﺎي‬‫ﺣﺎﻟﺖ‬‫از‬8!8‫ﺑﻪ‬8‫ﻛﺎﻫﺶ‬‫ﻣﻲ‬‫ﻳﺎﺑﺪ‬( 2(‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﺑﻌﺪي‬‫ﻧﻤﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫ﻳﻚ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻧﻘﺾ‬‫ﺷﺪه‬‫را‬‫ﺗﺼﺤﻴﺢ‬‫ﻛﻨﻨﺪ‬.)‫ﻣﺜﻼ‬‫اﮔﺮ‬ ‫در‬8-‫وزﻳﺮ‬‫دو‬‫وزﻳﺮ‬‫اول‬‫در‬‫ﻳﻚ‬‫ردﻳﻒ‬‫ﻗﺮار‬،‫ﺑﮕﻴﺮﻧﺪ‬‫ﺟﺴﺘﺠﻮي‬‫ﻋﻤﻘﻲ‬86‫ﺣﺎﻟﺖ‬ ‫در‬8‫وزﻳﺮ‬‫دو‬‫وزﻳﺮ‬‫اول‬‫در‬‫ﻳﻚ‬‫ردﻳﻒ‬‫ﻗﺮار‬،‫ﺑﮕﻴﺮﻧﺪ‬‫ﺟﺴﺘﺠﻮي‬‫ﻋﻤﻘﻲ‬8‫ﺣﺎﻟﺖ‬ ‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫را‬‫اﻣﺘﺤﺎن‬‫ﻣﻲ‬‫ﻛﻨﺪ‬‫ﺗﺎ‬‫ﺑﻔﻬﻤﺪ‬‫ﭘﺎﺳﺨﻲ‬‫وﺟﻮد‬‫ﻧﺪارد‬(‫ﺟﺴﺘﺠﻮي‬‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺐ‬‫ﻋﻘﺐ‬‫ﮔﺮد‬‫ﮔﺮد‬. N. Razavi - AI course - 2005 15 B kt kiBacktracking [Q 1 Q 3] •‫اﻧﺘﺴﺎب‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺟﺎﺑﻪ‬‫ﺟﺎﺑﻪ‬‫ﺟﺎﻳﻲ‬‫ﺟﺎﻳﻲ‬‫ﭘﺬﻳﺮ‬‫ﭘﺬﻳﺮ‬‫اﺳﺖ‬‫ﻣﺜﻼ‬[Q1=1,Q2=3]‫ﺑﺮاﺑﺮ‬‫اﺳﺖ‬‫ﺑﺎ‬ [Q2=3,Q1=1] •‫در‬‫ﻫﺮ‬‫ﮔﺮه‬‫ﺗﻨﻬﺎ‬‫ﺑﺎﻳﺪ‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫در‬‫ﻧﻈﺮ‬‫ﮔﺮﻓﺘﻪ‬،‫ﺷﻮد؛ﭘﺲ‬b=d‫و‬‫ﺗﻌﺪاد‬ ‫ﺑﺮﮔﻬﺎ‬=dn ‫ﻬ‬ ‫ﺑﺮ‬ •‫ﺟﺴﺘﺠﻮي‬‫اول‬-‫ﻋﻤﻖ‬‫ﺑﺎ‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﺟﺪاﮔﺎﻧﻪ‬‫در‬CSP،‫ﻫﺎ‬backtrackingbacktracking ‫ﻧﺎ‬‫ا‬ ‫ﻧﺎم‬‫دارد‬. •‫ا‬ ‫ﻗ‬‫دادن‬‫ﻳﻚ‬‫ن‬ ‫آزﻣ‬‫ﻞ‬ ‫ﻗ‬‫از‬‫ﻂ‬ ‫ﺑ‬‫ه‬ ‫ﮔ‬‫ﻫﺎ‬‫ﻛﻪ‬‫ﺑ‬‫ﻣ‬‫ﻛﻨﺪ‬‫آﻳﺎ‬‫ن‬ ‫ﺗﺎﻛﻨ‬‫ﻣﺤﺪودﻳﺘ‬ •‫ﻗﺮار‬‫دادن‬‫ﻳﻚ‬‫آزﻣﻮن‬‫ﻗﺒﻞ‬‫از‬‫ﺑﺴﻂ‬‫ﮔﺮه‬‫ﻫﺎ‬‫ﻛﻪ‬‫ﺑﺮرﺳﻲ‬‫ﻣﻲ‬‫ﻛﻨﺪ‬‫آﻳﺎ‬‫ﺗﺎﻛﻨﻮن‬‫ﻣﺤﺪودﻳﺘﻲ‬ ‫ﻧﻘﺾ‬‫ﺷﺪه‬‫ﻳﺎ‬‫ﺧﻴﺮ‬.‫اﮔﺮ‬‫ﻣﺤﺪودﻳﺘﻲ‬‫ﻧﻘﺾ‬‫ﺷﺪه‬،‫ﺑﺎﺷﺪ‬‫دﻳﮕﺮ‬‫اﻳﻦ‬‫ﮔﺮه‬‫ﺑﺴﻂ‬‫داده‬‫ﻧﻤﻲ‬‫ﺷﻮد‬‫و‬ ‫ﺟﺴﺘﺠﻮ‬‫ﺑﻪ‬‫ﻋﻘﺐ‬‫ﺑﺎز‬‫ﻣﻲ‬‫ﮔﺮدد‬. •‫ﻣﻲ‬‫ﺗﻮاﻧﺪ‬n-‫وزﻳﺮ‬‫را‬‫ﺗﺎ‬‫ﺣﺪود‬n=25‫ﺣﻞ‬‫ﻛﻨﺪ‬. N. Razavi - AI course - 2005 16
  • 5. ‫ﻣﺜﺎل‬:‫ﺑﺮاي‬ ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬4-‫وزﻳﺮ‬ ‫ﻣﺜﺎل‬:‫ﺑﺮاي‬ ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬4‫وزﻳﺮ‬ Start 1, 1 1, 2 2, 1 2, 2 2, 3 2, 4 2, 1 2, 2 2, 3 2, 4 ╳ ╳ ╳ ╳ ╳ 3 1 3 2 3 3 3 4 3 1 3 2 3 3 3 4 3 1 ╳ ╳ ╳ ╳ ╳ 3, 1 3, 2 3, 3 3, 4 3, 1 3, 2 3, 3 3, 4 3, 1 ╳ ╳ ╳ ╳ ╳ ╳ ╳ 4, 1 4, 2 4, 3 4, 4 4, 1 4, 2 4, 3 N. Razavi - AI course - 2005 17 ╳ ╳ ╳ ╳ ╳ ╳ ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬ N. Razavi - AI course - 2005 18 ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬ N. Razavi - AI course - 2005 19 ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬ N. Razavi - AI course - 2005 20
  • 6. ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬ N. Razavi - AI course - 2005 21 ‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬ ‫ﺟﺴﺘﺠﻮي‬ N. Razavi - AI course - 2005 22 ‫ﻛﺎرآﻳ‬ ‫ﺑﻬﺒﻮد‬backtracking ‫ﻛﺎرآﻳﻲ‬ ‫ﺑﻬﺒﻮد‬backtracking •‫اﻓﺰاﻳﺶ‬‫ﺳﺮﻋﺖ‬‫ﺗﻮﺳﻂ‬‫روش‬‫ﻫﺎي‬‫ﺟﺴﺘﺠﻮي‬‫ﻫﻤﻪ‬‫ﻫﻤﻪ‬‫ﻣﻨﻈﻮره‬‫ﻣﻨﻈﻮره‬: ‫ﻛ‬ 1-‫در‬‫ﻣﺮﺣﻠﻪ‬‫ﺑﻌﺪ‬‫ﺑﺎﻳﺪ‬‫ﺑﻪ‬‫ﻛﺪام‬‫ﻣﺘﻐﻴﺮ‬‫ﻣﻘﺪار‬‫داده‬‫ﺷﻮد؟‬ 2-‫ﻣﻘﺎدﻳ‬‫آن‬‫ﺑﺎﻳﺪ‬‫ﺑﻪ‬‫ﭼﻪ‬‫ﺗ‬ ‫ﺗ‬‫اﻣﺘﺤﺎن‬‫ﺷﻮﻧﺪ؟‬ 2‫ﻣﻘﺎدﻳﺮ‬‫آن‬‫ﺑﺎﻳﺪ‬‫ﺑﻪ‬‫ﭼﻪ‬‫ﺗﺮﺗﻴﺒﻲ‬‫اﻣﺘﺤﺎن‬‫ﺷﻮﻧﺪ؟‬ 3-‫آﻳﺎ‬‫ﻣﻲ‬‫ﺗﻮان‬‫ﺷﻜﺴﺖ‬‫ﻫﺎي‬‫ﺣﺘﻤﻲ‬‫را‬‫زودﺗﺮ‬‫ﺗﺸﺨﻴﺺ‬‫داد؟‬ ‫ﻓﺮض‬‫ﻛﻨﻴﺪ‬‫در‬‫ﻋﻘﺒﮕﺮد‬‫در‬‫ﻣﺴﺄﻟﻪ‬8-،‫وزﻳﺮ‬6‫وزﻳﺮ‬‫اول‬‫ﺑﻪ‬‫ﮔﻮﻧﻪ‬‫اي‬‫ﻗﺮار‬‫ﮔﺮﻓﺘﻪ‬‫اﻧﺪ‬‫ﻛﻪ‬‫ﻗﺮار‬ ‫ن‬ ‫ا‬‫ﺸ‬‫ز‬‫ا‬‫ﻏ‬‫ﻜ‬‫ﺎزﻧﺪ‬‫ﻘ‬‫ﮔ‬‫ﺎ‬ ‫ﺗ‬‫ﺎ‬ ‫ﻜﺎﻧ‬‫ﻜ‬‫ا‬‫ز‬ ‫دادن‬‫ﻫﺸﺘﻤﻴﻦ‬‫وزﻳﺮ‬‫را‬‫ﻏﻴﺮ‬‫ﻣﻤﻜﻦ‬‫ﻣﻲ‬‫ﺳﺎزﻧﺪ‬.‫ﻋﻘﺐ‬‫ﮔﺮد‬‫ﺗﻤﺎم‬‫ﻣﻤﻜﺎﻧﻬﺎي‬‫ﻣﻤﻜﻦ‬‫ﺑﺮاي‬‫وزﻳﺮ‬ ‫ﻫﻔﺘﻢ‬‫را‬‫ﭼﻚ‬‫ﻣﻲ‬،‫ﻛﻨﺪ‬‫اﮔﺮﭼﻪ‬‫ﻣﺴﺄﻟﻪ‬‫ﻏﻴﺮ‬‫ﻗﺎﺑﻞ‬‫ﺣﻞ‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬. ‫ﺄ‬‫ﮔ‬ 4-‫آﻳﺎ‬‫ﻣﻲ‬‫ﺗﻮان‬‫از‬‫ﺳﺎﺧﺘﺎر‬‫ﻣﺴﺄﻟﻪ‬‫ﺑﻬﺮه‬‫ﮔﺮﻓﺖ؟‬ N. Razavi - AI course - 2005 23 ‫ﻣﺤﺪودﻳﺖ‬ ‫ﺑﻴﺸﺘﺮﻳﻦ‬ ‫ﺑﺎ‬ ‫ﻣﺘﻐﻴﺮ‬‫ﻣﺤﺪودﻳﺖ‬ ‫ﺑﻴﺸﺘﺮﻳﻦ‬ ‫ﺑﺎ‬ ‫ﻣﺘﻐﻴﺮ‬ •‫ﻣﺘﻐﻴﺮ‬‫ﺑﺎ‬‫ﺑﻴﺸﺘﺮﻳﻦ‬‫ﻣﺤﺪودﻳﺖ‬: ‫ا‬‫ﺎ‬ ‫ا‬‫ﻛ‬‫ﻛ‬‫ﻛ‬‫ﻘﺎ‬‫ا‬‫ا‬ –‫ﻣﺘﻐﻴﺮي‬‫را‬‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬‫ﻛﻪ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﻌﺘﺒﺮ‬‫را‬‫دارد‬. –‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﻘﺎدﻳﺮ‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬(MRV) N. Razavi - AI course - 2005 24
  • 7. ‫ﻣﺤﺪودﻳﺖ‬ ‫ﺑﻴﺸﺘﺮﻳﻦ‬ ‫ﺑﺎ‬ ‫ﻣﺘﻐﻴﺮ‬‫ﻣﺤﺪودﻳﺖ‬ ‫ﺑﻴﺸﺘﺮﻳﻦ‬ ‫ﺑﺎ‬ ‫ﻣﺘﻐﻴﺮ‬ •‫ﺣﻞ‬‫درﮔﻴﺮي‬(tie)‫ﻣﻴﺎن‬‫ﻣﺘﻐﻴﺮﻫﺎﻳﻲ‬‫ﻛﻪ‬‫ﺑﻴﺸﺘﺮﻳﻦ‬‫ﻣﺤﺪودﻳﺖ‬‫را‬ ‫ﻧﺪ‬ ‫ا‬‫دارﻧﺪ‬ •‫ﻣﺘﻐﻴﺮ‬‫ﺑﺎ‬‫ﺑﻴﺸﺘﺮﻳﻦ‬‫ﻣﺤﺪودﻳﺖ‬:‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫درﺟﻪ‬‫درﺟﻪ‬ ‫ﻴﺮ‬‫ﺑ‬‫ﺮﻳﻦ‬ ‫ﺑﻴ‬‫ﻳ‬ ‫و‬‫ﻴ‬ ‫ﻴﻮرﻳ‬‫ﻴ‬ ‫ﻴﻮرﻳ‬‫رﺟ‬‫رﺟ‬ –‫ﻣﺘﻐﻴﺮ‬‫ﺑﺎ‬‫ﺑﻴﺸﺘﺮﻳﻦ‬‫ﻣﺤﺪودﻳﺖ‬‫را‬‫روي‬‫ﻣﻘﺎدﻳﺮ‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬ N. Razavi - AI course - 2005 25 ‫ﻣﺤﺪودﻳﺖ‬ ‫ﻛﻤﺘﺮﻳﻦ‬ ‫ﺑﺎ‬ ‫ﻣﻘﺪار‬ (Least constraining value) •‫ﺑﺮاي‬‫ﻳﻚ‬،‫ﻣﺘﻐﻴﺮ‬‫ﻣﻘﺪاري‬‫را‬‫ﻛﻪ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﻣﺤﺪودﻳﺖ‬‫را‬‫اﻳﺠﺎد‬‫ﻣﻲ‬‫ﻛﻨﺪ‬ ‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬ ‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬. –‫ﻣﻘﺪاري‬‫ﻛﻪ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﻣﻘﺎدﻳﺮ‬‫را‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺣﺬف‬‫ﻣﻲ‬‫ﻛﻨﺪ‬ ‫ﺎ‬‫ﻛ‬‫ا‬‫ﻚ‬‫ﺎ‬‫ﺄﻟ‬1‫ﻞ‬‫ﻗﺎ‬‫ﻞ‬‫ﺷ‬ •‫ﺑﺎ‬‫ﺗﺮﻛﻴﺐ‬‫اﻳﻦ‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﺎ‬‫ﻣﺴﺄﻟﻪ‬1000-‫وزﻳﺮ‬‫ﻗﺎﺑﻞ‬‫ﺣﻞ‬‫ﻣﻲ‬‫ﺷﻮد‬. N. Razavi - AI course - 2005 26 ‫ﺟﻠﻮ‬ ‫ﺑﻪ‬ ‫رو‬ ‫ﺑﺮرﺳﻲ‬ (Forward checking) ••‫اﻳﺪه‬‫اﻳﺪه‬:: –‫اﻗ‬‫ﻘﺎد‬‫ﺠﺎز‬‫ﺎﻧﺪه‬ ‫ﺎﻗ‬‫اي‬‫ﻫﺎي‬ ‫ﺘﻐ‬‫ﺪون‬‫ﻘﺪا‬‫ﺎش‬ –‫ﻣﺮاﻗﺐ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺑﺮاي‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﺎش‬. –‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻫﻴﭻ‬‫ﻣﻘﺪار‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫اي‬،‫ﻧﺪارد‬‫ﺑﻪ‬‫ﺟﺴﺘﺠﻮ‬‫ﭘﺎﻳﺎن‬‫ﺑﺪه‬. N. Razavi - AI course - 2005 27 ‫ﺟﻠﻮ‬ ‫ﺑﻪ‬ ‫رو‬ ‫ﺑﺮرﺳﻲ‬ (Forward checking) ••‫اﻳﺪه‬‫اﻳﺪه‬:: –‫اﻗ‬‫ﻘﺎد‬‫ﺠﺎز‬‫ﺎﻧﺪه‬ ‫ﺎﻗ‬‫اي‬‫ﻫﺎي‬ ‫ﺘﻐ‬‫ﺪون‬‫ﻘﺪا‬‫ﺎش‬ –‫ﻣﺮاﻗﺐ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺑﺮاي‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﺎش‬. –‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻫﻴﭻ‬‫ﻣﻘﺪار‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫اي‬،‫ﻧﺪارد‬‫ﺑﻪ‬‫ﺟﺴﺘﺠﻮ‬‫ﭘﺎﻳﺎن‬‫ﺑﺪه‬. N. Razavi - AI course - 2005 28
  • 8. ‫ﺟﻠﻮ‬ ‫ﺑﻪ‬ ‫رو‬ ‫ﺑﺮرﺳﻲ‬ (Forward checking) ••‫اﻳﺪه‬‫اﻳﺪه‬:: –‫اﻗ‬‫ﻘﺎد‬‫ﺠﺎز‬‫ﺎﻧﺪه‬ ‫ﺎﻗ‬‫اي‬‫ﻫﺎي‬ ‫ﺘﻐ‬‫ﺪون‬‫ﻘﺪا‬‫ﺎش‬ –‫ﻣﺮاﻗﺐ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺑﺮاي‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﺎش‬. –‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻫﻴﭻ‬‫ﻣﻘﺪار‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫اي‬،‫ﻧﺪارد‬‫ﺑﻪ‬‫ﺟﺴﺘﺠﻮ‬‫ﭘﺎﻳﺎن‬‫ﺑﺪه‬. N. Razavi - AI course - 2005 29 ‫ﺟﻠﻮ‬ ‫ﺑﻪ‬ ‫رو‬ ‫ﺑﺮرﺳﻲ‬ (Forward checking) ••‫اﻳﺪه‬‫اﻳﺪه‬:: –‫اﻗ‬‫ﻘﺎد‬‫ﺠﺎز‬‫ﺎﻧﺪه‬ ‫ﺎﻗ‬‫اي‬‫ﻫﺎي‬ ‫ﺘﻐ‬‫ﺪون‬‫ﻘﺪا‬‫ﺎش‬ –‫ﻣﺮاﻗﺐ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﺑﺮاي‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫ﺑﺪون‬‫ﻣﻘﺪار‬‫ﺑﺎش‬. –‫زﻣﺎﻧﻲ‬‫ﻛﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻫﻴﭻ‬‫ﻣﻘﺪار‬‫ﻣﺠﺎز‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫اي‬،‫ﻧﺪارد‬‫ﺑﻪ‬‫ﺟﺴﺘﺠﻮ‬‫ﭘﺎﻳﺎن‬‫ﺑﺪه‬. N. Razavi - AI course - 2005 30 ‫ﻣﺤﺪودﻳﺖ‬ ‫اﻧﺘﺸﺎر‬‫ﻣﺤﺪودﻳﺖ‬ ‫اﻧﺘﺸﺎر‬ •‫ﺑﺮرﺳﻲ‬‫رو‬‫ﺑﻪ‬‫ﺟﻠﻮ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫را‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎي‬‫اﻧﺘﺴﺎب‬‫ﻳﺎﻓﺘﻪ‬‫ﺑﻪ‬‫ﻣﺘﻐﻴﺮ‬‫ﻫﺎي‬ ‫اﻧﺘﺴﺎب‬‫ﻧﻴﺎﻓﺘﻪ‬‫ﻣﻨﺘﺸﺮ‬‫ﻣ‬،‫ﻛﻨﺪ‬‫اﻣﺎ‬‫ﺗﻤﺎم‬‫ﺷﻜﺴﺖ‬‫ﻫﺎ‬‫را‬‫ﻧﻤ‬‫ﺗﻮاﻧﺪ‬‫در‬‫زود‬‫ﺗﺮﻳﻦ‬ ‫اﻧﺘﺴﺎب‬‫ﻧﻴﺎﻓﺘﻪ‬‫ﻣﻨﺘﺸﺮ‬‫ﻣﻲ‬،‫ﻛﻨﺪ‬‫اﻣﺎ‬‫ﺗﻤﺎم‬‫ﺷﻜﺴﺖ‬‫ﻫﺎ‬‫را‬‫ﻧﻤﻲ‬‫ﺗﻮاﻧﺪ‬‫در‬‫زود‬‫ﺗﺮﻳﻦ‬ ‫زﻣﺎن‬‫ﻣﻤﻜﻦ‬‫ﺗﺸﺨﻴﺺ‬‫دﻫﺪ‬. •NT‫و‬SA‫ﻫﺮ‬‫دو‬‫ﻧﻤﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫آﺑﻲ‬‫ﺑﺎﺷﻨﺪ‬! NT‫و‬SA‫ﻫﺮ‬‫دو‬‫ﻧﻤﻲ‬‫ﺗﻮاﻧﻨﺪ‬‫آﺑﻲ‬‫ﺑﺎﺷﻨﺪ‬! ••‫اﻧﺘﺸﺎر‬‫اﻧﺘﺸﺎر‬‫ﻣﺤﺪودﻳﺖ‬‫ﻣﺤﺪودﻳﺖ‬‫ﺑﻪ‬‫ﻃﻮر‬‫ﻣﻜﺮر‬‫ﺑﺮ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫ﺑﻪ‬‫ﻃﻮر‬‫ﻣﺤﻠﻲ‬‫ﺗﺄﻛﻴﺪ‬‫دارد‬. N. Razavi - AI course - 2005 31 ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ (Arc consistency) •‫ﺳﺎده‬‫ﺗﺮﻳﻦ‬‫ﺷﻜﻞ‬،‫اﻧﺘﺸﺎر‬‫ﻫﺮ‬‫ﻛﻤﺎن‬‫را‬‫ﺳﺎزﮔﺎر‬‫ﺳﺎزﮔﺎر‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •X Y‫ﺎزﮔﺎ‬‫ا‬‫اﮔ‬‫ﻓﻘﻂ‬‫اﮔ‬ •X Y‫ﺳﺎزﮔﺎر‬‫اﺳﺖ‬‫اﮔﺮ‬‫و‬‫ﻓﻘﻂ‬‫اﮔﺮ‬ ‫ﺑﺎزاء‬‫ﻫﺮ‬‫ﻣﻘﺪار‬x‫ﺑﺮﺧﻲ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬y‫ﻣﻮﺟﻮد‬‫ﺑﺎﺷﻨﺪ‬. ‫ﻲ‬ N. Razavi - AI course - 2005 32
  • 9. ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ (Arc consistency) •‫ﺳﺎده‬‫ﺗﺮﻳﻦ‬‫ﺷﻜﻞ‬،‫اﻧﺘﺸﺎر‬‫ﻫﺮ‬‫ﻛﻤﺎن‬‫را‬‫ﺳﺎزﮔﺎر‬‫ﺳﺎزﮔﺎر‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •X Y‫ﺎزﮔﺎ‬‫ا‬‫اﮔ‬‫ﻓﻘﻂ‬‫اﮔ‬ •X Y‫ﺳﺎزﮔﺎر‬‫اﺳﺖ‬‫اﮔﺮ‬‫و‬‫ﻓﻘﻂ‬‫اﮔﺮ‬ ‫ﺑﺎزاء‬‫ﻫﺮ‬‫ﻣﻘﺪار‬x‫ﺑﺮﺧﻲ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬y‫ﻣﻮﺟﻮد‬‫ﺑﺎﺷﻨﺪ‬. ‫ﻲ‬ N. Razavi - AI course - 2005 33 ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ (Arc consistency) •‫ﺳﺎده‬‫ﺗﺮﻳﻦ‬‫ﺷﻜﻞ‬،‫اﻧﺘﺸﺎر‬‫ﻫﺮ‬‫ﻛﻤﺎن‬‫را‬‫ﺳﺎزﮔﺎر‬‫ﺳﺎزﮔﺎر‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •X Y‫ﺎزﮔﺎ‬‫ا‬‫اﮔ‬‫ﻓﻘﻂ‬‫اﮔ‬ •X Y‫ﺳﺎزﮔﺎر‬‫اﺳﺖ‬‫اﮔﺮ‬‫و‬‫ﻓﻘﻂ‬‫اﮔﺮ‬ ‫ﺑﺎزاء‬‫ﻫﺮ‬‫ﻣﻘﺪار‬x‫ﺑﺮﺧﻲ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬y‫ﻣﻮﺟﻮد‬‫ﺑﺎﺷﻨﺪ‬. ‫ﻲ‬ ‫اﮔ‬X‫ا‬ ‫ﻘ‬‫ا‬‫ا‬‫ﺎ‬‫ﺎ‬X‫ﺎ‬‫ا‬ ‫اﮔﺮ‬X‫ﻣﻘﺪاري‬‫را‬‫از‬‫دﺳﺖ‬،‫ﺑﺪﻫﺪ‬‫ﻫﻤﺴﺎﻳﻪ‬‫ﻫﺎي‬X‫ﻧﻴﺎز‬‫ﺑﻪ‬‫ﺑﺮرﺳﻲ‬‫ﻣﺠﺪد‬‫دارﻧﺪ‬. N. Razavi - AI course - 2005 34 ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ (Arc consistency) •‫ﺳﺎده‬‫ﺗﺮﻳﻦ‬‫ﺷﻜﻞ‬،‫اﻧﺘﺸﺎر‬‫ﻫﺮ‬‫ﻛﻤﺎن‬‫را‬‫ﺳﺎزﮔﺎر‬‫ﺳﺎزﮔﺎر‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •X Y‫ﺎزﮔﺎ‬‫ا‬‫اﮔ‬‫ﻓﻘﻂ‬‫اﮔ‬ •X Y‫ﺳﺎزﮔﺎر‬‫اﺳﺖ‬‫اﮔﺮ‬‫و‬‫ﻓﻘﻂ‬‫اﮔﺮ‬ ‫ﺑﺎزاء‬‫ﻫﺮ‬‫ﻣﻘﺪار‬x‫ﺑﺮﺧﻲ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﺎز‬y‫ﻣﻮﺟﻮد‬‫ﺑﺎﺷﻨﺪ‬. ‫ﻲ‬ ‫ﮔﺎ‬ ‫ﺎ‬‫ﺎ‬ ‫ﻛ‬‫ﻜ‬‫ﺎ‬‫ا‬‫ا‬FC ‫ﺳﺎزﮔﺎري‬‫ﻛﻤﺎن‬‫ﺷﻜﺴﺖ‬‫ﻫﺎ‬‫را‬‫زودﺗﺮ‬‫از‬FC‫ﺗﺸﺨﻴﺺ‬‫ﻣﻲ‬‫دﻫﺪ‬. ‫و‬‫ﻣﻲ‬‫ﺗﻮاﻧﺪ‬‫ﺑﻪ‬‫ﻋﻨﻮان‬‫ﭘﻴﺶ‬‫ﭘﺮدازﻧﺪه‬‫و‬‫ﻳﺎ‬‫ﺑﻌﺪ‬‫از‬‫ﻫﺮ‬‫اﻧﺘﺴﺎب‬‫اﺟﺮا‬‫ﺷﻮد‬. N. Razavi - AI course - 2005 35 ‫و‬‫ﻲ‬‫ﻮ‬‫ﺑ‬‫ﻮ‬‫ﭘﻴﺶ‬‫ز‬ ‫ﭘﺮ‬‫و‬‫ﻳ‬‫ﺑ‬‫ز‬‫ﺮ‬‫ب‬‫ﺮ‬‫ﻮ‬ ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ ‫اﻟﮕﻮرﻳﺘﻢ‬AC-3 ‫ﻛﻤﺎن‬ ‫ﺳﺎزﮔﺎري‬ ‫اﻟﮕﻮرﻳﺘﻢ‬AC 3 ••‫ﺪﮔ‬‫ﺪﮔ‬‫ﺎﻧ‬ ‫ز‬‫ﺎﻧ‬ ‫ز‬:O(n2d3) N. Razavi - AI course - 2005 36 ••‫ﭘﻴﭽﻴﺪﮔﻲ‬‫ﭘﻴﭽﻴﺪﮔﻲ‬‫زﻣﺎﻧﻲ‬‫زﻣﺎﻧﻲ‬:O(n2d3)
  • 10. ‫ﺑﺮاي‬ ‫ﻣﺤﻠ‬ ‫ﺟﺴﺘﺠﻮي‬CSP ‫ﺑﺮاي‬ ‫ﻣﺤﻠﻲ‬ ‫ﺟﺴﺘﺠﻮي‬CSP •‫ﺗﭙﻪ‬‫ﻧﻮردي‬‫و‬SA‫ﺑﺎ‬‫ﺣﺎﻻت‬‫ﻛﺎﻣﻞ‬‫ﻛﺎر‬‫ﻣﻲ‬‫ﻛﻨﻨﺪ؛‬‫ﻳﻌﻨﻲ‬‫ﺗﻤﺎم‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺑﺎﻳﺪ‬‫داراي‬‫ﻣﻘﺪار‬ ‫ﺑﺎﺷﻨﺪ‬. •‫ﺑﺮاي‬‫اﻋﻤﺎل‬‫آﻧﻬﺎ‬‫ﺑﺮ‬‫ﻣﺴﺎﺋﻞ‬CSP: ‫ي‬ ‫ﺑﺮ‬‫ﻬ‬‫ﺑﺮ‬‫ﻞ‬ –‫داﺷﺘﻦ‬‫ﺣﺎﻻﺗﻲ‬‫ﺑﺎ‬‫ﻣﺤﺪودﻳﺘﻬﺎي‬‫ﻧﻘﺾ‬‫ﺷﺪه‬‫ﺑﺎﻳﺪ‬‫ﻣﺠﺎز‬‫ﺑﺎﺷﺪ‬. –‫ﻋﻤﻠﮕﺮﻫﺎ‬‫ﺑﺎﻳﺪ‬‫ﺑﺘﻮاﻧﻨﺪ‬‫ﺑﻪ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﻣﻘﺎدﻳﺮ‬‫ﺟﺪﻳﺪ‬‫ﺑﺪﻫﻨﺪ‬. •‫اﻧﺘﺨﺎب‬‫ﻣﺘﻐﻴﺮ‬:‫ﺑﻪ‬‫ﺻﻮرت‬‫ﺗﺼﺎدﻓﻲ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫درﮔﻴﺮ‬‫را‬‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬ •‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬min-conflicts: –‫ﻣﻘﺪاري‬‫را‬‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬‫ﻛﻪ‬‫ﻛﻤﺘﺮﻳﻦ‬‫ﺗﻌﺪاد‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫را‬‫ﻧﻘﺾ‬‫ﻣﻲ‬،‫ﻛﻨﺪ‬ ،‫ﻳﻌﻨﻲ‬‫ﺗﭙﻪ‬‫ﻧﻮردي‬‫ﺑﺎ‬‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬”‫ﺗﻌﺪاد‬‫ﻛﻞ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎي‬‫ﻧﻘﺾ‬‫ﺷﺪه‬“ N. Razavi - AI course - 2005 37 ‫اﻟﮕﻮرﻳﺘﻢ‬Min Conflicts ‫اﻟﮕﻮرﻳﺘﻢ‬Min-Conflicts N. Razavi - AI course - 2005 38 ‫ﻣﺜﺎل‬8‫وزﻳﺮ‬ ‫ﻣﺜﺎل‬:8-‫وزﻳﺮ‬ N. Razavi - AI course - 2005 39 ‫ﻛﺎرآﻳ‬min conflicts ‫ﻛﺎرآﻳﻲ‬min-conflicts ‫ﺣﻞ‬n-‫وزﻳﺮ‬‫ﺑﺎ‬n‫دﻟﺨﻮاه‬)‫ﻣﺜﻼ‬10,000,000(‫در‬‫ﻳﻚ‬‫زﻣﺎن‬‫ﺗﻘﺮﻳﺒﺎ‬‫ﺛﺎﺑﺖ‬‫ﺑﺎ‬‫ﺷﺮوع‬‫از‬‫ﻳﻚ‬ ‫وﺿﻌﻴﺖ‬‫ﺗﺼﺎدﻓﻲ‬‫ﺑﺎ‬‫اﺣﺘﻤﺎل‬‫ﺑﺎﻻ‬)‫ﻣﻴﺎﻧﮕﻴﻦ‬50‫ﻣﺮﺣﻠﻪ‬( ‫ﻴ‬ ‫و‬‫ﻲ‬‫ﺑ‬‫ﺑ‬‫ﻴﻦ‬ ‫ﻴ‬‫ﺮ‬ ‫ﻫﻤﻴﻦ‬‫ﻣﻮﺿﻮع‬‫ﺑﻪ‬‫ﻧﻈﺮ‬‫ﻣﻲ‬‫رﺳﺪ‬‫ﺑﺮاي‬‫ﻫﺮ‬CSP‫ﺑﺎ‬‫ﺷﺮوع‬‫ﺗﺼﺎدﻓﻲ‬‫درﺳﺖ‬،‫ﺑﺎﺷﺪ‬‫ﺑﻪ‬‫ﻏﻴﺮ‬‫از‬‫ﻳﻚ‬ ‫ﻧﺎﺣﻴﻪ‬‫ﺑﺎرﻳﻚ‬‫از‬‫ﻧﺴﺒﺖ‬R. ‫ﻧﺎﺣﻴﻪ‬‫ﺑﺎرﻳﻚ‬‫از‬‫ﻧﺴﺒﺖ‬R. R = (num. of constraints)/(num. of variables) N. Razavi - AI course - 2005 40
  • 11. ‫ﻣﺴﺄﻟﻪ‬ ‫ﺳﺎﺧﺘﺎر‬‫ر‬ •Tasmania‫و‬‫ﺟﺰﻳﺮه‬‫اﺻﻠﻲ‬‫زﻳﺮﻣﺴﺎﻳﻞ‬‫زﻳﺮﻣﺴﺎﻳﻞ‬‫ﻣﺴﺘﻘﻞ‬‫ﻣﺴﺘﻘﻞ‬‫ﻫﺴﺘﻨﺪ‬. ‫ﺎ‬‫ﻟﻔ‬‫ﻟﻔ‬‫ﺎ‬‫ﺎ‬‫اف‬ ‫ﮔ‬‫ﻞ‬‫ﻗﺎ‬‫ﺎ‬ ‫ﺎ‬ ••‫و‬‫ﺑﺎ‬‫ﺗﻮﺟﻪ‬‫ﺑﻪ‬‫ﻣﻮﻟﻔﻪ‬‫ﻣﻮﻟﻔﻪ‬‫ﻫﺎي‬‫ﻫﺎي‬‫ﻫﻤﺒﻨﺪ‬‫ﻫﻤﺒﻨﺪ‬‫در‬‫ﮔﺮاف‬‫ﻣﺤﺪودﻳﺖ‬‫ﻗﺎﺑﻞ‬‫ﺷﻨﺎﺳﺎﻳﻲ‬‫ﻫﺴﺘﻨﺪ‬. N. Razavi - AI course - 2005 41 ‫ﻣﺴﺄﻟﻪ‬ ‫ﺳﺎﺧﺘﺎر‬)‫اداﻣﻪ‬( ‫ﻣﺴﺄﻟﻪ‬ ‫ﺳﺎﺧﺘﺎر‬)‫اداﻣﻪ‬( •‫ﻓﺮض‬‫ﻛﻨﻴﺪ‬‫ﻫﺮ‬‫زﻳﺮﻣﺴﺄﻟﻪ‬‫ﺷﺎﻣﻞ‬c‫ﻣﺘﻐﻴﺮ‬‫از‬‫ﻛﻞ‬n‫ﻣﺘﻐﻴﺮ‬‫ﺑﺎﺷﺪ‬ •‫ا‬‫ﻞ‬‫ﺗ‬‫ﺎﻟ‬‫ﺧﻄ‬‫ﺧﻄ‬)n(‫ا‬n/c dc‫ﺎﺷ‬ •‫ﻫﺰﻳﻨﻪ‬‫راه‬‫ﺣﻞ‬‫در‬‫ﺑﺪﺗﺮﻳﻦ‬‫ﺣﺎﻟﺖ‬‫ﺧﻄﻲ‬‫ﺧﻄﻲ‬)‫ﺑﺮﺣﺴﺐ‬n(‫و‬‫ﺑﺮاﺑﺮ‬n/c . dc‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬ •‫ﻣﺜﺎل‬:n = 80, d = 2, c = 20 280 4 billi 10 illi d /• 280 = 4 billion years at 10 million nodes/sec • 4.220 = 0.4 seconds at 10 million nodes/sec N. Razavi - AI course - 2005 42 ‫ﺑﺮاي‬ ‫اﻟﮕﻮرﻳﺘﻢ‬CSP‫درﺧﺘ‬ ‫ﺎﺧﺘﺎر‬ ‫داراي‬ ‫ﻫﺎي‬ ‫ﺑﺮاي‬ ‫اﻟﮕﻮرﻳﺘﻢ‬CSP‫درﺧﺘﻲ‬ ‫ﺳﺎﺧﺘﺎر‬ ‫داراي‬ ‫ﻫﺎي‬ 1.‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫را‬‫ﺑﻪ‬‫ﻋﻨﻮان‬‫رﻳﺸﻪ‬‫اﻧﺘﺨﺎب‬‫ﻛﻦ‬‫و‬‫ﺳﭙﺲ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫را‬‫از‬‫رﻳﺸﻪ‬‫ﺗﺎ‬‫ﺑﺮﮔﻬﺎ‬‫ﺑﻪ‬‫ﮔﻮﻧﻪ‬‫اي‬‫ﻣﺮﺗﺐ‬‫ﻛﻦ‬‫ﻛﻪ‬‫واﻟﺪ‬ ‫ﻫﺮ‬‫ﮔﺮه‬‫ﻗﺒﻞ‬‫از‬‫آن‬‫ﮔﺮه‬‫ﻗﺮار‬‫ﺑﮕﻴﺮد‬. 2.‫ﺑﺎزاء‬j‫از‬n‫ﺗﺎ‬2‫ﻋﻤﻞ‬‫زﻳﺮ‬‫را‬‫اﻧﺠﺎم‬‫ﺑﺪه‬ REMOVEINCONSISTENT(Parent(Xj), Xj) 3.‫ﺑﺮاي‬j‫از‬‫ﻳﻚ‬‫ﺗﺎ‬n،‫ﻣﻘﺪار‬Xj‫را‬‫ﺑﻪ‬‫ﻃﻮر‬‫ﺳﺎزﮔﺎر‬‫ﺑﺎ‬Parent(Xj)‫ﺗﻌﻴﻴﻦ‬‫ﻛﻦ‬ ‫ي‬ ‫ﺑﺮ‬j‫ز‬‫ﻳ‬‫ر‬j‫ر‬‫ﺑ‬‫ﻮر‬‫ر‬ ‫ز‬‫ﺑ‬( j)‫ﻴﻴﻦ‬‫ﻦ‬ ‫ﭘﻴﭽﻴﺪﮔﻲ‬‫ﭘﻴﭽﻴﺪﮔﻲ‬‫زﻣﺎﻧﻲ‬‫زﻣﺎﻧﻲ‬::O(nO(n .. dd22)) N. Razavi - AI course - 2005 43 CSP‫درﺧﺘ‬ ‫ﺷﺒﻪ‬ ‫ﺎﺧﺘﺎر‬ ‫داراي‬ ‫ﻫﺎي‬ CSP‫درﺧﺘﻲ‬ ‫ﺷﺒﻪ‬ ‫ﺳﺎﺧﺘﺎر‬ ‫داراي‬ ‫ﻫﺎي‬ ••‫ﺷﺮﻃﻲ‬‫ﺷﺮﻃﻲ‬‫ﺳﺎزي‬‫ﺳﺎزي‬:‫ﺑﻪ‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻣﻘﺪار‬‫ﺑﺪه؛‬‫داﻣﻨﻪ‬‫ﻫﻤﺴﺎﻳﻪ‬‫ﻫﺎي‬‫آن‬‫را‬‫ﻫﺮس‬‫ﻛﻦ‬ •‫ﺷﺮط‬‫ﺷﺮط‬‫ﺑﺮﺷﻲ‬‫ﺑﺮﺷﻲ‬:‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎ‬)‫در‬‫ﺗﻤﺎم‬‫ﺣﺎﻻت‬‫ﻣﻤﻜﻦ‬(‫را‬‫ﻣﻘﺪار‬‫دﻫﻲ‬‫ﻛﻦ‬‫ﺑﻪ‬ ‫ﺮ‬‫ﺮ‬‫ﻲ‬ ‫ﺮ‬‫ﻲ‬ ‫ﺮ‬‫ﻮ‬‫ﺮ‬‫م‬‫ﻦ‬‫ﻲ‬‫ﻦ‬ ‫ﻃﻮرﻳﻜﻪ‬‫ﮔﺮاف‬‫ﮔﺮاف‬‫ﻣﺤﺪودﻳﺖ‬‫ﺑﺎﻗﻴﻤﺎﻧﺪه‬‫ﻳﻚ‬‫درﺧﺖ‬‫ﺷﻮد‬. ‫اﻧﺪازه‬‫ﺑﺮش‬=c‫زﻣﺎن‬‫اﺟﺮا‬O(dc . (n - c) d2) ‫ز‬‫ﺑﺮش‬c‫ن‬ ‫ز‬‫ﺟﺮ‬O(d . ( c) d ) N. Razavi - AI course - 2005 44
  • 12. ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ N. Razavi - AI course - 2005 45 ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ •‫ﺷﺮاﻳﻂ‬‫ﺗﺠﺰﻳﻪ‬‫ﺗﺠﺰﻳﻪ‬‫درﺧﺘﻲ‬‫درﺧﺘﻲ‬:: ‫ﺄﻟ‬‫ﻠ‬ ‫ا‬‫ﺎ‬‫اﻗﻞ‬‫ﻚ‬‫ﺄﻟ‬‫ﻇﺎ‬ –‫ﻫﺮ‬‫ﻣﺘﻐﻴﺮ‬‫در‬‫ﻣﺴﺄﻟﻪ‬‫اﺻﻠﻲ‬‫ﺑﺎﻳﺪ‬‫ﺣﺪاﻗﻞ‬‫در‬‫ﻳﻚ‬‫زﻳﺮﻣﺴﺄﻟﻪ‬‫ﻇﺎﻫﺮ‬‫ﺷﻮد‬ –‫اﮔﺮ‬‫دو‬‫ﻣﺘﻐﻴﺮ‬‫ﺑﻪ‬‫وﺳﻴﻠﻪ‬‫ﻣﺤﺪودﻳﺘﻲ‬‫در‬‫ﻣﺴﺄﻟﻪ‬‫اﺻﻠﻲ‬‫ﻣﺘﺼﻞ‬‫ﺷﺪه‬،‫ﺑﺎﺷﻨﺪ‬ ‫ﺮ‬‫و‬‫ﻴﺮ‬‫ﺑ‬‫ﻴ‬ ‫و‬‫ﻲ‬ ‫ﻳ‬ ‫و‬‫ر‬‫ﻲ‬‫ﻞ‬‫ﺑ‬ ‫آﻧﮕﺎه‬‫آن‬‫دو‬‫ﻣﺘﻐﻴﺮﺑﺎ‬‫ﻫﻢ‬)‫ﺑﻪ‬‫ﻫﻤﺮاه‬‫ﻣﺤﺪودﻳﺖ‬(‫ﺑﺎﻳﺪ‬‫ﺣﺪاﻗﻞ‬‫در‬‫ﻳﻚ‬‫زﻳﺮ‬ ‫ﻣﺴﺄﻟﻪ‬‫ﻇﺎﻫﺮ‬‫ﺷﻮﻧﺪ‬ ‫ﻣﺴﺄﻟﻪ‬‫ﻇﺎﻫﺮ‬‫ﺷﻮﻧﺪ‬. –‫اﮔﺮ‬‫ﻣﺘﻐﻴﺮي‬‫در‬‫درﺧﺖ‬‫در‬‫دو‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫ﻇﺎﻫﺮ‬‫ﺷﺪه‬،‫ﺑﺎﺷﺪ‬‫آﻧﮕﺎه‬‫ﺑﺎﻳﺪ‬‫در‬ ‫ﺄﻟ‬‫ل‬ ‫ﻃ‬‫ﻛ‬‫ﻛ‬‫ﻇ‬ ‫ﻫﺮ‬‫زﻳﺮﻣﺴﺄﻟﻪ‬‫در‬‫ﻃﻮل‬‫ﻣﺴﻴﺮي‬‫ﻛﻪ‬‫زﻳﺮﻣﺴﺎﻳﻞ‬‫را‬‫ﻣﺘﺼﻞ‬‫ﻣﻲ‬،‫ﻛﻨﺪ‬‫ﻇﺎﻫﺮ‬ ‫ﺷﻮد‬. N. Razavi - AI course - 2005 46 ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ ‫دوم‬ ‫رﻫﻴﺎﻓﺖ‬:‫درﺧﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ‬ •‫ﺣﻞ‬‫ﺗﺠﺰﻳﻪ‬‫درﺧﺘﻲ‬: ‫ﺄ‬‫ﻚ‬i bli bl‫ﮔ‬ –‫ﻫﺮ‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫را‬‫ﺑﻪ‬‫ﺻﻮرت‬‫ﻳﻚ‬megamega--variablevariable‫در‬‫ﻧﻈﺮ‬‫ﻣﻲ‬‫ﮔﻴﺮﻳﻢ‬ ‫ﻛﻪ‬‫داﻣﻨﻪ‬‫آن‬‫ﻣﺠﻤﻮﻋﻪ‬‫ﺗﻤﺎم‬‫راه‬‫ﺣﻞ‬‫ﻫﺎي‬‫ﻣﻤﻜﻦ‬‫آن‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬. ‫م‬ –‫ﺳﭙﺲ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎي‬‫ﻣﻴﺎن‬‫زﻳﺮ‬‫ﻣﺴﺎﻳﻞ‬‫را‬‫ﺑﺎ‬‫اﺳﺘﻔﺎده‬‫از‬‫اﻟﮕﻮرﻳﺘﻢ‬‫ﻛﺎراي‬ ‫درﺧﺖ‬‫ﺣﻞ‬‫ﻣ‬‫ﻛﻨﻴﻢ‬‫ﻣﺜﻼ‬‫اﮔﺮ‬‫ﭘﺎﺳﺦ‬‫اوﻟﻴﻦ‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫اﻧﺘﺴﺎب‬‫زﻳﺮ‬‫ﺑﺎﺷﺪ‬: ‫درﺧﺖ‬‫ﺣﻞ‬‫ﻣﻲ‬‫ﻛﻨﻴﻢ‬.‫ﻣﺜﻼ‬‫اﮔﺮ‬‫ﭘﺎﺳﺦ‬‫اوﻟﻴﻦ‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫اﻧﺘﺴﺎب‬‫زﻳﺮ‬‫ﺑﺎﺷﺪ‬: {WA = red, SA= blue, NT = green} ‫آﻧﮕﺎه‬‫ﺗﻨﻬﺎ‬‫ﭘﺎﺳﺦ‬‫ﺳﺎزﮔﺎر‬‫ﺑﺮاي‬‫زﻳﺮ‬‫ﻣﺴﺄﻟﻪ‬‫ﺑﻌﺪي‬‫اﻧﺘﺴﺎب‬‫زﻳﺮ‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬: {SA = blue NT = green Q = red}{SA blue, NT green, Q red} ‫ﭘﻴﭽﻴﺪﮔﻲ‬‫زﻣﺎﻧﻲ‬:O(n . dw+1) N. Razavi - AI course - 2005 47 ‫ﺧﻼﺻﻪ‬‫ﺧﻼﺻﻪ‬ •‫ﻣﺴﺎﺋﻞ‬CSP‫ﻧﻮع‬‫ﺧﺎﺻﻲ‬‫از‬‫ﻣﺴﺎﺋﻞ‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬: –‫ﺣﺎﻻت‬‫ﺗﻮﺳﻂ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬‫ﺷﻮﻧﺪ‬. ‫ﺣﺎﻻت‬‫ﺗﻮﺳﻂ‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺠﻤﻮﻋﻪ‬‫اي‬‫از‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬‫ﺷﻮﻧﺪ‬. –‫ﺗﺴﺖ‬‫ﻫﺪف‬‫ﺗﻮﺳﻂ‬‫ﻣﺤﺪودﻳﺖ‬‫ﻫﺎ‬‫روي‬‫ﻣﻘﺎدﻳﺮ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫ﺗﻌﺮﻳﻒ‬‫ﻣﻲ‬‫ﺷﻮد‬. •‫ي‬ ‫ﺘ‬‫د‬ ‫ﮕ‬ ‫ﻋﻘ‬‫ي‬ ‫ﺘ‬‫ل‬ ‫ا‬‫ﻖ‬ ‫ﻋ‬‫ﻛﻪ‬‫د‬‫ﻫ‬‫ﮔ‬‫ﻚ‬‫ﺘﻐ‬‫ﻘﺪا‬‫ﻓﺘﻪ‬ ‫ﮔ‬ •‫ﺟﺴﺘﺠﻮي‬‫ﻋﻘﺒﮕﺮد‬=‫ﺟﺴﺘﺠﻮي‬‫اول‬-‫ﻋﻤﻖ‬‫ﻛﻪ‬‫در‬‫ﻫﺮ‬‫ﮔﺮه‬‫ﻳﻚ‬‫ﻣﺘﻐﻴﺮ‬‫ﻣﻘﺪار‬‫ﮔﺮﻓﺘﻪ‬ ‫ﺑﺎﺷﺪ‬. ‫ﻚ‬‫ﺎ‬‫ﺎ‬‫ﺎ‬ ‫ا‬‫ﻘﺎ‬‫ﺎ‬‫ﻚ‬ ‫ﻛ‬‫ﻛ‬‫ﺎ‬ •‫ﻫﻴﻮرﻳﺴﺘﻴﻚ‬‫ﻫﺎي‬‫ﺗﺮﺗﻴﺐ‬‫ﻣﺘﻐﻴﺮﻫﺎ‬‫و‬‫اﻧﺘﺨﺎب‬‫ﻣﻘﺎدﻳﺮ‬‫ﺑﺴﻴﺎر‬‫ﻛﻤﻚ‬‫ﻛﻨﻨﺪه‬‫ﻣﻲ‬‫ﺑﺎﺷﻨﺪ‬. •‫ﺑﺮرﺳﻲ‬‫رو‬‫ﺑﻪ‬‫ﺟﻠﻮ‬‫از‬‫اﻧﺘﺴﺎب‬‫ﻫﺎي‬‫ﻣﻨﺠﺮ‬‫ﺑﻪ‬‫ﺷﻜﺴﺖ‬‫ﺟﻠﻮﮔﻴﺮي‬‫ﻣﻲ‬‫ﻛﻨﺪ‬. •‫اﻧﺘﺸﺎر‬‫ﻣﺤﺪودﻳﺖ‬‫ﻛﺎرﻫﺎي‬‫ﺑﻴﺸﺘﺮي‬‫ﺑﺮاي‬‫ﻣﺤﺪود‬‫ﻛﺮدن‬‫ﻣﻘﺎدﻳﺮ‬‫و‬‫ﺗﺸﺨﻴﺺ‬ ‫ﻧﺎﺳﺎزﮔﺎري‬‫ﻫﺎ‬‫اﻧﺠﺎم‬‫ﻣﻲ‬‫دﻫﺪ‬. ‫ري‬ ‫ز‬‫م‬ ‫ﺠ‬‫ﻲ‬ •‫در‬‫ﻋﻤﻞ‬‫ﻣﻌﻤﻮﻻ‬‫ﺟﺴﺘﺠﻮي‬‫ﻣﺤﻠﻲ‬min-conflicts‫ﻣﺆﺛﺮ‬‫ﻣﻲ‬‫ﺑﺎﺷﺪ‬. N. Razavi - AI course - 2005 48