solving#
import qrules.solving
Functions to solve a particle reaction problem.
This module is responsible for solving a particle reaction problem stated by a
QNProblemSet
. The Solver
classes (e.g. CSPSolver
) generate new quantum
numbers (for example belonging to an intermediate state) and validate the decay
processes with the rules formulated by the conservation_rules
module.
- class EdgeSettings(conservation_rules: Set[GraphElementRule] = _Nothing.NOTHING, rule_priorities: Dict[GraphElementRule, int] = _Nothing.NOTHING, qn_domains: Dict[Any, list] = _Nothing.NOTHING)[source]#
Bases:
object
Solver settings for a specific edge of a graph.
- conservation_rules: Set[GraphElementRule][source]#
- rule_priorities: Dict[GraphElementRule, int][source]#
- class NodeSettings(conservation_rules: Set[GraphElementRule | EdgeQNConservationRule | ConservationRule] = _Nothing.NOTHING, rule_priorities: Dict[GraphElementRule | EdgeQNConservationRule | ConservationRule, int] = _Nothing.NOTHING, qn_domains: Dict[Any, list] = _Nothing.NOTHING, interaction_strength: float = 1.0)[source]#
Bases:
object
Container class for the interaction settings.
This class can be assigned to each node of a state transition graph. Hence, these settings contain the complete configuration information which is required for the solution finding, e.g:
set of conservation rules
mapping of rules to priorities (optional)
mapping of quantum numbers to their domains
strength scale parameter (higher value means stronger force)
- conservation_rules: Set[GraphElementRule | EdgeQNConservationRule | ConservationRule][source]#
- rule_priorities: Dict[GraphElementRule | EdgeQNConservationRule | ConservationRule, int][source]#
- GraphSettings: TypeAlias = 'MutableTransition[EdgeSettings, NodeSettings]'#
(Mutable) mapping of settings on a
Topology
.
- GraphElementProperties: TypeAlias = 'MutableTransition[GraphEdgePropertyMap, GraphNodePropertyMap]'#
(Mutable) mapping of edge and node properties on a
Topology
.
- class QNProblemSet(initial_facts: GraphElementProperties, solving_settings: GraphSettings)[source]#
Bases:
object
Particle reaction problem set, defined as a graph like data structure.
- Parameters:
initial_facts – all of the known facts quantum numbers of the problem.
solving_settings – solving specific settings, such as the specific rules and variable domains for nodes and edges of the
topology
.
- initial_facts: GraphElementProperties[source]#
- solving_settings: GraphSettings[source]#
- class QNResult(solutions: List[MutableTransition[Dict[Type[pid | mass | width | spin_magnitude | spin_projection | charge | isospin_magnitude | isospin_projection | strangeness | charmness | bottomness | topness | baryon_number | electron_lepton_number | muon_lepton_number | tau_lepton_number | parity | c_parity | g_parity], int | float], Dict[Type[l_magnitude | l_projection | s_magnitude | s_projection | parity_prefactor], int | float]]] = _Nothing.NOTHING, not_executed_node_rules: Dict[int, Set[str]] = _Nothing.NOTHING, violated_node_rules: Dict[int, Set[str]] = _Nothing.NOTHING, not_executed_edge_rules: Dict[int, Set[str]] = _Nothing.NOTHING, violated_edge_rules: Dict[int, Set[str]] = _Nothing.NOTHING)[source]#
Bases:
object
Defines a result to a problem set processed by the solving code.
- solutions: List[MutableTransition[Dict[Type[pid | mass | width | spin_magnitude | spin_projection | charge | isospin_magnitude | isospin_projection | strangeness | charmness | bottomness | topness | baryon_number | electron_lepton_number | muon_lepton_number | tau_lepton_number | parity | c_parity | g_parity], int | float], Dict[Type[l_magnitude | l_projection | s_magnitude | s_projection | parity_prefactor], int | float]]][source]#
- class Solver[source]#
Bases:
ABC
Interface of a Solver.
- abstract find_solutions(problem_set: QNProblemSet) QNResult [source]#
Find solutions for the given input.
It is expected that this function determines and returns all of the found solutions. In case no solutions are found a partial list of violated rules has to be given. This list of violated rules does not have to be complete.
- Parameters:
problem_set (
QNProblemSet
) – states a problem set- Returns:
- contains possible solutions, violated rules and not executed
rules due to requirement issues.
- Return type:
- validate_full_solution(problem_set: QNProblemSet) QNResult [source]#
- class CSPSolver(allowed_intermediate_states: Iterable[Dict[Type[pid | mass | width | spin_magnitude | spin_projection | charge | isospin_magnitude | isospin_projection | strangeness | charmness | bottomness | topness | baryon_number | electron_lepton_number | muon_lepton_number | tau_lepton_number | parity | c_parity | g_parity], int | float]])[source]#
Bases:
Solver
Solver reducing the task to a Constraint Satisfaction Problem.
Solving this done with the python-constraint module.
The variables are the quantum numbers of particles/edges, but also some composite quantum numbers which are attributed to the interaction nodes (such as angular momentum \(L\)). The conservation rules serve as the constraints and a special wrapper class serves as an adapter.
- find_solutions(problem_set: QNProblemSet) QNResult [source]#
Find solutions for the given input.
It is expected that this function determines and returns all of the found solutions. In case no solutions are found a partial list of violated rules has to be given. This list of violated rules does not have to be complete.
- Parameters:
problem_set (
QNProblemSet
) – states a problem set- Returns:
- contains possible solutions, violated rules and not executed
rules due to requirement issues.
- Return type:
- class Scoresheet[source]#
Bases:
object
- register_rule(graph_element_id: int, rule: GraphElementRule | EdgeQNConservationRule | ConservationRule) Callable[[bool], None] [source]#
- property rule_calls: Dict[Tuple[int, GraphElementRule | EdgeQNConservationRule | ConservationRule], int][source]#
- property rule_passes: Dict[Tuple[int, GraphElementRule | EdgeQNConservationRule | ConservationRule], int][source]#