Epidemic Analysis: Sort intersected curves with each day cycle

Hey guys,

I’ve been building an Epidemic analysis tool in grasshopper that analyses the effect urban spatial form has on the spread of a disease.

The core system is an urban environment model with a series of “home” points and “place” points, with a path network connected them (such as pavements/sidewalks and park paths).

The way the tool analyses for infection spread is by plotting people’s movement from “home” to “place” (using “shortest walk” component), with time in the z axis, such as a Marey Chart. Then when curves intersect = an interaction = potential infection.

The issue I have is that, I need to find the curves the “infected” curve touches, and then find which other curves those newly infected curves touch (for each day cycle). Hopefully to show exponential growth:

Day 1: 1 => 4
Day 2: 4 => 11
Day 3: 11 = 29
and so on…

I have managed this so far with a cluster I have made, which is then duplicated for each day. Although it is very cumbersome and inefficient, therefore I am looking for a better, more streamlined, way of doing this - i.e. that doesn’t involve a bunch of components being duplicate for each day.

I hope that makes sense, and help here would be amazing, thanks in advance.

Henry

Resim v2.5 for forum.gh (2.4 MB)

I’m not sure if this is a sound plan simulation-wise?

Your idea about using predefined paths is fine, since most people have a daily routine or commute during workdays with only small changes.
However, intersecting paths in my opinion don’t correlate directly with a high infection risk.

Generally, to make this a better simulation, you’d at least have to introduce some kind of “pheromone” - an infectious cloud - that would be emitted by a sick agent at regular, random intervals (coughing) while strolling along its path.
This “pheromone” would have a cool down phase. It would stay infectious for a certain time, then dissipate and disappear. Healthy agents, while passing through, would have a certain chance to get infected or not.

Path intersections probably don’t bare the highest infection risk, though. I’d say that rather agents walking the same route as an infected one, would have a far higher probability to get sick, especially when they don’t keep their distance (social distancing, Karens).
At intersections, this risk isn’t automatically higher. I’d argue it to be much more important on heavily frequented routes.

You should really start smaller and simpler! Start in 2D with a simple context and a single route, and get that working first, before translating it to 3d and complexer situations.
This is also harder to implement than you might think, if you are a beginner. You probably need a fully-fledged agent-based system, where agents have varied immune systems that define their individual infection risks for this to make sense.

I’d invite you to check this video out:

It nicely illustrates, how even pros - like Sebastian Lague - start out simple and gradually increase complexity. In this video, he does something very similar than want you might want to achieve.

Do you know how to program (Python, C#, etc.)?

1 Like

Thanks a lot for your response, I have come across this video before and it is super interesting!

The problem I have is that my project has to be finished and submitted in 3 weeks time, and my coding skills (I can code in python, not much C#) isn’t quite at the level for something this complex. Hence I am only asking for a smarter way to find intersecting curves, improving the method I already have.

I was imagining some way of listing items (curves) in a series such as: day 1 = 3 curves, day 2 = 12 curves…etc

Reason being, that this analysis tool combines with a generative design tool my groupmate is working on, to measure the performance of different spatial options, and compare them. Hence the complexity/accuracy isn’t actually that necessary - just needs to show some distinction between designs. On a urban scale, this involves things like density, porosity and compactness - then measuring how “infectious” each model is, to determine the best ones.

I probably should have pointed that out though sorry, thanks nonetheless though.

If you can’t intersect your line segements directly, because they only have apparent intersections for instance in the top view, but no real, geometric ones, you can for instance get a plane for one of the lines, whose x-axis is aligned to the line itself (tangent) and y-axis is for instance the world z-axis or a normal to the line.

Then you can intersect the other line with the plane to find an intersection point.

Yes, but a simple agent-based simulation would probably be neat for that.
I’ll see in the afternoon, if I can quickly come up with a simple Pythonic demo.

Three weeks is still a lot of time.
@AndersDeleuran did this beautiful creation in allegedly 3 days:
https://www.instagram.com/p/BlIg3K8HEcW/

1 Like

To be fair, I did have a lot of practice (with graph-based and dynamic stuff)

You’re right. Experience should be factored in.
I’m curious, what was graph-based in your parking simulation?

I used a bidirectional one-lane graph representation (using `networkx`) for the underlying route finding (i.e. for finding shortest paths in the road network). Which is why the cars “ghost” into each other. Here’s a fun example of what happens when you increase the `HeadOnAngle` and thus prevent the “ghosting”:

I really want to try this this with a proper one-directional two lane graph representation some time.

1 Like

Haha, so fun! Thanks for showing that.

That would be cool!

1 Like