Repository navigation
fix(EnergyTerm): make a term hard-core only for a zero parameter - #68
Merged
Merged
Conversation
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>
BotellaA
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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, andset_thetasaccepts 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.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_contextcalls the newModel::forbid_attraction, so γ > 1 is refused when the simulation is built (C++ and Python) and θ > 0 byset_thetasafterwards. 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 callforbid_attractionitself. The boundedness rule is shared with the buffer size check, which stays a warning for the other sets.Results unchanged
At fixed seed, the reference fracture simulation gives exactly the same files as before.
Tests
max_valuerefused (C++ and Python); p21 = 0.5 on it accepted, thenset_theta> 0 refused and < 0 accepted; an infinitemax_valueis not a bound; Gaussian refused even withmax_value; power law withmax_valueaccepted; a set without length term keeps an unbounded law; θ = 1 accepted on a bounded law.Behavior changes
Not marked as breaking: they will be gathered in the single
BREAKING CHANGEof the ABC release.max_valueis an unbounded length law: a warning instead of the buffer size error.🤖 Generated with Claude Code