How to optimize search parameters in r?

Asked

Viewed 39 times

1

I’ve been waiting for hours for my code to finish running. I imagine there must be a smarter way to do this, after all I don’t need to visit every point when I have a monotonous function around a minimum point.

My problem is related to the queue theory, I have the average time in the queue, the c and the exit rate.

  lambda    <-seq(0,ceiling(mu*PDV),0.0001)
  n.lambda<-seq_along(lambda)
  diferenca <-NULL
  diferenca1<-300
  for (i in n.lambda) {
    try(wq<-queueing::QueueingModel(
      queueing::NewInput.MMC(lambda=lambda[i], mu=mu, c=PDV))$Wq, silent = TRUE)
    if(is.na(wq)) next
    diferenca<-(wq-Wq)^2
    if(diferenca<diferenca1){
      lambdaWin <-lambda[i]
    }

    diferenca1<-diferenca
  }

Any suggestions on how to improve it?

  • If I understand correctly, your problem is to find the minimum point of a function, correct? Is there a reason not to use the function optim of R? I believe if you edit the question with some função_de_interesse, someone here will be able to help you implement a solution using optim.

  • It’s just that my problem is with queue theory. queueing::QueueingModel(&#xA; queueing::NewInput.MMC(lambda=lambda[i], mu=mu, c=PDV))$Lq I have the length of the queue I want to know the lambda that would return it.

  • Then I won’t be able to help. It’s not a subject I master.

  • @Marcusnunes Thanks. I had heard of codes that partitioned the domain successively to search for minimum points.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.