This is the first time I have ever had to do a simulation type program. This is what I'm trying to do:

Your application should use an array of tellers (10 tellers would be a good maximum) but on any particular run of the simulation, any number of tellers from 1 to 10 may be used. There is only one queue and when a teller becomes available, the person at the head of the queue goes to be served by that teller.

3. Write your program so that the inputs have the following characteristics:
• the arrival rate is in customers per second
• the average processing time is in minutes. You can double this value to get a maximum processing time
• the number of tellers is an integer from 1 to 10.
• the number of minutes that the simulation should run. When testing, plan to use at least 100 minutes.

4. Your program should compute and display at the end of the run
• the average customer wait time
• the maximum customer queue length
• number of minutes of teller idle time

Alright I basically have three java files here Customer, CustomerQueue and Banksim.

Questions are how would I be able to do the arrival rate in seconds? like arrivaltime = 60/60; That is the CustomerQueue.java,

Another question is how would I also do the tellers, I have them in my customer.java but I don't think I did it right?

Another question is the number of mintues. I have a simulated clock but that is equal too 0 do I need to set that to 100 to make the simulation run for a hundred minutes? this in my Banksim.java(This one right now is a work in progress.)

Final question is how would I be able to show the number of minutes of teller idle time?
would I have to do like something that records when the teller is busy and for how long and then minus that from the 100 minutes? kindof like teller.isBusy(); ?

Here is my Customer.java

import java.util.*;
import java.util.Random;

public class Customer {

  // Data Fields
  /** The ID number for this Customer. */
  private int CustomerId;

  /** The time needed to process this Customer. */
  private int processingTime;

  /** The time this Customer arrives. */
  private int arrivalTime;

  /** The maximum time to process a customer. */
  private static int maxProcessingTime;

  /** The sequence number for customer. */
  private static int idNum = 0;

  /** Create a new customer.
      @param arrivalTime The time this customer arrives */
  public Customer(int arrivalTime) {
    this.arrivalTime = arrivalTime;
    processingTime = 1 + (new Random()).nextInt(maxProcessingTime);
    CustomerId = idNum++;
  }

  /** Get the arrival time.
      @return The arrival time */
  public int getArrivalTime() {
    return arrivalTime;
  }

  /** Get the processing time.
      @return The processing time */
  public int getProcessingTime() {
    return processingTime;
  }

  /** Get the customer ID.
      @return The customer ID */
  public int getId() {
    return CustomerId;
  }

  /** Set the maximum processing time
      @param maxProcessingTime The new value */
  public static void setMaxProcessingTime(int maxProcessTime) {
    maxProcessingTime = maxProcessTime;
  }
}

Here is my CustomerQueue.java

import java.util.*;


public class CustomerQueue {
  // Data Fields
  /**  The queue of passengers. */
  private Queue < Customer > theQueue;

  /** The number of customers served. */
  private int numServed;

  /** The total time customers were waiting. */
  private int totalWait;
  
  /** The number of tellers*/
  private int numTellers;

  /** The name of this queue. */
  private String queueName;

  /** The average arrival rate. */
  private double arrivalRate;

  // Constructor
  /** Construct a CustomerQueue with the given name.
      @param queueName The name of this queue
   */
  public CustomerQueue(String queueName) {
    numTellers = 10;
    numServed = 0;
    totalWait = 0;
    this.queueName = queueName;
    theQueue = new LinkedList < Customer > ();
  }

  /** Return the number of Customer served
      @return The number of Customers served
   */
  public int getNumServed() {
    return numServed;
  }

  /** Return the total wait time
      @return The total wait time
   */
  public int getTotalWait() {
    return totalWait;
  }

  /** Return the queue name
      @return - The queu name
   */
  public String getQueueName() {
    return queueName;
  }

  /** Set the arrival rate
      @param arrivalRate the value to set
   */
  public void setArrivalRate(double arrivalRate) {
    this.arrivalRate = arrivalRate;
  }

  /** Determine if the Customer queue is empty
          @return true if the Customer queue is empty
   */
  public boolean isEmpty() {
    return theQueue.isEmpty();
  }

  /** Determine the size of the Customer queue
      @return the size of the Customer queue
   */
  public int size() {
    return theQueue.size();
  }

  /** Check if a new arrival has occurred.
      @param clock The current simulated time
      @param showAll Flag to indicate that detailed
                     data should be output
   */
  public void checkNewArrival(int clock, boolean showAll) {
    if (Math.random() < arrivalRate) {
      theQueue.add(new Customer(clock));
      if (showAll) {
        System.out.println("Time is "
                           + clock + ": "
                           + queueName
                           + " arrival, new queue size is "
                           + theQueue.size());
      }
    }
  }

  /** Update statistics.
      pre: The queue is not empty.
      @param clock The current simulated time
      @param showAll Flag to indicate whether to show detail
      @return Time passenger is done being served
   */
  public int update(int clock, boolean showAll) {
    Customer nextCustomer = theQueue.remove();
    int timeStamp = nextCustomer.getArrivalTime();
    int wait = clock - timeStamp;
    totalWait += wait;
    numServed++;
    if (showAll) {
      System.out.println("Time is " + clock
                         + ": Serving "
                         + queueName
                         + " with time stamp "
                         + timeStamp);
    }
    return clock + nextCustomer.getProcessingTime();
  }

}

And last but not least the work in progress Banksim.java

import javax.swing.*;

public class Banksim {
    
     private CustomerQueue CustomerQueue =
      new CustomerQueue("Customer");

 
    //private int maxProcessingTime;
    
   // private int totalTime;
    
    //private boolean showAll;
    
    //private int timeDone;

  // Data Fields
 


 

  /** Maximum time to service a Customer. */
  private int maxProcessingTime;

  /** Total simulated time. */
  private int totalTime;

  /** If set true, print additional output. */
  private boolean showAll;
  
  /** Simulated clock. */
  private int clock = 0;

  /** Time that the agent will be done with the current Customer.*/
  private int timeDone;

  

  private void runSimulation() {
    for (clock = 0; clock < totalTime; clock++) {
      CustomerQueue.checkNewArrival(clock, showAll);
      //regularCustomerQueue.checkNewArrival(clock, showAll);
      if (clock >= timeDone) {
        startServe();
      }
    }
  }

  private void enterData(){
     System.out.println(maxProcessingTime);
     System.out.println(CustomerQueue);
  }      
      
  private void startServe() {
   
      System.out.println("Time is " + clock
                         + " server is idle");
    }
  }

  /** Method to show the statistics. */
  private void showStats() {
    System.out.println("The number of Customers served was "
                       + CustomerQueue.getNumServed());
    averageWaitingTime =
        (double) CustomerQueue.getTotalWait()
        / (double) CustomerQueue.getNumServed();
    System.out.println(" with an average waiting time of "
                       + averageWaitingTime);
    System.out.println("Customers in queue: "
                       + CustomerQueue.size());
    
  }
  /** main method

        @param args Not used

  */

  public static void main(String args[]) {

        Banksim sim = new Banksim();

        sim.enterData();

        Customer.setMaxProcessingTime(sim.maxProcessingTime);

        sim.runSimulation();

        sim.showStats();

        System.exit(0);

  }


}

Thanks for your help again guys and gals.

So you are running a simulation, right? You're not supposed to calculate what the Poisson/Exponential distribution predicts it is supposed to be and approach it from a Statistics/Probability Theory viewpoint? Just straight random number generation of customer arrival and service times? No standard deviations and all that fun stuff from Statistics in the random number generation?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.