Code Monkey home page Code Monkey logo

constraint-satisfaction-problem's Introduction

# Constraint-satisfaction-problem
Suppose you have a wedding to plan, and want to arrange the wedding seating for a certain
number of guests in a hall. The hall has a certain number of tables for seating. Some pairs of
guests are couples or close Friends (F) and want to sit together at the same table. Some other
pairs of guests are Enemies(E) and must be separated into different tables. The rest of the pairs
are Indifferent (I) to each other and do not mind sitting together or not. However, each pair of
guests can have only one relationship, (F), (E) or (I). This program finds a seating arrangement that
satisfies all the above constraints.

This programming assignment, generates CNF sentences for an input instance of wedding seating arrangements. 

The inputs include the number of guests <M>, the number of tables <N>, and a sparse representation of the
relationship matrix R with elements Rij = 1, -1 or 0 to represent whether guests i and j are
Friends (F), Enemies (E) or Indifferent (I). 

The code implements a SAT solver to find a satisfying assignment for any given CNF sentences. 

This code implements two methods to find the satisfiability and truth assignments:

I) Satisfiability is check by the PL-Resolution algorithm.
If satisfiable, then the assignment of the truth values is determined by the WalkSAT algorithm.

II) The code also implements DPLL algorithm which checks the satisfiability and generates the truth assignments.

Sample Input
4 2
1 2 F
2 3 E
The first line contains two integers denoting the number of guests <M> and the number of
tables <N> respectively. Each line following contains two integers representing the indices of a
pair of guests and one character indicating whether they are Friends(F) or Enemies(E). The rest
of the pairs are indifferent by default. For example, in the above sample input, there are 4
guests and 2 tables in total, and guest 1 and guest 2 are Friends, and guest 2 and guest 3 are
Enemies.
Sample Output
yes
1 2
2 2
3 1
4 1

constraint-satisfaction-problem's People

Contributors

elmaestro08 avatar

Watchers

 avatar  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.