Giter Site home page Giter Site logo

constraint-satisfaction-problems's Introduction

Constraint-Satisfaction-Problems

In this session, you can find entirely implemented by me some contraint satisfaction problems (CSPs) using ic and branch-and-bound ECLiPSe libraries.

Getting Started

You can download all solutions to the problems just by typing:

git clone https://github.com/PanPapag/Constraint-Satisfaction-Problems.git

Prerequisites

ECLiPSe environment for constraint programming is mandatory in order to test the solutions to the problems above. You can simply download ECLiPSe here:

https://eclipseclp.org/download.html

Problems description

  • [Partition Problem] : One version of the problem of partitioning numbers is as follows. Given a positive integer ๐‘, divide the set ๐‘† = {1, 2, 3, ..., ๐‘} into two subsets ๐‘†1 and ๐‘†2 (๐‘†1 โˆฉ ๐‘†2 = โˆ…, ๐‘†1 โˆช ๐‘†2 = ๐‘†) such that S1 and S2 have the same number of elements (| ๐‘†1 | = | ๐‘†2 |), the sum of the elements of ๐‘†1 equals the sum of the elements of ๐‘†2 (ฮฃ๐‘– โˆˆ๐‘†1 ๐‘– = ฮฃ๐‘—โˆˆ๐‘†2 ๐‘—) and the sum of the squares of the elements of ๐‘†1 equals the sum of the squares of the elements of ๐‘†2 (ฮฃ๐‘– โˆˆ๐‘†1 ๐‘–2 = ฮฃ๐‘—โˆˆ๐‘†2 ๐‘—2).

  • [N Queens] : The N Queen is the problem of placing N chess queens on an Nร—N chessboard so that no two queens attack each other.

  • [MAXSAT] : In propositional logic, a formula is in conjugate normal form (CNF) when it is a coupling of couplings, where each disjunction, also called a clause, contains literals, that is, propositional symbols or denials propositional symbols. For example, the following formula is in CNF : (๐‘ฅ1 โˆจยฌ๐‘ฅ2 โˆจ๐‘ฅ4)โˆง(ยฌ๐‘ฅ1 โˆจ๐‘ฅ2)โˆง(ยฌ๐‘ฅ1 โˆจยฌ๐‘ฅ2 โˆจ๐‘ฅ3)โˆง(ยฌ๐‘ฅ2 โˆจยฌ๐‘ฅ4)โˆง(๐‘ฅ2 โˆจยฌ๐‘ฅ3)โˆง(๐‘ฅ1 โˆจ๐‘ฅ3)โˆง(ยฌ๐‘ฅ3 โˆจ๐‘ฅ4) The maximum satisfiability problem (MAXSAT) is to find appropriate assignments (true or false) in proposition symbols to maximize the number of true type sentences. In the above formula, consisting of seven sentences, there is no assignment of values to the propositional symbols to make all the sentences true, but it can be attributed to six of them (by assigning, for example, to all proposition symbols the value true).

  • [Scheduling] : Activity/2 events encode activities that should be staffed by individuals. Every activity activity (A, act (S, E)) means that activity A begins at the time S and ends at time E. Suppose that each activity has to be staffed by a single person and that each person can undertake as many activities required, provided that its total working time does not exceed a specified limit. There is also a limitation that not only can a person not take up two overlapping activities, but there must be at least one unit of time between two consecutive activities of each individual.Considering a set of events (activity/2) that encode activities, calling assignment_csp (NP, ST, ASP, ASA), where NP is the number of available individuals and ST is the maximum total time of activities a person can take, assign the given activities to the given individuals in a feasible way, returning to the ASP and ASA variables the representations of the assignment made.

  • [Seven-Eleven] : Someone goes to a haberdashery shop to buy four specific products. After asking for what he wants, his shopkeeper gives it to him, he makes the account with the help of a desktop calculator and says: "7,11 euros, please." The customer pays the sum and when the shopkeeper is at the exit he shouts: "Sorry, sir! Instead of adding, I did, by accident, multiply! Come back, please. " After doing the right thing now, he finds with surprise that the result is the same, 7.11 euros. What can be the cost of each product purchased by the customer?

constraint-satisfaction-problems's People

Contributors

panpapag avatar

Stargazers

Nick Galanis avatar Harry Maraziaris avatar

Watchers

James Cloos 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.