# Optimum shower occupied retry delay

I cycle to work in an office with a single shower. When the shower is occupied I set my stopwatch for 10 minutes. When the stopwatch expires I trek back to the shower and try again. Sometimes it is occupied again.

What is the optimum time to set my stopwatch to minimise the number of return trips?

I chose 10 minutes because I guessed that that's probably how long a reasonably quick shower takes. But thinking about it perhaps a shorter delay might avoid me being beaten once the shower becomes free, whilst a longer delay would increase the likelihood that the initial occupier has left.

I realize there are loads of variables here that you might need to know so here's some details to get started with:

• All shower users use the same system when they arrive at work
• Shower users arrive at work at different times, but let's say between 9-10
• All shower users want to be out of their Lycra by the end of the morning (12) and to avoid interference with the lunchtime shower users. Their co-workers want them out of their Lycra ASAP. I'm not sure how to balance this requirement with the requirement to minimize the number of trips to the shower. Suggestions?
• Shower users take between 8 and 16 minutes to shower
• There are between 4 and 10 shower users on a given day.
• I realize there are better ways to organize the shower queue!
• All shower user use the same retry delay
• Just curious, is this an exercise or a real-life problem you're trying to model? – Math1000 Feb 27 '15 at 14:14
• What is the distribution of the shower times, the interarrival times, and the number of arrivals? – Math1000 Feb 27 '15 at 14:16

I tried a numerical modelization of your problem (Scilab code below) and used a Monte-Carlo method to compute the minimum.

At first, I found a decreasing function of the retry, which is compatible with the intuition that, the more you wait for the least you risk interacting

Average total number of attempts to go to the shower as a function of the retry delay.

But then how can we respect the constraint: everyone is clean for lunch? Again we may graph the probability that the last one's shower is after 12: Probability of having someone shower after 12, as a function of the retry delay.

We see that waiting for more than 16 min is a bad idea and that your 10 min delay isn't that bad... but we can test if it's a good idea to have a fixed idea of when you go to the shower. Let's randomize it too: Average total number of attempts to go to the shower as a function of the retry delay.

Not so different from the first one is it? So you could have felt free to go shower whenever you wanted ;-)

function N=showerRetry(T)
Nbshower=grand(1,1,"uin",4,10);
Arrival=grand(1,Nbshower,"unf",0,60);
Showerduration=grand(1,Nbshower,"unf",8,16);//independant of the time you had to wait.
Nbtry=0;
Ttotry=gsort(Arrival,'g','i');
tfree=0;
nbclean=0;
while max(Ttotry)>0 do
if tfree<Ttotry(nbclean+1) do //youpi je me lave
nbclean=nbclean+1;
tfree=Ttotry(nbclean)+Showerduration(nbclean);
Ttotry(nbclean)=0;
else//oh non j'attends
Ttotry(nbclean+1)=Ttotry(nbclean+1)+T*grand(1,1,"unf",0.5,1.5)
Ttotry=gsort(Ttotry,'g','i');
Nbtry=Nbtry+1;
end
end
//Nbtry=0//to get only the penalty
if tfree>60*3 then// si la dernière douche se termine après midi
Nbtry=Nbtry+100 //forte pénalité
end
N=Nbtry//+exp(tfree-150)// smother penalization
endfunction

function M=Montecarlo(N,P)
n=size(P,'*')//le nombre de périodes à tester
Nb=zeros(1,n)
for i=1:n
for j=1:N
Nb(i)=Nb(i)+showerRetry(P(i));
end
Nb(i)=Nb(i)/N
end
M=Nb
endfunction

P=[6,7,8,9,10,11,12,13,14,15,16,17,18,20,25,30];
T= Montecarlo(10000,P)
plot(P,T)