From 9cc6f24eff09f63d9b896314d653f26e2f9959a6 Mon Sep 17 00:00:00 2001 From: Zizhe Wang <zizhe.wang@tu-dresden.de> Date: Wed, 17 Jul 2024 11:42:31 +0200 Subject: [PATCH] feat multiple goal expressions --- src/orchestration_config.json | 7 +++++-- src/orchestration_configurator.py | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/orchestration_config.json b/src/orchestration_config.json index 2f661da..ba9415b 100644 --- a/src/orchestration_config.json +++ b/src/orchestration_config.json @@ -6,7 +6,7 @@ "SIMULATION_TIME": 100, "TIME_CONFIG": { "START_TIME": 8, - "END_TIME": 13, + "END_TIME": 12, "TIME_UNIT": "hour" }, "OBJECTIVES": [ @@ -31,7 +31,10 @@ "user_demand": "userDemand" }, "CRITERIA": { - "GOAL_EXPRESSION": "evaluation_results['performance'] >= simulation_inputs['user_demand']" + "GOAL_EXPRESSION": [ + "evaluation_results['performance'] >= simulation_inputs['user_demand']", + "evaluation_results['remainingEnergy'] >= 0" + ] }, "OPTIMIZATION_CONFIG": { "USE_SINGLE_OBJECTIVE": false, diff --git a/src/orchestration_configurator.py b/src/orchestration_configurator.py index c28145b..4ef470d 100644 --- a/src/orchestration_configurator.py +++ b/src/orchestration_configurator.py @@ -76,7 +76,8 @@ def simulate_and_evaluate(parameters, simulation_time, simulation_inputs, orches print(f"{criterion}: {result_value}") # Evaluate the goal expression dynamically - goal_satisfied = eval(goal_expression) + local_vars = {"evaluation_results": evaluation_results, "simulation_inputs": simulation_inputs} + goal_satisfied = all(eval(expression, {}, local_vars) for expression in goal_expression) print(f"Goal satisfied: {goal_satisfied}") return evaluation_results, goal_satisfied, parameters, depletion_time @@ -107,16 +108,12 @@ def adaptive_control_loop(data, moo_wrapper, orchestration_config): # Create a dictionary of inputs simulation_inputs = dict(zip(input_keys, input_values)) - # 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() - # Get the list of best parameters from the optimization results parameter_list = moo_wrapper.get_parameters() - # Try each parameter set in order until goal is satisfied or options are exhausted goal_satisfied = False -- GitLab