Hello,
I am currently learning about the simmer package, but I am still struggling.
-
Question: why is the the number of generated instances not the same, as the length of the original data vectors?
-
Question: is the running of single steps alright, as it is implemented? It is a simple version, of what i have to do later on. For the solution priorities are not suitable.
Can somebody please help me?
library(simmer)
library(parallel)
library(simmer.plot)
max<-10000
data1 <- c(1133360, 1133360, 1133360, 1133360, 1133360, 1133360, 898684, 898684, 898684, 898684, 898684, 898684, 898684, 898684, 898684, 898684, 898790, 997564, 997564, 997564, 997564, 997564, 997564, 997564, 999595, 999595, 999595, 999595, 999595, 999595, 999595)
data2 <- c(57641, 57641, 57641, 685433, 685433, 685433, 685433, 685433, 685433, 685433, 685433, 685433, 685501, 828820, 828820, 828820)
i<-0
readytraj1<-0
readytraj2<-0
env <- simmer("env")
traj1 <- trajectory("traj1") %>%
seize("res", 1) %>%
timeout(task = 10) %>%
release("res", 1)
traj2 <- trajectory("traj2") %>%
seize("res", 1) %>%
timeout(task = 10) %>%
release("res", 1)
env %>%
add_resource("res", 1) %>%
add_generator("traj1", traj1, at(c(data1)), mon=2) %>%
add_generator("traj2", traj2, at(c(data2)), mon=2)
while(max > i){
queuetraj1 <- env %>% get_n_generated("traj1")
queuetraj1 <- queuetraj1 - readytraj1
if(queuetraj1>0){
traj1
env %>%
stepn(1) %>%
print()
readytraj1<-readytraj1+1
i<-i+1
}
queuetraj2 <- env %>% get_n_generated("traj2")
queuetraj2 <- queuetraj2 - readytraj2
if(queuetraj2>0){
traj2
env %>%
stepn(1) %>%
print()
readytraj2<-readytraj2+1
i<-i+1
}
}
get_n_generated("traj1")
length(data1)
get_n_generated("traj2")
length(data2)
thank you in advance!