geometrize-haxe icon indicating copy to clipboard operation
geometrize-haxe copied to clipboard

Algorithm Improvment proposal on the random shape generation

Open Cerdic opened this issue 5 years ago • 0 comments

As a matter of fact, it is quite visible that whereas the first steps are producing large shapes to fill the larger gap between the target image and the initial one, the mean size of the found shapes is mainly decreasing.

Then I found that generating constant size shapes was a loss of computation energy:

  • generating small shapes needs a lot of mutation at the start to reach an optimal size,
  • generating large shapes implies more and more of wasted effort on error computation of error on random shamoes during random phase

Then you have to find a compromise and between the start of processus and the late phase. So I tried to introduce a sizeFactor in shapes:

  • in the constructor it is used to adapt the scale of the random size ot shapes relatively to the bounds
  • a getSizeFactor() method is added to shapes classes to give a feedback on the approximative sizes factor of the found shapes

https://github.com/Cerdic/geometrize-php/commit/f9384cafccda96d7240591ece88e2e72d2eb5c2b

Then the Model get an internal shapeSizeFactor with an initial value set to 1.0 and that is updated at each call of addShape with a low-pass filter This shapeSizeFactor is then used to init random shapes in the interesting size range:

https://github.com/Cerdic/geometrize-php/commit/1a276c87f37cad59a35abf224ca12025efc32946

This is really improving the convergence process by a much better random shape generation, and avoiding random large shapes that have a big computation cost, when not any more useful

Cerdic avatar Jul 15 '19 14:07 Cerdic