# monte carlo simulation

• Mar 5th 2011, 03:32 PM
mathsohard
monte carlo simulation
Hello, I am currently doing my project and I need some help.
I am trying to schedule tutors for a study room where students come in and out for helps. My goal is to schedule the tutors to maximally accomodate to the flow of students that need help with math so that each tutor is given an appropriate(also consecutive) hours of schedule. I am using monte carlo simulation for this, however I have difficulties setting up constraints and variables. First I made some R codes concerning this to first get appropriate number of tutors for each hours (as the place opens from 8 am to 7 pm). I researched how many people are coming in and out for a week and I am just going to use those numbers for my probability for each hours.

a <- 1/5; #probability for each hour

tutors <- 2; #at least two tutors for each hour

cat("week", "weekday", "stock", "customers", " sold", " lost","\n");

total_stud <- 0; # coming in and out
total_sold <- 0; # number of questions answered for students
total_lost <- 0; # number of questions could not be answered due to overflow

for (week in 1:3) {
for (weekday in 1:5) {
for (eachhours in 1:11) {

sold <- 0;
lost <- 0;
random_num <- runif(1);
if (random_num < a)
students <- 1
else
students <- 0;
#if (eachhours == 1) {
if (students == 1) {
if (tutors > 0) {
sold <- sold+1;
tutors <- tutors-1;
}else{
lost = lost+1;
}
}
}

total_stud <- total_stud + students;
total_sold <- total_sold + sold;
total_lost <- total_lost + lost;

cat(week,"\t", weekday,"\t", stock,"\t", students,"\t", sold,"\t", lost,"\n"); # display results for
} # end loop on each hours
} # endloop on weekday
} # loop on week

# output total statistics now....
cat("\n totals over entire simulation:\n\n")
cat(" customers sold lost\n")
cat("\t",total_cust,"\t",total_sold,"\t", total_lost,"\n")

I got this so far, however how can I change the probability for each hours and improve this???

I don't think the code runs so far, and I am not sure if i am doing this right.

I really want to use monte carlo simulation however if you have better idea or please help me go forward. Completely stuck and have no idea
• Mar 15th 2011, 06:36 AM
BoboStrategy
Re: scheduling simulation
I understand you're trying to build a simple Monte Carlo simulation model that will help you develop insight into scheduling decisions for your tutors.

I've done this type of thing in a wide range of contexts (including a manufacturing company, restaurants, coffee shops, politicians, etc.) PM me, and let's schedule a chat on the phone.

I might be able to help you make the details work, in a way that is useful.

Chris