main
Module for running the resource usage and Monte Carlo simulation.
- ska_sdp_resource_model.simulate.main.main()[source]
Run the resource usage simulation.
Parses the command line arguments and runs the resource usage simulation.
- Returns:
dict – Dictionary containing the simulation output.
- ska_sdp_resource_model.simulate.main.monte_carlo_simulation(observations_list, pipelines_config, hardware_config, n_iter=100, num_workers=1, shuffle=False, seed=None, client=None)[source]
Run a Monte Carlo simulation of the SDP Resource Model.
- Parameters:
observations_list (list) – A list of dictionaries containing the observations to be simulated. This must contain the configurations for each scheduling block type and each pipeline step.
pipelines_config (dict) – A dictionary containing the configuration of each pipeline. Must contain the keys node_hours_mean, node_hours_uncertainty, pct_parallelism_min and pct_parallelism_max.
hardware_config (dict) – A dictionary containing the hardware configuration to use in the simulation.
n_iter (int) – The number of Monte Carlo trials to run. Default is 100.
num_workers (int) – Number of worker processes to use for running parallel simulations. If None or -1, a suitable default number of workers will be chosen. For a small number of iterations (n_iter < 100), the simulations will be run sequentially on a single worker. For larger simulations, the default value is set to four times the cpu count of the system at import time.
shuffle (bool) – Whether to shuffle the observations list before running the simulation. Default is False.
seed (int) – The random seed to use for the Monte Carlo simulation for reproducible results. Default is None.
client (dask.Client) – Optional Dask client to utilise for parallelism. If provided, the Monte Carlo iterations will be run using this scheduler. If None, any previously initialized schedulers will automatically be used by dask. If None, and no exisiting dask scheduler is running, the Monte Carlo iterations will be run sequentially on a single process.
- Returns:
run_times_days (list) – A list of the total simulation times for each Monte Carlo trial in days.
resource_usages (list) – A list of the resource usage dataframes for each Monte Carlo trial.
event_logs (list) – A list of the event logs dataframes for each Monte Carlo trial.
num_successful_runs (int) – The number of successful runs in the Monte Carlo simulation.
- ska_sdp_resource_model.simulate.main.run_simulation(hardware_config, observing_schedule_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-sdp-resource-model/checkouts/latest/src/ska_sdp_resource_model/data/schedules/observing_schedule.json'), scheduling_block_types_config_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-sdp-resource-model/checkouts/latest/src/ska_sdp_resource_model/data/config/scheduling_block_types.json'), hardware_config_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-sdp-resource-model/checkouts/latest/src/ska_sdp_resource_model/data/config/hardware.json'), pipelines_config_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-sdp-resource-model/checkouts/latest/src/ska_sdp_resource_model/data/config/pipelines.json'), num_monte_carlo_iterations=0, num_workers=1, shuffle=False, generate_observing_schedule_hrs=0)[source]
Runs a resource usage simulation based on the provided hardware configuration.
- Parameters:
hardware_config (str) – The key identifying the hardware configuration to use.
observing_schedule_path (str, optional) – Path to the CSV file containing the observing schedule. Defaults to “data/schedules/observing_schedule.json”.
scheduling_block_types_config_path (Path, optional) – Path to the JSON file defining scheduling block types. Defaults to Path(“data/config/scheduling_block_types.json”).
hardware_config_path (Path, optional) – Path to the JSON file containing hardware configurations. Defaults to Path(“data/config/hardware.json”).
pipelines_config_path (Path, optional) – Path to the JSON file defining pipeline configurations. Defaults to Path(“data/config/pipelines.json”).
num_monte_carlo_iterations (int) – Number of Monte Carlo iterations to run. Defaults to 0.
num_workers (int) – Number of worker processes to use for running parallel simulations.
shuffle (bool) – Whether to shuffle the observations list before running the simulation. Defaults to False.
generate_observing_schedule_hrs (int) – Number of hours of observations to generate. Replaces observations from file if > 0. Defaults to 0.
- Returns:
dict – A dictionary containing the simulation results.
- Raises:
KeyError – If the specified hardware_config is not found in the
hardware configuration data. –