How to set periodic genomes in evolutionary solvers

Hello,

speaking about the evolutionary solver in Galapagos,

when you set a slider as a genome and run the optimization, the solution converges to the best one, and so does the slider value (hopefully within its range).

However, if the variable is periodic (for example, a slider representing an angle in degrees ranging from 0 to 360), the start and end of the slider domain actually represent the same value.

In this case, it can happen that your best solution lies very close to the start, but during optimization, the solver gets stuck in a local minimum on the opposite side of the domain, unable to “jump” across the boundary of the slider.

Not knowing how to define a periodic genome, the only workaround I can think of is to set a large domain that includes multiple cycles of the actual range.
For example, if it should be 0 to 360, I set it to 0–1000, so the solver can oscillate more freely around any equivalent angle during optimization.
This way the probability of getting stuck at the domain boundaries is much lower, although technically not zero.

Is there a more efficient or elegant way to handle this?

Not knowing the details of the optimization problem, i would map periodic values back to their domain via modulo.

Let me rephrase my question with an example:

I have I slider within range 0.000 to 359.999

Imagine the best solution would be at slider value = 0.002

For some reason, during the optimization the solver get stuck al 359.999 without being able to reach the true solution because it is on the opposite side of the slider, although being near it in a period

Ahh.. I see. This is not really a GH question then.

In contrast to an gradient-based solver, an evolutionary solver like galapagos should be able to find the global optimum nonetheless, as they do not tend (always depending on the algorithms setting) to get stuck in local minima. Usually the “mutation” helps to get out of local minima.

See the related wiki-article.

If it is a “correct” local minimum I can accept it and I will try to set the algorithm in a better way but if the local minimum happens just because of that discontinuity in the genome domain I showed, I would like to solve it and have one less problem.

I was hoping it is just a matter of how you set your genome in GH.

Thanks anyway for the link

meanwhile I came up with some trick.. I’ll share it for my future self and for anyone as curious as I was

TLDR: use 2 sliders with domain around origin - use them for X and Y of a vector - measure its angle - remap it to your desired domain

1 Like