Module knowledge_rep
- class neasqc_qrbs.knowledge_rep.Buildable
Bases:
ABC
Interface for knowledge elements that can be built into quantum routines.
- abstract build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.LeftHandSide
Bases:
Buildable
Interface for elements that can be part of the left hand side of a rule. This class is used to model the Composite design pattern, acting as the Component interface.
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.Fact(attribute, value, precision=0.0)
Bases:
LeftHandSide
Class representing a Fact.
A Fact is the smallest unit of knowledge that can be represented. This class is used to model the Composite design pattern, acting as the Leaf class.
- attribute
Attribute that the fact is representing.
- Type:
str
- value
Value of the attribute that the fact is representing.
- Type:
float
- precision
Precision of the fact; the certainty of the attribute having said value (0 if not specified). Must be in range [0,1].
- Type:
float, optional
- property precision
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.AndOperator(left_child, right_child)
Bases:
LeftHandSide
Class representing an AndOperator.
An AndOperator relates the statements of its children with an AND relationship. This class is used to model the Composite design pattern, acting as (one of) the Composite class.
- left_child
One of the children which is relating.
- Type:
- right_child
One of the children which is relating.
- Type:
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.OrOperator(left_child, right_child)
Bases:
LeftHandSide
Class representing an OrOperator.
An OrOperator relates the statements of its children with an OR relationship. This class is used to model the Composite design pattern, acting as (one of) the Composite class.
- left_child
One of the children which is relating.
- Type:
- right_child
One of the children which is relating.
- Type:
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.NotOperator(child)
Bases:
LeftHandSide
Class representing a NotOperator.
A NotOperator negates the statement of its child. This class is used to model the Composite design pattern, acting as (one of) the Composite class.
- child
Child which statement is negating.
- Type:
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.Rule(left_hand_side, right_hand_side, certainty=0.0)
Bases:
Buildable
Class representing a Rule.
A Rule which establishes a relationship (to some level of uncertainty) between a left hand side element and a right hand side, which in this context is a Fact.
- left_hand_side
Left hand side element of the rule (also known as precedent).
- Type:
- certainty
Certainty of the relationship between precedent and consequent (0 if not specified). Must be in range [0,1].
- Type:
float, optional
- property certainty
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.KnowledgeIsland(rules)
Bases:
Buildable
Class representing a Knowledge Island.
A Knowledge Island is a set of rules that conform the inferential reasoning towards a hypothesis.
- build(builder) qat.lang.AQASM.QRoutine
- class neasqc_qrbs.knowledge_rep.Builder
Bases:
ABC
Interface for building the corresponding quantum routine from a Buildable element.
- abstract static build_fact(fact) qat.lang.AQASM.QRoutine
Builds the quantum routine of a fact.
- Parameters:
fact (
Fact
) – The Fact whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- abstract static build_and() qat.lang.AQASM.QRoutine
Builds the quantum routine of an and operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- abstract static build_or() qat.lang.AQASM.QRoutine
Builds the quantum routine of an or operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- abstract static build_not() qat.lang.AQASM.QRoutine
Builds the quantum routine of a not operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- abstract static build_rule(rule) qat.lang.AQASM.QRoutine
Builds the quantum routine of a rule.
- Parameters:
rule (
Rule
) – The Rule whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- abstract static build_island(island) Tuple[qat.lang.AQASM.QRoutine, Dict[LeftHandSide, int]]
Builds the quantum routine of a knowledge island.
- Parameters:
island (
KnowledgeIsland
) – The KnowledgeIsland whose quantum routine is being built.- Returns:
A tuple containing the corresponding quantum routine and the index of which qubit corresponds to each LeftHandSide element.
- Return type:
Tuple[
QRoutine
, Dict[LeftHandSide
, int]]
- class neasqc_qrbs.knowledge_rep.BuilderImpl
Bases:
Builder
Implementation of Builder interface.
- M = 'M'
- static build_fact(fact) qat.lang.AQASM.QRoutine
Builds the quantum routine of a fact.
- Parameters:
fact (
Fact
) – The Fact whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_and() qat.lang.AQASM.QRoutine
Builds the quantum routine of an and operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_or() qat.lang.AQASM.QRoutine
Builds the quantum routine of an or operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_not() qat.lang.AQASM.QRoutine
Builds the quantum routine of a not operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_rule(rule) qat.lang.AQASM.QRoutine
Builds the quantum routine of a rule.
- Parameters:
rule (
Rule
) – The Rule whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_island(island) Tuple[qat.lang.AQASM.QRoutine, Dict[LeftHandSide, int]]
Builds the quantum routine of a knowledge island.
- Parameters:
island (
KnowledgeIsland
) – The KnowledgeIsland whose quantum routine is being built.- Returns:
A tuple containing the corresponding quantum routine and the index of which qubit corresponds to each LeftHandSide element.
- Return type:
Tuple[
QRoutine
, Dict[LeftHandSide
, int]]
- class neasqc_qrbs.knowledge_rep.BuilderFuzzy
Bases:
Builder
Implementation of Builder interface for the fuzzy logic model.
- static build_fact(fact) qat.lang.AQASM.QRoutine
Builds the quantum routine of a fact.
- Parameters:
fact (
Fact
) – The Fact whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_and() qat.lang.AQASM.QRoutine
Builds the quantum routine of an and operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_or() qat.lang.AQASM.QRoutine
Builds the quantum routine of an or operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_not() qat.lang.AQASM.QRoutine
Builds the quantum routine of a not operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_rule(rule) qat.lang.AQASM.QRoutine
Builds the quantum routine of a rule.
- Parameters:
rule (
Rule
) – The Rule whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_island(island) Tuple[qat.lang.AQASM.QRoutine, Dict[LeftHandSide, int]]
Builds the quantum routine of a knowledge island.
- Parameters:
island (
KnowledgeIsland
) – The KnowledgeIsland whose quantum routine is being built.- Returns:
A tuple containing the corresponding quantum routine and the index of which qubit corresponds to each LeftHandSide element.
- Return type:
Tuple[
QRoutine
, Dict[LeftHandSide
, int]]
- class neasqc_qrbs.knowledge_rep.BuilderBayes
Bases:
Builder
Implementation of Builder interface for the bayesian model.
- CRY = 'CRY'
- static build_fact(fact) qat.lang.AQASM.QRoutine
Builds the quantum routine of a fact.
- Parameters:
fact (
Fact
) – The Fact whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_and() qat.lang.AQASM.QRoutine
Builds the quantum routine of an and operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_or() qat.lang.AQASM.QRoutine
Builds the quantum routine of an or operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_not() qat.lang.AQASM.QRoutine
Builds the quantum routine of a not operator.
- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_rule(rule) qat.lang.AQASM.QRoutine
Builds the quantum routine of a rule.
- Parameters:
rule (
Rule
) – The Rule whose quantum routine is being built.- Returns:
The corresponding quantum routine.
- Return type:
QRoutine
- static build_island(island) Tuple[qat.lang.AQASM.QRoutine, Dict[LeftHandSide, int]]
Builds the quantum routine of a knowledge island.
- Parameters:
island (
KnowledgeIsland
) – The KnowledgeIsland whose quantum routine is being built.- Returns:
A tuple containing the corresponding quantum routine and the index of which qubit corresponds to each LeftHandSide element.
- Return type:
Tuple[
QRoutine
, Dict[LeftHandSide
, int]]