Add ArbitraryConstraint for general structural constraints#143
Open
ryan112358 wants to merge 1 commit into
Open
Add ArbitraryConstraint for general structural constraints#143ryan112358 wants to merge 1 commit into
ryan112358 wants to merge 1 commit into
Conversation
9a02c56 to
c10c7db
Compare
Add ArbitraryConstraint to extensions/constraints.py for arbitrary cross-attribute constraints via allowed or disallowed index combinations. Unlike DeterministicConstraint (many-to-one only, O(|fine|) routing), this produces a dense -inf/0 log-space factor for standard inference. - Construct from valid OR invalid combinations (exactly one required) - Supports any number of attributes - from_mapping() classmethod bridges to DeterministicConstraint patterns - as_potential(domain) produces the constraint Factor - Both constrained_shafer_shenoy and constrained_implicit accept mixed tuples of DeterministicConstraint and ArbitraryConstraint; arbitrary constraints are folded into potentials before inference Tested: 21 new unit tests + full suite (1108 tests pass).
c10c7db to
b5003fd
Compare
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.
Adds
ArbitraryConstrainttoextensions/constraints.pyalongside the existingDeterministicConstraint. The two are complementary siblings:DeterministicConstraintArbitraryConstraintAPI
Exactly one of
validorinvalidmust be specified. Supports any number of attributes.Motivation
The census domain has 14 cross-attribute constraints. 13 are functional dependencies handled by
DeterministicConstraint, butgqtype ↔ gqis a conditional constraint (one-to-many in both directions). This class fills that gap.Tests
18 unit tests covering construction, validation, both potential modes, complementarity, from_mapping equivalence, message passing integration, and equality semantics.