def get_missing_element_penalty(shelx_file, cache):
    """
    Get the number of missing elements based on the nominal formula
    Bounds for this score are 0 to n_elements - 1.
    :param shelx_file: SHELX file
    :param cache: OptimizerCache object
    :return: missing elements score
    """
    nominal_elements = set(cache.element_names_list)
    result_elements = map(lambda site: site.get_element(True), shelx_file.get_all_sites())
    return len(nominal_elements.difference(result_elements))