CMPSCI 383: Artificial Intelligence

Fall 2014 (archived)

News for the Week of 13 October

No class Thursday 16 October

Class and office hours are canceled this Thursday. I will unavailable by email this week after Wednesday. If you need an extension for Assignment 04, ask for it before about 1500 on Wednesday, as I can’t guarantee I’ll be checking email right up until 1700.

TA Office Hours Canceled

Patrick’s office hours on Wednesday (1330) are canceled. I will be in my office if you would like to drop by.

Assignment 04

It is still due on 17 October.

The simple backtracking solver I posted last week is capable of handling the 6x6 board embedded in the assignment, as well as the 6x6 sample boards that a student kindly posted to Moodle. You can use it to produce solutions to check your own code against. I posted solutions to the 9x9 and 13x13 boards in a reply to the post on Moodle where the problems were posted.

You can use the solver I posted as a basis for your own work. As you know, it takes far too long to complete on larger boards.

Below is some information on its runtime on some simpler boards (either included in the posted solver tarball, or in the .zip file on Moodle):

board name    open cells  possible assignments  assignments considered  runtime
3x3-simple         4             6561                     10             < 1 sec
4x4-simple         8             4.3E7                   971             < 1 sec
6x6-easy          16             1.85E15               43098             < 1 sec
6x6-hard          16             1.85E15               31045             < 1 sec
6x6-assignment    20             1.21E19              862301               4 sec

I chose to implement forward checking on the AllDifferent constraint, the MRV heuristic for variable assignment choice, and an ad hoc rule to use the “naked pairs” strategy (essentially, additional checking on the AllDifferent constraint). I also wrote code to enumerate the valid possibilities for a cell, given the remaining possibilities in cells that participated in the same constraints. This took me about an hour, and can be done in about 100 lines of changed or added code, based upon the simple solver I provided to you.

Using this approach, inference runs once before the search begins, and as part of each assignment made by the search. This approach significantly reduces the search space and runtime:

                                possible      after      assignments 
  board name    open cells      assignments  inference    considered    runtime
  3x3-simple         4              6561            3           2       < 1 sec
  4x4-simple         8             4.3E7            1           1       < 1 sec
  6x6-easy          16           1.85E15      2097152          32       < 1 sec
  6x6-hard          16           1.85E15       6.00E7         127       < 1 sec
  6x6-assignment    20           1.21E19        20736          17       < 1 sec
  9x9-easy          46           7.85E43      5.24E18        1538         1 sec
  9x9-hard          40           1.47E38      1.62E19         159         1 sec
13x13-easy          88           9.40E83      1.76E43      636434        33 sec
13x13-hard          88           9.40E83      1.38E50    38447279        29 min

Your submission should work about this well for full credit, though you could also try other approaches, e.g., other ad hoc rules on the constraints, arc consistency checking (on either or both the AllDifferent or SumsTo constraint), path consistently checking, parallelizing the search, etc.

Update on 15 October: In fact, at least one student has done better. By performing forward checking on the SumsTo constraint, he is able to solve the 16x16 puzzles in under a second. Well done.