New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvement: batched generation #65

Closed
Enchufa2 opened this Issue Jun 15, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@Enchufa2
Member

Enchufa2 commented Jun 15, 2016

Until now, generators expect one interarrival value at a time in order to generate one arrival at a time. But it's perfectly possible (and more performant) to receive n interarrival values to generate n arrivals at a time. So instead of

add_generator("dummy", trajectory, function() rexp(1, 2))

it would be possible to do the following:

add_generator("dummy", trajectory, function() rexp(100, 2))

As a consequence, convenience functions could be improved. For instance, at could return all the values in one shot.

Finally, as a collateral benefit, if we want to generate arrivals following some distribution, but in rows of n, we would be able to do the following:

add_generator("dummy", trajectory, function() c(rexp(1, 2), rep(0, n-1)))

@Enchufa2 Enchufa2 added this to the v3.3.0 milestone Jun 15, 2016

@Enchufa2 Enchufa2 closed this in 6c23ff5 Jun 15, 2016

@Enchufa2 Enchufa2 referenced this issue Jun 18, 2016

Open

New vignettes #29

9 of 12 tasks complete
@nacnudus

This comment has been minimized.

Contributor

nacnudus commented Jun 28, 2016

This broke the hacky code I'd used in the Bank vignette (which I'm only just writing now, sorry).

customer <- 
  create_trajectory("Customer's path") %>%
  timeout(every(10, 7, 20))

which sets specific timeouts for three specific customers. Admittedly that's not a compelling use case. Is there an alternative to copying the original every code that created a function, i.e.

every <- function(...) {
    time_diffs <- c(...)
    i <- 0
    function() {        
      if (i < length(time_diffs)) {     
        i <<- i+1       
      } else {      
        i <<- 1     
      }     
      return(time_diffs[i])     
    }       
  }
@Enchufa2

This comment has been minimized.

Member

Enchufa2 commented Jun 29, 2016

There is no alternative, sorry. every is deprecated and will be removed from the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment