llamda.ga.hsevo package
Submodules
llamda.ga.hsevo.evolution module
llamda.ga.hsevo.hsevo module
- class llamda.ga.hsevo.hsevo.HSEvo(config, problem, evaluator, llm_client, output_dir)[source]
Bases:
GeneticAlgorithm[HSEvoConfig,Problem]- Parameters:
config (HSEvoConfig)
problem (Problem)
evaluator (Evaluator)
llm_client (BaseClient)
output_dir (str)
- cal_usage_LLM(lst_prompt, lst_completion, encoding_name='cl100k_base')[source]
Returns the number of tokens in a text string.
- crossover(population)[source]
- Parameters:
population (list[HSEvoIndividual])
- Return type:
- find_best_obj(population_hs)[source]
- Parameters:
population_hs (list[HSEvoIndividual])
- Return type:
- flash_reflection(population)[source]
- Parameters:
population (list[HSEvoIndividual])
- Return type:
None
- harmony_search()[source]
- Return type:
HSEvoIndividual | None
- mutate()[source]
Elitist-based mutation. We only mutate the best individual to generate n_pop new individuals.
- Return type:
- random_select(population)[source]
Random selection, select individuals with equal probability.
- Parameters:
population (list[HSEvoIndividual])
- Return type:
- response_to_individual(response, name, messages=None)[source]
Convert response to individual
- Parameters:
- Return type:
- responses_to_population(responses, try_hs_idx=None)[source]
Convert responses to population. Applied to the initial population.
- Parameters:
- Return type:
- save_log_population(population, logHS=False)[source]
- Parameters:
population (list[HSEvoIndividual])
logHS (bool)
- Return type:
None
- class llamda.ga.hsevo.hsevo.HSEvoConfig(max_fe: int = 450, pop_size: int = 10, init_pop_size: int = 30, mutation_rate: float = 0.5, hm_size: int = 5, hmcr: float = 0.7, par: float = 0.5, bandwidth: float = 0.2, max_iter: int = 5)[source]
Bases:
object- Parameters:
- class llamda.ga.hsevo.hsevo.HSEvoIndividual(name: str | None = None, code: str | None = None, exec_success: bool | None = None, obj: float | None = None, traceback_msg: str | None = None, tryHS: bool = False)[source]
Bases:
Individual- Parameters: