Search for question
Question

Question 2. (simulation.py): Develop a program that generates raw material arrival time for a job shop simulation system. There are different material types, and they could arrive at a random time between 0 and 5 (float value) minutes after the previous item. Develop a function called simulate that accepts two arguments, a list of job types and number of arrival times to generate. The function should generate arrival times for randomly selected job types. Each job arrives in a randomly generated time after the previous job. Generation always starts at time 0. For example, assume we have 3 types of jobs, "A", "B", and "C", and we need to generate 3 random arrivals. First, we pick a random job type. Assume we randomly pick type "C". To generate the first arrival, we generate a random value between 0 and 5, for example 0.556. Since we start at time 0, arrival time for the first job (which is of type "C") becomes 0.556. Next, we select another random job type, for instance, "C". Then, we generate a random time between 0 and 5, for instance 1.375. This means the arrival time for the second job becomes 1.931 (0.556 + 1.375). Next, we pick a random type for the last job, for instance "A". Finally, we generate a random number between 0 and 5 to determine the arrival time for the last job. Assume 0.698 is generated. This makes the arrival time for the last job 2.629 (1.931 +0.698). The simulate function should return a list of these generated arrival times and job types. Each list member should be a tuple with two values, first the arrival time and second the job type. This function should also print this information in the following format. Each arrival entry should be written in a separate line with arrival time as the first value and job type as the second. The two values should be separated using a comma (,) Next, develop a function called process arrivals that receives the generated arrival times and service times for each job type and determines how long it takes to process all these jobs. This function should accept two parameters, a dictionary of service times and a list of arrivals, which is structured the same as the return value of the "simulate" function. The service times dictionary should be a dictionary, where keys are job types (e.g., "A", "B") and values are associated service times. An example of the service times dictionary (first input parameter) is shown below. {"A": 2, "B": 3, "C": 1} This function should go over all the jobs and find their processing start time considering when the previous job's processing ended. It should process jobs in the order of arrival. For instance, if the processor finishes processing a job at time 10 and the next job had arrived at time 9, its processing will start at time 10. The above example indicates that a job of type "A" takes two-time units to process, type "B" takes 3-time units, and type "C" takes 1 time unit. This function should return a single number, which is the total time it takes to process all these jobs.

Fig: 1