Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. def AC2(csp):
  2. q1=queue.Queue()
  3. q2=queue.Queue()
  4. for i in range(len(csp.variables)):
  5. for arc in csp.edges:
  6. if arc[0]==i:
  7. if arc[0] > arc[1]:
  8. q1.put(arc)
  9. else:
  10. q2.put(arc)
  11. while q1.empty()==False:
  12. while q1.empty()==False:
  13. arc=q1.get()
  14. if revise(csp,arc):
  15. if len(csp.domain[arc[0]]) == 0:
  16. return False
  17. for edge in csp.edges:
  18. if edge[0]<edge[1] and edge[0]<=i and edge[0]!=arc[1]:
  19. q2.put(edge)
  20. q1=clone(q2)
  21. q2=queue.Queue()
  22. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement