agentlib_flexquant package

agentlib plugin

Subpackages

Submodules

agentlib_flexquant.generate_flex_agents module

class agentlib_flexquant.generate_flex_agents.FlexAgentGenerator(flex_config: str | Annotated[Path, PathType(path_type=file)] | FlexQuantConfig, mpc_agent_config: str | Annotated[Path, PathType(path_type=file)] | AgentConfig)[source]

Bases: object

adapt_indicator_config(module_config: FlexibilityIndicatorModuleConfig) FlexibilityIndicatorModuleConfig[source]

Adapts the indicator module config for automated flexibility quantification.

adapt_market_config(module_config: FlexibilityMarketModuleConfig) FlexibilityMarketModuleConfig[source]

Adapts the market module config for automated flexibility quantification.

adapt_mpc_module_config(module_config: BaseMPCConfig, mpc_dataclass: BaseMPCData) BaseMPCConfig[source]

Adapts 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 the Time variable to the inputs - add parameters for the activation and quantification of flexibility

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. :param simulator_agent_config: Path to the simulator agent config JSON file. :type simulator_agent_config: Union[str, Path]

Returns:

The updated simulator config with the modified result file path.

Return type:

dict

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]

Appends 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.

baseline_mpc_module_config: BaseMPCConfig
check_variables_in_casadi_config(config: CasadiModelConfig, expr: str)[source]

Check if all variables in the expression are defined in the config.

Parameters:
  • config (CasadiModelConfig) – casadi model config.

  • expr (str) – The expression to check.

Raises:

ValueError – If any variable in the expression is not defined in the config.

generate_flex_agents() [<class 'agentlib_mpc.modules.mpc.BaseMPCConfig'>, <class 'agentlib_mpc.modules.mpc.BaseMPCConfig'>, <class 'agentlib_mpc.modules.mpc.BaseMPCConfig'>, <class 'agentlib_flexquant.modules.flexibility_indicator.FlexibilityIndicatorModuleConfig'>, <class 'agentlib_flexquant.modules.flexibility_market.FlexibilityMarketModuleConfig'>][source]

Generates the configs and the python module for the flexibility agents. Power variable must be defined in the mpc config.

get_config_file_paths() List[str][source]

Returns a list of paths with the created config files

indicator_module_config: FlexibilityIndicatorModuleConfig
market_module_config: FlexibilityMarketModuleConfig
neg_flex_mpc_module_config: BaseMPCConfig
orig_mpc_module_config: BaseMPCConfig
pos_flex_mpc_module_config: BaseMPCConfig
run_config_validations()[source]

Function to validate integrity of user-supplied flex config.

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.