Extended DFO Experimentation

This week we have continued working on our optimisation algorithm using DFO and the focus this week was to apply our DFO to a specific problem.

The assigned problem for our DFO is to find the brightest pixels in an image. The image have replaced the sphere function I used in previous post.

In this experiment I am generating a black and white image using perlin noise, I am using the continuous randomising image as my search space. This will make the search space dynamic and the flies will always try to find the brightest pixel. My initial idea was to use the webcam to move the brightest pixel around but I found this more aesthetically appealing. ( I'm a huge fan of perlin noise )

The calculation to get the brightest pixel is very simple, I iterate through all the flies in my population and I take the fly’s current position and subtracting the brightness value from that particular location from 255, which is the maximum brightness. This means that if the current pixel brightness value is higher, the fly’s individual fitness value will be lower. The ideal goal is to have it get towards 0. The fly with the lowest fitness will become the best and the flies will swarm towards the best fly.

This is how the fitness is calculated based on the pixel brightness:

for (auto& f : population){
          f.fitness = 255.0 - surface.getColor(f.position[0], f.position[1]).getBrightness();
}

Here is an example with 100 flies and with a low disturbance threshold:



As you can see, the algorithm works well but they do not seem to behave as a swam might do in nature.

By tweeking the disturbance threshold (dt) you get a very different result. The second example is using more agents and with a higher disturbance threshold, as you can see, the end result is much more interesting when you add more disturbance to the flies.
As you have more flies distributed across the search space I think the behaviour simulates a more natural behaviour.


I find this algorithm to be very interesting, both the visual and the optimisation outcome of this experiment has led me down a path where I want to use this kind of behaviour to control various parameters in a synthesizer and generate interesting music with it.




Comments

Popular posts from this blog

Physical Computing, Final Project

Dispersive Flies Optimisation ( DFO )