Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3243 - Constraint Satisfaction Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Modified by Vali Derhami.

Similar presentations


Presentation on theme: "CS 3243 - Constraint Satisfaction Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Modified by Vali Derhami."— Presentation transcript:

1 CS 3243 - Constraint Satisfaction Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Modified by Vali Derhami

2 CS 3243 - Constraint Satisfaction234/ Outline Constraint Satisfaction Problems (CSP) Backtracking search for CSPs Local search for CSPs

3 CS 3243 - Constraint Satisfaction334/ Constraint satisfaction problems (CSPs) Standard search problem: state is a "black box“ – any data structure that supports successor function, heuristic function, and goal test هر ساختمان داده ای که آزمون هدف، ارزیابی، و تابع پسین را در خود دارد. CSP: state is defined by variables X i with values from domain D i حالت اولیه هیچ یک از متغیرها مقدار دهی نشده اند. goal test is a set of constraints specifying allowable combinations of values for subsets of variables Allows useful general-purpose algorithms with more power than standard search algorithms مسائل ارضای محدودیت می توانند توسط الگوریتم های جستجوی عمومی حل شوند، اما بخاطر ساختار خاصشان الگوریتمهایی در اینجا مطرح می شود که از الگوریتمهای عمومی کارآتر هستند

4 CS 3243 - Constraint Satisfaction434/ Example: Map-Coloring Variables Xi : WA, NT, Q, NSW, V, SA, T Domains D i = {red,green,blue} Constraints Ci: adjacent regions must have different colors e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red), (green,blue),(blue,red),(blue,green)}

5 CS 3243 - Constraint Satisfaction534/ Example: Map-Coloring Solutions are complete and consistent assignments, e.g., WA = red, NT = green,Q = red,NSW = green,V = red,SA = blue,T = green

6 CS 3243 - Constraint Satisfaction634/ Constraint graph Binary ( دوگانی ) CSP: each constraint relates two variables Constraint graph: nodes are variables, arcs are constraints

7 CS 3243 - Constraint Satisfaction734/ Varieties of CSPs Discrete variables finite domains: دامنه های محدود n variables, domain size d  O(d n ) complete assignments تعداد انتسابهای کامل ممکن، برابر با O(d n ) است e.g., Boolean CSPs, incl.~Boolean satisfiability (NP-complete) infinite domains: دامنه های نامحدود integers, strings, etc. e.g., job scheduling, variables are start/end days for each job need a constraint language ( زبان محدودیت ), e.g., StartJob 1 + 5 ≤ StartJob 3 Continuous variables e.g., start/end times for Hubble Space Telescope observations linear constraints solvable in polynomial time by linear programming مسائل با محدودیت خطی که از نظر مرتبه زمانی بصورت چند جمله ای هستند با روشهای برنامه ریزی خطی قابل حل هستند.

8 CS 3243 - Constraint Satisfaction834/ Varieties of constraints Unary constraints ( محدودیت های یگانی )involve a single variable, e.g., SA ≠ green می توان با یک پیش پردازش ساده مقدار غیر مجاز را از دامنه متغیر مربوطه از ابتدا حذف کرد. Binary constraints ( محدودیت دوگانی )involve pairs of variables, e.g., SA ≠ WA Higher-order constraints involve 3 or more variables, e.g., cryptarithmetic ( حساب رمزی )column constraints

9 CS 3243 - Constraint Satisfaction934/ Example: Cryptarithmetic ( حساب رمزی ) Variables: F T U W R O X 1 X 2 X 3 Domains: {0,1,2,3,4,5,6,7,8,9} Constraints: Alldiff (F,T,U,W,R,O) O + O = R + 10 · X 1 X 1 + W + W = U + 10 · X 2 X 2 + T + T = O + 10 · X 3 X 3 = F, T ≠ 0, F ≠ 0

10 CS 3243 - Constraint Satisfaction1034/ Real-world CSPs وجود محدودیتهای با تقدم دردنیای واقعی بجای محدودیتهای مطلق Assignment problems e.g., who teaches what class Timetabling problems e.g., which class is offered when and where? Transportation scheduling Factory scheduling Notice that many real-world problems involve real-valued variables

11 CS 3243 - Constraint Satisfaction1134/ Standard search formulation (incremental) Let's start with the straightforward approach, then fix it States are defined by the values assigned so far 1- Initial state: the empty assignment { } 2- Successor function: assign a value to an unassigned variable that does not conflict with current assignment تعیین یک مقدار برای متغیری که تاکنون مقداری به آن انتساب نیافته به گونه ای که محدودیتها را نقض نکند  fail if no legal assignments 3- Goal test: the current assignment is complete 4- Cost path: یک هزینه ثابت برای هر مرحله 1. This is the same for all CSPs 2. Every solution appears at depth n with n variables  use depth-first search 3. Path is irrelevant (مسیر مهم نیست), so can also use complete-state formulation 4. b = (n - l )d at depth l, hence )n! · d n ( leaves, although only d n possible complete assignments لذا مثلا مناسب نیست که از جستجوی اول سطح استفاده کنیم.

12 CS 3243 - Constraint Satisfaction1234/ Backtracking search جستجوی پس گرد Variable assignments are commutative(جابجایی پذیر) }, i.e., [ WA = red then NT = green ] same as [ NT = green then WA = red ] جابجایی پذیر است چرا که ترتیب انتساب مهم نیست. Only need to consider assignments to a single variable at each node  b = d and there are d n leaves  (در هر سطح تنها برای یک متغیر مقدار تعیین می شود)  Depth-first search for CSPs with single-variable assignments is called backtracking search Backtracking search is the basic uninformed algorithm for CSPs Can solve n-queens for n ≈ 25

13 CS 3243 - Constraint Satisfaction1334/ Backtracking search

14 CS 3243 - Constraint Satisfaction1434/ Backtracking example

15 CS 3243 - Constraint Satisfaction1534/ Backtracking example

16 CS 3243 - Constraint Satisfaction1634/ Backtracking example

17 CS 3243 - Constraint Satisfaction1734/ Backtracking example

18 CS 3243 - Constraint Satisfaction1834/ Improving backtracking efficiency General-purpose methods can give huge gains in speed: Which variable should be assigned next? (کدام متغیر برای مقدار دهی انتخاب شود) In what order should its values be tried? (چه ترتیبی برای مقدار دهی به متغیر لحاظ شود؟) Can we detect inevitable failure early? (آیا می توان شکست را سریعتر پیش بینی کرد)

19 CS 3243 - Constraint Satisfaction1934/ Minimum remaining values (MRV) heuristics Minimum remaining values (Most constrained variable): حداقل مقادیر باقیمانده یا متغیر با بیشترین محدودیت choose the variable with the fewest legal values متغیری مقدار دهی شود که که دارای کمترین مقدار ممکن مجاز باشد. به آن هیوریستیک اول شکست هم می گویند

20 CS 3243 - Constraint Satisfaction2034/ Degree heuristic هیوریستیک درجه مفید برای انتخاب اولین متغیر برای مقدار دهی. متغیری که دارای بالاترین درجه محدودیت است در ابتدای کار انتخاب می شود. منظور متغیری است که رابطه های محدودیت بیشتری دارد.

21 CS 3243 - Constraint Satisfaction2134/ Least constraining value مقدار با حداقل محدویت Given a variable, choose the least constraining value: (مقداری برای متغیر انتخاب می شود که کمترین محدودیت را برای متغیرهای مجاور آن ایجاد کند) Combining these heuristics makes 1000 queens feasible


Download ppt "CS 3243 - Constraint Satisfaction Constraint Satisfaction Problems Chapter 5 Section 1 – 3 Modified by Vali Derhami."

Similar presentations


Ads by Google