Skip to content

Cost Dimension Indicators

process_performance_indicators.indicators.cost.instances

fixed_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The fixed cost associated with an activity instance, measured as the latest recorded value among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required

Returns:

Name Type Description
float float | None

The fixed cost for single events of an activity instance.

None float | None

If no fixed cost is found.

Source code in process_performance_indicators/indicators/cost/instances.py
def fixed_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The fixed cost associated with an activity instance, measured as the latest recorded value
    among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    Returns:
        float: The fixed cost for single events of an activity instance.
        None: If no fixed cost is found.

    """
    assert_column_exists(event_log, StandardColumnNames.FIXED_COST)

    complete_event = instances_utils.cpl(event_log, instance_id)
    if not complete_event.empty:
        return float(complete_event[StandardColumnNames.FIXED_COST].unique()[0])

    start_event = instances_utils.start(event_log, instance_id)
    if not start_event.empty:
        return float(start_event[StandardColumnNames.FIXED_COST].unique()[0])

    return None

fixed_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The fixed cost associated with an activity instance, measured as the sum of all values among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def fixed_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The fixed cost associated with an activity instance, measured as the sum of
    all values among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.FIXED_COST)

    start_event = instances_utils.start(event_log, instance_id)
    complete_event = instances_utils.cpl(event_log, instance_id)

    if not start_event.empty and not complete_event.empty:
        return float(
            start_event[StandardColumnNames.FIXED_COST].unique()[0]
            + complete_event[StandardColumnNames.FIXED_COST].unique()[0]
        )

    return None

inventory_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The inventory cost associated with an activity instance, measured as the latest recorded value among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def inventory_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The inventory cost associated with an activity instance, measured as the latest
    recorded value among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.INVENTORY_COST)

    complete_event = instances_utils.cpl(event_log, instance_id)
    if not complete_event.empty:
        return float(complete_event[StandardColumnNames.INVENTORY_COST].unique()[0])

    start_event = instances_utils.start(event_log, instance_id)
    if not start_event.empty:
        return float(start_event[StandardColumnNames.INVENTORY_COST].unique()[0])

    return None

inventory_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The inventory cost associated with an activity instance, measured as the sum of all values among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def inventory_cost_for_sum_of_all_events_of_activity_instances(
    event_log: pd.DataFrame, instance_id: str
) -> float | None:
    """
    The inventory cost associated with an activity instance, measured as the sum of
    all values among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.INVENTORY_COST)

    start_event = instances_utils.start(event_log, instance_id)
    complete_event = instances_utils.cpl(event_log, instance_id)

    if not start_event.empty and not complete_event.empty:
        return float(
            start_event[StandardColumnNames.INVENTORY_COST].unique()[0]
            + complete_event[StandardColumnNames.INVENTORY_COST].unique()[0]
        )

    return None

labor_cost_and_total_cost_ratio(event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the labor cost associated with the activity instance, and the total cost associated with the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": The aggregation mode for single events of an activity instance. "sum": The aggregation mode for the sum of all events of an activity instance.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def labor_cost_and_total_cost_ratio(
    event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the labor cost associated with the activity instance, and the total cost
    associated with the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.
        aggregation_mode: The aggregation mode.
            "sgl": The aggregation mode for single events of an activity instance.
            "sum": The aggregation mode for the sum of all events of an activity instance.

    """
    # TODO: ask here what to do when labor_cost or total_cost is None
    assert_column_exists(event_log, StandardColumnNames.LABOR_COST)
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    aggregation_functions = {
        "sgl": (
            labor_cost_for_single_events_of_activity_instances,
            total_cost_for_single_events_of_activity_instances,
        ),
        "sum": (
            labor_cost_for_sum_of_all_events_of_activity_instances,
            total_cost_for_sum_of_all_events_of_activity_instances,
        ),
    }

    labor_cost_func, total_cost_func = aggregation_functions[aggregation_mode]
    labor_cost = labor_cost_func(event_log, instance_id)
    total_cost = total_cost_func(event_log, instance_id)

    return safe_division(labor_cost, total_cost)

labor_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The labor cost associated with an activity instance, measured as the lastest recorded value among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def labor_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The labor cost associated with an activity instance, measured as the lastest recorded value among the events
    of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.LABOR_COST)

    complete_event = instances_utils.cpl(event_log, instance_id)
    if not complete_event.empty:
        return float(complete_event[StandardColumnNames.LABOR_COST].unique()[0])

    start_event = instances_utils.start(event_log, instance_id)
    if not start_event.empty:
        return float(start_event[StandardColumnNames.LABOR_COST].unique()[0])

    return None

labor_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The labor cost associated with an activity instance, measured as the sum of all values among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def labor_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The labor cost associated with an activity instance, measured as the sum of
    all values among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.LABOR_COST)

    start_event = instances_utils.start(event_log, instance_id)
    complete_event = instances_utils.cpl(event_log, instance_id)

    if not start_event.empty and not complete_event.empty:
        return float(
            start_event[StandardColumnNames.LABOR_COST].unique()[0]
            + complete_event[StandardColumnNames.LABOR_COST].unique()[0]
        )

    return None

total_cost_and_lead_time_ratio(event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with the activity instance, and the total elapsed time of the activity instance. In cost per hour.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": The aggregation mode for single events of an activity instance. "sum": The aggregation mode for the sum of all events of an activity instance.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def total_cost_and_lead_time_ratio(
    event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with the activity instance, and the total elapsed
    time of the activity instance. In cost per hour.

    Args:
        event_log: The event log.
        instance_id: The instance id.
        aggregation_mode: The aggregation mode.
            "sgl": The aggregation mode for single events of an activity instance.
            "sum": The aggregation mode for the sum of all events of an activity instance.

    """
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    # TODO: ask here what to do when total_cost is None
    total_cost_function = {
        "sgl": total_cost_for_single_events_of_activity_instances,
        "sum": total_cost_for_sum_of_all_events_of_activity_instances,
    }

    return safe_division(
        total_cost_function[aggregation_mode](event_log, instance_id),
        time_instances_indicators.lead_time(event_log, instance_id) / pd.Timedelta(hours=1),
    )

total_cost_and_outcome_unit_ratio(event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with the activity instance, and the outcome units associated with the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost and outcome unit calculations. "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def total_cost_and_outcome_unit_ratio(
    event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with the activity instance, and the outcome
    units associated with the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost and outcome unit calculations.
            "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

    """
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    aggregation_functions = {
        "sgl": {
            "cost": total_cost_for_single_events_of_activity_instances,
            "outcome": quality_instances_indicators.outcome_unit_count_for_single_events_of_activity_instances,
        },
        "sum": {
            "cost": total_cost_for_sum_of_all_events_of_activity_instances,
            "outcome": quality_instances_indicators.outcome_unit_count_for_sum_of_all_events_of_activity_instances,
        },
    }

    cost_func = aggregation_functions[aggregation_mode]["cost"]
    outcome_func = aggregation_functions[aggregation_mode]["outcome"]

    total_cost = cost_func(event_log, instance_id) or 0
    outcome_unit = outcome_func(event_log, instance_id) or 0

    return safe_division(total_cost, outcome_unit)

total_cost_and_service_time_ratio(event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with the activity instance, and the elapsed time between the start and complete events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def total_cost_and_service_time_ratio(
    event_log: pd.DataFrame, instance_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with the activity instance, and the elapsed
    time between the start and complete events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    # TODO: ask here what to do when total_cost is None
    total_cost_function = {
        "sgl": total_cost_for_single_events_of_activity_instances,
        "sum": total_cost_for_sum_of_all_events_of_activity_instances,
    }
    return safe_division(
        total_cost_function[aggregation_mode](event_log, instance_id),
        time_instances_indicators.service_time(event_log, instance_id) / pd.Timedelta(hours=1),
    )

total_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The total cost associated with an activity instance, measured as the lastest recorded value among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def total_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The total cost associated with an activity instance, measured as the lastest recorded
    value among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    complete_event = instances_utils.cpl(event_log, instance_id)
    if not complete_event.empty:
        return float(complete_event[StandardColumnNames.TOTAL_COST].unique()[0])

    start_event = instances_utils.start(event_log, instance_id)
    if not start_event.empty:
        return float(start_event[StandardColumnNames.TOTAL_COST].unique()[0])

    return None

total_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The total cost associated with an activity instance, measured as the sum of all values among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def total_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The total cost associated with an activity instance, measured as the sum of
    all values among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.TOTAL_COST)

    start_event = instances_utils.start(event_log, instance_id)
    complete_event = instances_utils.cpl(event_log, instance_id)

    if not start_event.empty and not complete_event.empty:
        return float(
            start_event[StandardColumnNames.TOTAL_COST].unique()[0]
            + complete_event[StandardColumnNames.TOTAL_COST].unique()[0]
        )

    return None

variable_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The variable cost associated with an activity instance, measured as the latest recorded value among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def variable_cost_for_single_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None:
    """
    The variable cost associated with an activity instance, measured as the latest recorded
    value among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.VARIABLE_COST)

    complete_event = instances_utils.cpl(event_log, instance_id)
    if not complete_event.empty:
        return float(complete_event[StandardColumnNames.VARIABLE_COST].unique()[0])

    start_event = instances_utils.start(event_log, instance_id)
    if not start_event.empty:
        return float(start_event[StandardColumnNames.OUTCOME_UNIT].unique()[0])

    return None

variable_cost_for_sum_of_all_events_of_activity_instances(event_log: pd.DataFrame, instance_id: str) -> float | None

The variable cost associated with an activity instance, measured as the sum of all values among the events of the activity instance.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
instance_id str

The instance id.

required
Source code in process_performance_indicators/indicators/cost/instances.py
def variable_cost_for_sum_of_all_events_of_activity_instances(
    event_log: pd.DataFrame, instance_id: str
) -> float | None:
    """
    The variable cost associated with an activity instance, measured as the sum of all
    values among the events of the activity instance.

    Args:
        event_log: The event log.
        instance_id: The instance id.

    """
    assert_column_exists(event_log, StandardColumnNames.VARIABLE_COST)

    start_event = instances_utils.start(event_log, instance_id)
    complete_event = instances_utils.cpl(event_log, instance_id)

    if not start_event.empty and not complete_event.empty:
        return float(
            start_event[StandardColumnNames.VARIABLE_COST].unique()[0]
            + complete_event[StandardColumnNames.VARIABLE_COST].unique()[0]
        )
    return None

process_performance_indicators.indicators.cost.activities

fixed_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The fixed cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def fixed_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The fixed cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.fixed_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.fixed_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_fixed_cost = 0
    activity_instances = activities_utils.inst(event_log, activity_name)

    for instance_id in activity_instances:
        aggregate_value = aggregation_function[aggregation_mode](event_log, instance_id) or 0
        total_fixed_cost += aggregate_value

    return total_fixed_cost

human_resource_count(event_log: pd.DataFrame, activity_name: str) -> int

The number of human resources that are involved in the execution of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def human_resource_count(event_log: pd.DataFrame, activity_name: str) -> int:
    """
    The number of human resources that are involved in the execution of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.

    """
    return len(activities_utils.hres(event_log, activity_name))

inventory_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The inventory cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def inventory_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The inventory cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.inventory_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.inventory_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_inventory_cost = 0

    for instance_id in activities_utils.inst(event_log, activity_name):
        total_inventory_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_inventory_cost

labor_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The labor cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def labor_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The labor cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.labor_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.labor_cost_for_sum_of_all_events_of_activity_instances,
    }
    labor_cost = 0

    for instance_id in activities_utils.inst(event_log, activity_name):
        labor_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return labor_cost

labor_cost_and_total_cost_ratio(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the labor cost associated with all instantiations of the activity, and the total cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def labor_cost_and_total_cost_ratio(
    event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the labor cost associated with all instantiations of the activity,
    and the total cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        labor_cost(event_log, activity_name, aggregation_mode),
        total_cost(event_log, activity_name, aggregation_mode),
    )

resource_count(event_log: pd.DataFrame, activity_name: str) -> int

The number of resources that are involved in the execution of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def resource_count(event_log: pd.DataFrame, activity_name: str) -> int:
    """
    The number of resources that are involved in the execution of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.

    """
    return len(activities_utils.res(event_log, activity_name))

rework_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost of all times that the activity has been instantiated again, after its first instantiation, in any case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def rework_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The total cost of all times that the activity has been instantiated again, after its
    first instantiation, in any case.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    sum_of_first_occurrences_cost = 0
    for case_id in event_log[StandardColumnNames.CASE_ID].unique():
        sum_of_first_occurrences_cost += cases_activities_utils.fitc(
            event_log, case_id, activity_name, aggregation_mode
        )

    return total_cost(event_log, activity_name, aggregation_mode) - sum_of_first_occurrences_cost

rework_count(event_log: pd.DataFrame, activity_name: str) -> int

The number of times that the activity has been instantiated again, after its first intantiation, in any case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def rework_count(event_log: pd.DataFrame, activity_name: str) -> int:
    """
    The number of times that the activity has been instantiated again, after its first
    intantiation, in any case.

    Args:
        event_log: The event log.
        activity_name: The activity name.

    """
    rework_count = 0

    for case_id in event_log[StandardColumnNames.CASE_ID].unique():
        rework_count += max(0, cases_activities_utils.count(event_log, case_id, activity_name) - 1)
    return rework_count

rework_percentage(event_log: pd.DataFrame, activity_name: str) -> float

The percentage of times that the activity has been instantiated again, after its first instantiation, in any case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def rework_percentage(event_log: pd.DataFrame, activity_name: str) -> float:
    """
    The percentage of times that the activity has been instantiated again, after its first
    instantiation, in any case.

    Args:
        event_log: The event log.
        activity_name: The activity name.

    """
    return safe_division(
        rework_count(event_log, activity_name),
        general_activities_indicators.activity_instance_count(event_log, activity_name),
    )

total_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def total_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The total cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.total_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.total_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_cost: float = 0

    for instance_id in activities_utils.inst(event_log, activity_name):
        total_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_cost

total_cost_and_lead_time_ratio(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all instantiations of the activity, and the sum of total elapsed times for all instantiations of the activity. In cost per hour.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def total_cost_and_lead_time_ratio(
    event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all instantiations of the activity, and the
    sum of total elapsed times for all instantiations of the activity. In cost per hour.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    # TODO : ask here if calculation is correct
    return safe_division(
        total_cost(event_log, activity_name, aggregation_mode),
        time_activities_indicators.lead_time(event_log, activity_name) / pd.Timedelta(hours=1),
    )

total_cost_and_outcome_unit_ratio(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all instantiations of the activity, and the outcome units associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost and outcome unit calculations. "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def total_cost_and_outcome_unit_ratio(
    event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all instantiations of the activity, and the
    outcome units associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost and outcome unit calculations.
            "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

    """
    return safe_division(
        total_cost(event_log, activity_name, aggregation_mode),
        quality_activities_indicators.outcome_unit_count(event_log, activity_name, aggregation_mode),
    )

total_cost_and_service_time_ratio(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all instantiations of the activity, and the sum of elapsed times between the start and complete events of all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def total_cost_and_service_time_ratio(
    event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all instantiations of the activity, and the
    sum of elapsed times between the start and complete events of all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        total_cost(event_log, activity_name, aggregation_mode),
        time_activities_indicators.service_time(event_log, activity_name) / pd.Timedelta(hours=1),
    )

variable_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The variable cost associated with all instantiations of the activity.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
activity_name str

The activity name.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/activities.py
def variable_cost(event_log: pd.DataFrame, activity_name: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The variable cost associated with all instantiations of the activity.

    Args:
        event_log: The event log.
        activity_name: The activity name.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.variable_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.variable_cost_for_sum_of_all_events_of_activity_instances,
    }
    variable_cost = 0

    for instance_id in activities_utils.inst(event_log, activity_name):
        variable_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return variable_cost

process_performance_indicators.indicators.cost.cases

automated_activity_cost(event_log: pd.DataFrame, case_id: str, automated_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The total cost associated with all instantiations of automated activities in the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
automated_activities set[str]

The set of automated activities.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def automated_activity_cost(
    event_log: pd.DataFrame, case_id: str, automated_activities: set[str], aggregation_mode: Literal["sgl", "sum"]
) -> int | float:
    """
    The total cost associated with all instantiations of automated activities in the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        automated_activities: The set of automated activities.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.total_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.total_cost_for_sum_of_all_events_of_activity_instances,
    }

    total_cost = 0
    for instance_id in cases_utils.inst(event_log, case_id):
        if instances_utils.act(event_log, instance_id) in automated_activities:
            total_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_cost

desired_activity_count(event_log: pd.DataFrame, case_id: str, desired_activities: set[str]) -> int

The number of instantiated activities whose occurrences is desirable in the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
desired_activities set[str]

The set of desired activities.

required

Returns:

Type Description
int

The number of instantiated activities whose occurrences is desirable in the case.

Source code in process_performance_indicators/indicators/cost/cases.py
def desired_activity_count(event_log: pd.DataFrame, case_id: str, desired_activities: set[str]) -> int:
    """
    The number of instantiated activities whose occurrences is desirable in the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        desired_activities: The set of desired activities.

    Returns:
        The number of instantiated activities whose occurrences is desirable in the case.

    """
    return len(desired_activities.intersection(cases_utils.act(event_log, case_id)))

direct_cost(event_log: pd.DataFrame, case_id: str, direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The total cost associated with all instantiations of activities that have a direct effect on the outcome of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
direct_cost_activities set[str]

The set of activities that have a direct effect on the outcome of the case.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def direct_cost(
    event_log: pd.DataFrame, case_id: str, direct_cost_activities: set[str], aggregation_mode: Literal["sgl", "sum"]
) -> int | float:
    """
    The total cost associated with all instantiations of activities that have a direct effect
    on the outcome of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        direct_cost_activities: The set of activities that have a direct effect
            on the outcome of the case.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.total_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.total_cost_for_sum_of_all_events_of_activity_instances,
    }

    total_cost = 0
    for instance_id in cases_utils.inst(event_log, case_id):
        if instances_utils.act(event_log, instance_id) in direct_cost_activities:
            total_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_cost

fixed_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The fixed cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl" considers single events of activity instances for cost calculations. "sum" considers the sum of all events of activity intances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def fixed_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The fixed cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl" considers single events of activity instances for cost calculations.
            "sum" considers the sum of all events of activity intances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.fixed_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.fixed_cost_for_sum_of_all_events_of_activity_instances,
    }

    total_fixed_cost = 0
    for instance_id in cases_utils.inst(event_log, case_id):
        total_fixed_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_fixed_cost

human_resource_count(event_log: pd.DataFrame, case_id: str) -> int

The number of human resources that are involved in the execution of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def human_resource_count(event_log: pd.DataFrame, case_id: str) -> int:
    """
    The number of human resources that are involved in the execution of the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    return len(cases_utils.hres(event_log, case_id))

inventory_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The inventory cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl" considers single events of activity instances for cost calculations. "sum" considers the sum of all events of activity intances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def inventory_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The inventory cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl" considers single events of activity instances for cost calculations.
            "sum" considers the sum of all events of activity intances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.inventory_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.inventory_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_inventory_cost = 0

    for instance_id in cases_utils.inst(event_log, case_id):
        total_inventory_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_inventory_cost

labor_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The labor cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl" considers single events of activity instances for cost calculations. "sum" considers the sum of all events of activity intances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def labor_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The labor cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl" considers single events of activity instances for cost calculations.
            "sum" considers the sum of all events of activity intances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.labor_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.labor_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_labor_cost = 0

    for instance_id in cases_utils.inst(event_log, case_id):
        total_labor_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_labor_cost

labor_cost_and_total_cost_ratio(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the labor cost associated with all activity instances of the case, and the total cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def labor_cost_and_total_cost_ratio(
    event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the labor cost associated with all activity instances of the case,
    and the total cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        labor_cost(event_log, case_id, aggregation_mode),
        total_cost(event_log, case_id, aggregation_mode),
    )

maintenance_cost(event_log: pd.DataFrame, case_id: str) -> float

The maintenance cost associated with the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def maintenance_cost(event_log: pd.DataFrame, case_id: str) -> float:
    """
    The maintenance cost associated with the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    assert_column_exists(event_log, StandardColumnNames.MAINTENANCE_COST)
    case_events = event_log[event_log[StandardColumnNames.CASE_ID] == case_id]
    if not case_events[StandardColumnNames.MAINTENANCE_COST].empty:
        return float(case_events[StandardColumnNames.MAINTENANCE_COST].unique()[0])
    return 0

missed_deadline_cost(event_log: pd.DataFrame, case_id: str) -> float

The cost for missing deadlines associated with the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def missed_deadline_cost(event_log: pd.DataFrame, case_id: str) -> float:
    """
    The cost for missing deadlines associated with the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    assert_column_exists(event_log, StandardColumnNames.MISSED_DEADLINE_COST)
    case_events = event_log[event_log[StandardColumnNames.CASE_ID] == case_id]
    if not case_events[StandardColumnNames.MISSED_DEADLINE_COST].empty:
        return float(case_events[StandardColumnNames.MISSED_DEADLINE_COST].unique()[0])
    return 0

overhead_cost(event_log: pd.DataFrame, case_id: str, direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all instantiations of activities that do not have a direct effect on the outcome of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
direct_cost_activities set[str]

The set of activities that have a direct cost on the outcome of the case.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def overhead_cost(
    event_log: pd.DataFrame, case_id: str, direct_cost_activities: set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The total cost associated with all instantiations of activities that do not
    have a direct effect on the outcome of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        direct_cost_activities: The set of activities that have a direct cost
            on the outcome of the case.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.total_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.total_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_cost = 0
    for instance_id in cases_utils.inst(event_log, case_id):
        if instances_utils.act(event_log, instance_id) not in direct_cost_activities:
            total_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_cost

resource_count(event_log: pd.DataFrame, case_id: str) -> int

The number of resources that are involved in the execution of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def resource_count(event_log: pd.DataFrame, case_id: str) -> int:
    """
    The number of resources that are involved in the execution of the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    return len(cases_utils.res(event_log, case_id))

rework_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost of all times that any activity has been instantiated again, after its first instantiation, in the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def rework_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The total cost of all times that any activity has been instantiated again, after its first
    instantiation, in the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    _rework_cost = 0
    for activity_name in event_log[StandardColumnNames.ACTIVITY].unique():
        _rework_cost += cases_activities_utils.fitc(event_log, case_id, activity_name, aggregation_mode)

    return total_cost(event_log, case_id, aggregation_mode) - _rework_cost

rework_count(event_log: pd.DataFrame, case_id: str) -> int

The number of times that any activity has been instantiated again, after its first intantiation, in the case.

Source code in process_performance_indicators/indicators/cost/cases.py
def rework_count(event_log: pd.DataFrame, case_id: str) -> int:
    """
    The number of times that any activity has been instantiated again, after its first
    intantiation, in the case.
    """
    rework_count = 0
    for activity_name in event_log[StandardColumnNames.ACTIVITY].unique():
        rework_count += max(0, cases_activities_utils.count(event_log, case_id, activity_name) - 1)
    return rework_count

rework_percentage(event_log: pd.DataFrame, case_id: str) -> float

The percentage of times that any activity has been instantiated again, after its first instantiation, in the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def rework_percentage(event_log: pd.DataFrame, case_id: str) -> float:
    """
    The percentage of times that any activity has been instantiated again, after its first
    instantiation, in the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    return safe_division(
        rework_count(event_log, case_id),
        general_cases_indicators.activity_instance_count(event_log, case_id),
    )

total_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def total_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The total cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.total_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.total_cost_for_sum_of_all_events_of_activity_instances,
    }
    total_cost: float = 0

    for instance_id in cases_utils.inst(event_log, case_id):
        total_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return total_cost

total_cost_and_lead_time_ratio(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the case, and the total elpased time between the earliest and latest timestamps in the case. In cost per hour.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def total_cost_and_lead_time_ratio(
    event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the case, and
    the total elpased time between the earliest and latest timestamps in the case. In cost per hour.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        total_cost(event_log, case_id, aggregation_mode),
        time_cases_indicators.lead_time(event_log, case_id) / pd.Timedelta(hours=1),
    )

total_cost_and_outcome_unit_ratio(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the case, and the outcome units associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode.H "sgl": Considers single events of activity instances for cost and outcome unit calculations. "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def total_cost_and_outcome_unit_ratio(
    event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the case, and the
    outcome units associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.H
            "sgl": Considers single events of activity instances for cost and outcome unit calculations.
            "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

    """
    return safe_division(
        total_cost(event_log, case_id, aggregation_mode),
        quality_cases_indicators.outcome_unit_count(event_log, case_id, aggregation_mode),
    )

total_cost_and_service_time_ratio(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the case, and the sum of elapsed times between the start and complete events of all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def total_cost_and_service_time_ratio(
    event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the case, and
    the sum of elapsed times between the start and complete events of all activity
    instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        total_cost(event_log, case_id, aggregation_mode),
        time_cases_indicators.service_time(event_log, case_id) / pd.Timedelta(hours=1),
    )

transportation_cost(event_log: pd.DataFrame, case_id: str) -> float

The transportation cost associated with the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def transportation_cost(event_log: pd.DataFrame, case_id: str) -> float:
    """
    The transportation cost associated with the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    assert_column_exists(event_log, StandardColumnNames.TRANSPORTATION_COST)
    case_events = event_log[event_log[StandardColumnNames.CASE_ID] == case_id]
    if not case_events[StandardColumnNames.TRANSPORTATION_COST].empty:
        return float(case_events[StandardColumnNames.TRANSPORTATION_COST].unique()[0])
    return 0

variable_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal['sgl', 'sum']) -> float

The variable cost associated with all activity instances of the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def variable_cost(event_log: pd.DataFrame, case_id: str, aggregation_mode: Literal["sgl", "sum"]) -> float:
    """
    The variable cost associated with all activity instances of the case.

    Args:
        event_log: The event log.
        case_id: The case id.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    aggregation_function = {
        "sgl": cost_instances_indicators.variable_cost_for_single_events_of_activity_instances,
        "sum": cost_instances_indicators.variable_cost_for_sum_of_all_events_of_activity_instances,
    }
    variable_cost = 0
    for instance_id in cases_utils.inst(event_log, case_id):
        variable_cost += aggregation_function[aggregation_mode](event_log, instance_id) or 0

    return variable_cost

warehousing_cost(event_log: pd.DataFrame, case_id: str) -> float

The warehousing cost associated with the case.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_id str

The case id.

required
Source code in process_performance_indicators/indicators/cost/cases.py
def warehousing_cost(event_log: pd.DataFrame, case_id: str) -> float:
    """
    The warehousing cost associated with the case.

    Args:
        event_log: The event log.
        case_id: The case id.

    """
    assert_column_exists(event_log, StandardColumnNames.WAREHOUSING_COST)
    case_events = event_log[event_log[StandardColumnNames.CASE_ID] == case_id]
    if not case_events[StandardColumnNames.WAREHOUSING_COST].empty:
        return float(case_events[StandardColumnNames.WAREHOUSING_COST].unique()[0])
    return 0

process_performance_indicators.indicators.cost.groups

automated_activity_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], automated_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The total cost associated with all instantiations of automated activities in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
automated_activities set[str]

The set of automated activities.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def automated_activity_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    automated_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> int | float:
    """
    The total cost associated with all instantiations of automated activities in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        automated_activities: The set of automated activities.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_cost = 0
    for case_id in case_ids:
        total_cost += cost_cases_indicators.automated_activity_cost(
            event_log, case_id, automated_activities, aggregation_mode
        )
    return total_cost

desired_activity_count(event_log: pd.DataFrame, case_ids: list[str] | set[str], desired_activities: set[str]) -> int

The number of instantiated activities whose occurrence is desirable in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
desired_activities set[str]

The set of desired activities.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def desired_activity_count(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], desired_activities: set[str]
) -> int:
    """
    The number of instantiated activities whose occurrence is desirable in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        desired_activities: The set of desired activities.

    """
    desired_activity_count = 0
    for case_id in case_ids:
        desired_activity_count += cost_cases_indicators.desired_activity_count(event_log, case_id, desired_activities)
    return desired_activity_count

direct_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The total cost associated with all instantiations of activities that have a direct effect on the outcome of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
direct_cost_activities set[str]

The set of activities that have a direct effect on the outcome of the group of cases.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def direct_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    direct_cost_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> int | float:
    """
    The total cost associated with all instantiations of activities that have a
    direct effect on the outcome of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        direct_cost_activities: The set of activities that have a direct effect on the outcome of the group of cases.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_cost = 0
    for case_id in case_ids:
        total_cost += cost_cases_indicators.direct_cost(event_log, case_id, direct_cost_activities, aggregation_mode)
    return total_cost

expected_automated_activity_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], automated_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The expected total cost associated with all instantiations of automated activities in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
automated_activities set[str]

The set of automated activities.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_automated_activity_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    automated_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> int | float:
    """
    The expected total cost associated with all instantiations of automated activities
    in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        automated_activities: The set of automated activities.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    group_automated_activity_cost = automated_activity_cost(event_log, case_ids, automated_activities, aggregation_mode)
    case_group_count = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(group_automated_activity_cost, case_group_count)

expected_desired_activity_count(event_log: pd.DataFrame, case_ids: list[str] | set[str], desired_activities: set[str]) -> float

The expected number of instantiated activities whose occurrence is desirable in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
desired_activities set[str]

The set of desired activities.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_desired_activity_count(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], desired_activities: set[str]
) -> float:
    """
    The expected number of instantiated activities whose occurrence is desirable in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        desired_activities: The set of desired activities.

    """
    numerator = desired_activity_count(event_log, case_ids, desired_activities)
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

expected_direct_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float

The expected total cost associated with all instantiations of activities that have a direct effect on the outcome of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
direct_cost_activities set[str]

The set of activities that have a direct effect on the outcome of the group of cases.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_direct_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    direct_cost_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> int | float:
    """
    The expected total cost associated with all instantiations of activities that have a
    direct effect on the outcome of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        direct_cost_activities: The set of activities that have a direct effect on the outcome of the group of cases.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    numerator = direct_cost(event_log, case_ids, direct_cost_activities, aggregation_mode)
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

expected_fixed_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float | None

The expected fixed cost associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_fixed_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> int | float | None:
    """
    The expected fixed cost associated with all activity instances of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    numerator = fixed_cost(event_log, case_ids, aggregation_mode)
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

expected_human_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected number of human resources that are involved in the execution of cases belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_human_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected number of human resources that are involved in the execution of cases
    belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    count = 0
    for case_id in case_ids:
        count += cost_cases_indicators.human_resource_count(event_log, case_id)

    numerator = count
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

expected_inventory_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The expected inventory cost associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_inventory_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The expected inventory cost associated with all activity instances of a case
    belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    numerator = inventory_cost(event_log, case_ids, aggregation_mode)
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

expected_labor_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float | None

The expected labor cost associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_labor_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> int | float | None:
    """
    The expected labor cost associated with all activity instances of a case
    belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        labor_cost(event_log, case_ids, aggregation_mode),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_labor_cost_and_total_cost_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The expected ratio between the labor cost associated with all activity instances of the group of cases, and the total cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_labor_cost_and_total_cost_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The expected ratio between the labor cost associated with all activity instances of the group of cases,
    and the total cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        labor_cost(event_log, case_ids, aggregation_mode),
        total_cost(event_log, case_ids, aggregation_mode),
    )

expected_maintenance_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected maintenance cost associated with a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_maintenance_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected maintenance cost associated with a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        maintenance_cost(event_log, case_ids), general_groups_indicators.case_count(event_log, case_ids)
    )

expected_missed_deadline_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected cost for missing deadlines associated with a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_missed_deadline_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected cost for missing deadlines associated with a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        missed_deadline_cost(event_log, case_ids),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_overhead_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all instantiations of activities that do not have a direct effect on the outcome of case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
direct_cost_activities set[str]

The set of activities that have a direct cost on the outcome of the cases.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_overhead_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    direct_cost_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> float:
    """
    The total cost associated with all instantiations of activities that do not have a
    direct effect on the outcome of case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        direct_cost_activities: The set of activities that have a direct cost
            on the outcome of the cases.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        overhead_cost(event_log, case_ids, direct_cost_activities, aggregation_mode),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected number of resources that are involved in the execution of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected number of resources that are involved in the execution of a case belonging
    to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    resource_count = 0
    for case_id in case_ids:
        resource_count += cost_cases_indicators.resource_count(event_log, case_id)
    return safe_division(resource_count, general_groups_indicators.case_count(event_log, case_ids))

expected_rework_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The expected total cost of all times that any activity has been instantiated again, after its first instantiation, in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_rework_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The expected total cost of all times that any activity has been instantiated again, after
    its first instantiation, in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        rework_cost(event_log, case_ids, aggregation_mode),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_rework_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected number of times that any activity has been instantiated again, after its first instantiation, in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_rework_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected number of times that any activity has been instantiated again,
    after its first instantiation, in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        rework_count(event_log, case_ids),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_rework_percentage(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected percentage of times that any activity has been instantiated again, after its first instantiation, in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_rework_percentage(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected percentage of times that any activity has been instantiated again, after its first
    instantiation, in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    rework_count = 0
    for case_id in case_ids:
        rework_count += cost_cases_indicators.rework_percentage(event_log, case_id)

    return safe_division(rework_count, general_groups_indicators.case_count(event_log, case_ids))

expected_total_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> int | float | None

The expected total cost associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_total_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> int | float | None:
    """
    The expected total cost associated with all activity instances of a case belonging to the
    group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    group_total_cost = total_cost(event_log, case_ids, aggregation_mode)
    case_group_count = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(group_total_cost, case_group_count)

expected_total_cost_and_lead_time_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the expected total cost associated with all activity instances of a case belonging to the group of cases, and the expected total elapsed time between the earliest and latest timestamps in a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_total_cost_and_lead_time_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the expected total cost associated with all activity instances of a case
    belonging to the group of cases, and the expected total elapsed time between the
    earliest and latest timestamps in a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    sum_of_ratios = 0.0
    successful_cases = 0
    last_error: IndicatorDivisionError | None = None

    for case_id in case_ids:
        try:
            sum_of_ratios += cost_cases_indicators.total_cost_and_lead_time_ratio(event_log, case_id, aggregation_mode)
            successful_cases += 1
        except IndicatorDivisionError as e:  # noqa: PERF203
            last_error = e
            continue

    if len(case_ids) > 0 and successful_cases == 0 and last_error is not None:
        raise last_error

    return safe_division(sum_of_ratios, successful_cases) if successful_cases > 0 else 0.0

expected_total_cost_and_outcome_unit_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the expected total cost associated with all activity instances of a case belonging to the group of cases, and the expected outcome units associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost and outcome unit calculations. "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_total_cost_and_outcome_unit_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the expected total cost associated with all activity instances of a case
    belonging to the group of cases, and the expected outcome units associated with all activity
    instances of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost and outcome unit calculations.
            "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

    """
    return safe_division(
        total_cost(event_log, case_ids, aggregation_mode),
        quality_groups_indicators.outcome_unit_count(event_log, case_ids, aggregation_mode),
    )

expected_total_cost_and_service_time_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the expected total cost associated with all activity instances of a case belonging to the group of cases, and the expected sum of elapsed times between the start and complete events of all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_total_cost_and_service_time_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the expected total cost associated with all activity instances of a case
    belonging to the group of cases, and the expected sum of elapsed times between the start and
    complete events of all activity instances of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    sum_of_ratios = 0.0
    successful_cases = 0
    last_error: IndicatorDivisionError | None = None

    for case_id in case_ids:
        try:
            sum_of_ratios += cost_cases_indicators.total_cost_and_service_time_ratio(
                event_log, case_id, aggregation_mode
            )
            successful_cases += 1
        except IndicatorDivisionError as e:  # noqa: PERF203
            last_error = e
            continue

    if len(case_ids) > 0 and successful_cases == 0 and last_error is not None:
        raise last_error

    return safe_division(sum_of_ratios, successful_cases) if successful_cases > 0 else 0.0

expected_transportation_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected transportation cost associated with a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_transportation_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected transportation cost associated with a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        transportation_cost(event_log, case_ids),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_variable_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The expected variable cost associated with all activity instances of a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_variable_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The expected variable cost associated with all activity instances of a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        variable_cost(event_log, case_ids, aggregation_mode),
        general_groups_indicators.case_count(event_log, case_ids),
    )

expected_warehousing_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The expected warehousing cost associated with a case belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def expected_warehousing_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The expected warehousing cost associated with a case belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        warehousing_cost(event_log, case_ids),
        general_groups_indicators.case_count(event_log, case_ids),
    )

fixed_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The fixed cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def fixed_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The fixed cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_fixed_cost = 0

    for case_id in case_ids:
        total_fixed_cost += cost_cases_indicators.fixed_cost(event_log, case_id, aggregation_mode)

    return total_fixed_cost

human_resource_and_case_count_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float | None

The ratio between the number of human resources that are involved in the execution of cases in the group of cases, and the number of cases belonging to the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def human_resource_and_case_count_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float | None:
    """
    The ratio between the number of human resources that are involved in the execution
    of cases in the group of cases, and the number of cases belonging to the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    numerator = human_resource_count(event_log, case_ids)
    denominator = general_groups_indicators.case_count(event_log, case_ids)
    return safe_division(numerator, denominator)

human_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int

The number of human resources that are involved in the execution of cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def human_resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int:
    """
    The number of human resources that are involved in the execution of cases in
    the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    count = 0
    for case_id in case_ids:
        count += len(cases_utils.hres(event_log, case_id))
    return count

inventory_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The inventory cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def inventory_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The inventory cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_inventory_cost = 0

    for case_id in case_ids:
        total_inventory_cost += cost_cases_indicators.inventory_cost(event_log, case_id, aggregation_mode)

    return total_inventory_cost

labor_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The labor cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def labor_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The labor cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_labor_cost = 0

    for case_id in case_ids:
        total_labor_cost += cost_cases_indicators.labor_cost(event_log, case_id, aggregation_mode)

    return total_labor_cost

labor_cost_and_total_cost_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the labor cost associated with all activity instances of the group of cases, and the total cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def labor_cost_and_total_cost_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the labor cost associated with all activity instances of the group of cases,
    and the total cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        labor_cost(event_log, case_ids, aggregation_mode),
        total_cost(event_log, case_ids, aggregation_mode),
    )

maintenance_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The maintenance cost associated with all cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def maintenance_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The maintenance cost associated with all cases in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    total_maintenance_cost: float = 0

    for case_id in case_ids:
        total_maintenance_cost += cost_cases_indicators.maintenance_cost(event_log, case_id)

    return total_maintenance_cost

missed_deadline_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The cost for missing deadlines associated with all cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def missed_deadline_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The cost for missing deadlines associated with all cases in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    total_missed_deadline_cost = 0

    for case_id in case_ids:
        total_missed_deadline_cost += cost_cases_indicators.missed_deadline_cost(event_log, case_id)

    return total_missed_deadline_cost

overhead_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], direct_cost_activities: set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all instantiations of activities that do not have a direct effect on the outcome of the cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
direct_cost_activities set[str]

The set of activities that have a direct cost on the outcome of the cases.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def overhead_cost(
    event_log: pd.DataFrame,
    case_ids: list[str] | set[str],
    direct_cost_activities: set[str],
    aggregation_mode: Literal["sgl", "sum"],
) -> float:
    """
    The total cost associated with all instantiations of activities that do not
    have a direct effect on the outcome of the cases in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        direct_cost_activities: The set of activities that have a direct cost
            on the outcome of the cases.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_overhead_cost = 0
    for case_id in case_ids:
        total_overhead_cost += cost_cases_indicators.overhead_cost(
            event_log, case_id, direct_cost_activities, aggregation_mode
        )
    return total_overhead_cost

resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int

The number of resources that are involved in the execution of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def resource_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int:
    """
    The number of resources that are involved in the execution of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    resources = set()
    for case_id in case_ids:
        resources.update(cases_utils.res(event_log, case_id))
    return len(resources)

rework_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost of all times that any activity has been instantiated again, after its first instantiation, in every case of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def rework_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The total cost of all times that any activity has been instantiated again, after its first
    instantiation, in every case of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    _rework_cost = 0
    for case_id in case_ids:
        _rework_cost += cost_cases_indicators.rework_cost(event_log, case_id, aggregation_mode)
    return _rework_cost

rework_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int

The number of times that any activity has been instantiated again, after its first intantiation, in every case of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def rework_count(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> int:
    """
    The number of times that any activity has been instantiated again, after its first intantiation,
    in every case of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    rework_count = 0
    for case_id in case_ids:
        rework_count += cost_cases_indicators.rework_count(event_log, case_id)
    return rework_count

rework_percentage(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The percentage of times that any activity has been instantiated again, after its first instantiation, in every case of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def rework_percentage(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The percentage of times that any activity has been instantiated again, after its first
    instantiation, in every case of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    return safe_division(
        rework_count(event_log, case_ids),
        general_groups_indicators.activity_instance_count(event_log, case_ids),
    )

total_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The total cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def total_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The total cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    total_cost = 0

    for case_id in case_ids:
        total_cost += cost_cases_indicators.total_cost(event_log, case_id, aggregation_mode) or 0

    return total_cost

total_cost_and_lead_time_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the group of cases, and the total elapsed time between the earliest and latest events in the group of cases. In cost per hour.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def total_cost_and_lead_time_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the group of
    cases, and the total elapsed time between the earliest and latest events in the group of cases. In cost per hour.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        total_cost(event_log, case_ids, aggregation_mode),
        time_groups_indicators.lead_time(event_log, case_ids) / pd.Timedelta(hours=1),
    )

total_cost_and_outcome_unit_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the group of cases, and the outcome units associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost and outcome unit calculations. "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def total_cost_and_outcome_unit_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the group of
    cases, and the outcome units associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost and outcome unit calculations.
            "sum": Considers the sum of all events of activity instances for cost and outcome unit calculations.

    """
    return safe_division(
        total_cost(event_log, case_ids, aggregation_mode),
        quality_groups_indicators.outcome_unit_count(event_log, case_ids, aggregation_mode),
    )

total_cost_and_service_time_ratio(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The ratio between the total cost associated with all activity instances of the group of cases, and the sum of elapsed times between the start and complete events of all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def total_cost_and_service_time_ratio(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The ratio between the total cost associated with all activity instances of the group of
    cases, and the sum of elapsed times between the start and complete events of all activity
    instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    return safe_division(
        total_cost(event_log, case_ids, aggregation_mode),
        time_groups_indicators.service_time(event_log, case_ids) / pd.Timedelta(hours=1),
    )

transportation_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The transportation cost associated with all cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def transportation_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The transportation cost associated with all cases in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    transportation_cost = 0
    for case_id in case_ids:
        transportation_cost += cost_cases_indicators.transportation_cost(event_log, case_id)
    return transportation_cost

variable_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal['sgl', 'sum']) -> float

The variable cost associated with all activity instances of the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
aggregation_mode Literal['sgl', 'sum']

The aggregation mode. "sgl": Considers single events of activity instances for cost calculations. "sum": Considers the sum of all events of activity instances for cost calculations.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def variable_cost(
    event_log: pd.DataFrame, case_ids: list[str] | set[str], aggregation_mode: Literal["sgl", "sum"]
) -> float:
    """
    The variable cost associated with all activity instances of the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.
        aggregation_mode: The aggregation mode.
            "sgl": Considers single events of activity instances for cost calculations.
            "sum": Considers the sum of all events of activity instances for cost calculations.

    """
    variable_cost = 0
    for case_id in case_ids:
        variable_cost += cost_cases_indicators.variable_cost(event_log, case_id, aggregation_mode)
    return variable_cost

warehousing_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float

The warehousing cost associated with all cases in the group of cases.

Parameters:

Name Type Description Default
event_log DataFrame

The event log.

required
case_ids list[str] | set[str]

The case ids.

required
Source code in process_performance_indicators/indicators/cost/groups.py
def warehousing_cost(event_log: pd.DataFrame, case_ids: list[str] | set[str]) -> float:
    """
    The warehousing cost associated with all cases in the group of cases.

    Args:
        event_log: The event log.
        case_ids: The case ids.

    """
    warehousing_cost = 0
    for case_id in case_ids:
        warehousing_cost += cost_cases_indicators.warehousing_cost(event_log, case_id)
    return warehousing_cost