Essence' Examples |
||||||||||||||||||
OverviewThis is a collection of Essence' examples, including problem descriptions. Every problem is labelled according to its level of difficulty: (B) for beginners, (A) for advanced and (E) for expert level.Many thanks to all the modellers who have supplied problem models!
1. Balanced Incomplete Block Design (BIBD)(advanced)The BIBD problem is to assign v objects to b blocks such that such that each block contains k different objects, each object occurrs in exactly r different blocks and every 2 distinct objects occurr in exactly l blocks. We represent the problem by a vxb matrix of booleans, where matrix[i,j] equals 1(true) iff object i has been assign to block j. Below is the solution for the sample instance with v,b,k,r,l = 7,7,3,3,1.
0, 0, 0, 0, 1, 1, 1
0, 0, 1, 1, 0, 0, 1
0, 1, 0, 1, 0, 1, 0
0, 1, 1, 0, 1, 0, 0
1, 0, 0, 1, 1, 0, 0
1, 0, 1, 0, 0, 1, 0
1, 1, 0, 0, 0, 0, 1
Here is the BIBD problem model together with some parameter instances: param1, param2, param3. 2. Black Hole Patience(expert)
Black Hole Solitaire is a (one-player) card game with the objective to place cards onto "the black hole", a centre stack. Starting from 17 stacks of 3 cards and the spades ace in the middle (the black hole), cards are put on top of the black hole. It will accept a card if its rank is one greater or one less than the rank of the card currently on top of it. The game is won when all cards from the stacks are placed onto the middle stack (the black hole). The image above is taken from Lena Games and illustrates a sample initial configuration of Black Hole. Here is a Black Hole Problem Model (based on this brilliant paper) and some parameter files: param1 and param2. 3. Diet Problem(beginner)The diet problem is a standard Operation Research example that is concerned with computing a particular diet (with respect to fat, sugar, calorie intake) with minimal cost (price). Here is an Essence' problem model and here is a parameter specification for computing a diet from a selection of four items (chocolate cake, chocolate icecream, coke and pineapple cheesecake). 4. Discrete Tomography(beginner)This is a little "tomography" problem, taken from an old issue of Scientific American: a matrix which contains zeroes and ones gets "x-rayed" vertically and horizontally, giving the total number of ones in each row and column. The problem is to reconstruct the contents of the matrix from this information. Sample run from Eclipse (http://eclipse.crosscoreop.com/examples/tomo.ecl.txt):
?- go.
0 0 7 1 6 3 4 5 2 7 0 0
0
0
8 * * * * * * * *
2 * *
6 * * * * * *
4 * * * *
5 * * * * *
3 * * *
7 * * * * * * *
0
0
Eclipse solution by Joachim Schimpf, IC-Parc
Here is a problem model and here are some parameters:
discrete_tomography1.param,
discrete_tomography2.param,
discrete_tomography3.param and
discrete_tomography4.param.
5. Equidistant Frequency Permutation Arrays (EFPAs)(expert)
This example has been kindly provided by Ian Gent, Paul McKay, Ian Miguel, Peter Nightingale and Sophie Huczynska
and stems from their joint paper
Modelling Equidistant Frequency Permutation Arrays in Constraints.
6. Farm Puzzle(beginner)This is a very simple puzzle: A farmer has 7 animals on his farm: pigs and hens. They all together have 22 legs. How many pigs and how many hens does the farmer have? Here are two different models of the farmpuzzle: Farm Puzzle model 1 and Farm Puzzle model 2. 7. Futoshiki(advanced)
8. Golomb Ruler(beginner)
9. Grocery Puzzle(beginner)A child goes to a shop and buys 4 items. When the cashier charges 7.11 Euro he notices that he accidently multiplied the prices of the items. So he adds up the prices and suprisingly he gets the same amount, 7.11 Euro. How much did each item cost? Here is an Essence' Grocery problem model. 10. Killer Sudoku(advanced)
11. Knapsack Problem(advanced)The knapsack problem is a combinatorial optimisation problem: given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than a given limit and the total value is as large as possible. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most useful items. (quoted from Wikipedia's entry on the knapsack problem). Here is the problem model knapsack.eprime and a parameter file knapsack.param.12. Langford's Number Problem(advanced)We have a model of the Langford Number problem: arrange n sets of positive integers 1..k to a sequence, such that, following the first occurence of an integer i, each subsequent occurrence of i, appears i+1 indices later than the last. For example, for n=2, k=4, a solution would be 41312432. We model this problem using a 1-dimensional array 'position' with length 2*k
where the first k entries of the array hold the position of the i-th
number, i.e. position[2] holds the position of the first
occurrence of '2' in the sequence. In the sample solution for k=4,
position[2] would hold the value '5', because '2' occurs
first as 5th number in the sequence. sequence : 4 1 3 1 2 4 3 2 position [2,5,3,1,4,8,7,6] of numbers 1 2 3 4 1 2 3 4 Here is the simple Langford-2 problem model (for n=2) and general Langford-n problem model. 13. Magic Squares(beginner)
14. Map Colouring Problem(beginners)Colour every contry on a map in such a way that no two adajacent countries have the same colour.
15. N-Queens Problem(beginner)Place n queens on an nxn chessboard without attacking each other. A sample solution for n=8 is given in the picture.
16. Peaceful Army of Queens Problem(advanced)
17. Peg Solitaire(expert)
18. Quasigroup Existence Problems(advanced)A quasigroup is an mxm multiplication table of integers 1..m, where each element occurrs exactly once in each row and column and certain multiplication axioms hold. Depending on the multiplication axiom, the quaisgroup is enumerated (i.e. quasigroup3 denotes that mutliplication axiom 3 holds). We have models for several versions of the quasigroup existence problems:
19. Send More Money(beginner)The Send More Money problem is concerned with finding a solution to the following sum where every letter stands for a distinct number between 0 and 9: S E N D + M O R E ---------- M O N E YHere is the Send-More-Money problem model. 20. Sokoban(advanced)
21. SONET Problem(advanced)The SONET problem is a network design problem: set up a network between n nodes, where only certain nodes require a connection. Nodes are connected by putting them on a ring, where all nodes on a ring can communicate. Putting a node on a ring requires a so-called ADM, and each ring has a capacity of nodes, i.e. ADMs. There is a certain amount of rings, r, that is available. The objective is to set up a network by using a minimal amount of ADMs. The problem model has the amount of rings ('r'), amount of nodes('n'), the 'demand' (which nodes require communication) and node-capacity of each ring ('capacity_nodes') as parameters. The assignement of nodes to rings is modelled by a 2-dimensional matrix 'rings', indexed by the amnount of rings and nodes. The matrix-domain is boolean: If the node in column j is assigned to the ring in row i, then rings[i,j] = 1 and 0 otherwise. So all the '1's in the matrix 'rings' stand for an ADM. Hence the objective is to minimise the sum over all columns and rows of matrix 'rings'. Here is the SONET problem model and a parameter file.22. Sportsscheduling Problem(advanced)The sports scheduling problem is to schedule a sport competition with a certain amount of teams, weeks and periods such that teams play only once a week, every team plays at most twice a period and no game is repeated. This model is interesting for those who want to see how to use table constraints. Here is the Sports Scheduling problem model and a parameter file. 23. Sudoku(beginners)
|