{
"cells": [
{
"cell_type": "markdown",
"id": "8b925be0",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "95e7a97a-bf78-48d4-a0c1-c0e8dfc4fed9",
"papermill": {
"duration": 0.010033,
"end_time": "2023-12-09T18:51:05.337177",
"exception": false,
"start_time": "2023-12-09T18:51:05.327144",
"status": "completed"
},
"showInput": true,
"tags": []
},
"source": [
"# Multi-Objective Optimization Ax API\n",
"### Using the Service API\n",
"For Multi-objective optimization (MOO) in the `AxClient`, objectives are specified through the `ObjectiveProperties` dataclass. An `ObjectiveProperties` requires a boolean `minimize`, and also accepts an optional floating point `threshold`. If a `threshold` is not specified, Ax will infer it through the use of heuristics. If the user knows the region of interest (because they have specs or prior knowledge), then specifying the thresholds is preferable to inferring it. But if the user would need to guess, inferring is preferable.\n",
"\n",
"\n",
"To learn more about how to choose a threshold, see [Set Objective Thresholds to focus candidate generation in a region of interest](#Set-Objective-Thresholds-to-focus-candidate-generation-in-a-region-of-interest). See the [Service API Tutorial](/tutorials/gpei_hartmann_service.html) for more infomation on running experiments with the Service API."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "0eddfc68",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2023-12-09T18:51:05.356828Z",
"iopub.status.busy": "2023-12-09T18:51:05.356200Z",
"iopub.status.idle": "2023-12-09T18:51:08.556260Z",
"shell.execute_reply": "2023-12-09T18:51:08.555481Z"
},
"hidden_ranges": [],
"originalKey": "06bf2029-0ea4-40b4-aced-956f1411cb6e",
"papermill": {
"duration": 3.227652,
"end_time": "2023-12-09T18:51:08.573935",
"exception": false,
"start_time": "2023-12-09T18:51:05.346283",
"status": "completed"
},
"showInput": true,
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.utils.notebook.plotting: Injecting Plotly library into cell. Do not overwrite or delete cell.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.utils.notebook.plotting: Please see\n",
" (https://ax.dev/tutorials/visualizations.html#Fix-for-plots-that-are-not-rendering)\n",
" if visualizations are not rendering.\n"
]
},
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import torch\n",
"from ax.plot.pareto_frontier import plot_pareto_frontier\n",
"from ax.plot.pareto_utils import compute_posterior_pareto_frontier\n",
"from ax.service.ax_client import AxClient\n",
"from ax.service.utils.instantiation import ObjectiveProperties\n",
"\n",
"# Plotting imports and initialization\n",
"from ax.utils.notebook.plotting import init_notebook_plotting, render\n",
"from botorch.test_functions.multi_objective import BraninCurrin\n",
"\n",
"init_notebook_plotting()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4b83b24f",
"metadata": {
"execution": {
"iopub.execute_input": "2023-12-09T18:51:08.657599Z",
"iopub.status.busy": "2023-12-09T18:51:08.657037Z",
"iopub.status.idle": "2023-12-09T18:51:08.662012Z",
"shell.execute_reply": "2023-12-09T18:51:08.661328Z"
},
"papermill": {
"duration": 0.048711,
"end_time": "2023-12-09T18:51:08.663540",
"exception": false,
"start_time": "2023-12-09T18:51:08.614829",
"status": "completed"
},
"tags": []
},
"outputs": [],
"source": [
"# Load our sample 2-objective problem\n",
"branin_currin = BraninCurrin(negate=True).to(\n",
" dtype=torch.double,\n",
" device=torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\"),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6d708131",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2023-12-09T18:51:08.747512Z",
"iopub.status.busy": "2023-12-09T18:51:08.746817Z",
"iopub.status.idle": "2023-12-09T18:51:08.762025Z",
"shell.execute_reply": "2023-12-09T18:51:08.761344Z"
},
"executionStartTime": 1628191188673,
"executionStopTime": 1628191188746,
"hidden_ranges": [],
"originalKey": "c687973d-1b09-4a8f-9108-1f74adf64d4d",
"papermill": {
"duration": 0.058548,
"end_time": "2023-12-09T18:51:08.763675",
"exception": false,
"start_time": "2023-12-09T18:51:08.705127",
"status": "completed"
},
"requestMsgId": "ea523260-8896-48e4-a62f-3530d268b209",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.service.ax_client: Starting optimization with verbose logging. To disable logging, set the `verbose_logging` argument to `False`. Note that float values in the logs are rounded to 6 decimal points.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.service.utils.instantiation: Inferred value type of ParameterType.FLOAT for parameter x1. If that is not the expected value type, you can explicitly specify 'value_type' ('int', 'float', 'bool' or 'str') in parameter dict.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.service.utils.instantiation: Inferred value type of ParameterType.FLOAT for parameter x2. If that is not the expected value type, you can explicitly specify 'value_type' ('int', 'float', 'bool' or 'str') in parameter dict.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.service.utils.instantiation: Created search space: SearchSpace(parameters=[RangeParameter(name='x1', parameter_type=FLOAT, range=[0.0, 1.0]), RangeParameter(name='x2', parameter_type=FLOAT, range=[0.0, 1.0])], parameter_constraints=[]).\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.core.experiment: The is_test flag has been set to True. This flag is meant purely for development and integration testing purposes. If you are running a live experiment, please set this flag to False\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: Using Models.BOTORCH_MODULAR since there are more ordered parameters than there are categories for the unordered categorical parameters.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: Calculating the number of remaining initialization trials based on num_initialization_trials=None max_initialization_trials=None num_tunable_parameters=2 num_trials=None use_batch_trials=False\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: calculated num_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: num_completed_initialization_trials=0 num_remaining_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: `verbose`, `disable_progbar`, and `jit_compile` are not yet supported when using `choose_generation_strategy` with ModularBoTorchModel, dropping these arguments.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:08] ax.modelbridge.dispatch_utils: Using Bayesian Optimization generation strategy: GenerationStrategy(name='Sobol+BoTorch', steps=[Sobol for 5 trials, BoTorch for subsequent trials]). Iterations after 5 will take longer to generate due to model-fitting.\n"
]
}
],
"source": [
"ax_client = AxClient()\n",
"ax_client.create_experiment(\n",
" name=\"moo_experiment\",\n",
" parameters=[\n",
" {\n",
" \"name\": f\"x{i+1}\",\n",
" \"type\": \"range\",\n",
" \"bounds\": [0.0, 1.0],\n",
" }\n",
" for i in range(2)\n",
" ],\n",
" objectives={\n",
" # `threshold` arguments are optional\n",
" \"a\": ObjectiveProperties(minimize=False, threshold=branin_currin.ref_point[0]),\n",
" \"b\": ObjectiveProperties(minimize=False, threshold=branin_currin.ref_point[1]),\n",
" },\n",
" overwrite_existing_experiment=True,\n",
" is_test=True,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "f01cf5e4",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "70fd45e1-a2ce-4034-bb44-086507833472",
"papermill": {
"duration": 0.041811,
"end_time": "2023-12-09T18:51:08.847886",
"exception": false,
"start_time": "2023-12-09T18:51:08.806075",
"status": "completed"
},
"showInput": true,
"tags": []
},
"source": [
"### Create an Evaluation Function\n",
"In the case of MOO experiments, evaluation functions can be any arbitrary function that takes in a `dict` of parameter names mapped to values and returns a `dict` of objective names mapped to a `tuple` of mean and SEM values."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "4519a80d",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2023-12-09T18:51:08.932752Z",
"iopub.status.busy": "2023-12-09T18:51:08.931995Z",
"iopub.status.idle": "2023-12-09T18:51:08.936707Z",
"shell.execute_reply": "2023-12-09T18:51:08.936025Z"
},
"executionStartTime": 1628191201840,
"executionStopTime": 1628191201871,
"hidden_ranges": [],
"originalKey": "a0e4fa8d-ebc7-4dc6-b370-ed4a83e3208f",
"papermill": {
"duration": 0.048836,
"end_time": "2023-12-09T18:51:08.938301",
"exception": false,
"start_time": "2023-12-09T18:51:08.889465",
"status": "completed"
},
"requestMsgId": "9cfd336d-c317-4d1c-a028-42d45903bac6",
"showInput": true,
"tags": []
},
"outputs": [],
"source": [
"def evaluate(parameters):\n",
" evaluation = branin_currin(\n",
" torch.tensor([parameters.get(\"x1\"), parameters.get(\"x2\")])\n",
" )\n",
" # In our case, standard error is 0, since we are computing a synthetic function.\n",
" # Set standard error to None if the noise level is unknown.\n",
" return {\"a\": (evaluation[0].item(), 0.0), \"b\": (evaluation[1].item(), 0.0)}"
]
},
{
"cell_type": "markdown",
"id": "84906de2",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "4200cd7c-8e13-4cbf-b0c1-72b52d900aaf",
"papermill": {
"duration": 0.041713,
"end_time": "2023-12-09T18:51:09.022106",
"exception": false,
"start_time": "2023-12-09T18:51:08.980393",
"status": "completed"
},
"showInput": true,
"tags": []
},
"source": [
"### Run Optimization"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f6bf5aea",
"metadata": {
"customInput": null,
"execution": {
"iopub.execute_input": "2023-12-09T18:51:09.106590Z",
"iopub.status.busy": "2023-12-09T18:51:09.106258Z",
"iopub.status.idle": "2023-12-09T18:51:49.684216Z",
"shell.execute_reply": "2023-12-09T18:51:49.683660Z"
},
"executionStartTime": 1628191208271,
"executionStopTime": 1628191238749,
"originalKey": "f91b1a1e-c78a-4262-a211-a13115c007c1",
"papermill": {
"duration": 40.621895,
"end_time": "2023-12-09T18:51:49.685722",
"exception": false,
"start_time": "2023-12-09T18:51:09.063827",
"status": "completed"
},
"requestMsgId": "842a1cf8-97a3-43d6-83a3-f258ea96ae20",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Generated new trial 0 with parameters {'x1': 0.801417, 'x2': 0.797481}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Completed trial 0 with data: {'a': (-133.060547, 0.0), 'b': (-4.872849, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Generated new trial 1 with parameters {'x1': 0.154775, 'x2': 0.011071}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Completed trial 1 with data: {'a': (-122.925415, 0.0), 'b': (-13.280719, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Generated new trial 2 with parameters {'x1': 0.876942, 'x2': 0.650503}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Completed trial 2 with data: {'a': (-73.514954, 0.0), 'b': (-5.535253, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Generated new trial 3 with parameters {'x1': 0.597052, 'x2': 0.246692}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Completed trial 3 with data: {'a': (-7.307969, 0.0), 'b': (-9.687119, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Generated new trial 4 with parameters {'x1': 0.229407, 'x2': 0.792881}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:09] ax.service.ax_client: Completed trial 4 with data: {'a': (-19.713375, 0.0), 'b': (-6.44725, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:10] ax.service.ax_client: Generated new trial 5 with parameters {'x1': 0.34495, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:10] ax.service.ax_client: Completed trial 5 with data: {'a': (-105.452911, 0.0), 'b': (-5.103004, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:10] ax.service.ax_client: Generated new trial 6 with parameters {'x1': 0.0, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:10] ax.service.ax_client: Completed trial 6 with data: {'a': (-17.508297, 0.0), 'b': (-1.180408, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:11] ax.service.ax_client: Generated new trial 7 with parameters {'x1': 0.0, 'x2': 0.864791}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:11] ax.service.ax_client: Completed trial 7 with data: {'a': (-30.494167, 0.0), 'b': (-1.317236, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/linear_operator/utils/cholesky.py:40: NumericalWarning:\n",
"\n",
"A not p.d., added jitter of 1.0e-08 to the diagonal\n",
"\n",
"[INFO 12-09 18:51:12] ax.service.ax_client: Generated new trial 8 with parameters {'x1': 0.07822, 'x2': 0.961001}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:12] ax.service.ax_client: Completed trial 8 with data: {'a': (-2.752013, 0.0), 'b': (-4.093976, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:13] ax.service.ax_client: Generated new trial 9 with parameters {'x1': 1.0, 'x2': 0.06001}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:13] ax.service.ax_client: Completed trial 9 with data: {'a': (-6.364954, 0.0), 'b': (-10.177037, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:14] ax.service.ax_client: Generated new trial 10 with parameters {'x1': 0.036585, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:14] ax.service.ax_client: Completed trial 10 with data: {'a': (-7.935418, 0.0), 'b': (-2.630452, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:15] ax.service.ax_client: Generated new trial 11 with parameters {'x1': 0.089964, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:15] ax.service.ax_client: Completed trial 11 with data: {'a': (-3.771129, 0.0), 'b': (-4.263604, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:17] ax.service.ax_client: Generated new trial 12 with parameters {'x1': 0.017242, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:17] ax.service.ax_client: Completed trial 12 with data: {'a': (-12.381491, 0.0), 'b': (-1.880871, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:18] ax.service.ax_client: Generated new trial 13 with parameters {'x1': 0.054947, 'x2': 0.990203}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:18] ax.service.ax_client: Completed trial 13 with data: {'a': (-5.093365, 0.0), 'b': (-3.301131, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:20] ax.service.ax_client: Generated new trial 14 with parameters {'x1': 0.102521, 'x2': 0.913251}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:20] ax.service.ax_client: Completed trial 14 with data: {'a': (-1.29677, 0.0), 'b': (-4.857124, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:22] ax.service.ax_client: Generated new trial 15 with parameters {'x1': 0.065976, 'x2': 0.981466}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:22] ax.service.ax_client: Completed trial 15 with data: {'a': (-3.867712, 0.0), 'b': (-3.676576, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:24] ax.service.ax_client: Generated new trial 16 with parameters {'x1': 0.008402, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:24] ax.service.ax_client: Completed trial 16 with data: {'a': (-14.87924, 0.0), 'b': (-1.523604, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:27] ax.service.ax_client: Generated new trial 17 with parameters {'x1': 0.026451, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:27] ax.service.ax_client: Completed trial 17 with data: {'a': (-10.08528, 0.0), 'b': (-2.244707, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:30] ax.service.ax_client: Generated new trial 18 with parameters {'x1': 1.0, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:30] ax.service.ax_client: Completed trial 18 with data: {'a': (-145.872208, 0.0), 'b': (-4.005316, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:32] ax.service.ax_client: Generated new trial 19 with parameters {'x1': 0.045424, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:32] ax.service.ax_client: Completed trial 19 with data: {'a': (-6.396092, 0.0), 'b': (-2.950867, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:35] ax.service.ax_client: Generated new trial 20 with parameters {'x1': 0.088948, 'x2': 0.937745}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:35] ax.service.ax_client: Completed trial 20 with data: {'a': (-1.933097, 0.0), 'b': (-4.453242, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:39] ax.service.ax_client: Generated new trial 21 with parameters {'x1': 0.021752, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:39] ax.service.ax_client: Completed trial 21 with data: {'a': (-11.217245, 0.0), 'b': (-2.060355, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:42] ax.service.ax_client: Generated new trial 22 with parameters {'x1': 0.004155, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:42] ax.service.ax_client: Completed trial 22 with data: {'a': (-16.177761, 0.0), 'b': (-1.350344, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:45] ax.service.ax_client: Generated new trial 23 with parameters {'x1': 0.012752, 'x2': 1.0}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:45] ax.service.ax_client: Completed trial 23 with data: {'a': (-13.614934, 0.0), 'b': (-1.700151, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:49] ax.service.ax_client: Generated new trial 24 with parameters {'x1': 0.110926, 'x2': 0.861505}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 12-09 18:51:49] ax.service.ax_client: Completed trial 24 with data: {'a': (-0.609675, 0.0), 'b': (-5.247289, 0.0)}.\n"
]
}
],
"source": [
"for i in range(25):\n",
" parameters, trial_index = ax_client.get_next_trial()\n",
" # Local evaluation here can be replaced with deployment to external system.\n",
" ax_client.complete_trial(trial_index=trial_index, raw_data=evaluate(parameters))"
]
},
{
"cell_type": "markdown",
"id": "20da2027",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "e0a6feb4-8c38-42e4-9d7c-62b79307e043",
"papermill": {
"duration": 0.043411,
"end_time": "2023-12-09T18:51:49.772848",
"exception": false,
"start_time": "2023-12-09T18:51:49.729437",
"status": "completed"
},
"showInput": false,
"tags": []
},
"source": [
"### Plot Pareto Frontier"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "2380bf26",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2023-12-09T18:51:49.861439Z",
"iopub.status.busy": "2023-12-09T18:51:49.860957Z",
"iopub.status.idle": "2023-12-09T18:52:05.404391Z",
"shell.execute_reply": "2023-12-09T18:52:05.403731Z"
},
"executionStartTime": 1628191262231,
"executionStopTime": 1628191270720,
"hidden_ranges": [],
"originalKey": "c2c2b222-6b68-4f1a-839f-16b50019ada4",
"papermill": {
"duration": 15.58986,
"end_time": "2023-12-09T18:52:05.405978",
"exception": false,
"start_time": "2023-12-09T18:51:49.816118",
"status": "completed"
},
"requestMsgId": "563d345b-573c-4d93-a480-5db88a283250",
"showInput": true,
"tags": []
},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"linkText": "Export to plot.ly",
"plotlyServerURL": "https://plot.ly",
"showLink": false
},
"data": [
{
"error_x": {
"array": [
0.06297396855219958,
0.03958793716152724,
0.03890050215495271,
0.038877146880657854,
0.06297396851278254,
0.038597742445661054,
0.06297396855219958,
0.07036751688414815,
0.05365043391773155,
0.04126886584368919,
0.06297396867045069,
0.03890654469872722,
0.03866364354135287,
0.05235169101236722,
0.0871171601703099,
0.0679198349799958,
0.06620307217141069,
0.038788773924436075,
0.06989735878840327,
0.06758753711387497
],
"color": "rgba(128,177,211,0.4)",
"thickness": 2,
"type": "data"
},
"error_y": {
"array": [
0.004164322798281564,
0.0026182755061727662,
0.0025785663098738688,
0.0025779968447792977,
0.004164322812534608,
0.002558478899275519,
0.004164322811238877,
0.004192697965714826,
0.0034180177392134858,
0.0027259381780909983,
0.004164322812534608,
0.0025793728149100335,
0.0025639450303741383,
0.003362899598900884,
0.005114693751703573,
0.004188466708426285,
0.004017503022398529,
0.0025724709742302445,
0.004163498399637007,
0.004168949898886228
],
"color": "rgba(128,177,211,0.4)",
"thickness": 2,
"type": "data"
},
"hoverinfo": "text",
"legendgroup": "mean",
"marker": {
"color": "rgba(128,177,211,1)"
},
"mode": "markers",
"name": "mean",
"text": [
"Parameterization 0
b: -1.18 [-1.184, -1.176]
a: -17.504 [-17.567, -17.441]
Parameterization:
x1: 0.0
x2: 0.9999999999999994",
"Parameterization 1
b: -1.388 [-1.391, -1.386]
a: -15.891 [-15.930, -15.851]
Parameterization:
x1: 0.005081635990761516
x2: 0.9999999999999999",
"Parameterization 2
b: -1.644 [-1.647, -1.642]
a: -14.012 [-14.051, -13.973]
Parameterization:
x1: 0.011367866280524535
x2: 1.0",
"Parameterization 3
b: -1.595 [-1.598, -1.593]
a: -14.361 [-14.400, -14.323]
Parameterization:
x1: 0.010164393268567367
x2: 1.0",
"Parameterization 4
b: -1.18 [-1.184, -1.176]
a: -17.504 [-17.567, -17.441]
Parameterization:
x1: 3.832931492409189e-16
x2: 0.9999999999999994",
"Parameterization 5
b: -1.478 [-1.481, -1.476]
a: -15.217 [-15.255, -15.178]
Parameterization:
x1: 0.007285942229208715
x2: 1.0",
"Parameterization 6
b: -1.18 [-1.184, -1.176]
a: -17.504 [-17.567, -17.441]
Parameterization:
x1: 1.2878587085651816e-14
x2: 0.9999999999999998",
"Parameterization 7
b: -3.02 [-3.024, -3.016]
a: -6.101 [-6.172, -6.031]
Parameterization:
x1: 0.04737101096858027
x2: 1.0",
"Parameterization 8
b: -2.861 [-2.865, -2.858]
a: -6.803 [-6.857, -6.749]
Parameterization:
x1: 0.04289813660098198
x2: 1.0",
"Parameterization 9
b: -1.346 [-1.349, -1.343]
a: -16.214 [-16.255, -16.173]
Parameterization:
x1: 0.004042876641871355
x2: 1.0",
"Parameterization 10
b: -1.18 [-1.184, -1.176]
a: -17.504 [-17.567, -17.441]
Parameterization:
x1: 2.6032107121032415e-16
x2: 0.9999999999999999",
"Parameterization 11
b: -1.627 [-1.629, -1.624]
a: -14.138 [-14.177, -14.099]
Parameterization:
x1: 0.010931358447502775
x2: 1.0",
"Parameterization 12
b: -1.519 [-1.522, -1.517]
a: -14.914 [-14.953, -14.876]
Parameterization:
x1: 0.00829287488060538
x2: 1.0",
"Parameterization 13
b: -2.838 [-2.841, -2.834]
a: -6.913 [-6.965, -6.861]
Parameterization:
x1: 0.04224198525203626
x2: 1.0",
"Parameterization 14
b: -3.275 [-3.280, -3.269]
a: -5.13 [-5.218, -5.043]
Parameterization:
x1: 0.0546650317994858
x2: 0.9972660346596165",
"Parameterization 15
b: -3.424 [-3.428, -3.420]
a: -4.639 [-4.706, -4.571]
Parameterization:
x1: 0.05882332701248539
x2: 0.9918461916888434",
"Parameterization 16
b: -3.921 [-3.925, -3.917]
a: -3.186 [-3.252, -3.120]
Parameterization:
x1: 0.07292547285573221
x2: 0.9685638108599804",
"Parameterization 17
b: -1.559 [-1.562, -1.557]
a: -14.623 [-14.662, -14.584]
Parameterization:
x1: 0.009274108731099788
x2: 1.0",
"Parameterization 18
b: -4.1 [-4.104, -4.095]
a: -2.724 [-2.793, -2.654]
Parameterization:
x1: 0.07803869493537835
x2: 0.9576271220922514",
"Parameterization 19
b: -3.411 [-3.415, -3.407]
a: -4.681 [-4.748, -4.613]
Parameterization:
x1: 0.05844813827018583
x2: 0.9921279453357086"
],
"type": "scatter",
"x": [
-17.504325693273756,
-15.890784976942328,
-14.01229887193282,
-14.36144392780447,
-17.504325693272463,
-15.216826187862248,
-17.50432569325698,
-6.101333226823705,
-6.803070706834426,
-16.213927027218226,
-17.50432569326471,
-14.138350419979638,
-14.914377953755487,
-6.913011429706376,
-5.130475184655168,
-4.6385750844404186,
-3.1861480715901003,
-14.622971760493158,
-2.723597060112283,
-4.680681753881501
],
"y": [
-1.1801498423753425,
-1.3883651636239658,
-1.6442765164134259,
-1.595467707998445,
-1.1801498423759398,
-1.4783549335868202,
-1.1801498423764425,
-3.0197804643065522,
-2.8612906510312497,
-1.345880460415291,
-1.180149842375386,
-1.6265847416734274,
-1.5193785877938835,
-2.837672979231241,
-3.2745801203915748,
-3.4240765463637217,
-3.9210113605169106,
-1.5592989735831044,
-4.099663132460015,
-3.4112283437513136
]
}
],
"layout": {
"height": 500,
"hovermode": "closest",
"legend": {
"orientation": "h"
},
"margin": {
"b": 75,
"l": 225,
"pad": 4,
"t": 75
},
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
],
"sequentialminus": [
[
0.0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1.0,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"title": {
"text": "Pareto Frontier"
},
"width": 750,
"xaxis": {
"ticksuffix": "",
"title": {
"text": "a"
},
"zeroline": true
},
"yaxis": {
"ticksuffix": "",
"title": {
"text": "b"
},
"zeroline": true
}
}
},
"text/html": [
"