A* search for Sudoku

I have a homework problem for an Artificial Intelligence course that I am having trouble answering.

Consider solving the Sudoku problem using A* search. The start state
has some number of cells filled in, and the successors of each state
are all legal ways an additional cell can be filled in. At any time we
know exactly the number of cells that remain to filled.

Therefore, if K cells remain to be filled at node n, we know that h(n)
= K. Thus if we set our heuristic function h(n) to be h(n)=K, we will have perfect heuristic knowledge in A.

Explain the mistake in the above statement.

I understand that this heuristic is entirely pointless since if there was some function that could find legal successors you might as well run a depth first search but what exactly is wrong with the above statement.

0

This isn’t an answer, but it’s too long for a comment…

Using that remaining-distance metric, you can certainly implement an A* search and it will give the correct result, but it will be extremely inefficient. The reason is that it’s really a Dijkstra search disguised as A*. Worse than that, as Shawn notes, it’s really a simple breadth-first search.

The reason it has decayed to Dijkstra is because your metric gives no clues as to which is the best direction to take through the state space. Each step from a particular intermediate state is just filling in one digit in one cell – precisely as cheap/costly as filling in any other possible digit/cell at that point and with no clue as to which successor states (with the same number of empty cells) are closer to a correct solution. All paths from that intermediate state to the solution are the same length, including the ones leading through illegal states to a broken solution.

This is legal in the sense that the distance metric is a lower bound to the remaining distance to a solution. But it’s not just a lower bound, it’s an exact distance. Your “perfect heuristic” isn’t guiding the search towards the solution in any useful way beyond what Dijkstra could do.

The reason it has decayed to a breadth-first search is the same thing, but in terms of the weights of edges already traversed so far. Every path from the start to any intermediate state has the same number of edges and the same total cost (same number of cells filled in). Every edge effectively has weight one, and there are no short-cuts for Dijkstra to exploit.

In practice, Sodoku solvers usually use backtracking depth-first search with relatively cheap checks (if there are two of the same digit in any cell, row or block, this state is impossible as are all possible successor states) to avoid searching impossible parts of the search space. There’s not much guidance you can get on which intermediate states are better without spending more on the heuristics and search algorithm than you gain by pruning the search tree further, and besides, backtracking search with that simple pruning is very fast.

The “legal successor” is not same as “valid successor”. Eg. if single cell can contain N numbers, based on current state of the field, then each of them is “legal successor”. But only one of them is “valid successor” (assuming it has only one solution).

But I don’t agree that it describes number of unfilled cells as perfect heuristic. But that is just my feeling.

And shouldn’t you be asking this your professor?

This does not seem correct:

Therefore, if K cells remain to be filled at node n, we know that h(n) = K.

We don’t know that h(n) = K unless we know that the puzzle is solvable from node n.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

A* search for Sudoku

I have a homework problem for an Artificial Intelligence course that I am having trouble answering.

Consider solving the Sudoku problem using A* search. The start state
has some number of cells filled in, and the successors of each state
are all legal ways an additional cell can be filled in. At any time we
know exactly the number of cells that remain to filled.

Therefore, if K cells remain to be filled at node n, we know that h(n)
= K. Thus if we set our heuristic function h(n) to be h(n)=K, we will have perfect heuristic knowledge in A.

Explain the mistake in the above statement.

I understand that this heuristic is entirely pointless since if there was some function that could find legal successors you might as well run a depth first search but what exactly is wrong with the above statement.

0

This isn’t an answer, but it’s too long for a comment…

Using that remaining-distance metric, you can certainly implement an A* search and it will give the correct result, but it will be extremely inefficient. The reason is that it’s really a Dijkstra search disguised as A*. Worse than that, as Shawn notes, it’s really a simple breadth-first search.

The reason it has decayed to Dijkstra is because your metric gives no clues as to which is the best direction to take through the state space. Each step from a particular intermediate state is just filling in one digit in one cell – precisely as cheap/costly as filling in any other possible digit/cell at that point and with no clue as to which successor states (with the same number of empty cells) are closer to a correct solution. All paths from that intermediate state to the solution are the same length, including the ones leading through illegal states to a broken solution.

This is legal in the sense that the distance metric is a lower bound to the remaining distance to a solution. But it’s not just a lower bound, it’s an exact distance. Your “perfect heuristic” isn’t guiding the search towards the solution in any useful way beyond what Dijkstra could do.

The reason it has decayed to a breadth-first search is the same thing, but in terms of the weights of edges already traversed so far. Every path from the start to any intermediate state has the same number of edges and the same total cost (same number of cells filled in). Every edge effectively has weight one, and there are no short-cuts for Dijkstra to exploit.

In practice, Sodoku solvers usually use backtracking depth-first search with relatively cheap checks (if there are two of the same digit in any cell, row or block, this state is impossible as are all possible successor states) to avoid searching impossible parts of the search space. There’s not much guidance you can get on which intermediate states are better without spending more on the heuristics and search algorithm than you gain by pruning the search tree further, and besides, backtracking search with that simple pruning is very fast.

The “legal successor” is not same as “valid successor”. Eg. if single cell can contain N numbers, based on current state of the field, then each of them is “legal successor”. But only one of them is “valid successor” (assuming it has only one solution).

But I don’t agree that it describes number of unfilled cells as perfect heuristic. But that is just my feeling.

And shouldn’t you be asking this your professor?

This does not seem correct:

Therefore, if K cells remain to be filled at node n, we know that h(n) = K.

We don’t know that h(n) = K unless we know that the puzzle is solvable from node n.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật