In this session, you can find entirely implemented by me some contraint satisfaction problems (CSPs) using ic and branch-and-bound ECLiPSe libraries.
You can download all solutions to the problems just by typing:
git clone https://github.com/PanPapag/Constraint-Satisfaction-Problems.git
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
-
[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?