From a7f8e4a1c50cc5487691c902396cbabc8055844e Mon Sep 17 00:00:00 2001 From: Trang Nguyen Date: Sat, 21 Apr 2018 15:28:00 -0400 Subject: [PATCH] docs: Update README with more info on the project and setup --- README.md | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f30492..e18f355 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,40 @@ -In this exercise you will explore Constraint Satisfaction Problems by implementing the N-Queens problem using symbolic constraints in a Jupyter notebook, and solving it using the Backtracking Search algorithm from AIMA. +[//]: # (Image References) -To launch the notebook, run the following command from a terminal with anaconda3 installed and on the application path: +[image1]: EightQueens.gif "8-queens puzzle solution" - jupyter notebook AIND-Constraint_Satisfaction.ipynb \ No newline at end of file +# Constraint Satisfaction in the N-Queens problem + +## Introduction +Constraint Satisfaction is a technique for solving problems by expressing limits on the values of each variable in the solution with mathematical constraints. For example, constraints in [the Sudoku project](https://github.com/ntrang086/sudoku_solver) are enforced implicitly by filtering the legal values for each box, and [the planning project](https://github.com/ntrang086/cargo_planning_search) represents constraints as arcs connecting nodes in the planning graph. In this project we will use [SymPy](http://www.sympy.org/en/index.html), a symbolic math library, to explicitly construct binary constraints and then use Backtracking to solve the N-queens problem (which is a generalization [8-queens problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle)). Using symbolic constraints makes it easier to visualize and reason about the constraints (especially for debugging), but comes with a performance penalty. See the `Sympy_Intro notebook` in the same directory for example code on sympy. + +![8-queens puzzle solution][image1] + +Briefly, the 8-queens problem asks us to place 8 queens on a standard 8x8 chessboard such that none of the queens are in "check" (i.e., no two queens occupy the same row, column, or diagonal). The N-queens problem generalizes the puzzle to to any size square board. + +This project consists of three main steps: + +* Step 1: Implement the `NQueensCSP` class to develop an efficient encoding of the N-queens problem and explicitly generate the constraints bounding the solution +* Step 2: Implement the search functions for recursive backtracking +* Step 3: Solve the N-queens problem + +## Code + +* `AIND-Constraint_Satisfaction.ipynb` - Code to solve the N-queens problem +* `util.py` - Helper code to create constraints and visualize solutions +* `Sympy_Intro.ipynb` - Example code of sympy to show how it works + +## Setup + +* Python 3 +* numpy +* sympy +* matplotlib + +## Run +To run any script file, use: + +`python ` + +To open a notebook, use: + +`jupyter notebook `