#917 - started working on the Agent abstract classes and sub-classes
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional
|
||||
from typing import Optional, Final, Dict, Any
|
||||
|
||||
from primaite import getLogger
|
||||
from primaite.config.training_config import TrainingConfig
|
||||
from primaite.environment.primaite_env import Primaite
|
||||
|
||||
_LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
class AgentABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, env: Primaite):
|
||||
self._env: Primaite = env
|
||||
self._training_config: Final[TrainingConfig] = self._env.training_config
|
||||
self._lay_down_config: Dict[str, Any] = self._env.lay_down_config
|
||||
self._agent = None
|
||||
|
||||
@abstractmethod
|
||||
@@ -33,4 +39,35 @@ class AgentABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def export(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
class DeterministicAgentABC(AgentABC):
|
||||
@abstractmethod
|
||||
def __init__(self, env: Primaite):
|
||||
self._env: Primaite = env
|
||||
self._agent = None
|
||||
|
||||
@abstractmethod
|
||||
def _setup(self):
|
||||
pass
|
||||
|
||||
def learn(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
pass
|
||||
_LOGGER.warning("Deterministic agents cannot learn")
|
||||
|
||||
@abstractmethod
|
||||
def evaluate(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def load(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def export(self):
|
||||
pass
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
# from typing import Optional
|
||||
#
|
||||
# from primaite.agents.agent_abc import AgentABC
|
||||
# from primaite.environment.primaite_env import Primaite
|
||||
#
|
||||
#
|
||||
# class SB3PPO(AgentABC):
|
||||
# def __init__(self, env: Primaite):
|
||||
# super().__init__(env)
|
||||
#
|
||||
# def _setup(self):
|
||||
# if self._env.training_config
|
||||
# pass
|
||||
#
|
||||
# def learn(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
# pass
|
||||
#
|
||||
# def evaluate(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
# pass
|
||||
#
|
||||
# def load(self):
|
||||
# pass
|
||||
#
|
||||
# def save(self):
|
||||
# pass
|
||||
#
|
||||
# def export(self):
|
||||
# pass
|
||||
from typing import Optional
|
||||
|
||||
from stable_baselines3 import PPO
|
||||
|
||||
from primaite.agents.agent_abc import AgentABC
|
||||
from primaite.environment.primaite_env import Primaite
|
||||
from stable_baselines3.ppo import MlpPolicy as PPOMlp
|
||||
|
||||
class SB3PPO(AgentABC):
|
||||
def __init__(self, env: Primaite):
|
||||
super().__init__(env)
|
||||
|
||||
def _setup(self):
|
||||
self._agent = PPO(
|
||||
PPOMlp,
|
||||
self._env,
|
||||
verbose=0,
|
||||
n_steps=self._training_config.num_steps
|
||||
)
|
||||
|
||||
|
||||
def learn(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
pass
|
||||
|
||||
def evaluate(self, time_steps: Optional[int], episodes: Optional[int]):
|
||||
pass
|
||||
|
||||
def load(self):
|
||||
pass
|
||||
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
def export(self):
|
||||
pass
|
||||
Reference in New Issue
Block a user