https://github.com/ltfschoen/aind-constraint_satisfaction
Term 1 Lab 9 (Optional) by Luke Schoen for Udacity Artificial Intelligence Nanodegree (AIND)
https://github.com/ltfschoen/aind-constraint_satisfaction
algorithms artificial-intelligence constraint-satisfaction-problem jupyter-notebook n-queens python36 sympy
Last synced: 20 days ago
JSON representation
Term 1 Lab 9 (Optional) by Luke Schoen for Udacity Artificial Intelligence Nanodegree (AIND)
- Host: GitHub
- URL: https://github.com/ltfschoen/aind-constraint_satisfaction
- Owner: ltfschoen
- License: other
- Created: 2017-04-21T04:32:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-21T04:33:10.000Z (almost 8 years ago)
- Last Synced: 2024-12-07T04:05:28.478Z (3 months ago)
- Topics: algorithms, artificial-intelligence, constraint-satisfaction-problem, jupyter-notebook, n-queens, python36, sympy
- Language: Jupyter Notebook
- Size: 188 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## About
* Exercise implementing Constraint Satisfaction Problems (CSP) by implementing the N-Queens problem using symbolic constraints in a Jupyter notebook, and solving it using the Backtracking Search algorithm from AIMA.
To launch the notebook, run the following command from a terminal with anaconda3 installed and on the application path:
* Guide on Jupiter Notebook https://www.datacamp.com/community/tutorials/tutorial-jupyter-notebook#gs.WPbJuKE
## Setup
* Install Jupyter Notebook App with Miniconda http://jupyter.readthedocs.io/en/latest/install.html
```
pip3 install --upgrade pip setuptools
pip3 install jupyter
pip3 install matplotlib util sympy
```* Launch Jupyter Notebook App `jupyter notebook AIND-Constraint_Satisfaction.ipynb`
* Run code:
* Click any section containing a code snippet and go to menu: Cells > Run All,
then view the outputs shown below the code snippets## Solution - Sympy
* http://localhost:8888/notebooks/Sympy_Intro.ipynb
# Warmup: Add to top of code snippet
`pip3 install sympy`
# SymPy Exercises
* Question 1
* Solution
```
A = symbols("A:A0, A:A1, A:A2")
```* Question 2
* Solution
```
from operator import xor
x, y = symbols("x y")
xor_relation = xor(x, y)
# alternative:
# xor_relation = x ^ y
E = xor_relation
```* Question 3
* Solution
```
a, b, c = symbols(['a', 'b', 'c'])
maxAbsDiff = constraint("MaxAbsDiff", abs(a - b) < c)A = symbols("A:A0, A:A1, A:A2")
maxAbsDiff_copy = maxAbsDiff.subs({a: A[0], b: A[1], c: A[2]})
```* Question 4
* Attempt (WRONG)
https://discussions.udacity.com/t/sympy-intro-lab-question-4-help/229192/8## Solution
* diffDiag
* Discussion https://discussions.udacity.com/t/diffdiag-using-symbol/229264/8