Skip to content
Snippets Groups Projects
Commit 9cc6f24e authored by Zizhe Wang's avatar Zizhe Wang
Browse files

feat multiple goal expressions

parent 7d64e200
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"SIMULATION_TIME": 100, "SIMULATION_TIME": 100,
"TIME_CONFIG": { "TIME_CONFIG": {
"START_TIME": 8, "START_TIME": 8,
"END_TIME": 13, "END_TIME": 12,
"TIME_UNIT": "hour" "TIME_UNIT": "hour"
}, },
"OBJECTIVES": [ "OBJECTIVES": [
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
"user_demand": "userDemand" "user_demand": "userDemand"
}, },
"CRITERIA": { "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": { "OPTIMIZATION_CONFIG": {
"USE_SINGLE_OBJECTIVE": false, "USE_SINGLE_OBJECTIVE": false,
......
...@@ -76,7 +76,8 @@ def simulate_and_evaluate(parameters, simulation_time, simulation_inputs, orches ...@@ -76,7 +76,8 @@ def simulate_and_evaluate(parameters, simulation_time, simulation_inputs, orches
print(f"{criterion}: {result_value}") print(f"{criterion}: {result_value}")
# Evaluate the goal expression dynamically # 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}") print(f"Goal satisfied: {goal_satisfied}")
return evaluation_results, goal_satisfied, parameters, depletion_time return evaluation_results, goal_satisfied, parameters, depletion_time
...@@ -107,16 +108,12 @@ def adaptive_control_loop(data, moo_wrapper, orchestration_config): ...@@ -107,16 +108,12 @@ def adaptive_control_loop(data, moo_wrapper, orchestration_config):
# Create a dictionary of inputs # Create a dictionary of inputs
simulation_inputs = dict(zip(input_keys, input_values)) simulation_inputs = dict(zip(input_keys, input_values))
# Update the config for the optimization framework # Update the config for the optimization framework
moo_wrapper.update_config(simulation_inputs, simulation_time) moo_wrapper.update_config(simulation_inputs, simulation_time)
# Run the optimization using the wrapper # Run the optimization using the wrapper
moo_wrapper.run_optimization() moo_wrapper.run_optimization()
# Get the list of best parameters from the optimization results # Get the list of best parameters from the optimization results
parameter_list = moo_wrapper.get_parameters() parameter_list = moo_wrapper.get_parameters()
# Try each parameter set in order until goal is satisfied or options are exhausted # Try each parameter set in order until goal is satisfied or options are exhausted
goal_satisfied = False goal_satisfied = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment