def estimate_n_guesses(matrix, n_states, singles_only=True):
    """
    Implementation of a basic heuristic to find a good number of guess
    vectors to be searched for using the find_guesses function.
    Internal function called from run_adc.

    matrix             ADC matrix
    n_states           Number of states to be computed
    singles_only       Try to stay withing the singles excitation space
                       with the number of guess vectors.
    """
    n_guesses = max(4, 2 * n_states)
    if singles_only:
        mospaces = matrix.mospaces
        sp_occ = 'o2' if matrix.is_core_valence_separated else 'o1'
        n_virt_a = mospaces.n_orbs_alpha('v1')
        n_occ_a = mospaces.n_orbs_alpha(sp_occ)
        n_guesses = min(n_guesses, n_occ_a * n_virt_a)
    return max(n_states, n_guesses)
