All Downloads are FREE. Search and download functionalities are using the official Maven repository.

umontreal.iro.lecuyer.examples.QueueLindley Maven / Gradle / Ivy

Go to download

SSJ is a Java library for stochastic simulation, developed under the direction of Pierre L'Ecuyer, in the Département d'Informatique et de Recherche Opérationnelle (DIRO), at the Université de Montréal. It provides facilities for generating uniform and nonuniform random variates, computing different measures related to probability distributions, performing goodness-of-fit tests, applying quasi-Monte Carlo methods, collecting (elementary) statistics, and programming discrete-event simulations with both events and processes.

The newest version!
import umontreal.iro.lecuyer.stat.*;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.ExponentialDist;
import umontreal.iro.lecuyer.util.Chrono;

public class QueueLindley {

   RandomStream streamArr  = new MRG32k3a();
   RandomStream streamServ = new MRG32k3a();
   Tally averageWaits = new Tally ("Average waits");
 
   public double simulateOneRun (int numCust, double lambda, double mu) {
      double Wi = 0.0;
      double sumWi = 0.0;
      for (int i = 2; i <= numCust; i++) {
         Wi += ExponentialDist.inverseF (mu, streamServ.nextDouble()) -
               ExponentialDist.inverseF (lambda, streamArr.nextDouble());
         if (Wi < 0.0) Wi = 0.0;
         sumWi += Wi;
      }
      return sumWi / numCust;
   }

   public void simulateRuns (int n, int numCust, double lambda, double mu) {
      averageWaits.init();
      for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy