--
You received this message because you are subscribed to the Google Groups "simmer-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel+unsubscribe@googlegroups.com.
To post to this group, send email to simmer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/CALEXWq1_rsj6Zne%2B%2BEF4ki1WNRd94J4A_DsGyPUNpry9ADXsxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
> simulation <- function()
+ {
+ env<-simmer("Transportation")
+ env %>% add_generator("packstück", Production_Line, at(df$TIME_START_min))
+ env %>% run(until=max(df$TIME_START_min))
+ }
> simulation()
Error in run_(private$sim_obj, until) : Branch: index out of range
Called from: run_(private$sim_obj, until)
library(simmer)
library(shiny)
set.seed(1234)
bank <- simmer()
customer <-
trajectory("Customer's path") %>%
log_("Here I am") %>%
set_attribute("start_time", function() {now(bank)}) %>%
seize("counter") %>%
log_(function() {paste("Waited: ", now(bank) - get_attribute(bank, "start_time"))}) %>%
timeout(input) %>%
release("counter") %>%
log_(function() {paste("Finished: ", now(bank))})
bank <-
simmer("bank") %>%
add_resource("counter") %>%
add_generator("Customer", customer, function() {c(0, rexp(4, 1/10), -1)})
# User interface ----
ui <- fluidPage(
titlePanel("simple example"),
sidebarLayout(
sidebarPanel(
h3("Buttons"),
numericInput("input", "input timeout", 15),
actionButton("simulate","Simulate", icon(" fa-arrow-circle-o-right"))
),
mainPanel(
plotOutput("plot")
)
)
)
# Server logic
server <- function(input, output) {
### HERE ## HOW CAN I CALL THE INPUT TO BE USED ON THE SIMULATION?
bank %>% run(until = 400)
output$plot <- renderPlot({
plot(env, "resources", "usage","counter",item=c("server","queue"),steps=T)
})
}
# Run the app
shinyApp(ui, server)
library(shiny)
library(simmer)
ui<-fluidPage(
# Application title
titlePanel("Simple App"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("customers",
"Number of customers:",
min = 1,
max = 50,
value = 30),
actionButton("execute", "Run Model")
),
# Show a plot of the generated distribution
mainPanel(
textOutput("serviceTime"),
textOutput("numCustomers")
)
)
)
# simmer model as function of input
bankModel <- function(input)
{
customer <- trajectory("Customer's path") %>%
log_("Here I am") %>%
timeout(10) %>%
log_("I must leave")
bank <- simmer("bank") %>%
add_generator("Customer", customer, at(1:input$customers)) %>%
run() %>%
wrap()
bank
}
# This forces shiny to see a usage of inputs in simmer model
# Not always needed, but enough to be troublesome without
copyInputs <- function(inputs)
{
list(
customers = inputs$customers
)
}
# Define server logic required to draw a histogram
server <-function(input, output) {
observeEvent(input$execute, {
model <- bankModel(copyInputs(input))
output$serviceTime <- renderText(as.character(model$now()))
output$numCustomers <- renderText(as.character(input$customers))
})
}
# Run the app
shinyApp(ui, server)
> To unsubscribe from this group and stop receiving emails from it, send an email to simmer...@googlegroups.com.