Skip to content

Preserve decimal EMV2 branch probabilities 馃 - #3256

Merged
lwrage merged 2 commits into
masterfrom
2820_preserve_decimal_branch_probabilities
Sep 18, 2026
Merged

lwrage merged 2 commits into
masterfrom
2820_preserve_decimal_branch_probabilities

Conversation

@lwrage

@lwrage lwrage commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #2820

Branch-probability validation now constructs property probabilities from their original decimal text. Previously, constructing BigDecimal from the property's double introduced binary rounding error, so even 0.2 + 0.8 could fail the sum-to-one check.

The validator reads the real literal's value node after resolving property constants, accepts signed/exponent/underscore notation, and falls back to BigDecimal.valueOf when a literal has no node model. The change is local to branch validation.

Issue2820Test covers ordinary decimal values, constants, exponent notation, values beyond double precision, and a positive others remainder smaller than double precision can preserve. Separate invalid models verify that incorrect literal/property sums and an exhausted others remainder still produce errors. Before the fix, all five valid cases produced false sum diagnostics.

Validation:

  • Focused offline Tycho verify with -Dtest=Issue2820Test: 2 tests passed.
  • Clean offline root-reactor clean install: 1,689 tests passed, including all 307 EMV2 tests; 0 failures/errors/skips.
  • git diff --check passed.

Build flags: mvn -o -T5 -s releng/osate.releng/settings.xml -Plocal -Dpr.build=true -Dsign=false -Dspotbugs=false -Dcodecoverage=false -Djavadoc=false -DfailIfNoTests=false. The focused run uses -pl :org.osate.xtext.aadl2.errormodel,:org.osate.aadl2.errormodel.tests,:org.osate.xtext.aadl2.errormodel.feature -Dtycho.localArtifacts=default; the root run uses -Dtycho.localArtifacts=ignore clean install.

No dependency on another unmerged PR. Missing-property handling remains outside this change; #2821 addresses it separately. Models without source nodes retain the precision of their stored double values.

Reproduce false probability-sum errors for decimal property values, including property constants, exponent notation, and decimals beyond double precision. Preserve rejection of genuinely incorrect sums and exhausted others branches.
Construct branch-property probabilities from the original real-literal token after resolving constants, avoiding both binary double expansion and loss of source precision. Use BigDecimal.valueOf only when source nodes are unavailable and preserve existing sum diagnostics.
@lwrage
lwrage merged commit c2e5e31 into master Sep 18, 2026
1 check passed
@lwrage
lwrage deleted the 2820_preserve_decimal_branch_probabilities branch September 18, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sum of probabilities is inaccurate when using a property

2 participants