====== Lab 3 - Constraint Satisfaction Problems ====== **Note:** For this lab, you can work together in teams of up to 4 students. However, this is not a necessity. The assignment is small enough to do it alone in which case you may get more experience. You can use [[https://piazza.com/ru.is/spring2016/t622arti|Piazza]] to find team members and discuss problems. You will need a Java Development Kit (JDK) and a Java IDE (any text editor should do as well). ===== Problem Description ===== The following logic puzzle is known as Zebra Puzzle or Einstein Puzzle (source: [[http://en.wikipedia.org/wiki/Zebra_Puzzle|Wikipedia]]). It was first published in the Life International magazine in 1962. Also, exercise 6.6 in the book is a slight variation of that puzzle. In five houses, each with a different color, live five persons of different nationality, each of whom prefers a different brand of cigarettes, a different drink, and a different pet. The five houses are arranged in a row (no house has more than 2 neighbors, two houses have just 1 neighbor). - There are five houses. - The Englishman lives in the red house. - The Spaniard owns the dog. - Coffee is drunk in the green house. - The Ukrainian drinks tea. - The green house is immediately to the right of the ivory house. - The Old Gold smoker owns snails. - Kools are smoked in the yellow house. - Milk is drunk in the middle house. - The Norwegian lives in the first house. - The man who smokes Chesterfields lives in the house next to the man with the fox. - Kools are smoked in the house next to the house where the horse is kept. - The Lucky Strike smoker drinks orange juice. - The Japanese smokes Parliaments. - The Norwegian lives next to the blue house. Now, who drinks water? Who owns the zebra? ===== Tasks ===== - Model the problem as a CSP, that is define variables, their domains and constraints between them. There are different ways of modelling this. Typically you want to have fewer variables and smaller domains (to reduce the size of the state space) and fewer or simpler constraints (to speed up constraint propagation). What are your variables and their domains? - How big is the state space? Shortly, explain your answer. - Download the material below, implement your model (implement all things marked with TODO). - Run the program and compare the results. What does that tell you about the usefulness of different propagation algorithms and heuristics for this problem? ===== Material ===== The Java project for the lab can be found on Skel. See, instructions below on how to get it. The project contains a Main class which sets up and solves the CSP, as well as some additional classes implementing the constraints. You need to implement a few parts in Main.java and a method in DifferByOneConstraint.java (if you need that constraint). To run the code simply run the Main class or use "ant run" on the terminal. ===== Handing In ===== Connect to skel.ru.is using your favorite ssh client and unpack the assignment into your home directory by running the following commands: [student14@skel ~]$ tar xvf /labs/arti16/lab3/lab3.tar [student14@skel ~]$ cd arti16/lab3 [student14@skel hw1]$ ls answers build.xml dist Makefile questions src You can copy the code to your own machine for development by using any SCP or SFTP client (e.g., WinSCP). However, you need to copy it back to skel before handing in. To answer the questions run ''make answers'' while being in the directory containing ''Makefile''. Single answers will be put into files called ''answers/answerX.Y.txt'', which you can also edit. Finally, to hand in your answers run ''make handin'' while being in the directory containing ''Makefile''. This should produce a file ''/labs/art16/.handin/lab3/student14/handin.tar.gz''. You can check if it exists using the ls command or by running ''rutool check -c arti16 -p lab3''.