Simulating a Production Line

I’m trying to simulate a DVD production line in Java. The thing I have a problem with is the calculation of the time in this kind of simulation and the number of DVDs per hour.

The production line consists of 4 machines, each of which spends a certain random time working on 1 DVD. The third one can work on more than 1 DVD at the same time (max. 100). Also, the third one will always accept more DVDs to work on, as long it’s capacity is < 50%, which I plan to label as m3Capacity. But for now, let’s just ignore the capacity characteristic.

What I have so far is that, with a random number generator (since each machine has random DVD processing time each time it starts working on a new DVD), I assigned a random processing time to each of the four machines, summed up their processing times for the total time spent in one-go production (totalProdTime = processTime1 + processTime2 + processTime3 + processTime4), and then I keep summing up those totalProdTime values until the total time of the whole simulation reaches the desired duration of the simulation specified by the user (totalProdTimeSim = totalProdTimeSim + mTotal.totalProdTime). Later I just verify whether the totalProdTimeSim has reached the desired time and that’s it.

Now, the problem is that, this way, the production of the DVDs waits for one instance of production to finish all the way until the very end of the machine 4, and then the work begins on the second DVD, etc. What I want to do is that after machine 1 finishes it’s work, and the second one begins its work, machine 1 begins work on another DVD with it’s newly generated time. The same goes for all other machines. After machine 2 finishes work on a DVD, it immediately begins working on another DVD.

Now, since all machines have random processing times each time they start working on another DVD, it will often happen that one machine ‘wants to work on another DVD’ while the previous one hasn’t finished its work on the current one. In this case, the idle machine just ‘waits’ for the previous machine to finish processing and then accepts the DVD from the previous machine.

So, in my example, we have that all the machines work one by one, but I want them all to work constantly, even after they finish working on the current DVD (except in the first iteration, where the further machines need to wait for the previous ones to forward them their DVD they previously worked on).

How do you think I should calculate the total simulation time and DVD output? I’ve been thinking last night about it, but haven’t gotten any ideas.

My sketch of how it should work can be found in the picture below. In the sketch all machines behave as if they constantly have something to work on, but should wait from the input from the previous machine.

Sample sketch

Thanks in advance!

1

An odd question, and I’m not really sure it fits here… Here is a brute-force approach.

If I were to write code to solve this, I would create a ProductionLine class that contains a list of Machine-objects, along with a DiskOuput counter. The ProductionLine-class would have a method (‘timePasses’) you can call to simulate the passing of time, say 1-second increments. This would in turn call onto the Machine-objects who would also have a timePasses method. The Machine knows how many calls of timePasses are needed before it finishes wirting a disk (the random amount of seconds). When a Machine finishes writing a disk, the timePasses object would return a value to indicate a disk was finished. The Machine would then reset the random number of seconds needed to write a disk and start over. The ProductionLine class knows that when timePasses returns a value, the DiskOuput counter should be incremented because a disk was finished.

You now have an application where all machines start at the same time. You can run this with a loop until a certain amount of time passes or until DiskOuput reaches a certain value.

Now, to make your machines dependent on the first disk… Your ProductionLine would have a list of Machines (the ‘pool’ of available machines in the line) and a list of RunningMachines (that are currently producing something). You would only call timePasses on running machines. When you call timePasses on ProductionLine the first time it would take a Machine from the pool, put in onto RunningMachines and call timePasses on it. Every time a call to timePasses on a Machine indicates that a new disk is ready, the ProductionLine could check if additional machines are available and if so, put them onto the RunningMachines-list and start working with it.

What you are looking for is called Discrete Event Simulation. There are multiple libraries you can use to help you.

Your situation is almost textbook example of this kind of simulation. Each of the lines is an “agent”, that when it receives a DVD, it picks a random time it will take to process and asks the system to “notify it” (creates an event) when that time comes. When the system notifies the line, it will mark current DVD as processed, passes it to next line and picks next one. Each of those lines (or agents) is independent and behaves almost like a separate “thread”. The system is then responsible to “progress the time” by picking next event in the queue and executing it. You can then repeat this simulation multiple time with different parameters or different random times to get some stochastic metrics about the system.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Simulating a Production Line

I’m trying to simulate a DVD production line in Java. The thing I have a problem with is the calculation of the time in this kind of simulation and the number of DVDs per hour.

The production line consists of 4 machines, each of which spends a certain random time working on 1 DVD. The third one can work on more than 1 DVD at the same time (max. 100). Also, the third one will always accept more DVDs to work on, as long it’s capacity is < 50%, which I plan to label as m3Capacity. But for now, let’s just ignore the capacity characteristic.

What I have so far is that, with a random number generator (since each machine has random DVD processing time each time it starts working on a new DVD), I assigned a random processing time to each of the four machines, summed up their processing times for the total time spent in one-go production (totalProdTime = processTime1 + processTime2 + processTime3 + processTime4), and then I keep summing up those totalProdTime values until the total time of the whole simulation reaches the desired duration of the simulation specified by the user (totalProdTimeSim = totalProdTimeSim + mTotal.totalProdTime). Later I just verify whether the totalProdTimeSim has reached the desired time and that’s it.

Now, the problem is that, this way, the production of the DVDs waits for one instance of production to finish all the way until the very end of the machine 4, and then the work begins on the second DVD, etc. What I want to do is that after machine 1 finishes it’s work, and the second one begins its work, machine 1 begins work on another DVD with it’s newly generated time. The same goes for all other machines. After machine 2 finishes work on a DVD, it immediately begins working on another DVD.

Now, since all machines have random processing times each time they start working on another DVD, it will often happen that one machine ‘wants to work on another DVD’ while the previous one hasn’t finished its work on the current one. In this case, the idle machine just ‘waits’ for the previous machine to finish processing and then accepts the DVD from the previous machine.

So, in my example, we have that all the machines work one by one, but I want them all to work constantly, even after they finish working on the current DVD (except in the first iteration, where the further machines need to wait for the previous ones to forward them their DVD they previously worked on).

How do you think I should calculate the total simulation time and DVD output? I’ve been thinking last night about it, but haven’t gotten any ideas.

My sketch of how it should work can be found in the picture below. In the sketch all machines behave as if they constantly have something to work on, but should wait from the input from the previous machine.

Sample sketch

Thanks in advance!

1

An odd question, and I’m not really sure it fits here… Here is a brute-force approach.

If I were to write code to solve this, I would create a ProductionLine class that contains a list of Machine-objects, along with a DiskOuput counter. The ProductionLine-class would have a method (‘timePasses’) you can call to simulate the passing of time, say 1-second increments. This would in turn call onto the Machine-objects who would also have a timePasses method. The Machine knows how many calls of timePasses are needed before it finishes wirting a disk (the random amount of seconds). When a Machine finishes writing a disk, the timePasses object would return a value to indicate a disk was finished. The Machine would then reset the random number of seconds needed to write a disk and start over. The ProductionLine class knows that when timePasses returns a value, the DiskOuput counter should be incremented because a disk was finished.

You now have an application where all machines start at the same time. You can run this with a loop until a certain amount of time passes or until DiskOuput reaches a certain value.

Now, to make your machines dependent on the first disk… Your ProductionLine would have a list of Machines (the ‘pool’ of available machines in the line) and a list of RunningMachines (that are currently producing something). You would only call timePasses on running machines. When you call timePasses on ProductionLine the first time it would take a Machine from the pool, put in onto RunningMachines and call timePasses on it. Every time a call to timePasses on a Machine indicates that a new disk is ready, the ProductionLine could check if additional machines are available and if so, put them onto the RunningMachines-list and start working with it.

What you are looking for is called Discrete Event Simulation. There are multiple libraries you can use to help you.

Your situation is almost textbook example of this kind of simulation. Each of the lines is an “agent”, that when it receives a DVD, it picks a random time it will take to process and asks the system to “notify it” (creates an event) when that time comes. When the system notifies the line, it will mark current DVD as processed, passes it to next line and picks next one. Each of those lines (or agents) is independent and behaves almost like a separate “thread”. The system is then responsible to “progress the time” by picking next event in the queue and executing it. You can then repeat this simulation multiple time with different parameters or different random times to get some stochastic metrics about the system.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật