Rename benchmark variables and add h1 to notebooks
This commit is contained in:
@@ -458,7 +458,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.11"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Train a Multi agent system using RLLIB\n",
|
"# Train a Multi agent system using RLLIB\n",
|
||||||
"\n",
|
"\n",
|
||||||
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.8"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Train a Single agent system using RLLib\n",
|
"# Train a Single agent system using RLLib\n",
|
||||||
"\n",
|
"\n",
|
||||||
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.8"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -328,7 +328,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.11"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## Simple multi-processing demonstration\n",
|
"# Simple multi-processing demonstration\n",
|
||||||
"\n",
|
"\n",
|
||||||
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
"© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -143,7 +143,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.11"
|
"version": "3.10.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class PrimaiteGymEnv(gymnasium.Env):
|
|||||||
"""Name of the RL agent. Since there should only be one RL agent we can just pull the first and only key."""
|
"""Name of the RL agent. Since there should only be one RL agent we can just pull the first and only key."""
|
||||||
self.episode_counter: int = 0
|
self.episode_counter: int = 0
|
||||||
"""Current episode number."""
|
"""Current episode number."""
|
||||||
self.average_reward_per_episode: Dict[int, float] = {}
|
self.total_reward_per_episode: Dict[int, float] = {}
|
||||||
"""Average rewards of agents per episode."""
|
"""Average rewards of agents per episode."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -91,7 +91,7 @@ class PrimaiteGymEnv(gymnasium.Env):
|
|||||||
f"Resetting environment, episode {self.episode_counter}, "
|
f"Resetting environment, episode {self.episode_counter}, "
|
||||||
f"avg. reward: {self.agent.reward_function.total_reward}"
|
f"avg. reward: {self.agent.reward_function.total_reward}"
|
||||||
)
|
)
|
||||||
self.average_reward_per_episode[self.episode_counter] = self.agent.reward_function.total_reward
|
self.total_reward_per_episode[self.episode_counter] = self.agent.reward_function.total_reward
|
||||||
|
|
||||||
if self.io.settings.save_agent_actions:
|
if self.io.settings.save_agent_actions:
|
||||||
all_agent_actions = {name: agent.history for name, agent in self.game.agents.items()}
|
all_agent_actions = {name: agent.history for name, agent in self.game.agents.items()}
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ from typing import Any, Dict, Tuple, Union
|
|||||||
import polars as pl
|
import polars as pl
|
||||||
|
|
||||||
|
|
||||||
def av_rewards_dict(av_rewards_csv_file: Union[str, Path]) -> Dict[int, float]:
|
def total_rewards_dict(total_rewards_csv_file: Union[str, Path]) -> Dict[int, float]:
|
||||||
"""
|
"""
|
||||||
Read an average rewards per episode csv file and return as a dict.
|
Read an average rewards per episode csv file and return as a dict.
|
||||||
|
|
||||||
The dictionary keys are the episode number, and the values are the mean reward that episode.
|
The dictionary keys are the episode number, and the values are the mean reward that episode.
|
||||||
|
|
||||||
:param av_rewards_csv_file: The average rewards per episode csv file path.
|
:param total_rewards_csv_file: The average rewards per episode csv file path.
|
||||||
:return: The average rewards per episode csv as a dict.
|
:return: The average rewards per episode csv as a dict.
|
||||||
"""
|
"""
|
||||||
df_dict = pl.read_csv(av_rewards_csv_file).to_dict()
|
df_dict = pl.read_csv(total_rewards_csv_file).to_dict()
|
||||||
|
|
||||||
return {int(v): df_dict["Average Reward"][i] for i, v in enumerate(df_dict["Episode"])}
|
return {int(v): df_dict["Average Reward"][i] for i, v in enumerate(df_dict["Episode"])}
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ class SessionOutputWriter:
|
|||||||
Is used to write session outputs to csv file.
|
Is used to write session outputs to csv file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_AV_REWARD_PER_EPISODE_HEADER: Final[List[str]] = [
|
_TOTAL_REWARD_PER_EPISODE_HEADER: Final[List[str]] = [
|
||||||
"Episode",
|
"Episode",
|
||||||
"Average Reward",
|
"Total Reward",
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@@ -43,7 +43,7 @@ class SessionOutputWriter:
|
|||||||
:param env: PrimAITE gym environment.
|
:param env: PrimAITE gym environment.
|
||||||
:type env: Primaite
|
:type env: Primaite
|
||||||
:param transaction_writer: If `true`, this will output a full account of every transaction taken by the agent.
|
:param transaction_writer: If `true`, this will output a full account of every transaction taken by the agent.
|
||||||
If `false` it will output the average reward per episode, defaults to False
|
If `false` it will output the total reward per episode, defaults to False
|
||||||
:type transaction_writer: bool, optional
|
:type transaction_writer: bool, optional
|
||||||
:param learning_session: Set to `true` to indicate that the current session is a training session. This
|
:param learning_session: Set to `true` to indicate that the current session is a training session. This
|
||||||
determines the name of the folder which contains the final output csv. Defaults to True
|
determines the name of the folder which contains the final output csv. Defaults to True
|
||||||
@@ -56,7 +56,7 @@ class SessionOutputWriter:
|
|||||||
if self.transaction_writer:
|
if self.transaction_writer:
|
||||||
fn = f"all_transactions_{self._env.timestamp_str}.csv"
|
fn = f"all_transactions_{self._env.timestamp_str}.csv"
|
||||||
else:
|
else:
|
||||||
fn = f"average_reward_per_episode_{self._env.timestamp_str}.csv"
|
fn = f"total_reward_per_episode_{self._env.timestamp_str}.csv"
|
||||||
|
|
||||||
self._csv_file_path: "Path"
|
self._csv_file_path: "Path"
|
||||||
if self.learning_session:
|
if self.learning_session:
|
||||||
@@ -94,7 +94,7 @@ class SessionOutputWriter:
|
|||||||
if isinstance(data, Transaction):
|
if isinstance(data, Transaction):
|
||||||
header, data = data.as_csv_data()
|
header, data = data.as_csv_data()
|
||||||
else:
|
else:
|
||||||
header = self._AV_REWARD_PER_EPISODE_HEADER
|
header = self._TOTAL_REWARD_PER_EPISODE_HEADER
|
||||||
|
|
||||||
if self._first_write:
|
if self._first_write:
|
||||||
self._init_csv_writer()
|
self._init_csv_writer()
|
||||||
|
|||||||
Reference in New Issue
Block a user