def convergence_res(values, optimization_type="minimize"):
    """
    Compute the list of values to plot the convergence plot (i.e. the best seen at each iteration)

    :param values: the result(s) for which to compute the convergence trace.
    :type values: list
    :param optimization_type: "minimize" if the problem is a minimization problem, "maximize" otherwise
    :type optimization_type: str
    :return: a list with the best min seen for each iteration
    :rtype: list
    """

    values2 = values.copy()

    if optimization_type == "minimize":
        for i in range(1, len(values2)):
            if values2[i] > values2[i - 1]:
                values2[i] = values2[i - 1]
    else:
        for i in range(1, len(values2)):
            if values2[i] < values2[i - 1]:
                values2[i] = values2[i - 1]
    return values2