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, rule_priorities: dict[GraphElementRule, int] = NOTHING, qn_domains: dict[type[pid] | type[mass] | type[width] | type[spin_magnitude] | type[spin_projection] | type[charge] | type[isospin_magnitude] | type[isospin_projection] | type[strangeness] | type[charmness] | type[bottomness] | type[topness] | type[baryon_number] | type[electron_lepton_number] | type[muon_lepton_number] | type[tau_lepton_number] | type[parity] | type[c_parity] | type[g_parity], list] = NOTHING)[source]#

Bases: object

Solver settings for a specific edge of a graph.

conservation_rules: set[GraphElementRule][source]#
rule_priorities: dict[GraphElementRule, int][source]#
qn_domains: dict[type[pid] | type[mass] | type[width] | type[spin_magnitude] | type[spin_projection] | type[charge] | type[isospin_magnitude] | type[isospin_projection] | type[strangeness] | type[charmness] | type[bottomness] | type[topness] | type[baryon_number] | type[electron_lepton_number] | type[muon_lepton_number] | type[tau_lepton_number] | type[parity] | type[c_parity] | type[g_parity], list][source]#
class NodeSettings(conservation_rules: set[GraphElementRule | EdgeQNConservationRule | ConservationRule] = NOTHING, rule_priorities: dict[GraphElementRule | EdgeQNConservationRule | ConservationRule, int] = NOTHING, qn_domains: dict[type[l_magnitude] | type[l_projection] | type[s_magnitude] | type[s_projection] | type[parity_prefactor], 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[GraphElementRule | EdgeQNConservationRule | ConservationRule][source]#
rule_priorities: dict[GraphElementRule | EdgeQNConservationRule | ConservationRule, int][source]#
qn_domains: dict[type[l_magnitude] | type[l_projection] | type[s_magnitude] | type[s_projection] | type[parity_prefactor], list][source]#
interaction_strength: float[source]#
GraphSettings#

(Mutable) mapping of settings on a Topology.

alias of MutableTransition[EdgeSettings, NodeSettings]

GraphElementProperties#

(Mutable) mapping of edge and node properties on a Topology.

alias of 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 | Fraction], dict[type[l_magnitude | l_projection | s_magnitude | s_projection | parity_prefactor], int | float | Fraction]]

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]#
property topology: Topology[source]#
filter_quantum_number_problem_set(quantum_number_problem_set: QNProblemSet, edge_rules: set[GraphElementRule], node_rules: set[Rule], edge_properties: Iterable[EdgeQuantumNumberTypes], node_properties: Iterable[NodeQuantumNumberTypes]) QNProblemSet[source]#

Filter QNProblemSet for desired conservation rules, settings and domains.

Currently it is the responsibility of the user to provide fitting properties and domains for the correspinding conservation rules.

Parameters:
  • quantum_number_problem_setQNProblemSet as generated by CSPSolver.

  • edge_rules – Conservation rules regarding the edges.

  • node_rules – Conservation rules regarding the nodes.

  • edge_properties – Edge settings, properties and domains.

  • node_properties – Node settings, properties and domains.

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 | Fraction], dict[type[l_magnitude | l_projection | s_magnitude | s_projection | parity_prefactor], int | float | Fraction]]] = 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[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 | Fraction], dict[type[l_magnitude | l_projection | s_magnitude | s_projection | parity_prefactor], int | float | Fraction]]][source]#
not_executed_node_rules: dict[int, set[str]][source]#
violated_node_rules: dict[int, set[str]][source]#
not_executed_edge_rules: dict[int, set[str]][source]#
violated_edge_rules: dict[int, set[str]][source]#
extend(other_result: QNResult) None[source]#
class Solver[source]#

Bases: ABC

Interface of a Solver.

abstractmethod 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]#
class CSPSolver(allowed_intermediate_states: Iterable[GraphEdgePropertyMap])[source]#

Bases: Solver

Solver reducing the task to a Constraint Satisfaction Problem.

Solving this done with the constraint package.

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

dict_set_intersection(base_dict: dict[Any, Any], set_of_keys: set[Any]) dict[Any, Any][source]#
class Scoresheet[source]#

Bases: object

register_rule(graph_element_id: int, rule: Rule) 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]#