Skip to content

utilities¤

Helpers for lists and Pareto fronts.

Lists¤

list_split ¤

list_split(lst: list[Any], indices: list[int]) -> list[list[Any]]

Split list at given indices. Closed lists have the same first and last elements. If the list is closed, splitting wraps around if the first or last index is not in the indices to split.

Parameters:

  • lst (list) –
    A list.
    
  • indices (list) –
    A list of indices to split.
    

Returns:

  • split_lists ( list ) –

    Nest lists from splitting the list at the given indices.

sublist_from_to_items_in_closed_list ¤

sublist_from_to_items_in_closed_list(
    lst: list[Any], from_item: Any, to_item: Any
) -> list[Any] | None

Return sublist between oe item to another.

Parameters:

  • lst (list) –
    A list.
    
  • from_item (Any) –
    An item to be found in the list. The beginning of the sublist.
    
  • to_item (Any) –
    An item to be found in the list. The end of the sublist.
    

Returns:

  • sublist ( list ) –

    A sublist from the input list, between from_item and to_item.

are_items_in_list ¤

are_items_in_list(items: list[Any], lst: list[Any]) -> bool

Check if items are in a list.

Parameters:

  • items (list) –
    A list of items (order does not matter).
    
  • lst (list) –
    A list.
    

Returns:

  • bool –

    True if all items are in the list. False otherwise.

common_items ¤

common_items(l1: list[Any], l2: list[Any]) -> list[Any]

Return common items in two lists.

Parameters:

  • l1 (list) –
    A list.
    
  • l2 (list) –
    A list.
    

Returns:

  • list –

    The common items.

remove_isomorphism_in_integer_list ¤

remove_isomorphism_in_integer_list(lst: list[int]) -> list[int]

Pareto¤

extract_pareto_indices ¤

extract_pareto_indices(data: list[Iterable[float]], k: float = 1.0) -> list[int]

Get the Pareto front from data. The performances are to be minimised. If the metrics must be maximised, take the opposite X <- -X and the inverse k <- 1/k.

Parameters:

  • data (list) –

    A list of iterables storing the performance data.

  • k (float, default: 1.0 ) –

    Parameter for weak domination. Default is 1.0.

Returns:

  • list –

    List of indices of Pareto front in data.

References
  1. Wikipedia. Multi-objective optimization. Available at: https://en.wikipedia.org/wiki/Multi-objective_optimization.

is_dominating ¤

is_dominating(X1: Iterable[float], X2: Iterable[float], k: float = 1.0) -> bool

Check if design X1 dominates X2: all metrics below or equal and one strictly below.

k below 1.0 allows weak domination.

Parameters:

  • X1 (iterable) –

    A design to test if is dominating.

  • X2 (iterable) –

    A design to test if is dominated.

  • k (float, default: 1.0 ) –

    Parameter for weak domination. Default if 1.0.

Returns:

  • bool –

    True if is dominating, False otherwise

References
  1. Wikipedia. Multi-objective optimization. Available at: https://en.wikipedia.org/wiki/Multi-objective_optimization.