Diffing_Engine: implementation of NumericalDifferenceInclusion
Tolerance approximation to be reviewed
#3039
Labels
type:bug
Error or unexpected behaviour
Description:
(Edited by @alelom)
Currently, the Diffing uses a numerical comparison mechanism implemented in the
NumericalDifferenceInclusion()
method. This method has 2 distinct numerical approximation mechanisms that can be invoked for numerical comparisons: Tolerance and SignificantFigures.The Tolerance approximation mechanism is implemented like so: when two numbers are passed to the method
NumericalDifferenceInclusion()
method, they are individually rounded down using the specified tolerance, and then compared between each other. If they are found different, the method returns true (i.e. they are seen as different by the Diffing), otherwise false.BHoM_Engine/Diffing_Engine/Query/NumericalDifferenceInclusion.cs
Lines 86 to 91 in 8faa850
This logic is not correct. When an user uses the Tolerance, they expect the difference between the number to be compared against the Tolerance.
Instead, the above logic is correct when using the SignificantFigures approximation. This considers how many significant figures should be accounted for when comparing numbers (use case example: engineers only account for significant figures when comparing large forces).
Proposed changes
When using a numeric tolerance, the logic should instead be: compute the difference between the numbers, then see if it is larger than the specified tolerance.
Test File:
On SharePoint.
The text was updated successfully, but these errors were encountered: