# WirVsVirus 2020 hackathon participation

**URL:** <https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575>\
**Category:** Staff Picks\
**Tags:** biological-sciences, data-science, medical-sciences, operations-research, graphs-and-networks, modeling, statistics-and-probability, geography, staff-pick, living-systems\
**Created:** [March 24, 2020, 9:59pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575 "2020-03-24T21:59:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [March 24, 2020, 9:59pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/1 "2020-03-24T21:59:30Z")

</div>

# Introduction

Last weekend – 2020-03-20 ÷ 2020-03-22 – I participated in [the (Germany-centric) hackathon WirVsVirus](https://wirvsvirushackathon.org). (I friend of mine who lives in Germany asked me to team up and sign up. Participated together with Balint Badonfai and Diego Zviovich.)

[Our idea proposal](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/org/WirVsVirus-Hackathon-work-plan.org) was accepted, [listed in the dedicated overview table (see item 806)](https://airtable.com/shrs71ccUVKyvLlUA/tbl6Br4W3IyPGk1jt/viw7AlEju6qFtXJqL?blocks=hide). The title of our hackathon project is:

**“Geo-spatial-temporal Economic Model for COVID-19 Propagation and Management in Germany”**

[Nearly a dozen of people enlisted to help](https://devpost.com/software/geo-raumlich-zeitliches-wirtschaftsmodell-fur-covid-19). (We communicated through Slack.)

```mathematica
WebImage["https://devpost.com/software/geo-raumlich-zeitliches-\
wirtschaftsmodell-fur-covid-19"]

```

 ![13dzfagts8105](https://global.discourse-cdn.com/wolfram/original/3X/0/a/0a2df8e165204f0c9620c99893bb038dd60fb847.png)

Multiple people helped with the discussion of ideas, directions where to find data, with actual data gathering, and related documented analysis. Of course, just discussing the proposed solutions was already a great help!

# What was accomplished

## Work plans

The following mind-map reflects pretty well what was planned and done:

 ![15n5cjaej10q8](https://global.discourse-cdn.com/wolfram/original/3X/7/8/78ed1ad7cb7a86fae68ff6312a6a23a30654c4f2.png)

There is also a related [org-mode file with the work plan](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/org/WirVsVirus-Hackathon-work-plan.org).

## Data

I obtained Germany city data with Mathematica’s build-in functions and used it to heuristically derive a traveling patterns graph, [AA1].

Here is the data:

```mathematica
dsCityRecords = 
  ResourceFunction["ImportCSVToDataset"][
 "https://raw.githubusercontent.com/antononcube/SystemModeling/master/Data/dfGermanyCityRecords.csv"];
Dimensions[dsCityRecords]

(*{12538, 6}*)

```

Here is Geo-histogram of that data:

```mathematica
cellRadius = Quantity[70, "Kilometers"];
aCoordsToPopulations = AssociationThread[Values /@ Normal[dsCityRecords[All, {"Lat", "Lon"}]], Normal[dsCityRecords[All, "Population"]]];
GeoHistogram[aCoordsToPopulations, cellRadius, ColorFunction -> (Opacity[#, Blue] &), PlotLegends -> Automatic]

```

 ![0t08vw1kjdzbc](https://global.discourse-cdn.com/wolfram/original/3X/e/1/e108a58ec35a80fba93fa503fabf931ddfade461.jpeg)

We considered a fair amount of other data. But because of the time limitations of the hackathon we had to use only the one above.

## Single-site models

During the development phase I used the model SEI2R, but since we wanted to have a “geo-spatial-temporal epidemiological economics model” I productized the implementation of SEI2HR-Econ, [AAp1].

Here are the stocks, rates, and equations of SEI2HR-Econ:

```mathematica
Magnify[ModelGridTableForm[SEI2HREconModel[t]], 0.85]

```

 ![0tbp6de6zdez0](https://global.discourse-cdn.com/wolfram/original/3X/b/a/ba46fba1d5164b0eccfb9acb3d6179ce9c3ad82d.png)

## Multi-site SEI2R (SEI2HR-Econ) over a hexagonal grid graph

I managed to follow through with a large part of [the work plan for the hackathon](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/org/WirVsVirus-hackathon-Geo-spatial-temporal-model-mind-map.pdf) and make multi-site scaled model that “follows the money”, [[AA1](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/Documents/WirVsVirus-hackathon-Multi-site-SEI2R-over-a-hexagonal-grid-graph.md)]. Here is a diagram that shows the travelling patterns graph and solutions at one of the nodes:

 ![1vnygv6t7chgg](https://global.discourse-cdn.com/wolfram/original/3X/8/6/86413bc566ddf467b2786acd8c778b046815482b.jpeg)

Here is an interactive interface for studying and investigating the solution results:

 ![1pgmngb4uyuzb](https://global.discourse-cdn.com/wolfram/original/3X/9/d/9dae4613dfdebf66de0f5c4c5c285f0e2da94391.png)

For more details see the notebook [[AA1](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/Documents/WirVsVirus-hackathon-Multi-site-SEI2R-over-a-hexagonal-grid-graph.md)]. Different parameters can be set in the “Parameters” section. Especially of interest are the quarantine related parameters: start, duration, effect on contact rates and traffic patterns.

I also put simulations results code and programmed visualization routines in R, [AA2]. (In order other members of team to be able to explore the results.)

# References

[DP1] [47\_wirtschaftliche Auswirkung\_Geo-spatial-temp-econ-modell](https://devpost.com/software/geo-raumlich-zeitliches-wirtschaftsmodell-fur-covid-19), DevPost.

[WRI1] Wolfram Research, Inc., [Germany city data records](https://github.com/antononcube/SystemModeling/blob/master/Data/dfGermanyCityRecords.csv), (2020), [SystemModeling at GitHub](https://github.com/antononcube/SystemModeling).

[AA1] Anton Antonov, [“WirVsVirus hackathon multi-site SEI2R over a hexagonal grid graph”](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/Documents/WirVsVirus-hackathon-Multi-site-SEI2R-over-a-hexagonal-grid-graph.md), (2020), [SystemModeling at GitHub](https://github.com/antononcube/SystemModeling).

[AA2] Anton Antonov, [“WirVsVirus-Hackathon in R”](https://github.com/antononcube/SystemModeling/tree/master/Projects/Coronavirus-propagation-dynamics/R/WirVsVirus-Hackathon), (2020), [SystemModeling at GitHub](https://github.com/antononcube/SystemModeling).

[AAp1] Anton Antonov, [“Epidemiology models Mathematica package”](https://github.com/antononcube/SystemModeling/blob/master/Projects/Coronavirus-propagation-dynamics/WL/EpidemiologyModels.m), (2020), [SystemsModeling at GitHub](https://github.com/antononcube/SystemModeling).

[WirVsVirus-hackathon-Multi-site-SEI2R-over-a-hexagonal-grid-graph.nb](https://community.wolfram.com/uploads/short-url/vsev7zvsuBwvgCIxmZZkZeFragz.nb) (168 KB)

---

<div class="post-metadata">

**Author:** ![roellig](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/roellig/32/5423_2.png) [@roellig](https://community.wolfram.com/u/roellig)\
**Post date:** [March 25, 2020, 2:28pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/2 "2020-03-25T14:28:09Z")

</div>

Absolute amazing work! Thanks for sharing.  
The animation shows a second wave of infected people. Is that because of a relaxation in quaratine/travel bans?

Ideas:

- we could add non-constant number of hospital beds. Do we have the data geometry-wise?
- it would be nice to overlay the real-data on the individual cell predictions
- tooltips with the area identifier (city/region/Landkreis) would be neat)

---

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [March 25, 2020, 3:25pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/3 "2020-03-25T15:25:27Z")

</div>

Thanks for your comments, Markus!

> we could add non-constant number of hospital beds. Do we have the data geometry-wise?

Yes, that is the most important “next task” in my opinion. And Germany’s governmental sites provide very good, detailed information about hospital beds and workers. (One of our team members, who lives in Germany, demonstrated that to us.)

> it would be nice to overlay the real-data on the individual cell predictions

Calibration is important, and it is a lot of work. At this point I want to make a better simulation tool, not (personally) spent that much time on calibration. Of course, with a better tool calibration and scenario play-out experiments are much easier.

> tooltips with the area identifier (city/region/Landkreis) would be neat)

Ah, yes of course. That is in the next wave of work…

> The animation shows a second wave of infected people. Is that because of a relaxation in quarantine/travel bans?

I think the second wave in the animation is “an illusion” – when I plot the individual animation slides the second wave is not seen. (The animation in the notebook is done by-vertex normalization, just to demonstrate model’s spatial propagation simulation abilities.)

---

<div class="post-metadata">

**Author:** ![roellig](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/roellig/32/5423_2.png) [@roellig](https://community.wolfram.com/u/roellig)\
**Post date:** [March 26, 2020, 2:06pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/4 "2020-03-26T14:06:04Z")

</div>

Here is my naive attempt to ome up with informative tooltips:

## Tooltips

Following the definitions from the Notebook

```
lsCells = 
      Cases[grHist[[1]], 
       Tooltip[h_Polygon /; MatrixQ[h[[1]]], 
         pop_ /; NumberQ[pop] && pop > 3] :> <|"Cell" -> h, 
         "Population" -> pop|>, \[Infinity]];
 lsCells = 
      Map[Append[#, "Center" -> Mean[PolygonCoordinates[#["Cell"]]]] &, 
       lsCells];

```

And extrakting the plot dimensions and scaling:

absOps = AbsoluteOptions[grHist[[1](https://community.wolfram.com//c/portal/getImageAttachment?filename=2020-03-26%282%29.png&userId=87900)]];

We now have to scale between Geographic coordinates

```
GeoRange /. absOps

(* {{47.0295, 55.4005}, {5.5195, 15.4305}} *)

```

and GeoGridPositions

```
GeoGridRange /. absOps

(* {{5.5195, 15.4305}, {53.4218, 66.8345}} *)

```

The idea is to select largest cities from each bin (Polygon) and sow them together with their distance from the bin center. For this we need to scale between the coordinates and the geo grid used in the plot.

```
nlist = (Values /@ Normal[dsCityRecords]) /. {"Germany", b_, c_, d_, 
    e_, f_} :> {"Germany", b, c, d, Lon2X[f], Lat2Y[e]}

xyRange = GeoGridRange /. absOps
lonlatRange = Reverse[GeoRange /. absOps]
lonRescale[lon_] := Rescale[lon, xyRange[[1]], lonlatRange[[1]]]
latRescale[lon_] := Rescale[lon, xyRange[[2]], lonlatRange[[2]]]
rescaleLonLat[{lon_, lat_}] := {lonRescale[lon], latRescale[lat]}
X2Lon[x_] := Rescale[x, xyRange[[1]], lonlatRange[[1]]]
Y2Lat[y_] := Rescale[y, xyRange[[2]], lonlatRange[[2]]]
Lon2X[x_] := Rescale[x, lonlatRange[[1]], xyRange[[1]]]
Lat2Y[y_] := Rescale[y, lonlatRange[[2]], xyRange[[2]]]
LatLon2XY[{x_, y_}] := {Lon2X[y], Lat2Y[x]}

```

Let’s create the tooltips

```
tooltip = Table[
   numCities = 5;
   rmf = RegionMember[lsCells[[i]]["Cell"]];
   sel = Select[nlist, rmf[#[[-2 ;; -1]]] &];
   len = Min[{Length[sel], numCities}];
   selTake = Take[sel, len];
   dist = 
    Round@GeoDistance[XY2LatLon[lsCells[[i]]["Center"]], 
        XY2LatLon[#[[-2 ;; -1]]]] & /@ selTake;
   If[sel != {},
    Panel[
     TableForm[
      Flatten /@ Transpose[{selTake[[All, {2, 3, 4}]], dist}], 
      TableHeadings -> {None, {"Federal State", "City", "Population", 
         "Distance to ctr."}}]],
    Panel[
     TableForm[{{"", "", "", ""}}, 
      TableHeadings -> {None, {"Federal State", "City", "Population", 
         "Distance to ctr."}}]]], {i, 1, Length[lsCells]}];

```

and put them in an Association for easier replacement later

```
ttasoc = Association@
   Table[{lsCells[[i]]["Population"] -> 
      Panel[tooltip[[i]], 
       Style[lsCells[[i]]["Population"], Red, Bold], Top]}, {i, 1, 
     Length[lsCells]}];

```

Now we can jst replace the Tooltip from the original figure:

```
grHist /. Tooltip[p_Polygon, pop_?NumberQ] :> Tooltip[p, ttasoc[pop]]

```

 ![2020-03-26_OP_2_CP_.jpg](https://global.discourse-cdn.com/wolfram/original/3X/a/c/ac3a6419fe1b9344758c06bb7010f276cc6bceef.jpeg)

This is not perfect. If you move over the hexagon belonging to the Berlin area we note, that Berlin is not within the Polygon.

 ![2020-03-26_OP_3_CP_.jpg](https://global.discourse-cdn.com/wolfram/original/2X/2/202d54cfdb364877ec1743564e0bc66953ee520d.jpeg)

The reason is most likely my simple-minded rescaling of the geo positions but I couldn’t figure out a better transformation. Maybe some GeoGraphics experts can help here

---

<div class="post-metadata">

**Author:** ![roellig](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/roellig/32/5423_2.png) [@roellig](https://community.wolfram.com/u/roellig)\
**Post date:** [March 26, 2020, 4:25pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/5 "2020-03-26T16:25:38Z")

</div>

There is one type in the city csv file. Lline 7226 should read:

“Germany”,“RheinlandPalatinate”,“GemundenRheinlandPfalz”,1080,50.558889, 8.017778

---

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [March 26, 2020, 4:40pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/6 "2020-03-26T16:40:35Z")

</div>

Thanks for finding out this! Fixed now.

I noticed that outlier, that is why in the computation notebook I have code that removes outliers.

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [May 23, 2020, 10:37pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/7 "2020-05-23T22:37:00Z")

</div>

![news-congrads-kkluyshnik-02-04-19.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/a/6a310c2d0904616faf4e6e148260c9f29ab9f4eb.jpeg) – you have earned _ **Featured Contributor Badge** _ ![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)

Your exceptional post has been selected for our editorial column _ **Staff Picks** _ [http://wolfr.am/StaffPicks](http://wolfr.am/StaffPicks) and [Your Profile](http://community.wolfram.com/web/antononcube) is now distinguished by a _ **Featured Contributor Badge** _ and is displayed on the [Featured Contributor Board](https://community.wolfram.com/people). Thank you!

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [May 23, 2020, 10:37pm UTC](https://community.wolfram.com/t/wirvsvirus-2020-hackathon-participation/15575/8 "2020-05-23T22:37:33Z")

</div>

This post has been listed in the main resource-hub COVID-19 thread: [https://wolfr.am/coronavirus](https://wolfr.am/coronavirus) in the section _Computational Publications_. Please feel free to add your own comment on that discussion pointing to this post ( [WirVsVirus 2020 hackathon participation](https://wolfram.discourse.group/t/15575/1) ) so many more interested readers will become aware of your excellent work. Thank you for your contribution!
