inst/resources/scripts/a_lander.r

a_lander <- function(amax) {
  # Find that thrust a and firing time Ti which land the rocket using
  # the least fuel. amax is the maximum thrust possible
  g <- function(a) {
    Ti <- Ti_lander(a)
    return(lander(Ti, a)[3])
  }
  opt <- optimize(g, c(0, amax), maximum=T)
  a <- opt$maximum     # optimal thrust
  mf <- opt$objective  # final mass
  return(c(Ti_lander(a), a, mf))
}

Try the spuRs package in your browser

Any scripts or data that you put into this service are public.

spuRs documentation built on May 2, 2019, 12:44 p.m.