Starting from:
$35

$29

Assignment 3 Solution

 Introduction 

We want to write a program to simulate the advising area of a university 
advising center. The goal of this simulation is to collect statistical 
information of students and academic advisors. An advising area consists of 
several advisors and a student waiting line (or queue). In each time unit, 
at most one new student arrives at the waiting line. If the student waiting 
line is too long, the student leaves without meeting an advisor; otherwise, 
the student gets into the waiting line. If all advisors are busy, students in 
the waiting lines must wait for advisors. If an advisor is free and students 
are waiting, the first student in the waiting line advances to the advisor’s 
counter and begins advising session. When a student is done, the student departs 
and the advisor becomes free. We will run the simulation through many units 
of time. At the end of each time unit, your program should print out a "snap-shot" 
of queues, students and advisors. At the end of the program, your program should 
print out statistics and conclude simulation.


2. Assumptions and Requirements

2.1. Assumptions

- At most one student arrives per time unit
- All numbers are positive integer numbers (>=0), except average values 
  should be displayed to two decimal places
- No time lost in between events:
  a student arriving and entering waiting line
  a student arriving and leaving without meeting advisor
  a student completing advising session and departing
  a student leaving the waiting line, advancing to an advisor and 
    beginning an advising session 

2.2. The limits of simulations parameters

- Maximum number of advisors        10
- Maximum simulation length         10000
- Maximum advising time             500
- Maximum student queue limit       50
- Probability of new student arrival     1% - 100%


2.3. Input parameters and student (random/file) data 

- The following data are read at the beginning of the simulation:

  int numAdvisors;        // number of Advisors.
  int simulationTime;     // time to run simulation
  int studentQLimit;      // student queue limit
  int chancesOfArrival;   // probability of a new Student ( 1 - 100)
  int maxAdvisingTime;    // maximum advising time per student
  int dataSource;         // data source: from file or random


- Sample input layout:

        ***  Get Simulation Parameters  ***

  Enter simulation time (positive integer)       : 10
  Enter the number of advisors                   : 3
  Enter chances (0% < & <= 100%) of new student  : 75
  Enter maximum advising time of students        : 5
  Enter student queue limit                      : 2
  Enter 0/1 to get data from random/file         : 1        <- see details below
  Enter filename                                 : DataFile <- for input 1 above


- In each time unit of simulation, your program will need two positive integers 
  numbers to compute boolean anyNewArrival & int advisingTime. A user should 
  have two options to specify the source of those numbers (input 1 or 0):

  For user input 1, numbers are read from a file. A filename should be provided 
  at the beginning of simulation. Each line in a datafile should contain two 
  positive numbers (> 0). A datafile should contain sufficient data for
  simulationTime upto 500 units, i.e. at least 500 lines. In each time unit, 
  anyNewArrival & advisingTime are computed as follows :

         read data1 and data2 from the file;
         anyNewArrival = (((data1%100)+1)<= chancesOfArrival);
         advisingTime = (data2%maxAdvisingTime)+1;
 

  For user input 0, numbers are generated by method nextInt() in a Random 
  object, dataRandom, which should be constructed at the beginning of 
  simulation. In each time unit, anyNewArrival & advisingTime are computed as
  follows:

        anyNewArrival = ((dataRandom.nextInt(100)+1) <= chancesOfArrival);
        advisingTime = dataRandom.nextInt(maxAdvisingTime)+1;


2.4. INput/Output information

- At the end of each time unit, you program should print out "snap-shot" of 
  simulation. At the end of simulation, you program need to print out end 
  of simulation report 

- Sample run is provided at the end of Readme file.


2.5 Data structures and simulation algorithm

- I have defined package PJ3 with the Student, Advisor and AdvisingArea classes. 
  You need to implement their methods. I also provide an outline of a 
  simulation program AdvisingCenter.java. 


3. Compile and run program

- You need to download PJ3 zip file (with sample datafie) from ilearn.

- Compile programs (you are in directory containing Readme file):

  javac PJ3/*.java

- Run programs (you are in directory containing Readme file):

  // Run simulation
  java PJ3.AdvisingCenter


4. Due date and project submission 

- 11:55pm Sunday, November 24, 2019
- To submit your project, you need to zip (or tar) all source files and
  upload it to ilearn.


=====================================================================================
SAMPLE RUN
=====================================================================================

$ java PJ3.Student
Student Info --> studentID=1:advisingTime=5:arrivalTime=35:watiTime=10:finishTime=50

=====================================================================================

$ java PJ3.Advisor
AdvisorID=5
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null

AdvisorID=5
:startFreeTime=0:endFreeTime=25:totalFreeTime=25
:startBusyTime=25:endBusyTime=33:totalBusyTime=0
:totalStudent=1
-->currentStudent:studentID=1:advisingTime=8:arrivalTime=15:watiTime=10:finishTime=33

AdvisorID=5
:startFreeTime=33:endFreeTime=25:totalFreeTime=25
:startBusyTime=25:endBusyTime=33:totalBusyTime=8
:totalStudent=1
-->currentStudent:studentID=1:advisingTime=8:arrivalTime=15:watiTime=10:finishTime=33



                Advisor ID             : 5
                Total free time        : 25
                Total busy time        : 8
                Total # of students    : 1
                Average advising time  : 8.00

=====================================================================================

$ java PJ3.AdvisingArea
studentQ:[studentID=1:advisingTime=18:arrivalTime=10:watiTime=0:finishTime=0, studentID=2:advisingTime=33:arrivalTime=11:watiTime=0:finishTime=0, studentID=3:advisingTime=21:arrivalTime=12:watiTime=0:finishTime=0]
===============================================
Remove student:studentID=1:advisingTime=18:arrivalTime=10:watiTime=0:finishTime=0
Remove student:studentID=2:advisingTime=33:arrivalTime=11:watiTime=0:finishTime=0
Remove student:studentID=3:advisingTime=21:arrivalTime=12:watiTime=0:finishTime=0
===============================================
freeAdvisorQ:[AdvisorID=1
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null
, AdvisorID=2
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null
, AdvisorID=3
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null
]
===============================================
Remove free advisor:AdvisorID=1
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null

Remove free advisor:AdvisorID=2
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null

Remove free advisor:AdvisorID=3
:startFreeTime=0:endFreeTime=0:totalFreeTime=0
:startBusyTime=0:endBusyTime=0:totalBusyTime=0
:totalStudent=0
-->currentStudent:null

===============================================
freeAdvisorQ:[]
===============================================
busyAdvisorQ:[]
===============================================
busyAdvisorQ:[AdvisorID=1
:startFreeTime=0:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=31:totalBusyTime=0
:totalStudent=1
-->currentStudent:studentID=1:advisingTime=18:arrivalTime=10:watiTime=3:finishTime=31
, AdvisorID=2
:startFreeTime=0:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=46:totalBusyTime=0
:totalStudent=1
-->currentStudent:studentID=2:advisingTime=33:arrivalTime=11:watiTime=2:finishTime=46
, AdvisorID=3
:startFreeTime=0:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=34:totalBusyTime=0
:totalStudent=1
-->currentStudent:studentID=3:advisingTime=21:arrivalTime=12:watiTime=1:finishTime=34
]
===============================================
Remove busy advisor:AdvisorID=1
:startFreeTime=31:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=31:totalBusyTime=18
:totalStudent=1
-->currentStudent:studentID=1:advisingTime=18:arrivalTime=10:watiTime=3:finishTime=31

Remove busy advisor:AdvisorID=3
:startFreeTime=34:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=34:totalBusyTime=21
:totalStudent=1
-->currentStudent:studentID=3:advisingTime=21:arrivalTime=12:watiTime=1:finishTime=34

Remove busy advisor:AdvisorID=2
:startFreeTime=46:endFreeTime=13:totalFreeTime=13
:startBusyTime=13:endBusyTime=46:totalBusyTime=33
:totalStudent=1
-->currentStudent:studentID=2:advisingTime=33:arrivalTime=11:watiTime=2:finishTime=46


=====================================================================================

$ java PJ3.AdvisingCenter

        ***  Get Simulation Parameters  ***


Enter simulation time (positive integer)      : 10
Enter the number of advisors                  : 3
Enter chances (0% < & <= 100%) of new student : 75
Enter maximum advising time of students       : 5
Enter student queue limit                     : 2
Enter 0/1 to get data from random/file        : 1
Enter filename                                : DataFile


        ***  Start Simulation  ***


Advisor #1 to #3 are ready...


---------------------------------------------
Time : 0
        student #1 arrives with advising time 5 units
        student #1 waits in the student queue
        student #1 gets an advisor
        advisor #1 starts advising student #1 for 5 units
---------------------------------------------
Time : 1
        student #2 arrives with advising time 2 units
        student #2 waits in the student queue
        student #2 gets an advisor
        advisor #2 starts advising student #2 for 2 units
---------------------------------------------
Time : 2
        student #3 arrives with advising time 5 units
        student #3 waits in the student queue
        student #3 gets an advisor
        advisor #3 starts advising student #3 for 5 units
---------------------------------------------
Time : 3
        No new student!
        student #2 is done
        advisor #2 is free
---------------------------------------------
Time : 4
        student #4 arrives with advising time 3 units
        student #4 waits in the student queue
        student #4 gets an advisor
        advisor #2 starts advising student #4 for 3 units
---------------------------------------------
Time : 5
        No new student!
        student #1 is done
        advisor #1 is free
---------------------------------------------
Time : 6
        student #5 arrives with advising time 3 units
        student #5 waits in the student queue
        student #5 gets an advisor
        advisor #1 starts advising student #5 for 3 units
---------------------------------------------
Time : 7
        student #6 arrives with advising time 5 units
        student #6 waits in the student queue
        student #4 is done
        advisor #2 is free
        student #3 is done
        advisor #3 is free
        student #6 gets an advisor
        advisor #2 starts advising student #6 for 5 units
---------------------------------------------
Time : 8
        No new student!
---------------------------------------------
Time : 9
        No new student!
        student #5 is done
        advisor #1 is free


============================================


End of simulation report

        # total arrival students  : 6
        # students gone-away      : 0
        # students served         : 6

        *** Current Advisors Info. ***


        # waiting students   : 0
        # busy advisors      : 1
        # free advisors      : 2

        Total waiting time         : 0
        Average waiting time       : 0.00


        Busy Advisors Info. :


                Advisor ID             : 2
                Total free time        : 2
                Total busy time        : 8
                Total # of students    : 3
                Average advising time  : 2.67



        Free Advisors Info. :


                Advisor ID             : 3
                Total free time        : 5
                Total busy time        : 5
                Total # of students    : 1
                Average advising time  : 5.00


                Advisor ID             : 1
                Total free time        : 2
                Total busy time        : 8
                Total # of students    : 2
                Average advising time  : 4.00

More products