Skip to content

Multi‐objective Branin

arturluis edited this page Feb 17, 2021 · 7 revisions

Here, we will show how to use HyperMapper to optimize a multi-objective Branin function. We look for minimizing the value of this function and a fake energy estimation given two parameters x1, x2.

The Objective Function

In this example, we want to simultaneously minimize the Branin function and energy estimation. We define our black-box function as:

def Branin(X):
    x1 = X['x1']
    x2 = X['x2']
    a = 1.0
    b = 5.1 / (4.0 * math.pi * math.pi)
    c = 5.0 / math.pi
    r = 6.0
    s = 10.0
    t = 1.0 / (8.0 * math.pi)
    y_value = a * (x2 - b * x1 * x1 + c * x1 - r) ** 2 + s * (1 - t) * math.cos(x1) + s
    y_energy = x1 + x2

    optimization_metrics = {}
    optimization_metrics["Value"] = y_value
    optimization_metrics["Energy"] = y_energy

    return optimization_metrics

Recall that when we want to simultaneously optimize multiple objectives, the black-box function must return a dictionary containing all optimization metrics.

An example of this code can be found in multiobjective_branin.py.

The JSON Configuration File

The following is what needs to be specified as a json syntax:

{
    "application_name": "multiobjective_branin",
    "optimization_objectives": ["Value", "Energy"],
    "optimization_iterations": 50,
    "input_parameters" : {
        "x1": {
            "parameter_type" : "real",
            "values" : [-5, 10],
            "parameter_default" : 0
        },
        "x2": {
            "parameter_type" : "real",
            "values" : [0, 15],
            "parameter_default" : 0
        }
    }
}

Note that "optimization_objectives" informs HyperMapper about the number and name of the quality metrics (objectives) we aim to minimize, in our case we have two objectives: the value and energy of the Branin. The name has to match exactly the name of the keys in the dictionary returned by the black-box function providing the evaluation.

You can find this json in multiobjective_branin_scenario.json.

Run HyperMapper

In order to run this example, we use:

python3 example_scenarios/synthetic/multiobjective_branin/multiobjective_branin.py

An example of stdout output can be found here.

The result of this script is a csv file called multiobjective_branin_output_samples.csv.

Compute Pareto

After running HyperMapper, we can compute the Pareto front using:

hm-compute-pareto example_scenarios/synthetic/multiobjective_branin/multiobjective_branin_scenario.json

The result of this script is a csv file called multiobjective_branin_output_pareto.csv. Currently, this only works for applications with two objectives.

Visualize Pareto

We can also visualize the Pareto front using:

hm-plot-pareto example_scenarios/synthetic/multiobjective_branin/multiobjective_branin_scenario.json

The result of this script is a pdf image multiobjective_branin_output_pareto.pdf that represents the Pareto front and the samples drawn.

Other data visualizations and statistics are available out-of-the-box in HyperMapper. To have an idea look at the example_outputs folder.

Other examples

See the Ordinal Branin and DTLZ1 examples provided to see other examples of multi-objective optimization with HyperMapper.

Clone this wiki locally