Skip to content

Commit

Permalink
Merge pull request #318 from buildingSMART/78-testcase-floating-point…
Browse files Browse the repository at this point in the history
…-numbers-tolerance

no tolerance in ranges
  • Loading branch information
CBenghi authored Aug 19, 2024
2 parents 7171c00 + 605b8cc commit ebfa806
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.0000009),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.000000),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.0000011),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.0000001),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.0000009),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.000000),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.0000011),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.00000001),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.0000011),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.0000001),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.000001),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.000000),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.0000011),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(-0.0000001),$);
ENDSEC;
END-ISO-10303-21;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ DATA;
#7=IFCWALL('2nJrDaLQfJ1QPhdJR0o97J',$,$,$,$,$,$,$,$);
#8=IFCPROPERTYSET('16MocU_IDOF8_x3Iqllz0d',$,'Foo_Bar',$,(#10));
#9=IFCRELDEFINESBYPROPERTIES('1xdwj8qGXK4hzoNbvMdXJW',$,$,$,(#7),#8);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.000001),$);
#10=IFCPROPERTYSINGLEVALUE('Foo',$,IFCREAL(0.000000),$);
ENDSEC;
END-ISO-10303-21;
18 changes: 11 additions & 7 deletions Documentation/tolerance.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ The table below demonstrates characteristic ranges of values within the toleranc

Note: the tolerance value is not configurable, as it is specific only for rounding errors, not for construction-related tolerances, for which users need to provide an explicit range.

## Range tolerance
## Ranges

Adding tolerance to range checks would open up all kinds of strange edge cases like 41.999958 being both in the range 42-50 inclusive, but also < 42 exclusive. For that reason, **exclusive ranges should be shrunk, while inclusive ranges should be stretched**.
**The tolerance does not apply to ranges**, as it would open up all kinds of strange edge cases (for example: 41.999958 being both in the range 42-50 inclusive, but also < 42 exclusive). The values used in ranges (minExclusive/minInclusive/maxExclusive/maxInclusive) should therfore be compared explicitly. For example:

For example:
- `x > 0 ⇒ x > 1.0e⁻⁶`
- `x >= 0 ⇒ x >= -1.0e⁻⁶`
| | >1.0 | >=1.0 | <1.0 |
|---:|-------------:|-------------:|---------:|
| 0.99999999 | fail | fail | pass |
| 1.00000000 | fail | pass | fail |
| 1.00000001 | pass | pass | fail |

If a numeric range constraint's spread is lower than the agreed limit, the Audit-tool should raise a warning.
This approach allows for specifying a custom tolerance in cases where the general rule is not applicable. For example:
- `(v - 1e-10) <= x <= (v + 1e-10)` checks that `x` is equal `v` with the custom tolerance of 1e-10, which is much more precise than the default formula
- `v <= x <= v` checks that `x` is exactly equal `v` with no tolerance

#

Note: the history of these agreements can be traced in the history of [issue 78](https://github.com/buildingSMART/IDS/issues/78), [issue 36](https://github.com/buildingSMART/IDS/issues/36), and in [the summary by @giuseppeverduciALMA](https://github.com/buildingSMART/IDS/blob/0d50fd8f2dbd5b388f6fafb67da255cc3ce2b4ca/Documentation/tolerance.md).
Note: the history of these agreements can be traced in the [issue 78](https://github.com/buildingSMART/IDS/issues/78), [issue 36](https://github.com/buildingSMART/IDS/issues/36), and in [the summary by @giuseppeverduciALMA](https://github.com/buildingSMART/IDS/blob/0d50fd8f2dbd5b388f6fafb67da255cc3ce2b4ca/Documentation/tolerance.md).

0 comments on commit ebfa806

Please sign in to comment.