-
Notifications
You must be signed in to change notification settings - Fork 26
Chakong‐Haimes
Here, we will show how to use HyperMapper to optimize the constrained Chakong-Haimes multi-objective function. We look for minimizing the values of this function given two parameters x1 and x2, where some combinations of x1 and x2 are unfeasible.
In this example, we want to minimize the Chakong-Haimes function subject to constraints on x1 and x2. This is defined as:
def chakong_haimes(X):
x1 = X['x1']
x2 = X['x2']
f1_value = 2 + (x1 - 2)*(x1 - 2) + (x2 - 1)*(x2 - 1)
f2_value = 9*x1 - (x2 - 1)*(x2 - 1)
# check constraints
g1 = x1*x1 + x2*x2 <= 225
g2 = x1 - 3*x2 + 10 <= 0
valid = g1 and g2
output = {}
output['f1_value'] = f1_value
output['f2_value'] = f2_value
output['Valid'] = valid
return output
Note that we return both values of the function and a feasibility indicator for x1 and x2. These three values must be returned to HyperMapper. An example of this code can be found in chakong_haimes.py.
The following is what needs to be specified as a json syntax to run Chakong-Haimes:
{
"application_name": "chakong_haimes",
"optimization_objectives": ["f1_value", "f2_value"],
"feasible_output": {
"enable_feasible_predictor": true
},
"optimization_iterations": 50,
"input_parameters" : {
"x1": {
"parameter_type" : "real",
"values" : [-20, 20],
"parameter_default" : 0
},
"x2": {
"parameter_type" : "real",
"values" : [-20, 20],
"parameter_default" : 0
}
}
}
Note that we include a "feasible_output" field. This field enables a probabilistic model that will predict which samples of the space are feasible. This helps guide the search towards feasible parts of the search space. The feasibility probabilistic model is used only during the optimization iterations, it does not affect the design of experiment samples.
You can find this json in chakong_haimes_scenario.json.
In order to run this example, we use:
python3 example_scenarios/synthetic/chakong_haimes/chakong_haimes.py
An example of stdout output can be found here.
The result of this script is a csv file called chakong_haimes_output_dse_samples.csv.
After running HyperMapper, we can compute the Pareto front using:
hm-compute-pareto example_scenarios/synthetic/chakong_haimes/chakong_haimes_scenario.json
The result of this script is a csv file called chakong_haimes_output_pareto.csv. Note that the pareto front contains only feasible points.
We can also visualize the Pareto front using:
hm-plot-pareto example_scenarios/synthetic/chakong_haimes/chakong_haimes_scenario.json
The result of this script is a pdf image chakong_haimes_output_pareto.pdf.