solving¶
import qrules.solving
Functions to solve a particle reaction problem.
This module is responsible for solving a particle reaction problem stated by a
StateTransitionGraph
and corresponding GraphSettings
. 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 CSPSolver(allowed_intermediate_particles: List[Dict[Type[Union[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]], Union[int, float]]])[source]¶
Bases:
qrules.solving.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 EdgeSettings(conservation_rules: Set[GraphElementRule] = NOTHING, rule_priorities: Dict[GraphElementRule, int] = NOTHING, qn_domains: Dict[Any, list] = NOTHING)[source]¶
Bases:
object
Solver settings for a specific edge of a graph.
- conservation_rules: Set[GraphElementRule]¶
- rule_priorities: Dict[GraphElementRule, int]¶
- class GraphElementProperties(edge_props: Dict[int, Dict[Type[Union[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]], Union[int, float]]] = NOTHING, node_props: Dict[int, Dict[Type[Union[l_magnitude, l_projection, s_magnitude, s_projection, parity_prefactor]], Union[int, float]]] = NOTHING)[source]¶
Bases:
object
- edge_props: Dict[int, Dict[Type[Union[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]], Union[int, float]]]¶
- node_props: Dict[int, Dict[Type[Union[l_magnitude, l_projection, s_magnitude, s_projection, parity_prefactor]], Union[int, float]]]¶
- class GraphSettings(edge_settings: Dict[int, EdgeSettings] = NOTHING, node_settings: Dict[int, NodeSettings] = NOTHING)[source]¶
Bases:
object
- edge_settings: Dict[int, EdgeSettings]¶
- node_settings: Dict[int, NodeSettings]¶
- class NodeSettings(conservation_rules: Set[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]] = NOTHING, rule_priorities: Dict[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule], int] = NOTHING, qn_domains: Dict[Any, list] = 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[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]]¶
- rule_priorities: Dict[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule], int]¶
- class QNProblemSet(topology: Topology, initial_facts: GraphElementProperties, solving_settings: GraphSettings)[source]¶
Bases:
object
Particle reaction problem set, defined as a graph like data structure.
- Parameters
topology (
Topology
) – a topology that represent the structure of the reactioninitial_facts (
GraphElementProperties
) – all of the known facts quantum numbers of the problemsolving_settings (
GraphSettings
) – solving specific settings such as the specific rules and variable domains for nodes and edges of the topology
- initial_facts: GraphElementProperties¶
- solving_settings: GraphSettings¶
- class QNResult(solutions: List[QuantumNumberSolution] = NOTHING, not_executed_node_rules: Dict[int, Set[str]] = NOTHING, violated_node_rules: Dict[int, Set[str]] = NOTHING, not_executed_edge_rules: Dict[int, Set[str]] = NOTHING, violated_edge_rules: Dict[int, Set[str]] = NOTHING)[source]¶
Bases:
object
Defines a result to a problem set processed by the solving code.
- solutions: List[QuantumNumberSolution]¶
- class QuantumNumberSolution(node_quantum_numbers: Dict[int, Dict[Type[Union[l_magnitude, l_projection, s_magnitude, s_projection, parity_prefactor]], Union[int, float]]], edge_quantum_numbers: Dict[int, Dict[Type[Union[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]], Union[int, float]]])[source]¶
Bases:
object
- edge_quantum_numbers: Dict[int, Dict[Type[Union[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]], Union[int, float]]]¶
- node_quantum_numbers: Dict[int, Dict[Type[Union[l_magnitude, l_projection, s_magnitude, s_projection, parity_prefactor]], Union[int, float]]]¶
- class Scoresheet[source]¶
Bases:
object
- register_rule(graph_element_id: int, rule: Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]) Callable[[bool], None] [source]¶
- property rule_calls: Dict[Tuple[int, Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]], int]¶
- property rule_passes: Dict[Tuple[int, Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]], int]¶
- class Solver[source]¶
Bases:
abc.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]¶