Object-Oriented simulation of population dynamics

4 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by