ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
|
Downloads |
FlexSim HC: Q&A Questions about FlexSim Healthcare |
#1
|
|||
|
|||
simulation of an inhomogeneous poisson process
Hello everybody
I've been working on a model with an inhomogeneous arrival process. For this I created a code for an inhomogeneous poisson arrival. It works in the R script, but when I use a similar code in flexsim HC, the results are not the same. Attached are the test model and code of the R scripts. Is somebody able to explain the diffrence? Error/diffrence in my flexsim code? model: rm(list=ls()) DPfad <- "C:\Users\" # the path of the method arrival setwd(DPfad) source("arrival.R") t=0 #lambda=runif(24) lambda = 1:6 lambda = rep(lambda,4) event=c() for(i in 1:1e5) { iat=arrival(t,lambda) t=t+iat event=c(event,t) } hist(event%%24,breaks=0:24,freq=FALSE) points(0:23+0.5,lambda/sum(lambda)) # comparison with flexsim data ## load data sim <- read.csv(paste(DPfad,"test_model2.csv", sep=""), sep=",") # transform minutes into hours sim$TIME <- sim$TIME/60 # create a histogram hist(sim$TIME%%24,breaks=0:24,freq=FALSE) points(0:23+0.5,lambda/sum(lambda)) #------------------------------------------ arrival: # Funktion zur Berechnung der nächsten Interarrival Time arrival=function(t,lambda) { t0=t # aktuellen Zeitpunkt speichern p=runif(1) # Zufallszahl ziehen F=0; # Initialisierung der Verteilungsfunktion l=lambda[trunc(t%%24)+1] # aktuelles lambda ermitteln dt=ceiling(t)-t # Zeitspanne bis zum nächsten lambda P=(1-exp(-l*dt)) # Dichtefunktion der aktuellen Zeitspanne while(F+(1-F)*P { F=F+(1-F)*P # Verteilungsfunktion erweitern t=t+dt # Zeitspanne hinzufügen l=lambda[trunc(t%%24)+1] # aktuelles lambda berechnen dt=1 # aktuelle Zeitspanne P=(1-exp(-l*dt)) # Dichtefunktion der aktuellen Zeitspanne } t=t-log((1-p)/(1-F))/l # letzte angebrochene Zeitspanne hinzufügen return(t-t0) # berechneter Zeitunterschied } Thanks for your respond. |
#2
|
||||
|
||||
If you're suspecting a mismatch in code translation, have you tried putting breakpoints into your code to check the value of variables at various steps in the code? Go to Tools>Debugging>Breakpoints to turn on breakpoints, and then simply click to the left of each line in the interarrival time code window to add a breakpoint (red dot will appear). As you run the model, the breakpoint manager window will popup allowing you to further investigate your code.
|
#3
|
|||
|
|||
There may be a much easier and less cumbersome way to model the nonhomogeneous arrival process you're dealing with using a Log-Linear function. I'm assuming, of course, that your underlying pattern is Poisson distributed. Whatever the case, if you'd send me your data, I might be able to create the arrival pattern you're looking for.
Thanks, Lou Keller |
The Following User Says Thank You to Lou Keller For This Useful Post: | ||
Cliff King (05-02-2013) |
#4
|
|||
|
|||
Quote:
|
Thread | Thread Starter | Forum | Replies | Last Post |
Picking process | Simon Farsah | Q&A | 9 | 03-23-2015 06:55 AM |
How to set the process time ...? | Steffen Hainke | Q&A | 3 | 08-24-2011 03:35 AM |
Banking Process simulation using Flexsim | Simon Farsah | Q&A | 1 | 08-06-2010 06:05 AM |
different process times | mohanboyapati | Q&A | 1 | 11-02-2009 11:59 AM |
Re-entrant Process | ankus d | Q&A | 2 | 02-09-2009 07:53 PM |