mqt.core.ir.symbolic¶
Module Contents¶
- class Variable(name: str = '')¶
A symbolic variable.
Note
Variables are uniquely identified by their name, so if a variable with the same name already exists, the existing variable will be returned.
- Parameters:
name – The name of the variable.
- class Term(variable: Variable, coefficient: float = 1.0)¶
A symbolic term which consists of a variable with a given coefficient.
- Parameters:
variable – The variable of the term.
coefficient – The coefficient of the term.
- add_coefficient(coeff: float) None¶
Add a coefficient to the coefficient of this term.
- Parameters:
coeff – The coefficient to add.
- class Expression(constant: float = 0.0)¶
- class Expression(terms: Sequence[Term], constant: float = 0.0)
- class Expression(term: Term, constant: float = 0.0)
A symbolic expression which consists of a sum of terms and a constant.
The expression is of the form \(constant + term_1 + term_2 + \dots + term_n\). Alternatively, an expression can be created with a single term and a constant or just a constant.
- Parameters:
terms – The list of terms.
constant – The constant.
- evaluate(assignment: Mapping[Variable, float]) float¶
Evaluate the expression with a given variable assignment.
- Parameters:
assignment – The variable assignment.
- Returns:
The evaluated value of the expression.
- __add__(arg: Expression, /) Expression¶
- __add__(arg: float, /) Expression
- __add__(arg: Term, /) Expression
- __radd__(arg: Term, /) Expression¶
- __radd__(arg: float, /) Expression
- __sub__(arg: Expression, /) Expression¶
- __sub__(arg: float, /) Expression
- __sub__(arg: Term, /) Expression
- __rsub__(arg: float, /) Expression¶
- __rsub__(arg: Term, /) Expression
- __mul__(arg: float, /) Expression¶
- __rmul__(arg: float, /) Expression¶
- __truediv__(arg: float, /) Expression¶