Package restructuring
This commit is contained in:
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
||||
include src/primaite/config/*.yaml
|
||||
@@ -10,9 +10,9 @@ PrimAITE produces four types of data:
|
||||
* Outputs - Saved agents
|
||||
* Logging
|
||||
|
||||
Outputs can be found in the *[Install Directory]\\PRIMAITE\\PRIMAITE\\outputs* directory
|
||||
Outputs can be found in the *[Install Directory]\\Primaite\\Primaite\\outputs* directory
|
||||
|
||||
Logging can be found in the *[Install Directory]\\PRIMAITE\\PRIMAITE\\logs* directory
|
||||
Logging can be found in the *[Install Directory]\\Primaite\\Primaite\\logs* directory
|
||||
|
||||
**Outputs - Results**
|
||||
|
||||
@@ -39,4 +39,4 @@ For each training session, assuming the agent being trained implements the *save
|
||||
|
||||
**Logging**
|
||||
|
||||
PrimAITE also provides output logs (for diagnosis) using the Python Logging package. These can be found in the *[Install Directory]\\PRIMAITE\\PRIMAITE\\logs* directory
|
||||
PrimAITE also provides output logs (for diagnosis) using the Python Logging package. These can be found in the *[Install Directory]\\Primaite\\Primaite\\logs* directory
|
||||
@@ -80,8 +80,8 @@ environment is reset between episodes. Note that the example below should not be
|
||||
|
||||
In order to execute a session, carry out the following steps:
|
||||
|
||||
1. Navigate to "[Install directory]\\PRIMAITE\\PRIMAITE\\”
|
||||
2. Start a console window (type “CMD” in path window, or start a console window first and navigate to “[Install Directory]\\PRIMAITE\\PRIMAITE\\”)
|
||||
1. Navigate to "[Install directory]\\Primaite\\Primaite\\”
|
||||
2. Start a console window (type “CMD” in path window, or start a console window first and navigate to “[Install Directory]\\Primaite\\Primaite\\”)
|
||||
3. Type “python main.py”
|
||||
4. The session will start with an output indicating the current episode, and average reward value for the episode
|
||||
|
||||
60
pyproject.toml
Normal file
60
pyproject.toml
Normal file
@@ -0,0 +1,60 @@
|
||||
[build-system]
|
||||
requires = ["setuptools", "setuptools-scm", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "primaite"
|
||||
description = "PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme."
|
||||
authors = [{name="QinetiQ Training and Simulation Ltd"}]
|
||||
license = {text = "GFX"}
|
||||
requires-python = ">=3.8"
|
||||
dynamic = ["version", "readme"]
|
||||
classifiers = [
|
||||
"License :: GFX",
|
||||
"Development Status :: 4 - Beta",
|
||||
"Operating System :: Microsoft :: Windows",
|
||||
"Operating System :: MacOS",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Operating System :: Unix",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"gym==0.21.0",
|
||||
"matplotlib==3.7.1",
|
||||
"networkx==3.1",
|
||||
"numpy==1.23.5",
|
||||
"PyYAML==6.0",
|
||||
"stable-baselines3==1.6.2"
|
||||
]
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = {file = ["src/primaite/VERSION"]}
|
||||
readme = {file = ["README.md"]}
|
||||
|
||||
[tool.setuptools]
|
||||
package-dir = {"" = "src"}
|
||||
include-package-data = true
|
||||
license-files = ["LICENSE"]
|
||||
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"setuptools==66",
|
||||
"pytest==7.2.0",
|
||||
"flake8==6.0.0",
|
||||
"Sphinx==6.1.3",
|
||||
"furo==2023.3.27",
|
||||
"sphinx-code-tabs==0.5.3",
|
||||
"sphinx-copybutton==0.5.2",
|
||||
"pytest-cov==4.0.0",
|
||||
"pytest-flake8==1.1.1",
|
||||
"pip-licenses==4.3.0",
|
||||
"wheel==0.38.4",
|
||||
"build==0.10.0"
|
||||
]
|
||||
35
setup.py
35
setup.py
@@ -1,26 +1,17 @@
|
||||
# Crown Copyright (C) Dstl 2022. DEFCON 703. Shared in confidence.
|
||||
"""
|
||||
Setup
|
||||
"""
|
||||
from setuptools import setup
|
||||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
class bdist_wheel(_bdist_wheel): # noqa
|
||||
def finalize_options(self): # noqa
|
||||
super().finalize_options()
|
||||
# forces whee to be platform and Python version specific
|
||||
# Source: https://stackoverflow.com/a/45150383
|
||||
self.root_is_pure = False
|
||||
|
||||
setup(
|
||||
name="primaite",
|
||||
maintainer="QinetiQ Training and Simulation Ltd",
|
||||
url="https://github.com/qtsl/PrimAITE",
|
||||
description="A primary-level simulation tool",
|
||||
python_requires=">=3.7",
|
||||
version="1.1.0",
|
||||
install_requires=[
|
||||
"gym==0.21.0",
|
||||
"matplotlib==3.6.2",
|
||||
"networkx==2.8.8",
|
||||
"numpy==1.23.5",
|
||||
"stable_baselines3==1.6.2",
|
||||
# Required for older versions of Gym that aren't compliant with
|
||||
# Setuptools>=67.
|
||||
"setuptools==66"
|
||||
],
|
||||
packages=find_packages()
|
||||
)
|
||||
cmdclass={
|
||||
"bdist_wheel": bdist_wheel,
|
||||
}
|
||||
)
|
||||
1
src/VERSION
Normal file
1
src/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
1.2.0
|
||||
@@ -1,6 +1,6 @@
|
||||
# Crown Copyright (C) Dstl 2022. DEFCON 703. Shared in confidence.
|
||||
"""
|
||||
PRIMAITE - main (harness) module
|
||||
Primaite - main (harness) module
|
||||
|
||||
Coding Standards: PEP 8
|
||||
"""
|
||||
@@ -12,9 +12,9 @@ import os.path
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from environment.primaite import PRIMAITE
|
||||
from transactions.transactions_to_file import write_transaction_to_file
|
||||
from common.config_values_main import config_values_main
|
||||
from primaite.environment.primaite_env import Primaite
|
||||
from primaite.transactions.transactions_to_file import write_transaction_to_file
|
||||
from primaite.common.config_values_main import config_values_main
|
||||
|
||||
from stable_baselines3 import PPO
|
||||
from stable_baselines3.ppo import MlpPolicy as PPOMlp
|
||||
@@ -271,9 +271,9 @@ except Exception as e:
|
||||
# - new observation space
|
||||
transaction_list = []
|
||||
|
||||
# Create the PRIMAITE environment
|
||||
# Create the Primaite environment
|
||||
try:
|
||||
env = PRIMAITE(config_values, transaction_list)
|
||||
env = Primaite(config_values, transaction_list)
|
||||
logging.info("PrimAITE environment created")
|
||||
except Exception as e:
|
||||
logging.error("Could not create PrimAITE environment")
|
||||
@@ -3,7 +3,7 @@
|
||||
A class that implements the access control list implementation for the network
|
||||
"""
|
||||
|
||||
from acl.acl_rule import ACLRule
|
||||
from primaite.acl.acl_rule import ACLRule
|
||||
|
||||
class AccessControlList():
|
||||
"""
|
||||
@@ -3,7 +3,7 @@
|
||||
The Service class
|
||||
"""
|
||||
|
||||
from common.enums import SOFTWARE_STATE
|
||||
from primaite.common.enums import SOFTWARE_STATE
|
||||
|
||||
class Service(object):
|
||||
"""
|
||||
@@ -7,7 +7,7 @@
|
||||
# "GENERIC"
|
||||
agentIdentifier: STABLE_BASELINES3_A2C
|
||||
# Number of episodes to run per session
|
||||
numEpisodes: 10
|
||||
numEpisodes: 10000
|
||||
# Time delay between steps (for generic agents)
|
||||
timeDelay: 10
|
||||
# Filename of the scenario / laydown
|
||||
@@ -1,6 +1,6 @@
|
||||
# Crown Copyright (C) Dstl 2022. DEFCON 703. Shared in confidence.
|
||||
"""
|
||||
Main environment module containing the PRIMmary AI Training Evironment (PRIMAITE) class
|
||||
Main environment module containing the PRIMmary AI Training Evironment (Primaite) class
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
@@ -15,24 +15,24 @@ from gym import Env, spaces
|
||||
from matplotlib import pyplot as plt
|
||||
from datetime import datetime
|
||||
|
||||
from common.enums import *
|
||||
from links.link import Link
|
||||
from pol.ier import IER
|
||||
from nodes.node_state_instruction_green import NodeStateInstructionGreen
|
||||
from nodes.node_state_instruction_red import NodeStateInstructionRed
|
||||
from pol.green_pol import apply_iers, apply_node_pol
|
||||
from pol.red_agent_pol import apply_red_agent_iers, apply_red_agent_node_pol
|
||||
from nodes.active_node import ActiveNode
|
||||
from nodes.passive_node import PassiveNode
|
||||
from nodes.service_node import ServiceNode
|
||||
from common.service import Service
|
||||
from acl.access_control_list import AccessControlList
|
||||
from environment.reward import calculate_reward_function
|
||||
from transactions.transaction import Transaction
|
||||
from primaite.common.enums import *
|
||||
from primaite.links.link import Link
|
||||
from primaite.pol.ier import IER
|
||||
from primaite.nodes.node_state_instruction_green import NodeStateInstructionGreen
|
||||
from primaite.nodes.node_state_instruction_red import NodeStateInstructionRed
|
||||
from primaite.pol.green_pol import apply_iers, apply_node_pol
|
||||
from primaite.pol.red_agent_pol import apply_red_agent_iers, apply_red_agent_node_pol
|
||||
from primaite.nodes.active_node import ActiveNode
|
||||
from primaite.nodes.passive_node import PassiveNode
|
||||
from primaite.nodes.service_node import ServiceNode
|
||||
from primaite.common.service import Service
|
||||
from primaite.acl.access_control_list import AccessControlList
|
||||
from primaite.environment.reward import calculate_reward_function
|
||||
from primaite.transactions.transaction import Transaction
|
||||
|
||||
class PRIMAITE(Env):
|
||||
class Primaite(Env):
|
||||
"""
|
||||
PRIMmary AI Training Evironment (PRIMAITE) class
|
||||
PRIMmary AI Training Evironment (Primaite) class
|
||||
"""
|
||||
|
||||
# Observation / Action Space contants
|
||||
@@ -55,7 +55,7 @@ class PRIMAITE(Env):
|
||||
_agent_identifier: Identifier for the agent
|
||||
"""
|
||||
|
||||
super(PRIMAITE, self).__init__()
|
||||
super(Primaite, self).__init__()
|
||||
|
||||
# Take a copy of the config values
|
||||
self.config_values = _config_values
|
||||
@@ -3,9 +3,9 @@
|
||||
Implements reward function
|
||||
"""
|
||||
|
||||
from common.enums import *
|
||||
from nodes.active_node import ActiveNode
|
||||
from nodes.service_node import ServiceNode
|
||||
from primaite.common.enums import *
|
||||
from primaite.nodes.active_node import ActiveNode
|
||||
from primaite.nodes.service_node import ServiceNode
|
||||
|
||||
def calculate_reward_function(initial_nodes, final_nodes, reference_nodes, green_iers, red_iers, step_count, config_values):
|
||||
"""
|
||||
@@ -3,8 +3,8 @@
|
||||
The link class
|
||||
"""
|
||||
|
||||
from common.protocol import Protocol
|
||||
from common.enums import *
|
||||
from primaite.common.protocol import Protocol
|
||||
from primaite.common.enums import *
|
||||
|
||||
class Link(object):
|
||||
"""
|
||||
@@ -3,8 +3,8 @@
|
||||
An Active Node (i.e. not an actuator)
|
||||
"""
|
||||
|
||||
from nodes.node import Node
|
||||
from common.enums import *
|
||||
from primaite.nodes.node import Node
|
||||
from primaite.common.enums import *
|
||||
|
||||
class ActiveNode(Node):
|
||||
"""
|
||||
@@ -3,7 +3,7 @@
|
||||
The base Node class
|
||||
"""
|
||||
|
||||
from common.enums import *
|
||||
from primaite.common.enums import *
|
||||
|
||||
class Node:
|
||||
"""
|
||||
@@ -3,7 +3,7 @@
|
||||
The Passive Node class (i.e. an actuator)
|
||||
"""
|
||||
|
||||
from nodes.node import Node
|
||||
from primaite.nodes.node import Node
|
||||
|
||||
class PassiveNode(Node):
|
||||
"""
|
||||
@@ -3,8 +3,8 @@
|
||||
A Service Node (i.e. not an actuator)
|
||||
"""
|
||||
|
||||
from nodes.active_node import ActiveNode
|
||||
from common.enums import *
|
||||
from primaite.nodes.active_node import ActiveNode
|
||||
from primaite.common.enums import *
|
||||
|
||||
class ServiceNode(ActiveNode):
|
||||
"""
|
||||
@@ -5,9 +5,9 @@ Implements Pattern of Life on the network (nodes and links)
|
||||
|
||||
from networkx import shortest_path
|
||||
|
||||
from common.enums import *
|
||||
from nodes.active_node import ActiveNode
|
||||
from nodes.service_node import ServiceNode
|
||||
from primaite.common.enums import *
|
||||
from primaite.nodes.active_node import ActiveNode
|
||||
from primaite.nodes.service_node import ServiceNode
|
||||
|
||||
_VERBOSE = False
|
||||
|
||||
@@ -5,9 +5,9 @@ Implements Pattern of Life on the network (nodes and links) resulting from the r
|
||||
|
||||
from networkx import shortest_path
|
||||
|
||||
from common.enums import *
|
||||
from nodes.active_node import ActiveNode
|
||||
from nodes.service_node import ServiceNode
|
||||
from primaite.common.enums import *
|
||||
from primaite.nodes.active_node import ActiveNode
|
||||
from primaite.nodes.service_node import ServiceNode
|
||||
|
||||
_VERBOSE = False
|
||||
|
||||
@@ -9,7 +9,7 @@ import os.path
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from transactions.transaction import Transaction
|
||||
from primaite.transactions.transaction import Transaction
|
||||
|
||||
def turn_action_space_to_array(_action_space):
|
||||
"""
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@@ -4,8 +4,8 @@
|
||||
Used to tes the ACL functions
|
||||
"""
|
||||
|
||||
from acl.acl_rule import ACLRule
|
||||
from acl.access_control_list import AccessControlList
|
||||
from primaite.acl.acl_rule import ACLRule
|
||||
from primaite.acl.access_control_list import AccessControlList
|
||||
|
||||
def test_acl_address_match_1():
|
||||
"""
|
||||
0
tests/test_reward.py
Normal file
0
tests/test_reward.py
Normal file
Reference in New Issue
Block a user