Add multi-value QCA with direct cube minimisation - #18
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Categorical conditions with more than two levels, minimised as multi-value cubes rather than reduced to Boolean indicators.
The workflow mirrors
FSQCA/CSQCAdeliberately: moving between them is a change of estimator, not of method.Why not Boolean dummies
Encoding
A{0,1,2}as three indicators does not preserve the semantics. The binary space contains points such asA_0 = A_1 = 1— a case in two mutually exclusive categories at once, corresponding to no configuration at all — and the minimiser is free to build implicants across them, producing terms that look valid and describe nothing. Recovering a multi-value expression afterwards needs exactly the mutual-exclusivity constraints the encoding discarded.The cube algebra is therefore implemented directly. Merging generalises the binary rule: two cubes agreeing on every condition but one merge into a cube whose set at that condition is the union. Because they agree everywhere else, the merged cube covers exactly their union and nothing more — the property the binary rule relies on, unchanged. Tests assert that directly, and that every cube covers only real configurations.
One solver, one guarantee
Rather than write a second exact solver, the branch-and-bound was extracted into
solve_minimum_cover, which works on coverage sets. The binary engine and the multi-value engine now share one verified implementation; all 45 existing exactness and chart tests passed unchanged through the refactor.Verified by exhaustive enumeration for levels (2,2), (3,2), (2,3) and (3,3), and against the binary minimiser for every three-condition problem.
Agreement with R
R supports multi-value and writes
regime[2]. Truth tables and parsimonious solutions match exactly. The conservative solution can differ in representation:Same coverage, same cost (2 terms, 3 literals) — both minimal. R writes single-value literals only, so its
regime[1]*wealth[1]is a proper subset ofregime{1,2}*wealth{1}and is therefore not a prime implicant. Parity tests compare cost and coverage rather than text, which is the comparison that carries meaning.Levels are inferred from the data but can be declared, because an unobserved-but-possible level is a remainder and changes the parsimonious solution.
562 tests at 100% coverage; mypy strict and docs build clean.
Summary by cubic
Introduce multi-value QCA (
MVQCA) with direct cube minimisation so categorical conditions are handled correctly without boolean dummies. Share one exact cover solver across binary and multi-value; solutions match R in cost and coverage.New Features
MVQCAestimator,MultiValueDomain, andMultiValueTruthTablewith mixed‑radix indexing and direct cube merging.summary_frame()includes consistency and coverage.setqcaroot.Refactors
solve_minimum_coverand updated binary minimiser to use it, reducing duplication while preserving exactness (existing tests unchanged).Written for commit 878d7ca. Summary will update on new commits.