Modeling is the process of producing a model which is a representation of the construction and working of some system of interest. Simulation is used before an existing system is altered or a new system built, to reduce the chances of failure to meet specifications, to eliminate unforeseen bottlenecks, to prevent under or over-utilization of resources, and to optimize system performance.
In this article, we are going to learn the following :
- What is Simulation Modelling
- Benefits of having Simulation Modelling
- Elements of Simulation Analysis
- An Use Case: A Hospital ward Bed Occupancy Model.
- Implementation of the Use Case with Python code
- Limitations of Simulation Modelling.
- What is Data Modelling?
- Limitations of Data Modelling.
- Why is Simulation Modelling along with Data Science?
So let’s start..
What is Simulation Modelling?
Simulation Modeling is the process of creating and analyzing a digital prototype of a physical model to predict its performance in the real world, which helps the designers and engineers understand whether, under what conditions, and in which ways a part of the system could fail and what loads it can withstand. Simulation Modelling, provides valuable solutions by giving clear insights into complex systems, across industries and disciplines, simulation modelling. It is a physics-based simulation modeling is more classical, but powerful, approach to represent causal relationships between a set of controlled inputs and corresponding outputs.
Benefits of having Simulation Modelling
- Risk-free Environment: Simulation modeling provides to explore different “what-if” scenarios. The effect of changing bed capacity levels in a hospital (Please refer the Use Case) may be seen without putting production at risk, which helps to make the right decision before making real-world changes. Mathematical model built using historical data of a Healthcare system, enables a prospective analysis of the pressures on the system if the current trends continue into the future. The results can help you to understand and plan for scenarios that would place significant pressure on healthcare systems. For example, if there was a significant flu outbreak, some parameters can be predicted that can be added into a model to help understand the impact on service delivery. As well as extra demand for services, a flu outbreak would also affect healthcare staff, so the supply of services would also be affected. These are useful if we are considering making long term or significant changes, the impact of which can be difficult to predict. Before, we initiate change, it will help us to plan and implement more effective service improvements. They can also enable us to understand what the demand for services may be like in the future, to ensure that any service developments are ‘future proofed’.
- Save Money and Time: Virtual experiments with simulation models are less expensive and take less time than experiments with real assets.
- Increased accuracy: A simulation model can capture many more details than an analytical model, providing increased accuracy and more precise forecasting.
- Visualization: Simulation models concepts and ideas to be more easily verified, communicated, and understood using various kinds of 2D/3D visualizations. Analysts gain trust in a model by visualizing it in action and can clearly demonstrate findings to management.
- Handle uncertainty: Uncertainty in operation times and outcome can be easily represented in simulation models, allowing risk quantification, and for more robust solutions to be found.
Elements of Simulation Analysis
Following are the basic elements of Simulation Analysis:
- Problem Formulation
- Data Collection and Analysis
- Model development
- Model Verification and Validation
- Model Experimentation and Optimization
- Implementation of Simulation Results
Use Case: A Hospital ward Bed Occupancy Model.
Problem Statement: Bed management has been an issue from the evolution of hospitals, but due to the increasing demand it has become more critical and have become an important criterion in delivering quality and cost effective health service, which needs a Bed Management team. So, how do they manage this?
Data Collection and Analysis : Patient Arrival Rate, that is the rate at which Patients arrive to a hospital, which we can get with the time between any two patients sampled from an exponential distribution. Length of stay in the hospital is again sampled from an exponential distribution. We assume here that the hospital ward can expand to cope with peaks in demand, and use the model to look at the expected natural variation in ward bed occupancy.
It is a Goal orientated task. The goals of bed management involve access to an appropriate bed to each patient in a timely way and reduction in number of patients that are turned away and directed to another facility due to lack of an available bed. There are numerous benefits of bed management including customer satisfaction, increased profits, forecasting capacity, and increased level of care. Hospitals must focus on reliability, accuracy, and customer level of care to be competitive and profitable, a key method to accomplish this is by continuously improving their bed management system. Complexity in planning is rising due to the increased day to-day variations in demand and insufficient resources.
If we go little back to understand Goal Programming, then we can say that this is a type of Linear Programming, which is important and useful for the problems related to optimization. We optimize a scenario built upon a number of constraints which administer that situation.
So, there are many kinds of techniques used to build such kind of models, which is not out topic of discussion in this blog. What we will discuss is that how we will simulate the model, once it is built.
Model Development with Python code
In Python, simpy library provides event simulation.
There are three steps to run a simulation in Python:
- Establish the environment: env = simpy.Environment()
- Pass in the parameters: env.process(checkpoint_run(env, num_booths, check_time, passenger_arrival))
- Run the simulation: env.run(until=10)
Once we have our environment established, we’ll pass in all of the variables that will act as our parameters. These are the things we can vary to see how the system will react to changes.
Download the code here
Step 1: Importing all the required libraries.
SimPy is a process-based discrete-event simulation framework based on standard Python.
Step 2: We will store global variables in a class ‘g’. All the global variables are declared with required comments
Step 3: Second Class: ‘Hospital’ contains methods for audit of beds occupied, summarizing audit (at end of run), and plotting bed occupancy over time (at end of run).
Constructor method for hospital class. Initialize object with attributes.
Audit method. When called appends current simulation time to audit_time list, and appends current bed count to audit_beds.
This method is called at end of run. It creates a pandas DataFrame, transfers audit times and bed counts to the DataFrame, and
calculates/stores 5th, 50th and 95th percentiles.
This method is called at end of run. It plots beds occupancy over the model run, with 5%, 50% and 95% percentiles.
Plotting the occupied Beds
Plot the Queue of beds
Third Class: ‘Model’ contains the model environment. The modelling environment is set up, and patient arrival and audit processes initiated. Patient arrival triggers a spell for that patient in hospital. Arrivals and audit continue fort he duration of the model run. The audit is then summarized and bed occupancy, and number of people waiting for beds (with 5th, 50th and 95th percentiles) plotted.
Constructor class for new model.
Bed audit process. Begins by applying delay, then calls for audit at
intervals set in g.audit_interval :param delay: delay (days) at start of model run for model warm-up.
New admissions to hospital. :param interarrival_time: average time (days) between arrivals :param los: average length of stay (days)
Controls the main model run. Initializes model and patient arrival and audit processes. Instigates the run. At end of run calls for an audit summary and bed occupancy plot.
Patient hospital stay generator. Increment bed count, wait for patient length of stay to complete, then decrement bed count and remove patient from hospital patient dictionary. :param p: patient object (contains length of stay for patient)
Third Class: ‘Patient’ is the template for all patients generated (each new patient arrival creates a new patient object). The patient object contains patient id and length of stay.
Fourth Class:’Resources’ holds the beds resource (it could also hold other resources, such as doctors)
Fifth Class: ‘Main’ Creates model object, and runs model
Observation: Model displays the the percentiles of ‘Occupied Beds’ and ‘Queued Beds’, which helps to determine how many beds shall be put in queue in order to meet the patient’s demand and in this way, the entire system can be optimized.
Limitations of Simulation Modelling
Simulation modeling is a theory-based modeling approach, which uses physical or operational laws. Because the theory means a statement of what causes what and why, it is possible to represent clearly the causality between a set of controlled inputs and the corresponding outputs of the system which contradicts the data-modeling approach. Simulation-modeling approach is based on the prior knowledge of the target system, and its completion depends on how much we can understand about the system. Hence it cannot alone be a perfect solution for our problem.
What is Data Modelling
Big data has received greater attention in diverse research fields, where , the concept of modeling with data, has been referred to as data modeling, which has focused on representing correlations of data. Such an approach has been classified and studied in two ways: data mining and machine learning.
Data Modeling consists of a steps of processes: Data Acquisition, Modeling, Validation, and Prediction. However, data modeling is not always a powerful modeling approach. It has some limitations.
Limitations of Data Modelling
- One of the representative limitations is that it is able to just describe correlations between data, not represent causal relationships between controlled inputs and corresponding outputs. It cannot cope with anomalies and changing circumstances of the system. It can also be influenced by how much data we have of the target system.
- Prediction under changed environment, is difficult for a Data Model.
- Another limitation of the data model is that it cannot cope with unexpected events. In a real system, unexpected events, such as a rare event with a very low probability of occurrence, may occur due to its high complexity and uncertainty. Usually, a data set does not include these events, considering as outliers. When the event happens, the data model subordinated to the data set cannot predict the result of the unexpected events precisely.
To overcome such limitations of data modeling, it is necessary to use another approach through simulation modeling.
To sum up, each modeling approach has its advantages and disadvantages.
Why is Simulation Modelling along with Data Science?
To mitigate the disadvantages of both the modelling approaches, a new modeling method is required, that employs advantages of both data modeling and simulation modelling.
Analytics is of 3 types:
- Descriptive Analytics: Provides the insight of the current data pattern.
- Predictive Analytics: Provides a predictive outcome.
- Prescriptive Analytics: Provides discernment of how we can make things happen.
If we consider the last one: Prescriptive Analytics, then we can say that data set and data model can be used in the descriptive and predictive analysis, respectively, but cannot be used for the prescriptive analysis due to lack of causality. So, here, the role of Simulation Modelling comes into picture.
A Data Mining and Machine Learning model shall be built with correlation between and shall be fed to the Simulation Model, which shall contain the Causal relationship between the cause and effect, which is called Prescriptive Modelling, in combined.
In this post, we learnt about Simulation Modelling, Data Modelling and there respective benefits and Limitations. We learnt, Simulation Modelling for Bed Occupancy Model. We designed an overview of Data Flow and System Architecture of Prescriptive Modelling system.
Happy Learning…See you in my next blog. Till then, Stay Tuned!