# ensure connectivity in geometric optimization

I am working on parts of my master-thesis and got to a problem which I would like to solve and develop some algorithm for. Basically I am dealing with 2d-geometry which I would like to represent using a 2d grid.

My grid represents a density of my structure which should eventually converge to my final result. My nominal values for my grid are in the range of [0, 1].

On this grid I have a list of quantities which I may add into the optimization process. The most common values are:

But its surely not limited to this. A common constraint would be limitting the total area / density:

In order to ensure convergence, one sends the density through some exponential e^x in order to get a stiffness value. the trick is to enforce the density converging to either 0 or 1 not remaining at values like 0.5.

Now this works like explained above but in my technical application, I am required to enforce connectivity of my structure.

# Problem

An example solution to the previous problem where one would maximise I_x would be:

The problem with this solution is non-physical since it wouldnt represent a single geometry.

What I am looking for is a single connected structure during this optimization which allows gradients to be used in my process.

# Attempt

An attempt I made is to create some flood-fill which starts at some predetermined cell and computes reachability of the other cells. I introduced a function which is basically 1 when the density is above some threshold. otherwise close to 0. This floodfill would then be used to determine adjusted stiffness values. This works theoretically but when applying some gradient-algorithm, I am running into problems with this since adjusting the density of a cell can have huge impliciations on other cells. Using numerical approximations is not viable.

Does someone have some better idea?