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 EdgeSettings(conservation_rules: Set[GraphElementRule] = _Nothing.NOTHING, rule_priorities: Dict[GraphElementRule, int] = _Nothing.NOTHING, qn_domains: Dict[Any, list] = _Nothing.NOTHING)[source]#
Bases:
objectSolver settings for a specific edge of a graph.
- conservation_rules: Set[GraphElementRule]#
- rule_priorities: Dict[GraphElementRule, int]#
- class NodeSettings(conservation_rules: Set[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]] = _Nothing.NOTHING, rule_priorities: Dict[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule], int] = _Nothing.NOTHING, qn_domains: Dict[Any, list] = _Nothing.NOTHING, interaction_strength: float = 1.0)[source]#
Bases:
objectContainer 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 GraphSettings(edge_settings: Dict[int, EdgeSettings] = _Nothing.NOTHING, node_settings: Dict[int, NodeSettings] = _Nothing.NOTHING)[source]#
Bases:
object- edge_settings: Dict[int, EdgeSettings]#
- node_settings: Dict[int, NodeSettings]#
- 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.NOTHING, node_props: Dict[int, Dict[Type[Union[l_magnitude, l_projection, s_magnitude, s_projection, parity_prefactor]], Union[int, float]]] = _Nothing.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 QNProblemSet(topology: Topology, initial_facts: GraphElementProperties, solving_settings: GraphSettings)[source]#
Bases:
objectParticle 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 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- 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]]]#
- class QNResult(solutions: List[QuantumNumberSolution] = _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:
objectDefines a result to a problem set processed by the solving code.
- solutions: List[QuantumNumberSolution]#
- class Solver[source]#
Bases:
ABCInterface 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_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:
SolverSolver 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: 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]#