csle_agents.agents.lp_cmdp package
Submodules
csle_agents.agents.lp_cmdp.linear_programming_cmdp_agent module
- class csle_agents.agents.lp_cmdp.linear_programming_cmdp_agent.LinearProgrammingCMDPAgent(simulation_env_config: SimulationEnvConfig, experiment_config: ExperimentConfig, env: Optional[BaseEnv] = None, emulation_env_config: Union[None, EmulationEnvConfig] = None, training_job: Optional[TrainingJobConfig] = None, save_to_metastore: bool = True)[source]
Bases:
BaseAgent
Linear programming agent for CMDPs
- static compute_avg_metrics(metrics: Dict[str, List[Union[float, int]]]) Dict[str, Union[float, int]] [source]
Computes the average metrics of a dict with aggregated metrics
- Parameters
metrics – the dict with the aggregated metrics
- Returns
the average metrics
- linear_programming_cmdp(exp_result: ExperimentResult, seed: int, training_job: TrainingJobConfig, random_seeds: List[int]) ExperimentResult [source]
Runs the linear programming algorithm for normal-form games
- Parameters
exp_result – the experiment result object to store the result
seed – the seed
training_job – the training job config
random_seeds – list of seeds
- Returns
the updated experiment result and the trained policy
- static lp(actions: ndarray[Any, dtype[Any]], states: ndarray[Any, dtype[Any]], cost_tensor: ndarray[Any, dtype[Any]], transition_tensor: ndarray[Any, dtype[Any]], constraint_cost_tensors: ndarray[Any, dtype[Any]], constraint_cost_thresholds: ndarray[Any, dtype[Any]]) Tuple[str, ndarray[Any, dtype[Any]], ndarray[Any, dtype[Any]], ndarray[Any, dtype[Any]], float] [source]
Linear program for solving a CMDP (see Altman ‘99 for details)
- Parameters
actions – the action space
states – the state space
cost_tensor – the cost tensor
transition_tensor – the transition tensor
constraint_cost_tensors – the constraint cost tensors
constraint_cost_thresholds – the constraint cost thresholds
- Returns
the solution status, the optimal occupancy measure, the optimal strategy, the expeted constraint cost, the objective value
- static round_vec(vec) List[float] [source]
Rounds a vector to 3 decimals
- Parameters
vec – the vector to round
- Returns
the rounded vector
- train() ExperimentExecution [source]
Performs the policy training for the given random seeds using linear programming
- Returns
the training metrics and the trained policies
- static update_metrics(metrics: Dict[str, List[Union[float, int]]], info: Dict[str, Union[float, int]]) Dict[str, List[Union[float, int]]] [source]
Update a dict with aggregated metrics using new information from the environment
- Parameters
metrics – the dict with the aggregated metrics
info – the new information
- Returns
the updated dict