marcovirgolin / GP-GOMEA

Genetic Programming version of GOMEA. Also includes standard tree-based GP, and Semantic Backpropagation-based GP
Apache License 2.0
49 stars 23 forks source link

how does protected division work? #11

Closed lacava closed 3 years ago

lacava commented 3 years ago

https://github.com/marcovirgolin/GP-GOMEA/blob/894fd841daee98a0a08de0a6a82a595fcd985b15/src/Include/GPGOMEA/Operators/Regression/OpNewProtectedDivision.h#L33

can you help me understand how this protected division operator works?

marcovirgolin commented 3 years ago

Sure.

It does: my_div(a,b) := pseudosign(b) * (a / (abs(b) + epsilon) ), where pseudo-sign(b) is sign(b) if b!=0, else 1. Of course epsilon > 0.

Same thing, as an img for readability: image

This way it looks like a division unless b goes to 0, in which case it basically caps to a very large (if b ~ 0 and positive) value (namely, 1/epsilon), or a very small one (if b ~ 0 and negative, namely -1/epsilon).

I started using it in my recent works, like these: https://arxiv.org/abs/2009.06037 https://www.springerprofessional.de/en/learning-a-formula-of-interpretability-to-learn-interpretable-fo/18338610

lacava commented 3 years ago

got it, thanks. that makes sense. I'm still confused by the modulo operator. is it overloaded somewhere?

https://github.com/marcovirgolin/GP-GOMEA/blob/894fd841daee98a0a08de0a6a82a595fcd985b15/src/Include/GPGOMEA/Operators/Regression/OpNewProtectedDivision.h#L42

marcovirgolin commented 3 years ago

Oh, that is elementwise multiplication between armadillo vectors

lacava commented 3 years ago

great. thank you!