newground.comparison_tools module

The comparison tools module is used as a helper module, for various parts of the transformer. It is useful for domain inference, instantiations, calculations, etc.

class newground.comparison_tools.ComparisonTools

Bases: object

The comparison tools module is used as a helper module, for various parts of the transformer. It is useful for domain inference, instantiations, calculations, etc.

classmethod aggregate_count_special_variable_getter(binary_operation)

Special method for count-aggregate, for increased performance. Deprecated.

Binary_operation:

AST binary-operation

classmethod apply_binary_operation(left_domain, right_domain, binary_operation)

Compute the new domain.

Left_domain:

Domain-list.

Right_domain:

Domain-list.

Binary_operation:

Binary AST operation.

classmethod apply_unary_operation(domain, unary_operation)

Compute the new domain.

Domain:

Domain-list.

Unary_operation:

Unary AST operation.

classmethod compare_terms(comp, c1, c2)

Returns the computed boolean value of the comparison.

Comp:

The AST representation of the comparison operator.

C1:

The left side of the comparison (Python-value - assumed int).

C2:

The right side of the comparison (Python-value - assumed int).

classmethod comparison_handlings(comp, c1, c2)

Returns a string representation of the comparison operation (or false if not implemented).

Comp:

The AST representation of the comparison operator.

C1:

The left side of the comparison (AST).

C2:

The right side of the comparison (AST).

classmethod evaluate_binary_operation(operator_type, left_value, right_value)

Computes the resulting value after applying the operation.

Operator_type:

AST operator type.

Left_value:

Python value (int).

Right_value:

Python value (int).

classmethod evaluate_operation(operation, variable_assignments)

Computes a tree-traversal and the resulting value of the whole operation.

Operation:

AST operation.

Variable_assignment:

Variable assignment dict.

classmethod generate_binary_operator_domain(operator_type, left_domain, right_domain)

Computes the resulting domain, of the operation.

Operator_type:

AST type of binary-operator.

Left_domain:

Domain of the left part of the binary-operation.

Right_domain:

Domain of the right part of the binary operation.

classmethod generate_domain(variable_assignments, operation)

If a variable is inducing in a comparison, this method creates its domain.

Variable_assignments:

Corresponds to the domains of the variables.

Operation:

Comparison operator (Clingo AST).

classmethod generate_unary_operator_domain(operator_type, domain)

Computes the resulting domain, of the operation.

Operator_type:

AST type of unary-operator.

Domain:

the domain dict.

classmethod get_arguments_from_operation(root)

Given a root ast term, it computes all arguments from an operation. Performs a tree traversal of an operation (e.g. X+Y -> first ‘’+’’, then ‘’X’’ and lastly ‘’Y’’, then combines together)

Root:

A AST operation/term.

classmethod get_comp_operator(comp)

Returns the string representation (or false, if not implemented).

Comp:

The AST representation of the comparison operator.

classmethod instantiate_operation(root, variable_assignments)

Instantiates a operation and returns the corresponding string.

Root:

An AST operation/term.

Variable_assignment:

A variable-value dict.