Question

ExpressionEvaluator Answer Changed

  • 23 October 2013
  • 6 replies
  • 3 views

I have resently upgraded to FME 2013 SP3 (20130729 - Build 13528 - WIN32).

 

 

I just executed an existing workspace (created about 2 years ago) that failed to complete.

 

 

The issue that I found was an ExpressionEvaluator that was calculating differently then before. The original expression was:

 

 

@max(@Value(_ymax)-@Value(_ymin),@Value(_xmax)-@Value(_xmin))*0.1

 

 

Which should return 0.01731916666578 was now returning 48.9947966666626

 

 

I found that if I sub-bracketed the inner expressions I got the correct answer.

 

 

@max(@(Value(_ymax)-@Value(_ymin)),(@Value(_xmax)-@Value(_xmin)))*0.1

 

 

What I was wondering was if my original expression was not correctly formed and a updated Evaluator now exposes this.

 

 

Thanks,

 

Mike

 

 

Expression Values:

 

_xmax = -116.760933333319

 

_xmin = -117.051986111095

 

_ymax = 54.4194194444409

 

_ymin = 54.2462277777831

 


6 replies

Userlevel 2
Badge +17
Hi Mike,

 

 

The same result as yours was reproduced in my environment: FME 2013 SP4.

 

 

The result of the first expression of yours is equal to this:

 

54.4194194444409 - 54.2462277777831 * 0.1 = 48.9947966666626

 

 

My manual calculating result is:

 

dy = ymax - ymin

 

    = 54.4194194444409 - 54.2462277777831

 

    = 0.1731916666578

 

dx = xmax - xmin

 

    = -116.760933333319 - (-117.051986111095)

 

    = 0.291052777776002

 

dx is greater than dy, so the result should be:

 

dx * 0.1 =  0.0291052777776002

 

It's different from both of old and new results of your expressions.

 

 

I guess @max function compares the arguments as character strings like this:

 

"54.4194194444409-54.2462277777831"

 

is greater than

 

"-116.760933333319--117.051986111095"

 

in lexicographic order.

 

 

@max function returns "54.4194194444409-54.2462277777831", and then the ExpressionEvaluator evaluates this string as an arithmetic expression.

 

"54.4194194444409-54.2462277777831*0.1"

 

 

The ExpressionEvaluator with this expression returns the same result as my manual calculation.

 

@max(@double(@Value(_ymax)-@Value(_ymin)),@double(@Value(_xmax)-@Value(_xmin)))*0.1

 

 

And, the AttributeCreator with this expression as "Value" also creates the correct value.

 

@Evaluate([expr [expr max(@Value(_ymax)-@Value(_ymin),@Value(_xmax)-@Value(_xmin))]*0.1])

 

 

Anyway, I think @max function should interpret its arguments as numeric values or arithmetic expressions, since it's categorized as one of the FME Math Functions.

 

I think this is a serious issue for all FME users. I'd like to contact Safe support, may I use your example?

 

 

Takashi

 

 

Simple test:

 

The ExpressionEvaluator with this expression returns 1 (NG).

 

@Evaluate(@max(-(-5),1))

 

 

This returns 5 (OK):

 

@Evaluate(@max(@int(-(-5)),1))
Userlevel 2
Badge +17
I tested a little more. It seems sure that  FME Math Function max and min compare arguments as character strings in lexicographic order when the argument is an expression.

 

For example, these expressions return unexpected results.

 

@Evaluate(@max(-(-5),1)) -> returns 1

 

@Evaluate(@min(-(-5),1)) -> returns 5

 

@Evaluate(@max(1+0,0+5)) -> returns 1

 

@Evaluate(@min(1+0,0+5)) -> returns 5

 

 

Tease expressions return correct results.

 

@Evaluate(@max(@int(-(-5)),@int(1))) -> returns 5

 

@Evaluate(@min(@int(-(-5)),@int(1))) -> returns 1

 

@Evaluate(@max(@int(1+0),@int(0+5))) -> returns 5

 

@Evaluate(@min(@int(1+0),@int(0+5))) -> returns 1

 

 

I'll request the Safe support with the examples above. After receiving the answer, I'll report here.  
Thanks so much Takashi - yes, please submit whatever you need.

 

 

Mike
Userlevel 2
Badge +17
Hi Mike,

 

 

I received this answer from Safe support: "This is a bug in the ExpressionEvaluator and other similar transformers which has now been fixed and should be in the next FME 2014 betas - likely builds 14183+.  I will post a note to the FME Community once I have verified the fix."   Concluding, your expressions are correct, but you encountered the bug unfortunately...

 

As a present workaround, I think this expression is effective. @max(@double(@Value(_ymax)-@Value(_ymin)),@double(@Value(_xmax)-@Value(_xmin)))*0.1

 

 

Takashi
Userlevel 4
Badge +13
Hi Mike and Takashi,

 

 

This has been fixed in FME 2014 betas and also a hot-fix for FME 2013 SP4, build 13547.  @Evaluate(@max(-(-5),1)) now correctly returns 5 and not 1.

 

 

Cheers,

 

 

Dan
Userlevel 2
Badge +17
Hi,

 

 

I confirmed the max / min function in the newest FME 2013 SP4 (Build 13547) returns the expected values in all cases I tested.

 

Dan, thank you for the fixing and notification.

 

Takashi

Reply