Working Example

Note: This example is just for demonstration purposes. This app comes pre-loaded with some example data which you can delete and then add your own friends and gifts.

Meet Hercules!

Hercules has 7 friends for which he would like to buy presents:

 

First he begins by scouring the Internet in order to find presents for them. He creates his gift basket and fills it with the following twelve gifts:

Gift # Picture Gift Name Price Gift # Picture Gift Name Price Gift # Picture Gift Name Price
1 Apple Bunch 9.99 5 Pear 4.99 9 Redcurrant 4.50
2 Apple Duet 2.99 6 Pink Flower 19.99 10 Water Lily 39.99
3 Cherry 14.99 7 Plum 6.50 11 White Daffodil 28.95
4 Hay 24.99 8 Pumpkin 1.50 12 Yellow Daffodil 30.50

He then assigns preferences to each of his friends and preferences for each gift:

Friend # Image Friend Overall Preference Gift Preference
Apple Bunch Apple Duet Cherry Hay Pear Pink Flower Plum Pump-
kin
Red-
currant
Water Lily White Daffodil Yellow Daffodil
1 Racoon Boy 90 100 65 5 0 0 0 0 0 0 0 0 0
2 Moo Coo 35 0 0 0 100 0 0 0 0 0 0 0 0
3 Happy Hen 65 0 0 0 0 75 0 50 20 95 0 0 0
4 Piggy Pal 70 25 25 90 0 25 0 25 25 25 0 0 0
5 Dino Rex 30 0 0 75 0 0 50 0 0 0 40 45 40
6 Big Ted 60 0 0 0 0 0 0 0 0 0 100 60 80
7 Little Ted 80 0 0 0 0 0 40 0 0 0 75 65 100

Now he is able to begin his optimization. He starts by setting a maximum budget of 99,999.99:

Budget Apple Bunch Apple Duet Cherry Hay Pear Pink Flower Plum Pumpkin Redcurrant Water Lily White Daffodil Yellow Daffodil Amount Spent
 
Price 9.99 2.99 14.99 24.99 4.99 19.99 6.50 1.50 4.50 39.99 28.95 30.50
Target
99,999.99
144.95
For an unlimited budget, everyone gets their favourite item. Except for Dino Rex who wanted Cherry. Unfortunately these have already been allocated to Piggy Pal who has a higher Overall Preference. Hence Dino Rex is allocated the Pink Flower which is his second favourite item.
144 131.46
As the budget is reduced, those with a lower Overall Preference are examined first and allocated their next favourite preference. However, as in this case, White Daffodil is Dino Rex next favourite item but this would break the budget constraint. Hence the allocation of Plum is the next cheaper and available item.
131 126.46
126 106.46
106 104.46
104 99.46
99 86.46
86 84.46
84 82.91
82 79.46
79 72.97
72 69.46
69 67.91
67 65.97
65 58.95
58 55.46
55 45.46