CS计算机代考程序代写 python AI IERG3050_2021Fall_Assignment2withGrading

IERG3050_2021Fall_Assignment2withGrading

IERG3050 Simulation and Statistical Analysis (Fall 2021)
Assignment 2

Instructions:
1. Do your own work. You are welcome to discuss the problems with your fellow

classmates. Sharing ideas is great, and do write your own programs and explanations.
2. All work should be submitted onto the blackboard before the due date.
3. You are advised to submit a zip or rar containing all necessary files. In the submission,

you should have the following items
a. A python program, assignment2.py, the program written for the simulation.
b. Another python program, assignment2_featureX.py, the program written for the

extra feature. (X = 1, 2 or 3)
c. Some .csv files and a .pdf file, explaining your own test case in the extra features.

4. Do type/write your work neatly. If we cannot read your work, we cannot grade your work.
5. If the submitted programs cannot be run or are irrelevant to the problem (e.g. empty

python programs), you will receive no scores for that part.
6. Assignment 2 is equivalent to project phase I, and will take 10% of the course total.
7. Project phase II will be assignment 5.
8. Do spend at least three days for the project-like assignment 2.
9. Due date: 22nd Oct, 2021 (Friday) 23:59 29th Oct, 2021 (Friday) 23:59

Simulation Background:

In the CUHK Art Fair, different student societies gather, promote and share their culture with
all students. The Art Fair takes place at the University Mall. There are many booths set up in
the Mall, and each society stays in one Mall. The Art Fair lasts for 2 days, operating from 11
am to 6 pm.

The floor plan of the Art Fair is as follows. There are two entrances, which are library
entrance and science centre (SC) entrance. Students can only arrive and depart from the
two entrances. The n booths are arranged on the two sides of the Art Fair (n can be odd or
even).

1 3 5 … … … … n-1

Library → ← SC

2 4 6 … … … … n

You are going to write a simulation for the two-day Art Fair. The name of the program is
assignment2.py.

1

Notations for the simulations:
● Number of days in the simulation: D, D ≥ 1, default D = 2
● Number of booth: n, n ≥ 5
● Number of students on day i: Ni, Ni ≥ 1
● Promotion time of booth i: 1 ≤ si ≤ 10
● Arrival time of student i: 0 ≤ ai ≤ 720, where 720 time unit = 7 hours

Part A: Initial settings

There are two ways to initialize the system, which are initialized by file and initialized by
random numbers.

Initialization with file
1. The first argument refers to the name of the configuration file.
2. The configuration file is a two-column matrix with file extension csv.
3. An example of the configuration file is as follows.

○ D,2
○ n,20
○ N,100
○ Booth_promotion_time,”1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3”
○ Student_file,”student.csv”
○ Log_file,”simulation_log_customized.csv”
○ Summary_file,”simulation_summary_customized.csv”

4. The file for the students is a (2D+1)xN table. The file name is specified in the
configuration file.
○ Header is

“student_id,arrival_time_day_1,…,arrival_time_day_D,preference_day_1,…,prefe
rence_day_D”

○ The former D columns specify the arrival time of each student on different days.
Arrival time is an integer, the offset from 11:00 am. For example, 110 means that
the student arrives at 12:50 (= 11:00 am + 110 min).

○ The later D columns are lists of integers, ranging from 1 to n, meaning the
preference booths to be visited on the corresponding day.

5. The entry for the booth promotion time is a list of integers, specifying the promotion
time of the booths. The first booth is booth 1 (one-based).

Initialization by random numbers
1. There are some default numbers.

○ D = 2
○ n = 20
○ N = 100
○ Student number is one-based

2. Set the random seed to 0
3. Generate DN integers from U(400) as the arrival time of the students.
4. Set the random seed to 1
5. Repeat the following procedure for DN times, meaning the preference booths of the

students

2

○ Generate an integer p = min(U(5)+1,n), meaning the number of booths to be
visited in a day.

○ Generate p distinct integers ranging from 1 to n, meaning the list of
preference booths.

6. Set the random seed to 2
7. Generate n integers as min(1+expo(5), 10), corresponding the promotion time of the

booths.

Part B: One day in the simulation

1. The simulation starts with an empty-and-idle state.
2. The Art fair only opens during 11:00 am and 6:00 pm.
3. The simulation Initializes the parameters based on the descriptions in part A.
4. When a student arrive in front of the booth

○ If the society promotes other students, the newcomers line up as a queue and
wait, until the customer comes to the front of the booth.

○ The queue is using FCFS strategy.
○ If the society is free, the society will immediately promote it to the students.

The promotion time depends on the booth.
5. There is a time for traveling.

○ From library entrance to booth i: floor((i+1)/2)
○ From booth i to booth j: abs(floor((j+1)/2)-floor((i+1)/2))
○ From SC entrance to booth i: floor((n-i+2)/2)

6. You can assume all students arrive from the library and depart from the closest exit.
7. At 6 pm, the Art Fair closes. Students in the queue can still wait and listen to the

promotion. However, the students cannot continue to the remaining booths in their
preference list.

Part C: Output statistics

1. If the simulation is initialized by random numbers, you need to output the
configuration file as config_default_random.csv and the students information as
student_default_random.csv. The file format is the same as the initialization with file.

2. Output the result of the simulation to either the specified output file in the
configuration file or simulation_log.csv in the random setting.

○ Header is “Day,Time,Event,len(Queue)”
○ Day is the day of simulation, which is one-based.
○ Time is the simulation time. The start of the simulation of the day is 11:00.
○ Events can only be “Student i arrives at booth j/Art Fair” or “Student i departs

from booth j/Art Fair”.
○ len(Queue) is the number of students queuing in front of booth j.

3. Output the summary of the simulation to either the specified output file in the
configuration file or simulation_summary.csv in the random setting.

○ Header is “Day,TotalWaitingTime,TotalTravelingTime,TotalTourTime”.
○ Day is the day of simulation, which is one-based.
○ Total waiting time calculates the total waiting time of all students of a day.

3

○ Total traveling time calculates the total traveling time of all students of a day.
○ Total tour time reports the cumulative time of all students spent on the Art

Fair.

Hint: Do study the code provided in the lecture, “introduction to queueing system”. It is very
useful for writing a basic simulation.

Extra features

You are going to implement one feature out of the following three options. Your submitted
program is named as assignment2_featureX.py, where X = 1, 2 or 3, indicating the feature
you have chosen. In addition, you need to generate one test case showing the changes in
the simulation results before and after incorporating the feature.
1. Reordering the preference list based on distance: As the University Mall is outdoor and

the weather is very hot, students visit the closest booth according to their preference list.
2. Reordering the preference list based on queue length: If there are too many people

crowding at some booths, it will take a long time to wait. Students visit the booths with
the shortest queue length first.

3. Promoting to groups of students: The society can promote to at most 6 students at a
time. It is noted that late comers wait in the queue and join the next promotion.

4

Grading criteria:

Concept Description Score

Submission of
basic
simulation

The program cannot be executed, or the program is not relevant
to the problem.

0

The program is relevant to the simulation and can be executed
normally.

2

Initialization
with random
numbers

The program cannot output the expected statistics for the
simulation.

0

The program can generate the statistics, however, some
problems are identified.

1

The program can generate reasonable statistics for the
simulation.

2

Initialization
with a config
file

The program cannot output the expected statistics for the
simulation.

0

The program can generate the statistics, however, some
problems are identified.

1

The program can generate reasonable statistics for the
simulation.

2

Submission of
the extra
feature

The extra feature is not implemented appropriately. Or the
previous simulation cannot be executed properly.

0

The extra feature can be executed, and reasonable statistics
are reported.

2

Documentation
on the test
case for the
feature

Missing the supporting document. 0

Attempts are made to show the correctness of the extra
features, but some problems are identified.

1

The test case can illustrate the extra feature clearly. 2

For the basic simulation, it takes 6 points. 4 points will be deducted by 0.5 points if each of
the following task cannot be met:
● Implementation of traveling time according to the description
● The format for time string
● Generations of random numbers for preferent list of the students according to the

description
● Generations of random numbers for promotion time of the booths according to the

description
● Departure events in the simulation log
● The termination conditions of the simulation, stop after all students departing from the

Art Fair
● Output format for configuration file
● Output format for preference list (From 0-based to 1-based)

5

● Calculation of total waiting time
● Calculation of total traveling time
● Calculation of total tour time

6