Closed Afifa-Tamanna closed 4 years ago
The main reason is that many functions you mentioned are some kind of dangerous. That is, it is easy to generate unreasonably large (such as pow(13, 50)
) and even nan
or errors (like sqrt(-1.2)
).
Just like we usually define a protected version for div
, you should also do that for these functions. A common way is to
min(y, 1e6)
(you should adjust the threshold accordingly)nan
is generated, then output a default value like 0.0
Since evolution is always random, you cannot assume reasonable inputs or outputs for a given function. Instead, protect it.
See this example for protected_div
.
Thank you for your quick response and the clarification!
Hi Shuhua; Thank you for the useful examples you provided in your page. in regard to the example:
(Numerical expression inference problem: numerical constant finding with ephemeral numerical constant (ENC))
There is only the single input 'x' and random numerical constants (RNC). I just wondering if I have three inputs as the following:
x ( date from 2.3 to 6.5) y (from 0.25 to 3) z (from 1 to 99)
How to implement the code and do I need to change the code to be like this:
n_cases = 100 X1 = np.random.uniform(-10, 10, size=n_cases) # random numbers in range [-10, 10) X2 = np.random.uniform(-10, 10, size=n_cases) X3 = np.random.uniform(-10, 10, size=n_cases)
Y = f(X1,X2,X3) + np.random.normal(size=n_cases) # Gaussian noise
Also, do I need to change the random range to be (2.3 to 6.5), (0.25 to 3) and (1 to 99)
regards
Hi, I cannot add the above mentioned functions functions. If I add function such as pset.add_function(operator.pow,2)
then the following things return;