Simulation and Modelling-park planner

8 visualizzazioni (ultimi 30 giorni)
saurav prakash
saurav prakash il 2 Mar 2015
Hello, I am coding a park planner simulation where there are m rides and n people. The rides wait times varies with day time following a Gaussian curve function (random mean and std). As soon as a rider enters he has to be redirected to the ride with minimum weight time, and that's how we build up a schedule. I have done the coding but my code is always getting stuck in ind2sub and taking way long for any number of Monte Carlo simulation. Please help me out. Here is my code:
function [probab,count]= park(mc,n,m,wait)
%mc is the MonteCarlo Runs %n is the number of people %m is the number of rides %wait is the factor for wait time e.g. 10/30/40/20
% e.g [probab,count]=park(500,20,10,30) % mc=1; % n=1; % m=1; % wait=20;
count=0; probab=zeros([1,mc]); k=(1:5:720); flag=zeros([n,m]);
for q=1:mc
entrytime=zeros([1,n]); count=0; X=zeros([m,144]);
for i = 1:m mu=randi([250 450],1,1); sigma=randi([50 150],1,1); X(i,:) = (gaussmf(k,[sigma mu]).*wait);
end
for j=1:n entrytime(1,j) = randi([1 720],1,1); end
ws=1;
*for e=1:n actualwaittime = entrytime(e);
while(actualwaittime<720)
[we,ind]=min(X(:,min(find(k>=actualwaittime))));
[I,J] = ind2sub([size(X,1) size(X,2)],ind);
while(flag(e,I)==0)
flag(e,I)=ws;
actualwaittime = we+actualwaittime;
ws=ws+1;
end
end
end*
for d=1:n if((max(flag(d,:)==m))) count=count+1; end end
end for te=1:mc probab(te)=count/mc; end end

Risposte (0)

Categorie

Scopri di più su Seismology in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by