Esempio n. 1
0
def expand_configurations(configs: List[Configuration],
                          configuration_space: ConfigurationSpace, num: int):
    num_config = len(configs)
    num_needed = num - num_config
    config_cnt = 0
    while config_cnt < num_needed:
        config = configuration_space.sample_configuration(1)
        if config not in configs:
            configs.append(config)
            config_cnt += 1
    return configs
Esempio n. 2
0
def sample_configurations(configuration_space: ConfigurationSpace, num: int,
                          excluded_configs: List[Configuration] = None) -> List[Configuration]:
    if excluded_configs is None:
        excluded_configs = []
    result = []
    cnt = 0
    while cnt < num:
        config = configuration_space.sample_configuration(1)
        if config not in result and config not in excluded_configs:
            result.append(config)
            cnt += 1
    return result
Esempio n. 3
0
def expand_configurations(configs: List[Configuration], configuration_space: ConfigurationSpace, num: int,
                          excluded_configs: List[Configuration] = None):
    if excluded_configs is None:
        excluded_configs = []
    num_config = len(configs)
    num_needed = num - num_config
    config_cnt = 0
    while config_cnt < num_needed:
        config = configuration_space.sample_configuration(1)
        if config not in configs and config not in excluded_configs:
            configs.append(config)
            config_cnt += 1
    return configs
Esempio n. 4
0
def sample_configuration(configuration_space: ConfigurationSpace, excluded_configs: List[Configuration] = None):
    """
    sample one config not in excluded_configs
    """
    if excluded_configs is None:
        excluded_configs = []
    sample_cnt = 0
    max_sample_cnt = 1000
    while True:
        config = configuration_space.sample_configuration()
        sample_cnt += 1
        if config not in excluded_configs:
            break
        if sample_cnt >= max_sample_cnt:
            raise ValueError('Cannot sample non duplicate configuration after %d iterations.' % max_sample_cnt)
    return config