Object-Oriented simulation of population dynamics

조회 수: 3 (최근 30일)
Munzir Mohamed
Munzir Mohamed 2022년 1월 8일
답변: Noah Prisament 2023년 11월 30일
Hello everyone,
I want to simulate a population infection process where I have many stationary devices that can infect one another if they become infected themselves. I think the most convenient way is using object-oriented programming. I know how to create the class "device" and create objects and initialize their needed properties (e.g. location and status). I have good idea about how to create the methods of infection/curing.
first thing I want to know is how to simultaneously have all the infection & curing processes of different devices at different locations happening at the same time. so I dont want to do it by time slots where at each time slot I go through all the devices one by one and execute commands.
second thing, each devices can cure itself if it wants to but at the cost of becoming offline and this process takes time. Also when a device wants to infect another device, it takes time. the two durations are different but the important thing I dont want to make these processes happening instantly. is the best way to do that by having a global time clock as a refrence?
I'd highly appreciate any help.
best regards

답변 (2개)

Shivam
Shivam 2023년 11월 29일
Hi,
As per my understanding, you want to simultaneously simulate the infection and curing process of different devices. You also want to understand if implementing a global time reference ensures non-instantaneous processes for the actions of both devices.
It is essential to know that since these devices are running in "real-time," some prioritization algorithm or multi-threading will be required as a single thread won't be able to manage each device synchronously.
For prioritization algorithm, it is similar to the problem of CPU task processing. One solution is Discrete Event Simulation, where all the devices are put in a specific order (Priority Queue) where each event will have an associated time, and the priority of each device's processing can be decided based on this time.
The other approach is to have an inherently asynchronous simulation with mutex-controlled data sharing and control each device in a separate thread. This approach would utilize the Parallel Computing Toolbox.
Also, using a global time clock as a reference is a good approach. You can create a global time variable that keeps track of the overall simulation time. Each device can then use this global time to determine when to start and finish its infection or curing process.
Please refer to the following documentation to know more about the Prioritization Algorithms and the Parallel Computing Toolbox:
I hope it helps.

Noah Prisament
Noah Prisament 2023년 11월 30일
Hi Munzir, since you are looking to model population infection of a disease, an alternative to a "real-time" approach is a simulated approach that utilizes arbitrary time-steps. An example of this type of approach is a graph-theoretic SEIR (Susceptible-Exposed-Infectious-Removed) model that uses an interaction graph approach to modelling disease spread. This graph can be arbitrary, based on real world data or generated to simulate real world properties such as small-world or hub characteristics (see Watts-Strogatz or Barabasi-Albert). MathWorks has an example that demonstrates this type of modelling here: https://www.mathworks.com/matlabcentral/fileexchange/106400-modeling-disease-spread-using-an-seir-model.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by