def _sub2instance(initial_condition, perturbation_index, total_perturbations):
    """
    Converts initial condition index (ci) and perturbation index (pi) subscripts
    to an instance number (ii)

    instances use 1-based indexes and vary according to this function:
        ii = ci * len(PERTURBATIONS) + pi + 1
    where both pi and ci use 0-based indexes.
    """
    instance = initial_condition * total_perturbations + perturbation_index + 1
    return instance