Skip to content

fix(EnergyTerm): make a term hard-core only for a zero parameter - #68

Merged
BenPinet merged 10 commits into
nextfrom
fix/parameter-validity
Dec 2, 2026
Merged

BenPinet merged 10 commits into
nextfrom
fix/parameter-validity

Conversation

@francoisbonneau

@francoisbonneau francoisbonneau commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Every parameter accepted by the model now gives an integrable model and a stable computation, whatever the units. Needed before the ABC, which proposes the parameters by itself.

  • Hard-core only for γ = 0. A parameter below GLOBAL_EPSILON (1e-6) was a hard-core: a density of one fracture per km² given in m⁻² meant no fracture at all. Any positive γ is now an ordinary term, and set_thetas accepts any finite θ. The energy is computed in log, so a tiny γ is stable (γ = 1e-300 → θ ≈ −690, no NaN). A weak but positive repulsion no longer makes an attraction integrable. The observation term stays a hard-core when all the objects are observed, up to the rounding of λ·A.
  • Length term on a bounded length law. The energy weight of a fracture in a length term is its whole length. With an unbounded length law (no finite max_value, or Gaussian), γ > 1 — the usual value, to favor long fractures — gives a non integrable model, while γ ≤ 1 stays integrable. Such a term now has its attraction forbidden, like an attractive pairwise term without hard-core: build_simulation_context calls the new Model::forbid_attraction, so γ > 1 is refused when the simulation is built (C++ and Python) and θ > 0 by set_thetas afterwards. The rule needs the sampler laws, so it is applied by the simulation context, not by the model; a model assembled with samplers outside the context must call forbid_attraction itself. The boundedness rule is shared with the buffer size check, which stays a warning for the other sets.
  • No NaN on overflow. The energy and its deltas stop at the first +∞ term: with fixed objects violating a hard-core and a term overflowing to −∞, the energy was NaN. Finite sums are unchanged.

Results unchanged

At fixed seed, the reference fracture simulation gives exactly the same files as before.

Tests

  • Stability: γ = 1e-12 and 1e-300 give consistent deltas and an MH chain without NaN; θ = −700 accepted; γ = 1e-7 is an ordinary term; a 1e-7 repulsion no longer allows an attraction.
  • Observation term: all observed up to rounding (λ = 0.07, 7 fixed points on 100 m²) stays a hard-core.
  • Length term: p21 > 1 on a log-normal without max_value refused (C++ and Python); p21 = 0.5 on it accepted, then set_theta > 0 refused and < 0 accepted; an infinite max_value is not a bound; Gaussian refused even with max_value; power law with max_value accepted; a set without length term keeps an unbounded law; θ = 1 accepted on a bounded law.
  • Overflow: θ = 1e308 with a violated hard-core gives +∞ energy and deltas, not NaN.
  • Full suite: 39/39.

Behavior changes

Not marked as breaking: they will be gathered in the single BREAKING CHANGE of the ABC release.

  • 0 < γ < 1e-6 is no longer a hard-core.
  • A length term with γ > 1 on an unbounded length law is refused when the simulation is built, and its θ cannot be set above 0.
  • An infinite max_value is an unbounded length law: a warning instead of the buffer size error.

🤖 Generated with Claude Code

francoisbonneau and others added 10 commits November 30, 2026 11:36
A parameter gamma below GLOBAL_EPSILON was a hard-core: a density of one
fracture per km2 given in m-2 (1e-6) meant no fracture at all. Only gamma = 0
is now a hard-core; any finite theta is accepted by set_thetas, however
negative: the energy is computed in log, so a tiny gamma is stable. A weak
but positive repulsion no longer makes an attraction integrable. The
observation term stays a hard-core when all the objects are observed up to
the rounding of lambda * A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The energy weight of a fracture in a length term is its whole length. With
an unbounded length law (no max_value, or Gaussian), a parameter above 1,
the usual one to favor long fractures, gives a non integrable model. The
simulation context now refuses such a length term; the bounded length law
rule is shared with the buffer size check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A violated hard-core forbids the configuration whatever the other terms.
The energy and its deltas now stop at the first +inf term: with fixed
objects violating a hard-core and a term overflowing to -inf, the energy
was NaN. The finite sums are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_intensity documents, in C++ and Python, that the length law of the set
must be bounded, and the refusal speaks of gamma > 1 (theta > 0). The
set_thetas documentation no longer says that the unbounded length law is
not refused. Tests: a Gaussian length law is refused even with a max_value,
a set without length term keeps an unbounded law, and a birth crossing a
fixed fracture stays +inf with an overflowing term.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The integrability of the simulated model depends on the model config and on
the laws of the set samplers, which define the reference measure. The
length term rule becomes check_model_integrability on a
SimulationContextConfig: it applies the rules of the model config and checks
that each length term has a bounded length law. build_simulation_context
calls it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_model_integrability keeps a single meaning: the rules of the model
config. The length term rule, which needs the laws of the set samplers,
becomes check_bounded_length_laws on a SimulationContextConfig, called by
build_simulation_context; it no longer reapplies the model config rules,
already checked when the model is built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onless tolerance

DIMENSIONLESS_EPSILON (1e-6) is the tolerance for the quantities without
unit: ratios, weights, exponents, numbers of objects. GLOBAL_EPSILON is a
length tolerance and depends on the units: it stays for lengths only. The
observation term uses a single rule on the number of unobserved objects
lambda * A - F: below -epsilon lambda is underestimated, within epsilon all
the objects are observed (hard-core), above the observation is partial. The
proposal weights, the von Mises concentration and the power law exponent
use the new constant, with the same value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_model_integrability only checked one rule: an attractive pairwise
term needs intra-set hard-cores. It becomes check_attractions_have_hard_cores,
symmetric with check_bounded_length_laws. model.hpp documents the
integrability of the model in one place, with references: the reference
measure, why a repulsive model is integrable, the two sources of non
integrability and where each one is checked, at construction and in
set_thetas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n an unbounded law

A length term on an unbounded length law was refused whatever its
parameter, although p21 <= 1 (theta <= 0) is integrable. The rule now
goes through the attraction flag of the term, like the hard-core rule of
the pairwise terms: build_simulation_context calls the new
Model::forbid_attraction on such a term, so theta > 0 is refused when the
simulation is built and by set_thetas afterwards, and theta <= 0 is
accepted. The segment specific rule moves out of the generic header.

A length law with an infinite max_value is no longer seen as bounded.

Tests: term indices named in the model parameter tests, literal tiny
parameters instead of GLOBAL_EPSILON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BenPinet
BenPinet merged commit 68313bf into next Dec 2, 2026
15 checks passed
@BenPinet
BenPinet deleted the fix/parameter-validity branch December 2, 2026 11:08
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.

3 participants