This is the pupal stage of a lepidopteran (i.e. a butterfly/moth). The pupa is encased in the brown silken cocoon in the centre of the 'net'. The 'net' itself is built from the setae (hairs) of the caterpillar, which it sheds prior to cocoon formation.
Here's some photos of similar formations:
I'm going to assume that when you say algorithms, you mean the forms of innate behavior an organism may have relating to their senses (e.g. when sunlight is detected by a worm through the photoreceptors in their skin, it will move towards the opposite direction of the source of light to stay in their preferred environment).
These mentioned species of insects ...
Those look to me like fungus gnats. If you're looking to get rid of them, I've heard that putting a layer of rice hulls on top of the soil keeps them from reproducing. From what little I've read my identification doesn't go much deeper than superfamily, taxonomically, but it's a least a common name to work from.
It could be Pyralis farinalis, the meal moth. It is a cosmopolitan moth of the family Pyralidae. Its larvae are pests of certain stored foods, namely milled plant products. I don't think it's adults feed as they do not live long after mating.
Here is a link to its Wikipedia article:Pyralis farinalis
Some moths exude a yellow lymph excretion when they are threatened.
The photo is not very clear, It's difficult to see the species of moth. what did the moth do after? did it fly away? If the moth was looking ill, it could be that it had a parasite.
The first picture is of a Clothes Moth (Tineola bisselliella). The uniform gold colour of the wings (with shiny dust that easily comes off) is diagnostic.
The second and third pictures appear to be Pantry moths.
I could not find a scientific reference, so I describe my own observations below. Happy to delete this if it is not appropriate.
Both species ...