Docsity

Penny Pincher's Shopping Problem: Constraint Satisfaction and Combinatorial Optimization, Exams of Computer Numerical Control

Toggle sidebar
bg1
063200
, 2001/2002
Part B
Constraint Satisfaction and Combinatorial Optimisation (CSO)
Open Examination
Issued at:
Monday 11 March 2002
Submission due:
12:00 Wednesday 22 May 2002
Your attention is drawn to the Guidelines on Mutual Assistance and Collaboration in the
Student’s Handbook.
All queries on this assessment should be addressed to Alan Frisch.
Your examination number must be written on the front of your submission.
You must not identify yourself in any other way.
Instructions
•All questions should be attempted.
•Any programs that you construct should be fully documented. For each program a
couple of simple runs should be presented to illustrate how your program is used and
what output it produces.
•Where you are asked to give experimental evidence, you are not expected to conduct
rigorous controlled experiments; a few simple runs measuring cpu time or nodes visited
suffice. (Note: The Eclipse built-in predicate cputime/1 returns the elapsed cpu time,
in seconds, since the session began. It may be unreliable at measuring short runs, in
which case it is better to count nodes visited.)
•In the interest of fairness, any clarification or further information that is issued will
appear at
http://www.cs.york.ac.uk/∼frisch/CSO.
No such information will be issued between 15:15 on 15 March and 9:00 on 22 April.
It is therefore highly recommended that you carefully read the exam questions before
March 15.
1
pf3

Partial preview of the text

Download Penny Pincher's Shopping Problem: Constraint Satisfaction and Combinatorial Optimization and more Exams Computer Numerical Control in PDF only on Docsity!

Part B

Constraint Satisfaction and Combinatorial Optimisation (CSO) Open Examination Issued at: Monday 11 March 2002

Submission due: 12:00 Wednesday 22 May 2002

Your attention is drawn to the Guidelines on Mutual Assistance and Collaboration in the Student’s Handbook.

All queries on this assessment should be addressed to Alan Frisch.

Your examination number must be written on the front of your submission. You must not identify yourself in any other way.

Instructions

  • All questions should be attempted.
  • Any programs that you construct should be fully documented. For each program a couple of simple runs should be presented to illustrate how your program is used and what output it produces.
  • Where you are asked to give experimental evidence, you are not expected to conduct rigorous controlled experiments; a few simple runs measuring cpu time or nodes visited suffice. (Note: The Eclipse built-in predicate cputime/1 returns the elapsed cpu time, in seconds, since the session began. It may be unreliable at measuring short runs, in which case it is better to count nodes visited.)
  • In the interest of fairness, any clarification or further information that is issued will appear at http://www.cs.york.ac.uk/∼frisch/CSO. No such information will be issued between 15:15 on 15 March and 9:00 on 22 April. It is therefore highly recommended that you carefully read the exam questions before March 15.
  1. (3 marks) Consider an arbitrary instance of the constraint satisfaction problem and assume that every variable has a domain of exactly one element. Argue convincingly that the instance has a solution if and only it it is generalized-arc-consistent.
  2. Penny Pincher is an economics student with a tight budget and a small refrigerator. To save money she has already planned all her meals in advance and now would like you to write a program that can solve the difficult problem of planning all her shopping in advance. The various parts of this question involve writing an Eclipse program to solve this shopping plan problem. The programs should work by performing partial assignment search and should exploit the features of the fd library. (You are entitled to use other Eclipse libraries as well.) The input to the program should be passed as parameters to the main predicate. First let us consider a particular case of the problem. She needs three food products— A, B, and C—all of which require refrigeration. She is planning her shopping for 4 weeks and has no food at the start of this period. Each food product is available in packages of different sizes, always a whole number of units. For each week she knows how many units of product are needed; this is always a whole number of units, possibly zero. She also knows the capacity of her refrigerator in terms of number of units, which is also a whole number. She goes shopping each week and puts all the food products she buys into her refriger- ator, which already holds unused food products from the previous week. At this point the refrigerator must hold enough of each food product to meet her planned usage for the forthcoming week. All food products that are unused at the end of the week remain in the refrigerator; Penny discards nothing. Obviously the total amount of food in the refrigerator cannot exceed the capacity of the refrigerator. The food packages are elastic; the amount of space they consume is equal to the amount of food product. Thus, when half a package is used up it consumes half the space. The input to your program will contain: - The capacity of the refrigerator. - The amount of each product that is needed each week. - For each product a list of the sizes in which it is available.

We shall assume that for each product the list of sizes is consistent in that if the product is available in n units then it is available in all multiples of n since one could purchase multiple packages of size n. Any package sizes that exceed the refrigerator capacity are not listed.

(a) (10 marks) Write an Eclipse program that tells Penny how much of each product to buy each week for this special case. If there are no solutions to the problem, your program should fail. If there is a solution then it ought to be returned to the user through variable bindings. Indeed, through the “More?” facility of Eclipse your program ought to be capable of returning all solutions. The aim of this question is to write a very simple program that is correct, but without considering efficiency. Give a couple of examples of your program running, one showing that it recognises a non-trivial failure and one showing it returning multiple solutions.