nemo_rl.data.packing.metrics#

Metrics for evaluating sequence packing algorithms.

Module Contents#

Classes#

PackingMetrics

Class for tracking and computing metrics for sequence packing algorithms.

API#

class nemo_rl.data.packing.metrics.PackingMetrics[source]#

Class for tracking and computing metrics for sequence packing algorithms.

This class provides methods to calculate various metrics that evaluate the efficiency and effectiveness of sequence packing algorithms, such as bin utilization, waste, and imbalance.

Initialization

Initialize the metrics tracker.

reset() None[source]#

Reset all metrics.

update(
sequence_lengths: List[int],
bins: List[List[int]],
bin_capacity: int,
packing_time: Optional[float] = None,
) Dict[str, float][source]#

Update metrics with a new packing solution.

Parameters:
  • sequence_lengths – List of sequence lengths

  • bins – List of bins, where each bin is a list of indices

  • bin_capacity – Maximum capacity of each bin

  • packing_time – Optional time taken to compute the packing solution

Returns:

Dictionary of metrics for this packing solution

calculate_stats_only(
sequence_lengths: List[int],
bins: List[List[int]],
bin_capacity: int,
) Dict[str, float][source]#

Calculate metrics for a packing solution without updating the tracker.

Parameters:
  • sequence_lengths – List of sequence lengths

  • bins – List of bins, where each bin is a list of indices

  • bin_capacity – Maximum capacity of each bin

Returns:

Dictionary of metrics for this packing solution

get_aggregated_stats() Dict[str, float][source]#

Get aggregated metrics across all packing operations.

Returns:

Dictionary of aggregated metrics

print_aggregated_stats() None[source]#

Print the aggregated metrics in a formatted way.