csle_common.dao.simulation_config package

Submodules

csle_common.dao.simulation_config.action module

class csle_common.dao.simulation_config.action.Action(id: int, descr: str)[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing an action in a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.action.Action[source]

Converts a dict representation of the DTO into an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.action.Action[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]
Returns

a dict representation of the DTO

csle_common.dao.simulation_config.action_space_config module

class csle_common.dao.simulation_config.action_space_config.ActionSpaceConfig(actions: List[csle_common.dao.simulation_config.action.Action], player_id: int, action_type: csle_common.dao.simulation_config.value_type.ValueType, descr: str = '')[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO Class representing the action space configuration of a player in a simulation environment

actions_ids() List[int][source]
Returns

a list of action ids

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.action_space_config.ActionSpaceConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.action_space_config.ActionSpaceConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.agent_log module

class csle_common.dao.simulation_config.agent_log.AgentLog[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO Representing the Agent Log

add_entry(msg) None[source]

Adds an entry to the log

Parameters

msg – the msg to add to the log

Returns

None

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.agent_log.AgentLog[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.agent_log.AgentLog[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

reset() None[source]

Resets the log

Returns

None

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.base_env module

class csle_common.dao.simulation_config.base_env.BaseEnv[source]

Bases: gymnasium.core.Env, abc.ABC

Abstract class representing a csle Environment

action_space: spaces.Space[ActType]
abstract get_traces() List[csle_common.dao.simulation_config.simulation_trace.SimulationTrace][source]
Returns

the list of simulation traces

abstract manual_play() None[source]

An interactive loop for manual play of the environment

Returns

None

observation_space: spaces.Space[ObsType]
abstract reset_traces() None[source]

Resets the list of traces

Returns

None

abstract set_model(model: Any) None[source]

Sets the model. Useful when using RL frameworks where the stage policy is not easy to extract

Parameters

model – the model

Returns

None

abstract set_state(state: Any) None[source]

Sets the state. Allows to simulate samples from specific states

Parameters

state – the state

Returns

None

csle_common.dao.simulation_config.env_parameter module

class csle_common.dao.simulation_config.env_parameter.EnvParameter(id: int, name: str, descr: str)[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the a general parameter of a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.env_parameter.EnvParameter[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.env_parameter.EnvParameter[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.env_parameters_config module

class csle_common.dao.simulation_config.env_parameters_config.EnvParametersConfig(parameters: List[csle_common.dao.simulation_config.env_parameter.EnvParameter])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the the configuration of custom environment parameters of a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.env_parameters_config.EnvParametersConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.env_parameters_config.EnvParametersConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]
Returns

a dict representation of the DTO

csle_common.dao.simulation_config.initial_state_distribution_config module

class csle_common.dao.simulation_config.initial_state_distribution_config.InitialStateDistributionConfig(initial_state_distribution: List[float])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO class representing the configuration of the initial state distribution of a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.initial_state_distribution_config.InitialStateDistributionConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.initial_state_distribution_config.InitialStateDistributionConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.joint_action_space_config module

class csle_common.dao.simulation_config.joint_action_space_config.JointActionSpaceConfig(action_spaces: List[csle_common.dao.simulation_config.action_space_config.ActionSpaceConfig])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the joint action space of a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.joint_action_space_config.JointActionSpaceConfig[source]

Converts a dict representation into an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.joint_action_space_config.JointActionSpaceConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.joint_observation_space_config module

class csle_common.dao.simulation_config.joint_observation_space_config.JointObservationSpaceConfig(observation_spaces: List[csle_common.dao.simulation_config.observation_space_config.ObservationSpaceConfig])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing a joint observation space configuration

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.joint_observation_space_config.JointObservationSpaceConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.joint_observation_space_config.JointObservationSpaceConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.observation module

class csle_common.dao.simulation_config.observation.Observation(id: int, val: int, descr: str)[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO class representing an observation in a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.observation.Observation[source]

Converts a dict representation to an instance :param d: the dict to convert :return: the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.observation.Observation[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.observation_function_config module

class csle_common.dao.simulation_config.observation_function_config.ObservationFunctionConfig(observation_tensor: numpy.ndarray[Any, numpy.dtype[Any]], component_observation_tensors: Dict[str, numpy.ndarray[Any, numpy.dtype[Any]]])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the configuration of the observation function of a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.observation_function_config.ObservationFunctionConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.observation_function_config.ObservationFunctionConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.observation_space_config module

class csle_common.dao.simulation_config.observation_space_config.ObservationSpaceConfig(observations: List[csle_common.dao.simulation_config.observation.Observation], observation_type: csle_common.dao.simulation_config.value_type.ValueType, descr: str, player_id: int, observation_component_name_to_index: Dict[str, int], observation_id_to_observation_id_vector: Dict[int, List[int]], observation_id_to_observation_vector: Dict[int, List[int]], component_observations: Dict[str, List[csle_common.dao.simulation_config.observation.Observation]])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the configuration of the observation space of a single player in a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.observation_space_config.ObservationSpaceConfig[source]

Converts a dict representation to an instance :param d: the dict to convert :return: the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.observation_space_config.ObservationSpaceConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

observation_ids() List[int][source]
Returns

a list of observation ids

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.player_config module

class csle_common.dao.simulation_config.player_config.PlayerConfig(name: str, id: int, descr: str = '')[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the configuration of a player in a simulation environment in CSLE

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.player_config.PlayerConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.player_config.PlayerConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.players_config module

class csle_common.dao.simulation_config.players_config.PlayersConfig(player_configs: List[csle_common.dao.simulation_config.player_config.PlayerConfig])[source]

Bases: csle_base.json_serializable.JSONSerializable

A DTO representing the configuration of players in a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.players_config.PlayersConfig[source]

Converts a dict representation of the object to a DTO

Parameters

d – the dict to convert

Returns

the created object

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.players_config.PlayersConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.reward_function_config module

class csle_common.dao.simulation_config.reward_function_config.RewardFunctionConfig(reward_tensor: numpy.ndarray[Any, numpy.dtype[Any]])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO containing the reward tensor of a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.reward_function_config.RewardFunctionConfig[source]

Converts a dict representation into an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.reward_function_config.RewardFunctionConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]
Returns

a dict representation of the object

csle_common.dao.simulation_config.simulation_env_config module

class csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig(name: str, descr: str, version: str, gym_env_name: str, simulation_env_input_config: csle_common.dao.simulation_config.simulation_env_input_config.SimulationEnvInputConfig, players_config: csle_common.dao.simulation_config.players_config.PlayersConfig, state_space_config: csle_common.dao.simulation_config.state_space_config.StateSpaceConfig, joint_action_space_config: csle_common.dao.simulation_config.joint_action_space_config.JointActionSpaceConfig, joint_observation_space_config: csle_common.dao.simulation_config.joint_observation_space_config.JointObservationSpaceConfig, time_step_type: csle_common.dao.simulation_config.time_step_type.TimeStepType, reward_function_config: csle_common.dao.simulation_config.reward_function_config.RewardFunctionConfig, transition_operator_config: csle_common.dao.simulation_config.transition_operator_config.TransitionOperatorConfig, observation_function_config: csle_common.dao.simulation_config.observation_function_config.ObservationFunctionConfig, initial_state_distribution_config: csle_common.dao.simulation_config.initial_state_distribution_config.InitialStateDistributionConfig, env_parameters_config: csle_common.dao.simulation_config.env_parameters_config.EnvParametersConfig, plot_transition_probabilities: bool = False, plot_observation_function: bool = False, plot_reward_function: bool = False)[source]

Bases: csle_base.json_serializable.JSONSerializable

A DTO class representing the configuration of a simulation environment

copy() csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig[source]
Returns

a copy of the DTO

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.simulation_env_config.SimulationEnvConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.simulation_env_input_config module

class csle_common.dao.simulation_config.simulation_env_input_config.SimulationEnvInputConfig[source]

Bases: csle_base.json_serializable.JSONSerializable

Abstract class representing the input to a simulation

abstract static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.simulation_env_input_config.SimulationEnvInputConfig[source]

Converts a dict representation of the object to an instance

Parameters

d – the dict to convert

Returns

the converted instance

abstract static from_json_file(json_file_path: str) csle_common.dao.simulation_config.simulation_env_input_config.SimulationEnvInputConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

abstract to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.simulation_trace module

class csle_common.dao.simulation_config.simulation_trace.SimulationTrace(simulation_env: str)[source]

Bases: csle_base.json_serializable.JSONSerializable

Class that represents a trace in the simulation system

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.simulation_trace.SimulationTrace[source]

Converts a dict representation of the trace to a DTO representation

Parameters

d – the dict to convert

Returns

the trace DTO

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.simulation_trace.SimulationTrace[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

static load_traces(traces_save_dir: str, traces_file: Optional[str] = None) List[csle_common.dao.simulation_config.simulation_trace.SimulationTrace][source]

Utility function for loading and parsing a list of traces from a json file

Parameters
  • traces_save_dir – the directory where to load the traces from

  • traces_file – (optional) a custom name of the traces file

Returns

a list of the loaded traces

static save_traces(traces_save_dir, traces: List[csle_common.dao.simulation_config.simulation_trace.SimulationTrace], traces_file: Optional[str] = None) None[source]

Utility function for saving a list of traces to a json file

Parameters
  • traces_save_dir – the directory where to save the traces

  • traces – the traces to save

  • traces_file – the filename of the traces file

Returns

None

to_dict() Dict[str, Any][source]
Returns

a dict representation of the trace

csle_common.dao.simulation_config.state module

class csle_common.dao.simulation_config.state.State(id: int, name: str, descr: str, state_type: csle_common.dao.simulation_config.state_type.StateType)[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the state of a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.state.State[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.state.State[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.state_space_config module

class csle_common.dao.simulation_config.state_space_config.StateSpaceConfig(states: List[csle_common.dao.simulation_config.state.State])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the state space configuration of a simulation environment

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.state_space_config.StateSpaceConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.state_space_config.StateSpaceConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

states_ids() List[int][source]
Returns

list of state ids

to_dict() Dict[str, Any][source]
Returns

a dict representation of the DTO

csle_common.dao.simulation_config.state_type module

class csle_common.dao.simulation_config.state_type.StateType(value)[source]

Bases: enum.IntEnum

Enum representing the different state types in CSLE

ACTIVE = 0
TERMINAL = 1

csle_common.dao.simulation_config.time_step_type module

class csle_common.dao.simulation_config.time_step_type.TimeStepType(value)[source]

Bases: enum.IntEnum

Enum representing the time-step types of a simulation

CONTINUOUS = 1
DISCRETE = 0

csle_common.dao.simulation_config.transition_operator_config module

class csle_common.dao.simulation_config.transition_operator_config.TransitionOperatorConfig(transition_tensor: numpy.ndarray[Any, numpy.dtype[Any]])[source]

Bases: csle_base.json_serializable.JSONSerializable

DTO representing the transition operator definition of a simulation

static from_dict(d: Dict[str, Any]) csle_common.dao.simulation_config.transition_operator_config.TransitionOperatorConfig[source]

Converts a dict representation to an instance

Parameters

d – the dict to convert

Returns

the created instance

static from_json_file(json_file_path: str) csle_common.dao.simulation_config.transition_operator_config.TransitionOperatorConfig[source]

Reads a json file and converts it to a DTO

Parameters

json_file_path – the json file path

Returns

the converted DTO

to_dict() Dict[str, Any][source]

Converts the object to a dict representation

Returns

a dict representation of the object

csle_common.dao.simulation_config.value_type module

class csle_common.dao.simulation_config.value_type.ValueType(value)[source]

Bases: enum.IntEnum

Represents a type of action in a simulation environment

FLOAT = 1
INTEGER = 0

Module contents