agentlib_flexquant package
agentlib plugin
Subpackages
- agentlib_flexquant.data_structures package
- Submodules
- agentlib_flexquant.data_structures.flex_kpis module
FlexibilityDataFlexibilityData.electricity_price_seriesFlexibilityData.flex_offer_time_gridFlexibilityData.kpis_negFlexibilityData.kpis_posFlexibilityData.mpc_time_gridFlexibilityData.power_profile_baseFlexibilityData.power_profile_flex_negFlexibilityData.power_profile_flex_posFlexibilityData.stored_energy_profile_baseFlexibilityData.stored_energy_profile_flex_negFlexibilityData.stored_energy_profile_flex_posFlexibilityData.switch_timeFlexibilityData.ConfigFlexibilityData.calculate()FlexibilityData.get_kpis()FlexibilityData.reset_time_grid()FlexibilityData.unify_inputs()
FlexibilityKPIsFlexibilityKPIs.corrected_costsFlexibilityKPIs.corrected_costs_relFlexibilityKPIs.costsFlexibilityKPIs.costs_relFlexibilityKPIs.directionFlexibilityKPIs.electricity_costs_seriesFlexibilityKPIs.energy_flexFlexibilityKPIs.power_flex_fullFlexibilityKPIs.power_flex_offerFlexibilityKPIs.power_flex_offer_avgFlexibilityKPIs.power_flex_offer_maxFlexibilityKPIs.power_flex_offer_minFlexibilityKPIs.power_flex_within_boundaryFlexibilityKPIs.calculate()FlexibilityKPIs.get_kpi_dict()FlexibilityKPIs.get_name_dict()
KPIKPISeries
- agentlib_flexquant.data_structures.flex_offer module
- agentlib_flexquant.data_structures.flex_results module
ResultsResults.baseline_agent_configResults.baseline_module_configResults.convert_timescale_of_dataframe_index()Results.create_instance_with_skipped_validation()Results.current_timescale_of_dataResults.df_baselineResults.df_baseline_statsResults.df_indicatorResults.df_marketResults.df_neg_flexResults.df_neg_flex_statsResults.df_pos_flexResults.df_pos_flex_statsResults.df_simulationResults.generator_configResults.get_intersection_mpcs_sim()Results.indicator_agent_configResults.indicator_module_configResults.market_agent_configResults.market_module_configResults.neg_flex_agent_configResults.neg_flex_module_configResults.pos_flex_agent_configResults.pos_flex_module_configResults.simulator_agent_configResults.simulator_module_config
load_indicator()load_market()
- agentlib_flexquant.data_structures.flexquant module
FlexQuantConfigFlexQuantConfig.baseline_config_generator_dataFlexQuantConfig.casadi_sim_time_stepFlexQuantConfig.delete_filesFlexQuantConfig.flex_base_directory_pathFlexQuantConfig.flex_event_durationFlexQuantConfig.flex_files_directoryFlexQuantConfig.indicator_configFlexQuantConfig.market_configFlexQuantConfig.market_timeFlexQuantConfig.overwrite_filesFlexQuantConfig.prep_timeFlexQuantConfig.results_directoryFlexQuantConfig.shadow_mpc_config_generator_dataFlexQuantConfig.adapt_paths_and_create_directoryFlexQuantConfig.check_config_file_extensionFlexQuantConfig.is_none_negative_integer
FlexibilityIndicatorConfigFlexibilityMarketConfigShadowMPCConfigGeneratorConfig
- agentlib_flexquant.data_structures.globals module
- agentlib_flexquant.data_structures.market module
- agentlib_flexquant.data_structures.mpcs module
BaseMPCDataBaseMPCData.class_nameBaseMPCData.config_inputs_appendixBaseMPCData.config_parameters_appendixBaseMPCData.created_flex_mpcs_fileBaseMPCData.module_idBaseMPCData.module_typesBaseMPCData.name_of_created_fileBaseMPCData.power_aliasBaseMPCData.results_suffixBaseMPCData.stored_energy_aliasBaseMPCData.weights
BaselineMPCDataBaselineMPCData.class_nameBaselineMPCData.comfort_variableBaselineMPCData.config_inputs_appendixBaselineMPCData.config_parameters_appendixBaselineMPCData.module_idBaselineMPCData.module_typesBaselineMPCData.name_of_created_fileBaselineMPCData.power_aliasBaselineMPCData.power_unitBaselineMPCData.power_variableBaselineMPCData.profile_comfort_weightBaselineMPCData.profile_deviation_weightBaselineMPCData.results_suffixBaselineMPCData.stored_energy_aliasBaselineMPCData.weightsBaselineMPCData.update_config_parameters_appendix
NFMPCDataPFMPCData
- agentlib_flexquant.modules package
- Submodules
- agentlib_flexquant.modules.baseline_mpc module
- agentlib_flexquant.modules.flexibility_indicator module
FlexibilityIndicatorModuleFlexibilityIndicatorModule.calc_and_send_offer()FlexibilityIndicatorModule.callback()FlexibilityIndicatorModule.check_power_end_deviation()FlexibilityIndicatorModule.cleanup_results()FlexibilityIndicatorModule.dataFlexibilityIndicatorModule.get_results()FlexibilityIndicatorModule.process()FlexibilityIndicatorModule.register_callbacks()FlexibilityIndicatorModule.send_flex_offer()FlexibilityIndicatorModule.write_results()
FlexibilityIndicatorModuleConfigFlexibilityIndicatorModuleConfig.calculate_costsFlexibilityIndicatorModuleConfig.correct_costsFlexibilityIndicatorModuleConfig.inputsFlexibilityIndicatorModuleConfig.integration_methodFlexibilityIndicatorModuleConfig.outputsFlexibilityIndicatorModuleConfig.parametersFlexibilityIndicatorModuleConfig.power_unitFlexibilityIndicatorModuleConfig.price_variableFlexibilityIndicatorModuleConfig.results_fileFlexibilityIndicatorModuleConfig.save_resultsFlexibilityIndicatorModuleConfig.shared_variable_fieldsFlexibilityIndicatorModuleConfig.check_results_file_extensionFlexibilityIndicatorModuleConfig.model_post_init()
InputsForCalculateFlexCostsInputsForCorrectFlexCosts
- agentlib_flexquant.modules.flexibility_market module
FlexibilityMarketModuleFlexibilityMarketModule.abs_flex_event_endFlexibilityMarketModule.cleanup_results()FlexibilityMarketModule.custom_flexibility_callback()FlexibilityMarketModule.dummy_callback()FlexibilityMarketModule.flex_offer_dfFlexibilityMarketModule.get_results()FlexibilityMarketModule.process()FlexibilityMarketModule.random_flexibility_callback()FlexibilityMarketModule.register_callbacks()FlexibilityMarketModule.set_random_seed()FlexibilityMarketModule.single_flexibility_callback()FlexibilityMarketModule.write_results()
FlexibilityMarketModuleConfigFlexibilityMarketModuleConfig.inputsFlexibilityMarketModuleConfig.market_specsFlexibilityMarketModuleConfig.outputsFlexibilityMarketModuleConfig.parametersFlexibilityMarketModuleConfig.results_fileFlexibilityMarketModuleConfig.save_resultsFlexibilityMarketModuleConfig.shared_variable_fieldsFlexibilityMarketModuleConfig.check_results_file_extensionFlexibilityMarketModuleConfig.model_post_init()
- agentlib_flexquant.modules.shadow_mpc module
- agentlib_flexquant.optimization_backends package
- agentlib_flexquant.utils package
- Submodules
- agentlib_flexquant.utils.config_management module
- agentlib_flexquant.utils.data_handling module
- agentlib_flexquant.utils.interactive module
- agentlib_flexquant.utils.parsing module
SetupSystemModifierSetupSystemModifier.get_leftmost_list()SetupSystemModifier.modify_config_class_baseline()SetupSystemModifier.modify_config_class_shadow()SetupSystemModifier.modify_setup_system_baseline()SetupSystemModifier.modify_setup_system_shadow()SetupSystemModifier.visit_ClassDef()SetupSystemModifier.visit_Module()
add_import_to_tree()add_input()add_output()add_parameter()create_ast_element()remove_all_imports_from_tree()
Submodules
agentlib_flexquant.generate_flex_agents module
Generate agents for flexibility quantification.
This module provides the FlexAgentGenerator class that creates and configures flexibility agents. The agents created include the baseline, positive and negative flexibility agents, the flexibility indicator and market agents. The agents are created based on the flex config and the MPC config.
- class agentlib_flexquant.generate_flex_agents.FlexAgentGenerator(flex_config: str | Path | FlexQuantConfig, mpc_agent_config: str | Path | AgentConfig)[source]
Bases:
objectClass for generating the flex agents
- orig_mpc_module_config: the config for the original mpc,
which has nothing to do with the flexibility quantification
- baseline_mpc_module_config: the config for the baseline mpc
for flexibility quantification
- pos_flex_mpc_module_config: the config for the positive flexibility mpc
for flexibility quantification
- neg_flex_mpc_module_config: the config for the negative flexibility mpc
for flexibility quantification
indicator_module_config: the config for the indicator for flexibility quantification market_module_config: the config for the market for flexibility quantification
- adapt_indicator_config(module_config: FlexibilityIndicatorModuleConfig) FlexibilityIndicatorModuleConfig[source]
Adapt the indicator module config for automated flexibility quantification.
- adapt_market_config(module_config: FlexibilityMarketModuleConfig) FlexibilityMarketModuleConfig[source]
Adapt the market module config for automated flexibility quantification.
- adapt_mpc_module_config(module_config: MPCConfig, mpc_dataclass: BaseMPCData, agent_id: str) MPCConfig[source]
Adapt the mpc module config for automated flexibility quantification.
Things adapted among others are: - the file name/path of the mpc config file - names of the control variables for the shadow mpcs - reduce communicated variables of shadow mpcs to outputs - add the power variable to the outputs - add parameters for the activation and quantification of flexibility
- Parameters:
module_config – The module config to be adapted
mpc_dataclass – The dataclass corresponding to the type of the MPC module. It contains all the extra data necessary for flexibility quantification, which will be used to update the module_config.
agent_id – agent_id for creating the flexquant mpc module config
- Returns:
The adapted module config
- adapt_sim_results_path(simulator_agent_config: str | Path) dict[source]
Optional helper function to adapt file path for simulator results in sim config, so that sim results land in the same results directory as flex results.
- Parameters:
simulator_agent_config – Path to the simulator agent config JSON file.
- Returns:
The updated simulator config dictionary with the modified result file path.
- Raises:
FileNotFoundError – If the specified config file does not exist.
- append_module_and_dump_agent(module: BaseModuleConfig, agent: AgentConfig, module_type: str, config_name: str)[source]
Append the given module config to the given agent config and dumps the agent config to a json file.
The json file is named based on the config_name.
- Parameters:
module – The module config to be appended.
agent – The agent config to be updated.
module_type – The type of the module
config_name – The name of the json file for module config (e.g. baseline.json)
- baseline_mpc_module_config: MPCConfig
- check_variables_in_casadi_config(config: CasadiModelConfig, expr: str)[source]
Check if all variables in the expression are defined in the config.
- Parameters:
config – casadi model config.
expr – The expression to check.
- Raises:
ValueError – If any variable in the expression is not defined in the config.
- generate_flex_agents() list[str][source]
Generate the configs and the python module for the flexibility agents.
- Returns:
list of the full path for baseline mpc, pos_flex mpc, neg_flex mpc, indicator and market config
- get_collocation_time_grid(discretization_options: dict)[source]
Get the mpc output collocation grid over the horizon
- indicator_module_config: FlexibilityIndicatorModuleConfig
- market_module_config: FlexibilityMarketModuleConfig
- neg_flex_mpc_module_config: MPCConfig
- orig_mpc_module_config: MPCConfig
- pos_flex_mpc_module_config: MPCConfig
- run_config_validations()[source]
Function to validate integrity of user-supplied flex config.
Since the validation depends on interactions between multiple configurations, it is performed within this function rather than using Pydantic’s built-in validators for individual configurations.
The following checks are performed: 1. Ensures the specified power variable exists in the MPC model outputs. 2. Ensures the specified comfort variable exists in the MPC model states. 3. Validates that the stored energy variable exists in MPC outputs if energy cost correction is enabled. 4. Verifies the supported collocation method is used; otherwise, switches to ‘legendre’ and raises a warning. 5. Ensures that the sum of prep time, market time, and flex event duration does not exceed the prediction horizon. 6. Ensures market time equals the MPC model time step if market config is present. 7. Ensures that all flex time values are multiples of the MPC model time step. 8. Checks for mismatches between time-related parameters in the flex/MPC and indicator configs and issues warnings when discrepancies exist, using the flex/MPC config values as the source of truth.