def compute_loss_ref_gen(generation, reflection):
    """
    Compute loss percentage based on a generation count and a reflection count.
    """

    if generation != 0:
        loss = (1.0 - reflection / generation)*100
    else:
        loss = (1.0 - reflection / (generation+0.1))*100

    return loss if loss >=0 else 0