avl._core.object module

class avl._core.object.Object(*args: Any, **kwargs: Any)[source]
__init__(name: str, parent: Component) None[source]

Initialize Object.

Parameters:
  • name (str) – Name of the object.

  • parent (Object, optional) – Parent object.

set_name(name: str)[source]

Set the name of the object.

Parameters:

name (str) – Name to set.

get_name() str[source]

Get the name of the object.

Returns:

Name of the object.

Return type:

str

get_full_name() str[source]

Get the full hierarchical name of the component.

Returns:

Full name of the component.

Return type:

str

set_parent(parent: Component) None[source]

Set the parent of the component.

Parameters:

parent (Component) – Parent component.

get_parent() Component[source]

Get the parent of the component.

Returns:

Parent component.

Return type:

Component

set_field_attributes(name: str, fmt: ~collections.abc.Callable[[...], str] = <class 'str'>, compare: bool = True) None[source]

Set attributes for a field.

Parameters:
  • name (str) – Field name.

  • fmt (type) – Format of the field.

  • compare (bool) – Whether to compare the field.

get_field_attributes(name: str) dict[str, Any][source]

Get attributes for a field.

Parameters:

name (str) – Field name.

Returns:

Field attributes.

Return type:

tuple

remove_field_attributes(name: str) None[source]

Remove attributes for a field.

Parameters:

name (str) – Field name.

set_table_fmt(fmt: str | None = None, transpose: bool | None = None, recurse: bool | None = None) None[source]

Set the table format for string representation.

Parameters:
  • fmt (str) – Table format.

  • transpose (bool) – Whether to transpose the table.

  • recurse (bool) – Whether to recurse into Object fields.

debug(msg: str, group: str | None = None) None[source]

Logs a debug message.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

info(msg: str, group: str | None = None) None[source]

Logs an info message.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

warn(msg: str, group: str | None = None) None[source]

Logs a warning message.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

warning(msg: str, group: str | None = None) None[source]

Logs a warning message.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

error(msg: str, group: str | None = None) None[source]

Logs an error message.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

critical(msg: str, group: str | None = None) None[source]

Logs a critical message. Instantly stops the simulation by raising a SimFailure exception.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

fatal(msg: str, group: str | None = None) None[source]

Logs a fatal message and raises a SimFailure exception. Instantly stops the simulation by raising a SimFailure exception.

Parameters:
  • msg (str) – Message to be logged.

  • group (str) – Group to which the message belongs.

compare(rhs: Object, verbose: bool = False, bidirectional: bool = True) bool[source]

Compare this object with another Object.

Parameters:
  • rhs (Object) – Object to compare with.

  • verbose (bool) – Whether to print comparison details.

  • bidirectional (bool) – Whether to perform bidirectional comparison.

Returns:

1 if comparison passed, 0 otherwise.

Return type:

int

add_constraint(name: str, constraint: BoolRef, *args: Any, hard: bool = True, target: dict | None = None) None[source]

Add a constraint to the object.

Parameters:
  • name (str) – Name of the constraint.

  • constraint (z3.constraint) – The constraint function to add.

  • args (list) – Additional arguments for the constraint.

  • hard (bool) – Whether the constraint is hard (default: True).

  • target (dict, optional) – Optional target dictionary to store the constraint.

remove_constraint(name: str) None[source]

Remove a constraint from the object.

Parameters:

constraint (function) – The constraint function to remove.

pre_randomize() None[source]

Pre-randomization function.

post_randomize() None[source]

Post-randomization function.

randomize(hard: list[BoolRef] | None = None, soft: list[BoolRef] | None = None) None[source]

This method randomizes the value of the variable by considering hard and soft constraints. It uses an optimization solver to find a suitable value that satisfies the constraints.

Parameters:
  • hard (list, optional) – Optional list of hard constraints to be added. Each constraint is a tuple where the first element is the constraint expression and the second element is the constraint value.

  • soft (list, optional) – Optional list of soft constraints to be added. Each constraint is a tuple where the first element is the constraint expression and the second element is the constraint value.

Hard and soft constraints follow the SV naming convention. Hard constraints must be satisfied, otherwise an error is raised. Soft constraints will attempt to be satisfied, but if not, the solver will return a solution that minimizes the number of unsatisfied constraints.

Raises:
  • ValueError – If an unknown variable is encountered in the model.

  • Exception – If the solver fails to randomize the variable.