cristiklein / simpy

MIT License
109 stars 16 forks source link

Resource utilization #1

Closed reuschp closed 5 years ago

reuschp commented 6 years ago

Hi there,

I am trying to code some examples with SimPy. I am currently stuck with a monitoring problem.

I just wanted to implement a simple M/M/1 queueing system.

I used a basic simpy resource with capacity=1 and everything seems to run OK. But how do I get the average resource utilization over time? In the documentation there is a comment, that it is very easy and very often required. However I did not find any example for it and am currently out of ideas that would not require pages of code.

Thanks for your support. Pascal

cristiklein commented 6 years ago

Hi,

For average utilization I would do the following.

Each resource should have a variable start_time_utilization and total_time_utilized. When a resource is acquired, start_time_utilization should be set to "now" (simulation time). When a resource is released total_time_utilized should be incremented by now minus start_time_utilization.

The average utilization is total_time_utilized / now, i.e., the total amount of time the resource was utilized divised by the current simulation time.

Hope this helps.

Cheers, Cristian

2018-08-11 18:25 GMT+02:00 reuschp notifications@github.com:

Hi there,

I am trying to code some examples with SimPy. I am currently stuck with a monitoring problem.

I just wanted to implement a simple M/M/1 queueing system.

I used a basic simpy resource with capacity=1 and everything seems to run OK. But how do I get the average resource utilization over time? In the documentation there is a comment, that it is very easy and very often required. However I did not find any example for it and am currently out of ideas that would not require pages of code.

Thanks for your support. Pascal

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cristiklein/simpy/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK .

reuschp commented 6 years ago

Dear Christian,

thanks. I figured it out. At least for resources with capacity = 1 it seems to work fine. For the ones with more than one server, some more coding is necessary.

Based on this utilization problem, I am also struggling with a different problem - which is downtime of the resource.

I want to model statistical machine failures.

I think the interrupts can do the trick. To achieve my machine breakdown, I modeled a separate process. I found some examples to do that in the documentation.

env.process(bad_luck(env, user))

BUT - this connects me to a user/part and not the resource - which results in all kinds of trouble.

If I have a queue full of other processes at this resource, this approach does not work at all. If I interrupt one process, the next one automatically moves up - and the resources keeps working - instead of „breaking down"

Is there any way to interrupt the resource itself - and not the process?

Thanks for any ideas or sample code. Pascal

Am 13.08.2018 um 11:42 schrieb Cristian Klein notifications@github.com:

Hi,

For average utilization I would do the following.

Each resource should have a variable start_time_utilization and total_time_utilized. When a resource is acquired, start_time_utilization should be set to "now" (simulation time). When a resource is released total_time_utilized should be incremented by now minus start_time_utilization.

The average utilization is total_time_utilized / now, i.e., the total amount of time the resource was utilized divised by the current simulation time.

Hope this helps.

Cheers, Cristian

2018-08-11 18:25 GMT+02:00 reuschp notifications@github.com:

Hi there,

I am trying to code some examples with SimPy. I am currently stuck with a monitoring problem.

I just wanted to implement a simple M/M/1 queueing system.

I used a basic simpy resource with capacity=1 and everything seems to run OK. But how do I get the average resource utilization over time? In the documentation there is a comment, that it is very easy and very often required. However I did not find any example for it and am currently out of ideas that would not require pages of code.

Thanks for your support. Pascal

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cristiklein/simpy/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cristiklein/simpy/issues/1#issuecomment-412463898, or mute the thread https://github.com/notifications/unsubscribe-auth/AnhTtXy0N9dW5xP680FkodPdTCiEP9R6ks5uQUoSgaJpZM4V5OXK.

reuschp commented 6 years ago

Dear Christian,

any suggestions regarding modeling the statistical resource breakdown?

Thanks Pascal

Am 14.08.2018 um 17:10 schrieb Pascal Reusch reuschp@gmail.com:

Dear Christian,

thanks. I figured it out. At least for resources with capacity = 1 it seems to work fine. For the ones with more than one server, some more coding is necessary.

Based on this utilization problem, I am also struggling with a different problem - which is downtime of the resource.

I want to model statistical machine failures.

I think the interrupts can do the trick. To achieve my machine breakdown, I modeled a separate process. I found some examples to do that in the documentation.

env.process(bad_luck(env, user))

BUT - this connects me to a user/part and not the resource - which results in all kinds of trouble.

If I have a queue full of other processes at this resource, this approach does not work at all. If I interrupt one process, the next one automatically moves up - and the resources keeps working - instead of „breaking down"

Is there any way to interrupt the resource itself - and not the process?

Thanks for any ideas or sample code. Pascal

Am 13.08.2018 um 11:42 schrieb Cristian Klein <notifications@github.com mailto:notifications@github.com>:

Hi,

For average utilization I would do the following.

Each resource should have a variable start_time_utilization and total_time_utilized. When a resource is acquired, start_time_utilization should be set to "now" (simulation time). When a resource is released total_time_utilized should be incremented by now minus start_time_utilization.

The average utilization is total_time_utilized / now, i.e., the total amount of time the resource was utilized divised by the current simulation time.

Hope this helps.

Cheers, Cristian

2018-08-11 18:25 GMT+02:00 reuschp <notifications@github.com mailto:notifications@github.com>:

Hi there,

I am trying to code some examples with SimPy. I am currently stuck with a monitoring problem.

I just wanted to implement a simple M/M/1 queueing system.

I used a basic simpy resource with capacity=1 and everything seems to run OK. But how do I get the average resource utilization over time? In the documentation there is a comment, that it is very easy and very often required. However I did not find any example for it and am currently out of ideas that would not require pages of code.

Thanks for your support. Pascal

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/cristiklein/simpy/issues/1 https://github.com/cristiklein/simpy/issues/1>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK> .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cristiklein/simpy/issues/1#issuecomment-412463898, or mute the thread https://github.com/notifications/unsubscribe-auth/AnhTtXy0N9dW5xP680FkodPdTCiEP9R6ks5uQUoSgaJpZM4V5OXK.

cristiklein commented 6 years ago

Hi Pascal,

Sorry for my delayed answer.

I would try to model failure as a process that make a PriorityRequest to a PreemptiveResource. If a non-failure process has said resource while the failure takes place, then it would get a Preempted exception.

Have you checked this example: https://simpy.readthedocs.io/en/latest/examples/machine_shop.html

Let me know if it helps.

Regards, Cristian

În lun., 27 aug. 2018 la 09:11, reuschp notifications@github.com a scris:

Dear Christian,

any suggestions regarding modeling the statistical resource breakdown?

Thanks Pascal

Am 14.08.2018 um 17:10 schrieb Pascal Reusch reuschp@gmail.com:

Dear Christian,

thanks. I figured it out. At least for resources with capacity = 1 it seems to work fine. For the ones with more than one server, some more coding is necessary.

Based on this utilization problem, I am also struggling with a different problem - which is downtime of the resource.

I want to model statistical machine failures.

I think the interrupts can do the trick. To achieve my machine breakdown, I modeled a separate process. I found some examples to do that in the documentation.

env.process(bad_luck(env, user))

BUT - this connects me to a user/part and not the resource - which results in all kinds of trouble.

If I have a queue full of other processes at this resource, this approach does not work at all. If I interrupt one process, the next one automatically moves up - and the resources keeps working - instead of „breaking down"

Is there any way to interrupt the resource itself - and not the process?

Thanks for any ideas or sample code. Pascal

Am 13.08.2018 um 11:42 schrieb Cristian Klein <notifications@github.com mailto:notifications@github.com>:

Hi,

For average utilization I would do the following.

Each resource should have a variable start_time_utilization and total_time_utilized. When a resource is acquired, start_time_utilization should be set to "now" (simulation time). When a resource is released total_time_utilized should be incremented by now minus start_time_utilization.

The average utilization is total_time_utilized / now, i.e., the total amount of time the resource was utilized divised by the current simulation time.

Hope this helps.

Cheers, Cristian

2018-08-11 18:25 GMT+02:00 reuschp <notifications@github.com <mailto: notifications@github.com>>:

Hi there,

I am trying to code some examples with SimPy. I am currently stuck with a monitoring problem.

I just wanted to implement a simple M/M/1 queueing system.

I used a basic simpy resource with capacity=1 and everything seems to run OK. But how do I get the average resource utilization over time? In the documentation there is a comment, that it is very easy and very often required. However I did not find any example for it and am currently out of ideas that would not require pages of code.

Thanks for your support. Pascal

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/cristiklein/simpy/issues/1 < https://github.com/cristiklein/simpy/issues/1>>, or mute the thread < https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK < https://github.com/notifications/unsubscribe-auth/ABlXodag4kQ_GAl9XkwuPuaC_0iZbXhfks5uPwV_gaJpZM4V5OXK

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/cristiklein/simpy/issues/1#issuecomment-412463898>, or mute the thread < https://github.com/notifications/unsubscribe-auth/AnhTtXy0N9dW5xP680FkodPdTCiEP9R6ks5uQUoSgaJpZM4V5OXK .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cristiklein/simpy/issues/1#issuecomment-416135941, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlXoWIvZqY4N8RIJLxdiLuu2dwQ48o5ks5uU5u4gaJpZM4V5OXK .