Coverage for examples/OneRoom_SimpleMPC/main_one_room_flex.py: 92%
25 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-08-01 15:10 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-08-01 15:10 +0000
1import logging
2from agentlib_flexquant.generate_flex_agents import FlexAgentGenerator
3from agentlib.utils.multi_agent_system import LocalMASAgency
4from agentlib_flexquant.utils.interactive import Dashboard, CustomBound
5from plot_results import plot_results
7# Set the log-level
8logging.basicConfig(level=logging.WARN)
9until = 21600
11ENV_CONFIG = {"rt": False, "factor": 0.01, "t_sample": 60}
14def run_example(until=until, with_plots=False):
15 results = []
16 mpc_config = "mpc_and_sim/simple_model.json"
17 sim_config = "mpc_and_sim/simple_sim.json"
18 predictor_config = "predictor/predictor_config.json"
19 flex_config = "flex_configs/flexibility_agent_config.json"
20 agent_configs = [sim_config, predictor_config]
22 config_list = FlexAgentGenerator(
23 flex_config=flex_config, mpc_agent_config=mpc_config
24 ).generate_flex_agents()
25 agent_configs.extend(config_list)
27 mas = LocalMASAgency(
28 agent_configs=agent_configs, env=ENV_CONFIG, variable_logging=False
29 )
31 mas.run(until=until)
32 results = mas.get_results(cleanup=False)
34 if with_plots:
35 Dashboard(
36 flex_config="flex_configs/flexibility_agent_config.json",
37 simulator_agent_config="mpc_and_sim/simple_sim.json",
38 results=results
39 ).show(
40 custom_bounds=CustomBound(
41 for_variable="T",
42 lb_name="T_lower",
43 ub_name="T_upper"
44 )
45 )
46 # plot_results(results_data=results) # Alternative plotscript using matplotlib,
47 return results
50if __name__ == "__main__":
51 run_example(until, with_plots=True)