llamda package

Subpackages

Submodules

llamda.evaluate module

class llamda.evaluate.Evaluator(problem, timeout=30)[source]

Bases: object

Parameters:
batch_evaluate(population, output_dir)[source]

Evaluate population by running code in parallel and computing objective values.

Parameters:
  • population (list[T])

  • output_dir (Path)

Return type:

list[T]

mark_invalid_individual(individual, traceback_msg)[source]

Mark an individual as invalid.

Parameters:
  • individual (T)

  • traceback_msg (str)

Return type:

T

llamda.evaluate.filter_traceback(s)[source]
Parameters:

s (str)

Return type:

str

llamda.individual module

class llamda.individual.Individual(name: str | None = None, code: str | None = None, exec_success: bool | None = None, obj: float | None = None, traceback_msg: str | None = None)[source]

Bases: object

Parameters:
  • name (str | None)

  • code (str | None)

  • exec_success (bool | None)

  • obj (float | None)

  • traceback_msg (str | None)

code: str | None = None
exec_success: bool | None = None
classmethod from_dict(data)[source]
Parameters:

data (dict)

Return type:

Individual

classmethod from_json(json_str)[source]
Parameters:

json_str (str)

Return type:

Individual

name: str | None = None
obj: float | None = None
to_dict()[source]
Return type:

dict

to_json()[source]
Return type:

str

traceback_msg: str | None = None
write_code_to_file(filepath)[source]
Parameters:

filepath (str)

Return type:

None

llamda.problem module

class llamda.problem.BaseProblem(name: str, type: str, obj_type: str, size: int, description: str, func_name: str, func_outputs: list[str], path: pathlib.Path)[source]

Bases: object

Parameters:
property code_path: Path
description: str
property eval_path: Path
func_name: str
func_outputs: list[str]
name: str
obj_type: str
path: Path
size: int
type: str
class llamda.problem.EohProblem(name: str, type: str, obj_type: str, size: int, description: str, func_name: str, func_outputs: list[str], path: pathlib.Path, func_inputs: list[str], inout_info: str, other_info: str)[source]

Bases: BaseProblem

Parameters:
func_inputs: list[str]
inout_info: str
other_info: str
class llamda.problem.Problem(name: str, type: str, obj_type: str, size: int, description: str, func_name: str, func_outputs: list[str], path: pathlib.Path, seed_func: str, func_signature: str, func_desc: str, external_knowledge: str)[source]

Bases: BaseProblem

Parameters:
external_knowledge: str
func_desc: str
func_signature: str
classmethod load_builtin(problem_name)[source]
Parameters:

problem_name (ProblemName)

Return type:

Problem

classmethod load_problem(path)[source]
Parameters:

path (Path)

Return type:

Problem

seed_func: str
class llamda.problem.ProblemName(value)[source]

Bases: Enum

BPP_OFFLINE_ACO = 'bpp_offline_aco'
BPP_ONLINE = 'bpp_online'
CVRP_ACO = 'cvrp_aco'
MKP_ACO = 'mkp_aco'
TSP_ACO = 'tsp_aco'
TSP_CONSTRUCTIVE = 'tsp_constructive'
llamda.problem.adapt_prompt(problem)[source]
Parameters:

problem (Problem)

Return type:

EohProblem

llamda.utils module

llamda.utils.file_to_string(filename)[source]
Parameters:

filename (str | PathLike[str])

Return type:

str

llamda.utils.load_heuristic_from_code(code_path, possible_func_names)[source]

Dynamically load heuristic function from given code path.

Parameters:
Return type:

Callable

Print hyperlink to file or folder for convenient navigation

Parameters:
  • path (str)

  • text (str | None)

Return type:

str

Module contents