From 923b9028083fdfb40a133affc7d42601917c5f0f Mon Sep 17 00:00:00 2001 From: Zizhe Wang <zizhe.wang@tu-dresden.de> Date: Mon, 1 Jul 2024 17:08:41 +0200 Subject: [PATCH] refactor update optimization config --- src/orchestration_config.json | 6 ++++++ src/orchestration_configurator.py | 2 +- src/orchestration_wrapper.py | 8 +++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/orchestration_config.json b/src/orchestration_config.json index b93e40b..77174c8 100644 --- a/src/orchestration_config.json +++ b/src/orchestration_config.json @@ -33,6 +33,12 @@ "CRITERIA": { "GOAL_EXPRESSION": "evaluation_results['performance'] >= simulation_inputs['user_demand']" }, + "OPTIMIZATION_CONFIG": { + "USE_SINGLE_OBJECTIVE": false, + "ALGORITHM_NAME": "nsga2", + "POP_SIZE": 5, + "N_GEN": 2 + }, "PLOT_CONFIG": { "PLOT_X": "", "PLOT_Y": "", diff --git a/src/orchestration_configurator.py b/src/orchestration_configurator.py index f496ab9..8eddc07 100644 --- a/src/orchestration_configurator.py +++ b/src/orchestration_configurator.py @@ -98,7 +98,7 @@ def adaptive_control_loop(data, moo_wrapper, orchestration_config): # Update the config for the optimization framework moo_wrapper.update_config(simulation_inputs, simulation_time) - + # Run the optimization using the wrapper moo_wrapper.run_optimization() diff --git a/src/orchestration_wrapper.py b/src/orchestration_wrapper.py index 095075c..5531f2b 100644 --- a/src/orchestration_wrapper.py +++ b/src/orchestration_wrapper.py @@ -5,10 +5,6 @@ import json import os from optimize_main import run_optimization -import json -import os -from optimize_main import run_optimization - class MOO4ModelicaWrapper: def __init__(self, orchestration_config_path, config_path): self.orchestration_config_path = orchestration_config_path @@ -33,7 +29,9 @@ class MOO4ModelicaWrapper: self.config['OBJECTIVES'] = self.orchestration_config['OBJECTIVES'] self.config['PLOT_CONFIG'] = self.orchestration_config['PLOT_CONFIG'] self.config['N_JOBS'] = self.orchestration_config['N_JOBS'] - + for key, value in self.orchestration_config['OPTIMIZATION_CONFIG'].items(): + self.config['OPTIMIZATION_CONFIG'][key] = value + with open(self.config_path, 'w') as f: json.dump(self.config, f, indent=4) -- GitLab