cpsc 242 Mostly in elassa Blackboard Resource Queues package

cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation programs that model real world events and track A theater manager wants a program tha Movie B. simulates a line or box omee customers wa iting to see one of two movies. Perhaps to find another theater, The desired program knows that if the waiting line gets too long, newly arriving customers will tum away. simulate the activity in the waiting line over a 30-minute with number for MovieB and the number of customers who were turned away because the line was too long. ersion 1 The manager\'s experience suggests that the average time to serve one customer is ten seconds, and during those ten seconds, the probability is 20 percent that a new customer will join the line. To simulate a 30-minute time span. program will cover 180 ten-second waiting intervals. of the line and, with a 20 percent probability, one customer will join the rear of the line. For this simulation, the textbook\'s queue package is available with the operations we have discussed in class. The simulation program should use a \"bounded (Why? The program simulates a customer entering the waiting line enqueue queue by ing the string \"MovieA\" or the customer\'s choice of movies. Each \"MovieA\" or \"MovieB is obtained by generating a random integer of 0 (for MovieA)or 1 (for MovieB). Version 2 is programming assignment extends the theater simulation discussed in class. The theater manager now wants a more realistic simulation of the Expand the theater program to accommodate the following waiting que changes. I. Use a parameterized constructor to create a queue of the size input by the user. 2. Instead of starting the 30-minute simulation with an empty the queue with some number of customers before starting the main loop. Prompt the user for this number. 3. Input the service time, and probability of two new customers getting in line. 4. The program will conclude by displaying the average queue length over all ten-second inte the cash register receipts for MovieA (at $9.50 per ticke) and MovieB (at $10.00 per ticket), and the number of customers who were turned away. t about finding the queue length? What does it mean, and how can it be determined? Will we need an additional od in the queue class?

Solution

please provide the exact question for which answer is needed.

here i provide the sample program which will calculate the time based on first in first out order and Minimum Processing Time

#include<iostream>

#include <cmath>

#include <cstdlib>

#include <ctime>

   

using namespace std;

const int Queue_lim=100;

const int BUSY=1;

const int IDLE=0;

int       choice, Comp_cust, No_events, Completed, No_queue, Server_Status;

double      End_Time,      Type_Next_Event,      Mean_interArrival_Time,       Mean_service_Time, clock,

      Time_Arrival[Queue_lim + 1],

      Service_Time[Queue_lim + 1],

      Flow_time,

      Progres_Arrival_Time,

      Progres_Completed_Time,

      Wait_time;

      Next_Arrival_Time,

      Next_Completed_Time,

      Next_Service_Time,

//functions in simulation

void start();

void Timing();

void Arrival();

void Completion();

float expon(float mean);

void Min_search(double[],double[]);

int main()

{

    start();           // Intialization of the System

    cout<<\"   fixed run theater ticket simulation *\ \";

   cout<<\"\ 1.FIFO order\"<<endl;

     cout<<\" 2.with Minimum Processing Time\"<<endl<<endl;

do

    {

    cout<<\"\\tEnter your choice: \"; // to simulate based on above policies

     cin>>choice;

         } while(choice>2||choice<1);

    

    cout<<\"\ Mean InterArrival Time is: \"<<Mean_interArrival_Time;

     cout<<\"\ Mean Service Time is: \"<<Mean_service_Time<<endl;

     cout<<\"The End of Simulation Time: \"<<End_Time<<endl<<endl;

    while(true)

    {

               Timing();                                                     // Routine To check next event

         if(Clock > End_Time)

           break;

         switch (int(Type_Next_Event))

        {

         case 1:

            Arrival();                                                 //customer arrival time

            break;

            

        case 2:

            Completition();                                     //completion of task

            break;

        }

    }

     

    // Print Summary

    

    cout<<\"\ Total Flow Time: \"<<Flow_time;

     cout<<\"\ Total Waiting Time in Queue: \"<<Wait_time;

     cout<<\"\ Average Waiting Time in Queue: \"<<Wait_time / Comp_cust;

    cout<<\"\ Average Flow Time: \"<<Flow_time / Comp_cust;

    cout<<\"\ Number of Completed Customers: \"<<Comp_cust;

    cout<<\"\ Average Number of Customers In System / Unit Time: \"<<Comp_cust / Clock<<endl<<endl;

    return 0;

}

//start function

void start()

{

     No_events = 2;      // Arrival and Completion

     Mean_service_Time=1.0;

Mean_interArrival_Time=0.7* Mean_service_Time;

End_Time=100.0;

    Clock = 0.0;

    Server_Status = IDLE;

    No_queue = 3;                              //pre filling the queue

     Comp_cust = 0;

     Flow_time = 0.0;

     Wait_time = 0.0;

    Next_Arrival_Time = Clock + expon(Mean_interArrival_Time);//Arriving

     Next_Service_Time = expon(Mean_service_Time);

     Nxt_Comp_Time = 1.0e+10;    // Completing Guarantening that the first event is arriving

      Progres_Arrival_Time=0.0;

     Progres_Completed_Time = 0.0;

}

// Timing Routine Function

void Timing()

{

    Type_Next_Event = 0;

    if(Next_Arrival_Time < Next_Completed_Time)

    {

        Type_Next_Event = 1;

        Clock=Next_Arrival_Time;

    }

    else

    {

        Type_Next_Event = 2;

        Clock = Next_Completed_Time;

    }

    if (Type_Next_Event == 0)

    {

        cout<<\"\ List Empty at Time: \"<<Clock;

        exit(1);

    }      

}

// customer Arriving function

void Arrival()

{

    if (Server_Status == BUSY)

    {

        ++No_queue;

        if (No_queue > Queue_lim)

        {

            cout<<\"\ Overflow of the array time_arrival at\";

            cout<<\"time: \"<<Clock;

            exit(2);

        }

        Time_Arrival[No_queue] = Clock;

        Service_Time[No_queue] = Next_Service_Time;

    }

    else

    {

        Server_Status = BUSY;

        Nxt_Comp_Time = Clock + Next_Service_Time;

        Progres_Arrival_Time = Next_Arrival_Time;

        Progres_Completed_Time = Next_Completed_Time;

    }

    Next_Arrival_Time = Clock + expon(Mean_interArrival_Time);

    Next_Service_Time = expon(Mean_service_Time);

}

// Completed Customer Function

void Completition()

{

    double Delay;

    ++Comp_cust;

    Flow_time+= ( Progres_Completed_Time - Progres_Arrival_Time );

    if (No_queue == 0)

    {

        Server_Status= IDLE;

        Nxt_Comp_Time = 1.0e+10;      // Max Value

    }

    else

    {

        if(choice==2)

            Min_search(Time_Arrival,Service_Time);    // Minimum Processing Time

           Delay= Clock - Time_Arrival[1];

         Wait_time+= Delay;

        Nxt_Comp_Time = Clock + Service_Time[1];

        Progres_Arrival_Time = Time_Arrival[1];

        Progres_Completed_Time = Next_Completed_Time;

              --No_queue;                                       //decrement queue after completion of service

                 for (int i=1;i<=No_queue;i++)

        {

            Time_Arrival [i] = Time_Arrival[i + 1];

                         Service_Time[i] = Service_Time[i + 1];

        }

             }

}

//Sorting Functtion

void Min_search(double Arr_time[],double Ser_time[])

{

    int Min=1;

     double temp;

     for(int i=1;i<No_queue;i++)

        if(Ser_time[Min]>Ser_time[i+1])

            Min=i+1;

     temp=Ser_time[1];

    Ser_time[1]=Ser_time[Min];

    Ser_time[Min]=temp;

     temp=Arr_time[1];

    Arr_time[1]=Arr_time[Min];

    Arr_time[Min]=temp;

}

// Generate The Rondom Number

float expon(float mean)

{

     srand((unsigned)time(0));

   typedef float random_integer = rand();                             //calculates random number

return random_integer;

}

 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro
 cpsc 242 Mostly in elassa Blackboard Resource Queues package from the Dextbook Design Problem their behavior queue data structures being used in simulation pro

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site