Get startedGet started for free

SimPy package: Types of resources

1. SimPy package: Types of resources

Let's learn the types of resources available in SimPy. Resources are necessary to improve model accuracy and inform business decisions.

2. Types of resources available

SimPy provides three types of resources: resource, container, and store. Let's examine each of these.

3. Types of resources available

The first method is simpy-dot-resource. This helps simulate resources shared between processes. Tables in a restaurant are a limited resource shared between customers. The second method is simpy-dot-container. This helps simulate resources that share homogeneous content between processes, including discrete objects, such as apples, or continuous quantities, such as water. For instance, reservoirs can receive and discharge water but have limited storage capacity. The third method is simpy-dot-store. This is like a container but can store more than one type of object. Supermarkets can stock thousands of different items. Let's use each of these.

4. Method: simpy.Resources()

simpy-dot-resource creates a shared resource with pre-defined capacity. In this example, the capacity is eight, which could be the number of tables in a restaurant. This method is appropriate for controlling the number of processes concurrently using a resource. Processes need to make usage requests to this resource. If all instances of the resource are being used, the request is queued. Once a process releases a resource slot, the pending request ahead in the queue is triggered. Observe how in SimPy, the request is opened with the with-statement and dot-request methods, then yielded. Once a resource becomes available, the second yield is triggered, and the duration of that event is clocked in.

5. Resources: priorities and preemption

A variation of the previous method is simpy-dot-PreemptiveResource. This is helpful in situations where some processes have priority in using a resource. In a factory, a repairman will prioritise fixing machines that break, temporarily suspending all other activities. Requesting usage of a simpy-dot-PreemptiveResource is similar to requests for a general simpy-dot-resource. A request is first opened and then yielded, but additionally, a priority can be assigned to the request. The first example has priority one, while the second has priority two.

6. Method: simpy.Container()

Containers simulate production and consumption of homogeneous, undifferentiated bulk, which can be continuous, like water, or discrete, like apples. Petrol reserves in a gas station are a good example. Customers refueling cars remove petrol, and refilling trucks replenish the reserve. Containers are created with simpy-dot-container, where the tank size and initial conditions are specified. To add and remove content from the container, we use the methods dot-put and dot-get. To obtain the current quantity available, we use dot-level. To get the total tank capacity, we use dot-capacity.

7. Method: simpy.Store()

Finally, the resource provided by dot-store is similar to a container, but it allows storing different types of objects, instead of only one undifferentiated type. Similarly, items can be added or removed using dot-put and dot-get. To obtain the list of items available, we use the dot-items method, and to get the capacity, we have dot-capacity.

8. How can SimPy resources inform business decisions?

How can resources be used to inform business decisions? Let's consider a supermarket with one cashier. The owner might wonder if it is worth investing in more cashiers to reduce waiting time and increase profit. One cashier serves 30 customers in 23-point-7 minutes. We can now run scenarios where we change the number of cashiers available. Results show that the time needed to serve these same 30 customers is greatly reduced as we incrementally add up to three cashiers, where it now takes eight-point-six minutes. However, adding a fourth cashier does not reduce the waiting time. The rate of arrival of customers is now the limiting factor.

9. Let's practice!

Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.