Git Product home page Git Product logo

ben-xj / constraint-satisfaction-notebook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tonirv/constraint-satisfaction-notebook

0.0 0.0 0.0 5.39 MB

Example lecture for Constraint Satisfaction Problems in an interactive jupyter notebook. With python code to solve CSPs, with visualization of Sudoku and NQueens problems.

License: MIT License

Python 20.82% Jupyter Notebook 79.18%

constraint-satisfaction-notebook's Introduction

Constraint-Satisfaction-Notebook

Example lecture for Constraint Satisfaction Problems (CSP) in an interactive jupyter notebook. We present multiple algorithms to solve CSPs and we explain the inner workings of these algorithms. For example, we show how to solve NQueens problem using backtracking with forward checking or with Maintaining-Arc-Consistency algorithm.

example_output

Example of visualization tool in jupyter notebook to explain backtracking with forward checking:

example_output

We also present how to solve Sudoku problems, both using constraint propagation algorithms (AC1 & AC3), as well as backtracking with Minimum-Remaining-Value heuristic and Maintaining-Arc-Consistency algorithm:

example_output_sudoku example_output_sudoku

CONTENTS

  1. Introduction to Constraint Propagation Problems (L13 & L14):

    1. Definition
    2. Examples
  2. Solving CSPs (L14 & L15) :

    1. Constraint Propagation in CSPs:

      1. AC-1:
      2. AC-3:
    2. Search in CSPs:

      1. Generic Search:
      2. Backtracking Search (BT):
      3. Backtracking Search with Forward Checking (BT-FC):
      4. Backtracking while Maintaining Arc Consistency (BT-MAC):
      5. Backtracking with Dynamic Variable Ordering:
    3. Elimination for Constraints in CSPs:

      1. Variable Elimination for Constraints:
        • Definition: join and project
        • Example
      2. Bucket elimination (Adaptive Consistency):
        • Definition
        • Example
  3. Appendix:

    1. Constraint Optimization Problem:
      1. Branch-and-Bound
      2. Example: using Map Coloring problem with cost added to the colors to use.
    2. Incremental Repair / Iterative Repair / Min-Conflict Heuristic
      • Definition
      • Example

Installation

Heavily recommended to use a virtual environment to use this setup. You can do that by for example using virtualenv and virtualenvwrapper.

Install pip:

If in Mac, do (assuming you installed brew, which you should...):

brew install pip

If in Linux:

sudo apt-get install pip

Install virtualenv:

pip install virtualenv

Install virtualenvwrapper:

pip install virtualenvwrapper

Now, let's clone this repo and install the necessary requirements.

git clone [email protected]:ToniRV/Constraint-Satisfaction-Notebook.git csp_notebook

Or if you don't want to use SSH or you don't have it setup:

git clone https://github.com/ToniRV/Constraint-Satisfaction-Notebook.git csp_notebook

Let us build the virtual environment for python, we will need to have python3 installed (which I assume you have in /usr/local/bin/python3 but it could be somewhere else! Make sure you specify the correct path in the following command:

cd csp_notebook
mkvirtualenv csp_notebook --python=/usr/local/bin/python3 -r requirements.txt

Finally, activate your virtual environment:

workon csp_notebook

You are ready to go!

jupyter notebook CSPs.ipynb

Enjoy!

constraint-satisfaction-notebook's People

Contributors

tonirv avatar sharanraja avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.