2024-06-14 12:59:44 +08:00
|
|
|
from abc import ABC, abstractmethod
|
2024-07-02 17:58:37 +08:00
|
|
|
from typing import Generic, List, Sequence, TypeVar
|
2024-06-14 12:59:44 +08:00
|
|
|
|
2024-07-02 17:58:37 +08:00
|
|
|
from rdagent.core.experiment import Experiment
|
2024-07-05 17:42:00 +08:00
|
|
|
from rdagent.core.scenario import Scenario
|
2024-06-28 11:45:23 +08:00
|
|
|
|
2024-07-02 17:58:37 +08:00
|
|
|
ASpecificExp = TypeVar("ASpecificExp", bound=Experiment)
|
2024-06-14 12:59:44 +08:00
|
|
|
|
2024-07-02 17:58:37 +08:00
|
|
|
|
|
|
|
|
class TaskGenerator(ABC, Generic[ASpecificExp]):
|
2024-07-05 17:42:00 +08:00
|
|
|
def __init__(self, scen: Scenario) -> None:
|
|
|
|
|
self.scen: Scenario = scen
|
|
|
|
|
|
2024-06-14 12:59:44 +08:00
|
|
|
@abstractmethod
|
2024-07-02 17:58:37 +08:00
|
|
|
def generate(self, exp: ASpecificExp) -> ASpecificExp:
|
2024-06-21 16:41:34 +08:00
|
|
|
"""
|
2024-07-02 17:58:37 +08:00
|
|
|
Task Generator should take in an experiment.
|
2024-06-21 16:41:34 +08:00
|
|
|
|
|
|
|
|
Because the schedule of different tasks is crucial for the final performance
|
|
|
|
|
due to it affects the learning process.
|
|
|
|
|
|
|
|
|
|
"""
|
2024-06-14 12:59:44 +08:00
|
|
|
raise NotImplementedError("generate method is not implemented.")
|
|
|
|
|
|
|
|
|
|
def collect_feedback(self, feedback_obj_l: List[object]):
|
|
|
|
|
"""
|
|
|
|
|
When online evaluation.
|
2024-07-02 17:58:37 +08:00
|
|
|
The previous feedbacks will be collected to support advanced factor generator
|
2024-06-14 12:59:44 +08:00
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
feedback_obj_l : List[object]
|
|
|
|
|
|
|
|
|
|
"""
|