ffx icon indicating copy to clipboard operation
ffx copied to clipboard

FFX not summing expressions of same variable with different coefficients

Open misgeatgit opened this issue 4 years ago • 3 comments

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?

misgeatgit avatar Apr 20 '20 16:04 misgeatgit

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?

jmmcd avatar Apr 21 '20 09:04 jmmcd

@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

misgeatgit avatar Apr 21 '20 14:04 misgeatgit

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...

jmmcd avatar Apr 21 '20 16:04 jmmcd