natekupp / ffx

Fast Function Extraction
http://trent.st/ffx
Other
80 stars 97 forks source link

FFX not summing expressions of same variable with different coefficients #49

Open misgeatgit opened 4 years ago

misgeatgit commented 4 years ago

I just came across the following FFX model:

(-0.124 - 0.228*Land_Use - 0.228*Land_Use) / (1.0 + 2.62*Land_Use + 2.60*Land_Use)   

Why isn't FFX reducing this expression?

jmmcd commented 4 years ago

I think I've seen this before but didn't really investigate. Would you be able to show us a small dataset/code that gives this result?

misgeatgit commented 4 years ago

@jmmcd thanks for replying. Here is the code to reproduce this: https://gist.github.com/misgeatgit/dae5ce08a101f10c3e4a861ec99fb904 and input data is here https://github.com/misgeatgit/prj-climate/tree/master/data/ffx

jmmcd commented 4 years ago

Thanks. Yes, when building that model I see that we get duplicate bases.

After Step 1A we have four (non-duplicate) Order-1 bases: x0, x1, x2, x3.

But just before we return from build, we have the following bases:

here are the order1 bases
x1
x2
x1
x2
x3
here are the order2 bases
x1^2
x2^2
x1^2
x2^2
x3^2
x2 * x1
x1 * x2

That contains several duplicates and even a "mirror image" (cf model_factories.py L 331).

I'll look more later...