None Notebook

This notebook contains material from cbe30338-2021; content is available on Github.

< 7.1 Introduction to Simpy | Contents | Tag Index | 7.3 Chemotaxis >

Open in Colab

Download

7.2 Agent Based Models

7.2.1 Simpy: What we have learned so far

What we will learn in this unit:

7.2.2 3.3.2 Example: A room full of Roombas

Let's imagine a large facility that is being cleaned by a collection of Roomba-type robotic cleaning units. Each unit is characterized by time required to charge, and an amount of time it can clean before needing to be recharged. The facility must be cleaned during a 16 hour overnight shift. On average, 3 units must be operating continuously to meet the cleaning requirements, i.e., 3 x 16 = 48 hours machine cleaning each night. We would like to determine how many charging stations will be required.

Unit Charge Time (hrs) Clean Time (hrs)
A 1.0 2.5
B 0.5 1.5
C 0.8 2.0
D 1.4 3.5
E 0.5 1.2
F 1.0 3.0

roomba

7.2.3 One Roomba

The first challenge is to model the performance of a single Roomba. Our first attempt at a model consists of a simple Python generator. The data log consists of start and finish of each charge and cleaning cycle. For this first attempt, we'll assume a charging station is always available when needed, and we'll create just one instance of a Roomba to get started.

7.2.4 Processing the data log with Pandas

7.2.4.1 Convert nested list to a Pandas Dataframe

7.2.4.2 Aggregating data with pivot tables

Among the many great reasons to use a Pandas dataframe for manipulating data are pivot tables. Pivot tables aggregate data using labels that appear in selected columns. In this case, we seek to aggregate data using labels appearing in the "id" and "activity" columns. The type of aggregation is to sum entries appearing in the "time".

7.2.5 Adding the full complement of Roombas

The next step is to include all of the available Roombas to the simulation. We do this by looping over the data set that describes the available devices. For each interation, an instance of the Roomba model is created and an associated process added to the simulation environment.


Study Question: Change the pivot table to report total time spent charging and cleaning. The warehouse requires 48 hours of cleaning time. Is this requirement satisfied?

Study Question: Demonstrate that the warehouse requirements can be met by one less Roomba.


7.2.5.1 Gantt Charts

Create a function that accepts df (the data log after converting to a pandas DataFrame) and, for every Roomba, shows a time line of events.

7.2.6 Charging stations as shared resources

A charging station is an example of a shared resource. There are three types of resources that can be modeled in Simpy:

In this example, charging stations are an example of Resources.

The next cell shows how a charging station can be incorporated into the simulation as a shared resource. Three changes required:

The following cell implements charger system with a capacity of 1. Examine the data log to verify that only one Roomba is charging at any point in time.

7.2.7 How many charging stations are required?

The following cell uses the Python with statement to request a changer and release it upon completion of a code block. The advantage of this construction is that it handles the release automatically, thereby avoiding a potential source of coding errors, and also provides a visual demarcation of the code block where the charger is being use.

The cell also uses the Pandas pivot_table to report the total amount of charging used and cleaning time provided. Find the minimum number of chargers required to produce 48 hours of cleaning time in a 16 hour shift.


Study Question: Rerun the simulation to determine the minimum number of chargers required to meet the requirement for 48 hours of cleaning in a 16 hour shift.

Study Question: Modify the model to assume the changers are not charged at the start of the cleaning shift. Does that change the number of chargers required to meet the cleaning requirement?

Study Question: Assume each Roomba needs to dispose of waste after 20 minutes of cleaning, that it takes 5 minutes to dispose of the waste, and requires access to a waste disposal station.

Hints:


7.2.8 Adding a reporter process

< 7.1 Introduction to Simpy | Contents | Tag Index | 7.3 Chemotaxis >

Open in Colab

Download