diff --git a/src/orchestration_config.json b/src/orchestration_config.json index 2f661da491e7200b742e9fbbe9330879da96604d..ba9415bcbaec4660f6bbcc28f633abe65a0f4ae4 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 c28145b242f7327b1dcc567939f361e92354eb2a..4ef470d20dc7b14e974cdb0ceea243603bc85f5e 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