Skip to content

Fix Dirichlet variation generation to honor base material min/max bounds#98

Draft
Copilot wants to merge 2 commits into
v0.9.6from
copilot/fix-dirichlet-variations-issue
Draft

Fix Dirichlet variation generation to honor base material min/max bounds#98
Copilot wants to merge 2 commits into
v0.9.6from
copilot/fix-dirichlet-variations-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

Dirichlet sampling could fail to produce valid variations for some materials because generated samples were effectively shaped by broad overview-sheet statistics, then normalized into values that violated the narrower per-grade element bounds. This change keeps variation generation constrained to the base material’s element ranges while still producing compositional vectors that sum to 100%.

  • Bounded Dirichlet projection in sampler

    • Reworked DirichletSampler#createElementVariation to map each sample into the base composition bounds (Element.min/max) instead of relying on unconstrained normalization.
    • Added bounded solver logic to distribute mass within [min, max] and satisfy total composition = 100%.
    • Added guardrails for infeasible bounds and invalid sample shapes.
  • Preserve domain constraints through generation

    • Removed the previous post-scaling approach that could push values outside element limits after normalization.
    • Ensures generated elements remain within original per-material constraints, which addresses the failure mode seen with narrow datasheet ranges.
  • Regression coverage for narrow-range materials

    • Added a focused unit test in CompositionalVariationsTest to cover the case where:
      • base material ranges are tight,
      • overview statistics are broad,
      • Dirichlet output must still stay within base bounds.
// New bounded conversion path (conceptual)
double[] boundedPercentages = generateBoundedPercentages(sample, mins, maxs);
Element variationElement = new Element(
    baseElement.getName(),
    baseElement.getSymbol(),
    boundedPercentages[i],
    baseElement.getMin(),
    baseElement.getMax(),
    baseElement.getAverageComposition()
);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • accounts.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --use-angle=swiftshader-webgl --crashpad-handler-pid=5897 --enable-crash-reporter=, --noerrdialogs --user-agent=Chrome/120.0.0.0 --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.lk2YaY --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,16022446666412780126,3040340503438469386,262144 --disable-features=IgnoreDuplicateNavs,PaintHolding,Prewarm --variations-seed-version --pseudonymization-salt-handle=7,i,14025070495839717569,282331497969182528,4 --trace-process-track-uuid=3190708989122997041 --enable-logging --log-level=0 (dns block)
    • Triggering command: /opt/google/chrome/chrome /usr/bin/google-chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-blink-features=AutomationControlled --disable-client-side-phishing-detection --disable-default-apps --disable-features=IgnoreDuplicateNavs,Prewarm --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 (dns block)
  • android.clients.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --use-angle=swiftshader-webgl --crashpad-handler-pid=5897 --enable-crash-reporter=, --noerrdialogs --user-agent=Chrome/120.0.0.0 --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.lk2YaY --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,16022446666412780126,3040340503438469386,262144 --disable-features=IgnoreDuplicateNavs,PaintHolding,Prewarm --variations-seed-version --pseudonymization-salt-handle=7,i,14025070495839717569,282331497969182528,4 --trace-process-track-uuid=3190708989122997041 --enable-logging --log-level=0 (dns block)
    • Triggering command: /opt/google/chrome/chrome /usr/bin/google-chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-blink-features=AutomationControlled --disable-client-side-phishing-detection --disable-default-apps --disable-features=IgnoreDuplicateNavs,Prewarm --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 (dns block)
  • clients2.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --use-angle=swiftshader-webgl --crashpad-handler-pid=5897 --enable-crash-reporter=, --noerrdialogs --user-agent=Chrome/120.0.0.0 --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.lk2YaY --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,16022446666412780126,3040340503438469386,262144 --disable-features=IgnoreDuplicateNavs,PaintHolding,Prewarm --variations-seed-version --pseudonymization-salt-handle=7,i,14025070495839717569,282331497969182528,4 --trace-process-track-uuid=3190708989122997041 --enable-logging --log-level=0 (dns block)
    • Triggering command: /opt/google/chrome/chrome /usr/bin/google-chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-blink-features=AutomationControlled --disable-client-side-phishing-detection --disable-default-apps --disable-features=IgnoreDuplicateNavs,Prewarm --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 (dns block)
  • dl.google.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)
  • optimizationguide-pa.googleapis.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --use-angle=swiftshader-webgl --crashpad-handler-pid=5897 --enable-crash-reporter=, --noerrdialogs --user-agent=Chrome/120.0.0.0 --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.lk2YaY --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,16022446666412780126,3040340503438469386,262144 --disable-features=IgnoreDuplicateNavs,PaintHolding,Prewarm --variations-seed-version --pseudonymization-salt-handle=7,i,14025070495839717569,282331497969182528,4 --trace-process-track-uuid=3190708989122997041 --enable-logging --log-level=0 (dns block)
    • Triggering command: /opt/google/chrome/chrome /usr/bin/google-chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-blink-features=AutomationControlled --disable-client-side-phishing-detection --disable-default-apps --disable-features=IgnoreDuplicateNavs,Prewarm --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 (dns block)
  • www.google.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --use-angle=swiftshader-webgl --crashpad-handler-pid=5897 --enable-crash-reporter=, --noerrdialogs --user-agent=Chrome/120.0.0.0 --user-data-dir=/tmp/org.chromium.Chromium.scoped_dir.lk2YaY --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,16022446666412780126,3040340503438469386,262144 --disable-features=IgnoreDuplicateNavs,PaintHolding,Prewarm --variations-seed-version --pseudonymization-salt-handle=7,i,14025070495839717569,282331497969182528,4 --trace-process-track-uuid=3190708989122997041 --enable-logging --log-level=0 (dns block)
    • Triggering command: /opt/google/chrome/chrome /usr/bin/google-chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-blink-features=AutomationControlled --disable-client-side-phishing-detection --disable-default-apps --disable-features=IgnoreDuplicateNavs,Prewarm --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-logging --headless --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix Dirichlet variations for certain materials Fix Dirichlet variation generation to honor base material min/max bounds May 20, 2026
Copilot AI requested a review from sprince0031 May 20, 2026 21:00
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.

[bug] Dirichlet variations failing for certain materials due to incorrect min-max ranges

2 participants