Friday, July 4, 2008

MouseHunt Math Quiz #2: Hunting Strategy

* MICE

there are unlimited numbers of mice but there are only two breeds of mice, white and brown.

a white mouse will give you 50 points and 75 gold.
a brown mouse will give you 150 points and 25 gold.

75% of mouse population are white.

on average, one mouse, randomly, visits your camp every hour. but only cheese can attracts the mouse to your trap. you can

place only one cheese at a time on your trap. unfortunately, there are only two kinds of cheese.

* CHEESE

a cheddar costs 5 gold.
a brie costs 50 gold.

cheddar has a 50% probability of attracting a white mouse (to the trap) and 25% probability of attracting a brown mouse.
brie has a 25% probability of attracting a white mouse and 75% probability of attracting a brown mouse.

* TRAP

there are also only two kinds of traps. you already have both traps in possession. after you cheese successfully attracts a mouse, it is now the job of your trap to catch it.

glue has a 50% probability of catching a white mouse and 25% probability of catching a brown mouse.
deathbot has a 25% probability of catching a white mouse and 75% probability of catching a brown mouse.

* LOCATION

there are also only two locations.

in the town, if you successfully attract a mouse but fail to catch it, you lose just the bait (just one piece of cheese).

in the lab, there is 220% gold bonus (for example, 240 gold for white mouse) but if you fail to catch it. the mouse will steal something in addition to the bait:
a white mouse -> 20% steals 500 gold, 80% steals 5 points.
a brown mouse -> 80% steals 250 gold, 20% steals nothing else than the bait.

traveling is free.

you start with a large number of gold.

* QUESTION

as a hunter, what is your hunting strategy if you want to maximize points but do not want to lose gold in the long run?

* UPDATE (Clarification)
  1. no mixing two cheeses together to create a new kind of cheese
  2. no mixing two traps together to create a new kind of trap
  3. you can assume no staleness should cheese fails to attract a mouse.
  4. if the bait successfully attracts a mouse, the bait (cheese) will be gone, no matter you can catch it or not.
  5. you can use only one trap and one cheese at a time.


* SOLUTION

step 1: establish understanding

note that there are three possible outcomes:
1) fail- fail to attract a mouse
2) catch- successfully catch a mouse
3) steal- a mouse steals your cheese (and probably something else)

step 2: calculate hunting results probabilities

(lab/cheddar/deathbot example)

brown mouse calculation:

a cheddar has 25% attraction rate to brown mice, and deathbot has 75% success rate to catch a brown mouse.

fail% = 100% - attraction rate = 75%
catch% = successful attraction and successful catch = 25% * 75% = 18.75%
steal% = successful attraction but unsuccessful catch = 25% * (100% - 75%) = 6.25%

similarly, white mouse calculation:

fail% = 50%
catch% = 12.5%
steal% = 37.5%

overall mouse hunting results probabilities:

note that brown mice account for 25% and white mice account for 75%.

brown mouse fail% = 25% * 75% = 18.75%
brown mouse catch% = 25% * 18.75% = 4.6875%
brown mouse steal% = 25% * 6.25% = 1.5625%
white mouse fail% = 75% * 50% = 37.5%
white mouse catch% = 75% * 12.5% = 9.375%
white mouse steal% = 75% * 37.5% = 28.125%

what does this mean? this means that every 100 hours, you can expect 18.75 times, on average, that you fail to catch a brown mouse.

step 3: calculate hourly-average stats (or per-mouse stats)

(lab/cheddar/deathbot example)

net points and profit (gold) are two important derived variables.

revenue is generated only when you successfully catch a mouse (220% bonus at lab)
cheese cost incurs only when a mouse is successfully caught or it steals your cheese
steal cost incurs only when a mouse steals your gold

revenue = brown catches + white catches = (25*320%*4.6875%) + (75*320%*9.375%) = 26.25 gold
cheese cost = brown catches + brown steals + white catches + white steals = 5 * (4.6875%+1.5625%+9.375%+28.125%) = 2.1875 gold

steal cost = brown steals + white steals = (250*80%*1.5625%) + (500*20%*28.125%) = 31.25 gold

profit = revenue - cheese cost - steal cost = -7.1875 gold (loss)

points earned = brown catches + white catches = (150*4.6875%) + (50*9.375%) = 11.71875 points

points stolen = white steals = 5*80%*28.125% = 1.125 points

net points = points earned - points stolen = 10.59375 points


step 4: Set up optimization model

Please note that you are free to change trap/cheese/location at any time.
So you should set time-allocation strategy wisely.

locationcheesetrap
profit net point time allocation
town cheddar glue 12.265625 11.71875 x1
town cheddar deathbot 6.015625 11.71875 x2
town brie glue -10.546875 11.71875 x3
town brie deathbot -11.71875 23.4375 x4
lab cheddar glue 15.9375 10.96875 x5
lab cheddar deathbot -7.1875 10.59375 x6
lab brie glue -30 11.34375 x7
lab brie deathbot -19.6875 22.875 x8


Objective: maximize points; 11.71875x1 + 11.71875x2 + … + 22.875x8

Constraints:
  • sum of time allocation is 100%; x1+x2+…+x8 = 1
  • time allocation is between 0 and 100%; 0 <= x1, x2, …, x8 <=1
  • profit is non negative; 12.265625x1 + 6.015625x2 - … - 19.6875x8 >= 0

This is a linear programming model. You can run it on Excel (Solver add-in) or use matrix algebra like the Simplex method. If you'd like, you can exclude x2 from the model because x1 is always a better choice (and so on).

The model result: x4 = 57.6271%, x5 = 42.3729%, other x's = 0%.

step 5: ANSWER

you should spend about 57.63% of the time in the town using brie/deathbot to earn points and about 42.37% of the time in lab using cheddar/glue to recover gold. The hourly- average points (or points per mouse) = 18.1541 points. The hourly-average profit = 0.00 gold.

This solution is better than town/cheddar/glue alone in terms of net points earned.

No comments: