Scenario¶
todo intro text
scenario.py - Scenario Management
This module defines the Scenario class and related enums for managing simulation scenarios. It provides functionality for creating, processing, and analyzing scenarios with different algorithms and parameters.
- class algomancy_scenario.scenario.ScenarioStatus(*values)[source]¶
Bases:
StrEnumConstants representing the possible states of a scenario.
- CREATED = 'created'¶
- QUEUED = 'queued'¶
- PROCESSING = 'processing'¶
- COMPLETE = 'complete'¶
- FAILED = 'failed'¶
- class algomancy_scenario.scenario.Scenario(tag, input_data, kpis, algorithm, provided_id=None, data_params=None)[source]¶
Bases:
Generic[BASE_KPI]Represents a scenario with input data, algorithm, and results.
A scenario encapsulates the input data, processing algorithm, parameters, and results of a simulation or analysis run.
- property input_data_key: str¶
- property data_source: BASEDATASOURCE¶
- property algorithm_description: str¶
- property kpis: Dict[str, BASE_KPI]¶
- property data_params: BaseParameterSet¶
- property progress: float¶
- process(logger=None)[source]¶
Processes the scenario using the specified algorithm.
This method runs the algorithm in the background, updates the scenario status, and computes KPIs based on the results.
Exceptions during processing are caught, and the scenario status is set to FAILED.
- compute_kpis()[source]¶
Calculates key performance indicators (KPIs) for the given scenario.
- Raises:
ValueError – If there is no result available for the scenario.
KpiError – If one or more KPI calculations fail.
- to_dict()[source]¶
Converts the attributes of the instance into a dictionary representation.
This method creates a dictionary containing the key attributes of the instance by converting them into a serializable format. Attributes that have a to_dict method are recursively processed. If some attributes do not exist or cannot be accessed, they may return None.
- Returns:
A dictionary representation of the instance’s attributes.
- Return type:
dict