User Tools

Site Tools


public:t-622-arti-16-1:lab_3_-_csps

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 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: 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).

  1. There are five houses.
  2. The Englishman lives in the red house.
  3. The Spaniard owns the dog.
  4. Coffee is drunk in the green house.
  5. The Ukrainian drinks tea.
  6. The green house is immediately to the right of the ivory house.
  7. The Old Gold smoker owns snails.
  8. Kools are smoked in the yellow house.
  9. Milk is drunk in the middle house.
  10. The Norwegian lives in the first house.
  11. The man who smokes Chesterfields lives in the house next to the man with the fox.
  12. Kools are smoked in the house next to the house where the horse is kept.
  13. The Lucky Strike smoker drinks orange juice.
  14. The Japanese smokes Parliaments.
  15. The Norwegian lives next to the blue house.

Now, who drinks water? Who owns the zebra?

Tasks

  1. 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?
  2. How big is the state space? Shortly, explain your answer.
  3. Download the material below, implement your model (implement all things marked with TODO).
  4. 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.

/var/www/cadia.ru.is/wiki/data/pages/public/t-622-arti-16-1/lab_3_-_csps.txt · Last modified: 2024/04/29 13:33 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki