Skip to content

BEHAVIOR: derive CSP variables from problem set - #380

Open
grayson-helmholz wants to merge 1 commit into
typeddict-factsfrom
facts-driven-solving
Open

grayson-helmholz wants to merge 1 commit into
typeddict-factsfrom
facts-driven-solving

Conversation

@grayson-helmholz

@grayson-helmholz grayson-helmholz commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

❗ Behavioral changes

  • CSPSolver now creates all its variables up front from what the QNProblemSet declares, instead of creating them while walking the rules of each node and edge. A graph element without initial facts contributes one variable per declared quantum number domain; an element with initial facts contributes fixed values. Rules then only select among the variables that already exist, so the set of variables no longer depends on which rules happen to be inspected first.
  • An initial fact may now hold a list or tuple of values instead of a single value. Such a range becomes a solver variable with the range as its domain, which is what allows several spin-projection cases to be solved inside one constraint problem.
  • complete_intermediate_states() merges the initial facts into a completed solution without overwriting the solved values, since a fact carrying a value range only covers the case that the solution actually selected.

✨ New features

  • merge_qn_problem_sets() in qrules.solving groups problem sets that differ only in the given quantum numbers (by default spin_projection) and merges each group into a single QNProblemSet carrying value ranges. A group is merged only when its values form a full Cartesian product over the edges, so no combination is added or lost.
  • create_qn_problem_sets() takes an optional merge_spin_projections argument that applies this merging to the problem sets it returns, which cuts the number of problem sets and the solving time for reactions with many spin-projection combinations.

⚙️ Enhancements

  • create_graph_settings() drops the quantum number domains that no conservation rule of the surrounding graph elements can consume. An edge domain survives if an edge rule of that edge, or a node rule of an adjacent node, requires the quantum number. Since the solver creates a variable per declared domain, this keeps the constraint problem from carrying variables that nothing constrains.

Squash commit messages

* ENH: restrict QN domains to what rules require
* FEAT: add merge_qn_problem_sets function
* FEAT: add merge_spin_projections flag

@redeboer
redeboer added this pull request to stack #386 September 15, 2026 14:29
@redeboer redeboer changed the title BEHAVIOR: drive CSP variables from declared facts and domains BEHAVIOR: derive CSP variables from problem set Sep 15, 2026
@redeboer redeboer added ⚙️ Enhancement Improvements and optimizations of existing features ✨ Feature New feature added to the package ❗ Behavior Changes that may affect the framework output labels Sep 15, 2026
@redeboer
redeboer self-requested a review September 15, 2026 14:40
@redeboer redeboer added this to the 0.11.0 milestone Sep 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❗ Behavior Changes that may affect the framework output ⚙️ Enhancement Improvements and optimizations of existing features ✨ Feature New feature added to the package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drive CSP variable creation from declared facts Allow initial facts to contain ranges of values

2 participants