solving

Deprecated since version 0.7.3: Use QRules and AmpForm instead

import expertsystem.reaction.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: expertsystem.reaction.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

QNResult

class EdgeSettings(conservation_rules: Set[GraphElementRule] = NOTHING, rule_priorities: Dict[GraphElementRule, int] = NOTHING, qn_domains: Dict[Any, Any] = NOTHING)[source]

Bases: object

Solver settings for a specific edge of a graph.

__eq__(other)

Method generated by attrs for class EdgeSettings.

conservation_rules: Set[GraphElementRule]
qn_domains: Dict[Any, Any]
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

__eq__(other)

Method generated by attrs for 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]]]
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

__eq__(other)

Method generated by attrs for class GraphSettings.

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, Any] = NOTHING)[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)

__eq__(other)

Method generated by attrs for class NodeSettings.

conservation_rules: Set[Union[GraphElementRule, EdgeQNConservationRule, ConservationRule]]
interaction_strength: float = 1.0
qn_domains: Dict[Any, Any]
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 reaction

  • initial_facts (GraphElementProperties) – all of the known facts quantum numbers of the problem

  • solving_settings (GraphSettings) – solving specific settings such as the specific rules and variable domains for nodes and edges of the topology

__eq__(other)

Method generated by attrs for class QNProblemSet.

initial_facts: GraphElementProperties
solving_settings: GraphSettings
topology: Topology
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.

__eq__(other)

Method generated by attrs for class QNResult.

extend(other_result: QNResult)None[source]
not_executed_edge_rules: Dict[int, Set[str]]
not_executed_node_rules: Dict[int, Set[str]]
solutions: List[QuantumNumberSolution]
violated_edge_rules: Dict[int, Set[str]]
violated_node_rules: Dict[int, Set[str]]
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

__eq__(other)

Method generated by attrs for class QuantumNumberSolution.

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
property rule_passes
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

QNResult

validate_full_solution(problem_set: QNProblemSet)QNResult[source]