TimeloopFE
Loading...
Searching...
No Matches
timeloopfe.v4.constraints.Factors Class Reference

A list of factors used to describe loop bounds. More...

Inheritance diagram for timeloopfe.v4.constraints.Factors:
Collaboration diagram for timeloopfe.v4.constraints.Factors:

Public Member Functions

 declare_attrs (cls, *args, **kwargs)
 Initialize the attributes of this node.
 
List[Tuple[str, str, str]] get_split_factors (self)
 Get a list of split factors.
 
List[str] get_factor_names (self)
 Get a list of factor names.
 
 remove_factor (self, str name)
 Remove a factor from the list of factors.
 
 add_eq_factor (self, str name, int value, bool overwrite=False)
 Adds an equality factor to the constraint.
 
 add_leq_factor (self, str name, int value, bool overwrite=False)
 Adds a less than or equal to (<=) factor constraint to the list of constraints.
 
 add_geq_factor (self, str name, int value, bool overwrite=False)
 Adds a greater-than-or-equal factor constraint to the constraint set.
 
 check_unique_remove_repeat (self)
 
"Factors" combine (self, "Factors" other)
 Extends this list with the contents of another list.
 
 get_minimum_product (self, problem.Instance problem_instance)
 Calculates the minimum product of all factors in this list.
 
bool add_eq_factor_iff_not_exists (self, str name, int value)
 Add an "name=value" factor iff "name" is not already in the factor list.
 
bool add_leq_factor_iff_not_exists (self, str name, int value)
 Add an "name<=value" factor iff "name" is not already in the factor list.
 
Optional[str] name2factor (self, str name)
 Return the factor with the given name, or None if not found.
 
 __init__ (self, *args, **kwargs)
 
- Public Member Functions inherited from timeloopfe.common.nodes.CombinableListNode
- Public Member Functions inherited from timeloopfe.common.nodes.ListNode
- Public Member Functions inherited from timeloopfe.common.nodes.Node
 get_specifiers_from_processors (cls, "BaseSpecification" spec)
 Get the specifiers that have been set from processors.
 
 reset_specifiers_from_processors (cls, Optional[Type] processor=None)
 Reset the specifiers that have been set from processors.
 
 reset_processor_elems (cls, Optional[Type] processor=None)
 
 recognize_all (cls, bool recognize_all=True)
 Set whether all attributes under this node should be recognized.
 
str get_tag (self)
 Get the tag of this node.
 
Iterable[Tuple[Union[str, int], Any]] items (self)
 Get iterable of (key, value) or (index, value) pairs.
 
T combine_index (self, Union[str, int] key, T value)
 Combine the value at the given key with the given value.
 
str get_name (self, Union[Set, None] seen=None)
 Get the name of this node.
 
 check_unrecognized (self, bool ignore_empty=False, ignore_should_have_been_removed_by=False)
 Check for unrecognized keys in this node and all subnodes.
 
Any recursive_apply (self, callable func, bool self_first=False, set applied_to=None)
 Apply a function to this node and all subnodes.
 
 clean_empties (self)
 Remove empty nodes from this node and all subnodes.
 
bool isempty (self)
 Return True if this node is empty.
 
bool isempty_recursive (self)
 Return True if this node or all subnodes are empty.
 
 add_attr (cls, str key_or_tag, Optional[Union[type, Tuple[type,...], Tuple[None,...], Tuple[str,...], None]] required_type=None, Any default=default_unspecified_, Optional[Callable] callfunc=None, Optional[bool] part_name_match=None, Optional[bool] no_change_key=None, Any _processor_responsible_for_removing=None, Optional[Dict[str, TypeSpecifier]] _add_checker_to=None)
 Initialize a type specifier for this class.
 
List[Tget_nodes_of_type (self, Type[T] node_type)
 Return a list of all subnodes of a given type.
 
Callable get_setter_lambda (self, Union[str, int] keytag)
 Get a function that can be used to set a value in this node.
 
Callable get_combiner_lambda (self, Union[str, int] keytag)
 Get a function that can be used to combine a value to this node.
 
List[Tuple[Any, Callable]] get_setters_for_keytag (self, str keytag, bool recursive=True)
 Get a list of tuples of the form (value, setter) for all keys/tags in this node that match the given key/tag.
 
List[Tuple[Any, Callable]] get_combiners_for_keytag (self, str keytag, bool recursive=True)
 Get a list of tuples of the form (value, combiner) for all keys/tags in this node that match the given key/tag.
 
List[Tuple[Any, Callable]] get_setters_for_type (self, Type t, bool recursive=True)
 Get a list of tuples of the form (value, setter) for all keys/tags in this node that match the given type.
 
List[Tuple[Any, Callable]] get_combiners_for_type (self, Type t, bool recursive=True)
 Get a list of tuples of the form (value, combiner) for all keys/tags in this node that match the given type.
 
 __str__ (self)
 Return the name of this node.
 
 __format__ (self, format_spec)
 Formats the name of this node.
 
bool is_defined_non_default_non_empty (self, str key)
 Returns True if the given key is defined in this node and is not the default value and is not empty.
 
Any __getitem__ (self, Union[str, int] key)
 Get the value at the given key or index.
 
 __setitem__ (self, Union[str, int] key, Any value)
 Set the value at the given key or index.
 
 parse_expressions (self, Optional[Dict[str, Any]] symbol_table=None, Optional[set] parsed_ids=None, Optional[Callable] callfunc=None)
 Parse expressions in this node and all subnodes.
 
 unique_class_name (cls)
 Return a unique name for this class.
 

Static Public Member Functions

 check_valid_factor (f)
 Check if a factor is valid.
 
"Factors" factory (Union[str, list] x)
 Create a Factors object from a string or a list.
 
Tuple[str, str, int] splitfactor (str x)
 Split a factor string into its components.
 
- Static Public Member Functions inherited from timeloopfe.common.nodes.Node
"BaseSpecification" get_global_spec ()
 Get the global specification object.
 
 set_global_spec ("BaseSpecification" spec)
 Set the global specification object.
 
Any try_combine (Any a, Any b, Union["Node", None] innonde=None, Union[int, str, None] index=None)
 Try to combine two values.
 

Protected Member Functions

 _check_factors_compatible (self, a, b)
 
- Protected Member Functions inherited from timeloopfe.common.nodes.Node
Dict[str, TypeSpecifier_get_type_specifiers (cls, "BaseSpecification" spec)
 Get the type specifiers for this node.
 
 _get_all_recognized (self)
 
Dict[Union[str, int], TypeSpecifier_get_index2checker (self, Optional[List[Tuple[str, Any]]] key2elem=None)
 
 _parse_elem (self, Union[str, int] key, TypeSpecifier check, Any value_override=None)
 
 _parse_elems (self)
 
 _parse_extra_elems (self, List[Tuple[str, Any]] key2elem)
 
 _check_unrecognized (self, ignore_empty=False, ignore_should_have_been_removed_by=False)
 
 _parse_expression (self, Union[str, int] index, Dict[str, Any] symbol_table, Optional[TypeSpecifier] checker=None)
 

Additional Inherited Members

- Public Attributes inherited from timeloopfe.common.nodes.ListNode
 from_data = list(self)
 
- Public Attributes inherited from timeloopfe.common.nodes.Node
Node parent_node = None
 
"BaseSpecification" spec = Node.get_global_spec()
 
 logger = logging.getLogger(self.__class__.__name__)
 
 from_data = None
 
- Static Protected Member Functions inherited from timeloopfe.common.nodes.Node
str _get_tag (x)
 
- Protected Attributes inherited from timeloopfe.common.nodes.Node
tuple _init_args = (args, kwargs)
 
bool _default_parse = False
 

Detailed Description

A list of factors used to describe loop bounds.

Constructor & Destructor Documentation

◆ __init__()

timeloopfe.v4.constraints.Factors.__init__ ( self,
* args,
** kwargs )

Reimplemented from timeloopfe.common.nodes.ListNode.

Member Function Documentation

◆ _check_factors_compatible()

timeloopfe.v4.constraints.Factors._check_factors_compatible ( self,
a,
b )
protected

◆ add_eq_factor()

timeloopfe.v4.constraints.Factors.add_eq_factor ( self,
str name,
int value,
bool overwrite = False )

Adds an equality factor to the constraint.

Args: name (str): The name of the factor. value (int): The value of the factor. overwrite (bool, optional): If True, removes any existing factor with the same name before adding the new one. Defaults to False.

◆ add_eq_factor_iff_not_exists()

bool timeloopfe.v4.constraints.Factors.add_eq_factor_iff_not_exists ( self,
str name,
int value )

Add an "name=value" factor iff "name" is not already in the factor list.

Return True if the factor was added.

◆ add_geq_factor()

timeloopfe.v4.constraints.Factors.add_geq_factor ( self,
str name,
int value,
bool overwrite = False )

Adds a greater-than-or-equal factor constraint to the constraint set.

Args: name (str): The name of the factor. value (int): The value of the factor. overwrite (bool, optional): If True, removes any existing factor with the same name before adding the new one. Defaults to False.

◆ add_leq_factor()

timeloopfe.v4.constraints.Factors.add_leq_factor ( self,
str name,
int value,
bool overwrite = False )

Adds a less than or equal to (<=) factor constraint to the list of constraints.

Args: name (str): The name of the factor. value (int): The value of the factor. overwrite (bool, optional): If True, removes any existing factor with the same name before adding the new one. Defaults to False.

◆ add_leq_factor_iff_not_exists()

bool timeloopfe.v4.constraints.Factors.add_leq_factor_iff_not_exists ( self,
str name,
int value )

Add an "name<=value" factor iff "name" is not already in the factor list.

Return True if the factor was added.

◆ check_unique_remove_repeat()

timeloopfe.v4.constraints.Factors.check_unique_remove_repeat ( self)

◆ check_valid_factor()

timeloopfe.v4.constraints.Factors.check_valid_factor ( f)
static

Check if a factor is valid.

Parameters:

  • f: The factor to be checked.

Returns:

  • Factor: The factor if it is valid.

Raises:

  • ValueError: If the factor cannot be split.

◆ combine()

"Factors" timeloopfe.v4.constraints.Factors.combine ( self,
"Factors" other )

Extends this list with the contents of another list.

Reimplemented from timeloopfe.common.nodes.CombinableListNode.

◆ declare_attrs()

timeloopfe.v4.constraints.Factors.declare_attrs ( cls,
* args,
** kwargs )

Initialize the attributes of this node.

Reimplemented from timeloopfe.common.nodes.Node.

◆ factory()

"Factors" timeloopfe.v4.constraints.Factors.factory ( Union[str, list] x)
static

Create a Factors object from a string or a list.

Args: x (Union[str, list]): The input string or list.

Returns: Factors: The Factors object created from the input.

Raises: None

◆ get_factor_names()

List[str] timeloopfe.v4.constraints.Factors.get_factor_names ( self)

Get a list of factor names.

Example: get_factor_names() returns ["X", "Y", "Z"] if the factors are "X=123", "Y=456", and "Z=789".

◆ get_minimum_product()

timeloopfe.v4.constraints.Factors.get_minimum_product ( self,
problem.Instance problem_instance )

Calculates the minimum product of all factors in this list.

Args: problem_instance (problem.Instance): The problem instance.

Returns: int: The calculated minimum product.

◆ get_split_factors()

List[Tuple[str, str, str]] timeloopfe.v4.constraints.Factors.get_split_factors ( self)

Get a list of split factors.

Example: get_split_factors() returns [("X", "=", "123"), ("Y", "=", "456"), ("Z", "=", "789")] if the factors are "X=123", "Y=456", and "Z=789".

◆ name2factor()

Optional[str] timeloopfe.v4.constraints.Factors.name2factor ( self,
str name )

Return the factor with the given name, or None if not found.

◆ remove_factor()

timeloopfe.v4.constraints.Factors.remove_factor ( self,
str name )

Remove a factor from the list of factors.

Args: name (str): The name of the factor to be removed.

Raises: None

Example: remove_factor("X") removes the factor "X=123" from the list of factors.

◆ splitfactor()

Tuple[str, str, int] timeloopfe.v4.constraints.Factors.splitfactor ( str x)
static

Split a factor string into its components.

Args: x (str): The factor string to be split.

Returns: Tuple[str, str, int]: A tuple containing the factor name, the comparison operator, and the factor value.

Raises: ValueError: If none of the valid comparison operators are found in the factor string.

Example: splitfactor("X=123") returns ("X", "=", 123)


The documentation for this class was generated from the following file: