Giter Club home page Giter Club logo

dots-virus-simulation's Introduction

Infectious disease simulator with Unity DOTS

INTRODUCTION

2D simulation of a configurable viral pandemic developed under Unity 2019 ECS DOTS Environment. Each entity replicates the human behaviour, characterized by some primary basic needs such as going to work, at home to rest, to the grocery shop but also social needs like need for a run in a park or visiting friends. The purpose of the project is to simulate the trend of a viral infection enhancing the parallelism provided by ECS: many entities are spawn at the beginning, the majority is non-infected. The intention is to show how a potential viral infection can spread among the population of entities according both to viral parameters but also on entities behaviour.

ENTITIES

  • Humans are represented with a 2d sprite symbol.

  • The color of the symbol changes with the “infection state” in which the human is.

alt text

  • The simulation follows the SEIRS model, it means that the contagion follow a state machine of the kind:
    • S susceptible
    • E exposed
    • I infected, modeled as Symptomatic and Asymptomatic
    • R recovered or removed, the entity may also die
    • S susceptible, after some time after recovery, an entity may be infected again

alt text

  • Humans movement based on pathfinding in order to satisfy needs, each time a human needs to satisfy a demand, the pathfinding algorithm drives the human to the closest place where to satisfy the necessity:

_ Home Park Pub* Supermarket Office
Fatigue X
Hunger X X
Sportivity X
Sociality X* X X
Grocery X
Work X

The Home in the Sociality need is not the Human home, in order to simulate visit to friends. If the lockdown setting is True, all needs increase more slowly and are correlated to the human social responsibility. Furthermore, the Pubs are closed.

Needs are set in order to reproduce a normal behavior:

  • Fatigue: Human rest for 8 hours, need restored after 16 hours from fulfillment;
  • Hunger: Human eat for 1 hour three times each day
  • Sportivity: Human does 1.5 hours of sport every two days
  • Sociality: Human does 2 hours of sociality each day
  • Grocery: Human goes to the supermarket for one hour once every 3 days
  • Work: Human goes to work for 8 hourse every day

MAP

The map is implemented using a tilemap file as input, specified in the configuration file. Each sprite model a specific city element:

alt text

CONTAGION

Contagion probability based formula that keeps into account several parameters such as:

  • Distance, 2 meters is the value of risk
  • Time, 15 minutes are enough to make infection happen
  • Social Responsibility (that represents several factors about social behaviours during a pandemic, mainly mask usage and social distancing)

HOW TO CONFIGURE THE SIMULATION

./Conf/conf.json is the configuration file, the user can set up many parameters for modeling the simulation, such as

  • number of humans i.e. population
  • number of initial infects
  • time scale i.e. speed-up time factor
  • probability of death
  • length (among min and max value) of every state of infection
  • map to use (see folder ./Conf/Maps)
  • lockdown, set to true to see an implementation of a partial lockdown

PERFORMANCES

For avoiding main memory bottleneck, we suggest to execute the simulation with at least 16 GB DRAM and the following parameters less than a cap value:

  • numberOfHumans at most 250k-300k
  • timeScale at most 60

HOW TO USE

  • Upper right corner shows stats
  • Key "Q" -> Zoom In
  • Key "E" -> Zoom Out
  • W-A-S-D for xy movement on the map

SIMULATION STATISTICS

No restriction simulation example:

alt text

Lockdown simulation example: alt text

dots-virus-simulation's People

Contributors

lucarinelli avatar vina97 avatar

Stargazers

Grigorij Matuhov avatar

Watchers

James Cloos avatar  avatar Pietro Oricco avatar

dots-virus-simulation's Issues

skin swap

  • The skin change is triggered by adding the InfectionComponent to the entity

  • It is not done in the most performant way (no burst, fault of unity devs, will be available in the future...), if in the future this becomes a bottleneck we will need to change this

Path finding

  • PathfindingParams component causes path calculation that triggers pathfollow
  • Make start "non road cell" and arrival "non road cell" walkable for each path

Improve UnitMoveOrderSystem performance

HumanSystem.cs ->
Monitorare i parametri per identificare un need,
quando identifica un need fa
AddComponent
AddComponent
remove NeedComponent when threshold...

UnitMoveOrderSystem.cs (MoveToNeedSystem.cs) ->
Agisce solo sulle entity che hanno un NeedComponent
chiama path finding
remove SearchNeedComponent

Contagion logic

Proposta: se distanza tra entità < parametro minima distanza per avere contagio aggiungi componente con counter che si incrementa a ogni frame se la distanza da tizio contagiato rimane < threshold_distanza (threshold_distanza inizializzato random tra min e max parametrizzati); se counter > threshold_time (che può variare in base ad età, difese immunitarie, mascherina, ecc) entità diventa infetta.
Se distanza > threshold distanza e il counter non supera la soglia contagio, si resetta a 0/diminuisce col tempo.

  • Misurare distanza tra più entità? Struttura dati accessibile per celle e neighbors
  • Parametri sono
    • threshold distanza
    • threshold tempo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.