1 / 76

MBD and CSP

MBD and CSP. Meir Kalech. Partially based on slides of Jia You and Brian Williams. Outline. Last lecture: Autonomous systems Model-based programming Livingstone Today’s lecture: Constraints satisfaction problems (CSP) Optimal CSP Conflict-directed A* Expand best child.

luann
Télécharger la présentation

MBD and CSP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MBD and CSP Meir Kalech Partially based on slides of Jia You and Brian Williams

  2. Outline • Last lecture: • Autonomous systems • Model-based programming • Livingstone • Today’s lecture: • Constraints satisfaction problems (CSP) • Optimal CSP • Conflict-directed A* • Expand best child

  3. Intro Example: 8-Queens Generate-and-test, 88 combinations

  4. Intro Example: 8-Queens

  5. Constraint Satisfaction Problem • Set of variables {X1, X2, …, Xn} • Each variable Xi has a domain Di of possible values • Usually Di is discrete and finite • Set of constraints {C1, C2, …, Cp} • Each constraint Ck involves a subset of variables and specifies the allowable combinations of values of these variables • Goal: Assign a value to every variable such that all constraints are satisfied

  6. Example: 8-Queens Problem • 8 variables Xi, i = 1 to 8 • Domain for each variable {1,2,…,8} • Constraints are of the forms: • Xi = k  Xj k for all j = 1 to 8, ji

  7. NT Q WA SA NT NSW Q V WA SA T NSW V T Example: Map Coloring • 7 variables {WA,NT,SA,Q,NSW,V,T} • Each variable has the same domain {red, green, blue} • No two adjacent variables have the same value: • WANT, WASA, NTSA, NTQ, SAQ, SANSW, SAV,QNSW, NSWV

  8. T1 T2 T4 T3 Example: Task Scheduling T1 must be done during T3 T2 must be achieved before T1 starts T2 must overlap with T3 T4 must start after T1 is complete

  9. Binary constraints NT T1 Q WA T2 NSW T4 SA V T3 T Constraint Graph Two variables are adjacent or neighbors if they are connected by an edge or an arc

  10. CSP as a Search Problem • Initial state: empty assignment • Successor function: a value is assigned to any unassigned variable, which does not conflict with the currently assigned variables • Goal test: the assignment is complete • Path cost: irrelevant

  11. Backtracking example

  12. Backtracking example

  13. Backtracking example

  14. Backtracking example

  15. Backtracking Algorithm CSP-BACKTRACKING(PartialAssignment a) • If a is complete then return a • X select an unassigned variable • D  select an ordering for the domain of X • For each value v in D do • If v is consistent with a then • Add (X= v) to a • result CSP-BACKTRACKING(a) • If resultfailure then return result • Remove (X= v) from a • Return failure Start with CSP-BACKTRACKING({})

  16. Improving backtracking efficiency • Which variable should be assigned next? • In what order should its values be tried? • Can we detect obvious failure early?

  17. Outline • Last lecture: • Autonomous systems • Model-based programming • Livingstone • Today’s lecture: • Constraints satisfaction problems (CSP) • Optimal CSP • Conflict-directed A* • Expand best child

  18. What is an Optimal CSP(OCSP)? • Set of decision variables y, • A utility function gon y, • A set of constraints C that y must satisfy. • The solution is an assignment to y, maximizing g and satisfyingC.

  19. What is an OCSP formally? • OCSP is: • Where CSP = • x – set of variables • Dx – Domain over variables • Cx – set of constraints over variables • - set of decision variables • Cost function – • We call the elements of Dy decision states. • A solution y* to an OCSP is a minimum cost decision state that is consistent with the CSP.

  20. Methods for solving OCSP • Traditional method: A* • Good at finding optimal solutions. • Visits every state that whose estimated cost is less than the true optimum*.Computationally unacceptable for model-based executives. * A* heuristic is admissible, that is, it never overestimates cost. • Solution: CONFLICT-DIRECTED A* • Also searches in best-first order • Eliminates subspaces around inconsistent states

  21. Outline • Last lecture: • Autonomous systems • Model-based programming • Livingstone • Today’s lecture: • Constraints satisfaction problems (CSP) • Optimal CSP • Conflict-directed A* • Expand best child

  22. CONFLICT-DIRECTED A*Williams&Rango 03 Step 1: Best candidate S generated Step 2: S is tested for consistency Step 3: If S is inconsistent, the inconsistency is generalized to conflicts, removing a subspace of the solution space Step 4: The program jumps to the next-best candidate, resolving all conflicts.

  23. Enumerating Probable Candidates Generate Candidate Leading Candidate Based on Priors Test Candidate Yes No Consistent? Keep Extract Conflict Compute Posterior p Yes Below Threshold? No Done

  24. A* - must visit all states with cost lower than optimum Increasing Cost inconsistent consistent

  25. Conflict-directed A* - found inconsistent state eliminates all states entail the same symptom Increasing Cost inconsistent consistent

  26. Conflict-directed A* Increasing Cost Conflict 1 inconsistent consistent

  27. Conflict-directed A* Increasing Cost Conflict 1 inconsistent consistent

  28. Conflict-directed A* Increasing Cost Conflict 1 inconsistent Conflict 2 consistent

  29. Conflict-directed A* Increasing Cost Conflict 1 inconsistent Conflict 2 consistent

  30. Conflict-directed A* Increasing Cost Conflict 1 inconsistent Conflict 2 consistent Conflict 3

  31. Conflict-directed A* Increasing Cost Conflict 1 inconsistent Conflict 2 consistent • Feasible regions described by the implicates of known conflicts (Kernel Assignments) • Want kernel assignment containing the best cost candidate Conflict 3

  32. Conflict-directed A* Function Conflict-directed-A*(OCSP) returns the leading minimal cost solutions. Conflicts[OCSP]  {} OCSP Initialize-Best-Kernels(OCSP) Solutions[OCSP]  {} loop do decision-state Next-Best-State-Resolving-Conflicts(OCSP) if no decision-state returned or Terminate?(OCSP) then return Solutions[OCSP] if Consistent?(CSP[OCSP ], decision-state) then add decision-state to Solutions[OCSP] else new-conflicts  Extract-Conflicts(CSP[OCSP], decision-state) Conflicts[OCSP]  Eliminate-Redundant-Conflicts(Conflicts[OCSP]  new-conflicts) end

  33. Conflict-directed A* Function Conflict-directed-A*(OCSP) returns the leading minimal cost solutions. Conflicts[OCSP]  {} OCSP Initialize-Best-Kernels(OCSP) Solutions[OCSP]  {} loop do decision-state Next-Best-State-Resolving-Conflicts(OCSP) if no decision-state returned or Terminate?(OCSP) then return Solutions[OCSP] if Consistent?(CSP[OCSP ], decision-state) then add decision-state to Solutions[OCSP] else new-conflicts  Extract-Conflicts(CSP[OCSP], decision-state) Conflicts[OCSP]  Eliminate-Redundant-Conflicts(Conflicts[OCSP]  new-conflicts) end

  34. A M1 X F B A1 3 C 10 M2 Y 2 D G A2 2 12 M3 E Z 3 3 Example: Diagnosis as an OCSP Assume Independent failures: • PG(mi) >> PU(mi) //G-good, U-unknown • Psingle >> Pdouble • PU(M2) > PU(M1) > PU(M3) > PU(A1) > PU(A2)

  35. A M1 X F B A1 3 C 10 M2 Y 2 D G A2 2 12 M3 E Z 3 3 Example: Diagnosis • OBS = observation. • COMPONENTS = variable set y. • System Description = constraints - Cy. • M1=G  X=A+B • Candidate = a mode assignments to y. • Diagnosis = a candidate that is consistent with Cy and OBS. • Utility = candidate probability P(y). • Cost = 1/P(y).

  36. A M1 X F B A1 3 C 10 M2 Y 2 D G A2 2 12 M3 E Z 3 3 First Iteration • Conflicts / Constituent Diagnoses • none • Best Kernel: • {} • Best Candidate: • ?

  37. M1=?  M2=?  M3=?  A1=?  A2=? M1=G  M2=G  M3=G  A1=G  A2=G { } • Select most likely value for unassigned modes

  38. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 3 M1 X F 10 B A1 2 C M2 2 Y 12 D G A2 3 M3 E Z 3

  39. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 3 M1 X F 10 B A1 2 C M2 2 Y 12 D G A2 3 M3 E Z 3

  40. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 M3 E Z 3

  41. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3

  42. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3

  43. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3 • Extract Conflict and Constituent Diagnoses:

  44. Test: M1=G  M2=G  M3=G  A1=G  A2=G A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3 • Extract Conflict and Constituent Diagnoses:

  45. A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3 • Test: M1=G  M2=G  M3=G  A1=G  A2=G • Extract Conflict and Constituent Diagnoses:¬ [M1=G  M2=G  A1=G]

  46. A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3 • Test: M1=G  M2=G  M3=G  A1=G  A2=G • Extract Conflict and Constituent Diagnoses:¬ [M1=G  M2=G  A1=G] M1=U  M2=U  A1=U This process has been done through propositional satisfiability algorithm DPLL algorithm*

  47. A 6 12 3 M1 X F 10 B A1 2 6 C M2 2 Y 12 D G A2 3 6 M3 E Z 3 Second Iteration • Conflicts / Constituent Diagnoses • M1=U  M2=U  A1=U • Best Kernel: • M2=U • Best Candidate: • M1=G M2=U M3=G  A1=G  A2=G Later we will describe how to determine the best Kernel

  48. Test: M1=G M2=U M3=G  A1=G  A2=G A 3 M1 X F 10 B A1 2 C 2 Y 12 D G A2 3 M3 E Z 3

  49. Test: M1=G M2=U M3=G  A1=G  A2=G A 6 3 M1 X F 10 B A1 2 C 2 Y 12 D G A2 3 M3 E Z 3

  50. Test: M1=G M2=U M3=G  A1=G  A2=G A 6 3 M1 X F 10 B A1 2 C 2 Y 12 D G A2 3 6 M3 E Z 3

More Related