from typing import Any
from typing import Iterable
from typing import Tuple
import random


def mut_triangular(
    individual: Any, low: Iterable[int], up: Iterable[int], indpb: float
) -> Tuple[Any]:
    """Implementation of mutation based on triangular probability distribution.

    Args:
        individual (Any): Individual to be mutated.
        low (Iterable[int]): List of lower bounds, len(low) == len(individual).
        up (Iterable[int]): List of upper bounds, len(up) == len(individual).
        indpb (float): Probability of mutating individual elements of the individual.

    Returns:
        Tuple[Any]: Mutated individual.
    """
    size = len(individual)

    for i, l, u in zip(range(size), low, up):
        if random.random() < indpb:
            individual[i] = int(random.triangular(low=l, high=u + 1, mode=individual[i]))

    return (individual,)