BaseTask¶
evotoolkit.core.BaseTask
¶
Bases: ABC
Abstract base class for evolutionary optimization tasks.
This class unifies the functionality of BaseEvaluator and BaseTaskConfig into a single concept, providing both evaluation capabilities and task configuration in one place.
Source code in src/evotoolkit/core/base_task.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
__init__
¶
Initialize the task with input data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Task-specific input data (format varies by task type). |
required |
evaluate_code
abstractmethod
¶
Evaluate a candidate code solution and return evaluation result.
This is the simple interface for tasks that only need a code string. For tasks requiring additional information, override evaluate_solution().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate_code
|
str
|
The code to evaluate |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvaluationResult |
EvaluationResult
|
Result of the evaluation |
Source code in src/evotoolkit/core/base_task.py
evaluate_solution
¶
evaluate_solution(solution: Solution) -> EvaluationResult
Evaluate a Solution object and return evaluation result.
This method provides a richer interface for complex tasks that need additional information beyond just code. The Solution object can carry: - sol_string: The main code (e.g., kernel source) - other_info: Additional metadata (e.g., tiling config, block_dim)
Default implementation simply calls evaluate_code(solution.sol_string). Complex tasks (e.g., CANN) should override this method to extract additional information from solution.other_info.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution
|
Solution
|
Solution object containing code and optional metadata |
required |
Returns:
| Name | Type | Description |
|---|---|---|
EvaluationResult |
EvaluationResult
|
Result of the evaluation |
Source code in src/evotoolkit/core/base_task.py
get_base_task_description
abstractmethod
¶
Get the base task description for prompt generation.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Task description text |
make_init_sol_wo_other_info
abstractmethod
¶
make_init_sol_wo_other_info() -> Solution
Create initial solution from task info without other_info.
Returns:
| Name | Type | Description |
|---|---|---|
Solution |
Solution
|
Initial solution for this task |
get_task_type
¶
Get the type of this task (e.g., 'Python', 'Cuda').
Default implementation returns 'Python'. Subclasses should override if they represent different task types.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Task type identifier |
Source code in src/evotoolkit/core/base_task.py
get_task_info
¶
Get the task_info dictionary.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Task information dictionary |
See the Custom Task Tutorial for a complete guide.