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:
JSONSerializable
DTO representing an action in a simulation environment
- static from_dict(d: Dict[str, Any]) Action [source]
Converts a dict representation of the DTO into an instance
- Parameters
d – the dict to convert
- Returns
the created instance
csle_common.dao.simulation_config.action_space_config module
- class csle_common.dao.simulation_config.action_space_config.ActionSpaceConfig(actions: List[Action], player_id: int, action_type: ValueType, descr: str = '')[source]
Bases:
JSONSerializable
DTO Class representing the action space configuration of a player in a simulation environment
- static from_dict(d: Dict[str, Any]) 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) ActionSpaceConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.agent_log module
- class csle_common.dao.simulation_config.agent_log.AgentLog[source]
Bases:
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]) AgentLog [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
csle_common.dao.simulation_config.base_env module
- class csle_common.dao.simulation_config.base_env.BaseEnv[source]
Bases:
Env
,ABC
Abstract class representing a csle Environment
- abstract get_traces() List[SimulationTrace] [source]
- Returns
the list of simulation traces
- abstract manual_play() None [source]
An interactive loop for manual play of the environment
- 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:
JSONSerializable
DTO representing the a general parameter of a simulation environment
- static from_dict(d: Dict[str, Any]) 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) EnvParameter [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.env_parameters_config module
- class csle_common.dao.simulation_config.env_parameters_config.EnvParametersConfig(parameters: List[EnvParameter])[source]
Bases:
JSONSerializable
DTO representing the the configuration of custom environment parameters of a simulation
- static from_dict(d: Dict[str, Any]) 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) EnvParametersConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted 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:
JSONSerializable
DTO class representing the configuration of the initial state distribution of a simulation
- static from_dict(d: Dict[str, Any]) 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) InitialStateDistributionConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.joint_action_space_config module
- class csle_common.dao.simulation_config.joint_action_space_config.JointActionSpaceConfig(action_spaces: List[ActionSpaceConfig])[source]
Bases:
JSONSerializable
DTO representing the joint action space of a simulation environment
- static from_dict(d: Dict[str, Any]) 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) JointActionSpaceConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.joint_observation_space_config module
- class csle_common.dao.simulation_config.joint_observation_space_config.JointObservationSpaceConfig(observation_spaces: List[ObservationSpaceConfig])[source]
Bases:
JSONSerializable
DTO representing a joint observation space configuration
- static from_dict(d: Dict[str, Any]) 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) JointObservationSpaceConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.observation module
- class csle_common.dao.simulation_config.observation.Observation(id: int, val: int, descr: str)[source]
Bases:
JSONSerializable
DTO class representing an observation in a simulation
- static from_dict(d: Dict[str, Any]) 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) Observation [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.observation_function_config module
- class csle_common.dao.simulation_config.observation_function_config.ObservationFunctionConfig(observation_tensor: ndarray[Any, dtype[Any]], component_observation_tensors: Dict[str, ndarray[Any, dtype[Any]]])[source]
Bases:
JSONSerializable
DTO representing the configuration of the observation function of a simulation
- static from_dict(d: Dict[str, Any]) 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) ObservationFunctionConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.observation_space_config module
- class csle_common.dao.simulation_config.observation_space_config.ObservationSpaceConfig(observations: List[Observation], observation_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[Observation]])[source]
Bases:
JSONSerializable
DTO representing the configuration of the observation space of a single player in a simulation environment
- static from_dict(d: Dict[str, Any]) 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) ObservationSpaceConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
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:
JSONSerializable
DTO representing the configuration of a player in a simulation environment in CSLE
- static from_dict(d: Dict[str, Any]) 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) PlayerConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.players_config module
- class csle_common.dao.simulation_config.players_config.PlayersConfig(player_configs: List[PlayerConfig])[source]
Bases:
JSONSerializable
A DTO representing the configuration of players in a simulation environment
- static from_dict(d: Dict[str, Any]) 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) PlayersConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.reward_function_config module
- class csle_common.dao.simulation_config.reward_function_config.RewardFunctionConfig(reward_tensor: ndarray[Any, dtype[Any]])[source]
Bases:
JSONSerializable
DTO containing the reward tensor of a simulation
- static from_dict(d: Dict[str, Any]) 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) RewardFunctionConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
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: SimulationEnvInputConfig, players_config: PlayersConfig, state_space_config: StateSpaceConfig, joint_action_space_config: JointActionSpaceConfig, joint_observation_space_config: JointObservationSpaceConfig, time_step_type: TimeStepType, reward_function_config: RewardFunctionConfig, transition_operator_config: TransitionOperatorConfig, observation_function_config: ObservationFunctionConfig, initial_state_distribution_config: InitialStateDistributionConfig, env_parameters_config: EnvParametersConfig, plot_transition_probabilities: bool = False, plot_observation_function: bool = False, plot_reward_function: bool = False)[source]
Bases:
JSONSerializable
A DTO class representing the configuration of a simulation environment
- copy() SimulationEnvConfig [source]
- Returns
a copy of the DTO
- static from_dict(d: Dict[str, Any]) 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) SimulationEnvConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.simulation_env_input_config module
- class csle_common.dao.simulation_config.simulation_env_input_config.SimulationEnvInputConfig[source]
Bases:
JSONSerializable
Abstract class representing the input to a simulation
- abstract static from_dict(d: Dict[str, Any]) 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) SimulationEnvInputConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.simulation_trace module
- class csle_common.dao.simulation_config.simulation_trace.SimulationTrace(simulation_env: str)[source]
Bases:
JSONSerializable
Class that represents a trace in the simulation system
- static from_dict(d: Dict[str, Any]) 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) 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[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[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
csle_common.dao.simulation_config.state module
- class csle_common.dao.simulation_config.state.State(id: int, name: str, descr: str, state_type: StateType)[source]
Bases:
JSONSerializable
DTO representing the state of a simulation environment
- static from_dict(d: Dict[str, Any]) State [source]
Converts a dict representation to an instance
- Parameters
d – the dict to convert
- Returns
the created instance
csle_common.dao.simulation_config.state_space_config module
- class csle_common.dao.simulation_config.state_space_config.StateSpaceConfig(states: List[State])[source]
Bases:
JSONSerializable
DTO representing the state space configuration of a simulation environment
- static from_dict(d: Dict[str, Any]) 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) StateSpaceConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO
csle_common.dao.simulation_config.state_type module
csle_common.dao.simulation_config.time_step_type module
csle_common.dao.simulation_config.transition_operator_config module
- class csle_common.dao.simulation_config.transition_operator_config.TransitionOperatorConfig(transition_tensor: ndarray[Any, dtype[Any]])[source]
Bases:
JSONSerializable
DTO representing the transition operator definition of a simulation
- static from_dict(d: Dict[str, Any]) 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) TransitionOperatorConfig [source]
Reads a json file and converts it to a DTO
- Parameters
json_file_path – the json file path
- Returns
the converted DTO