{
"cells": [
{
"cell_type": "markdown",
"id": "dd75f122",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "95e7a97a-bf78-48d4-a0c1-c0e8dfc4fed9",
"papermill": {
"duration": 0.009285,
"end_time": "2024-04-27T05:34:58.091408",
"exception": false,
"start_time": "2024-04-27T05:34:58.082123",
"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": "2f14521e",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-04-27T05:34:58.110074Z",
"iopub.status.busy": "2024-04-27T05:34:58.109733Z",
"iopub.status.idle": "2024-04-27T05:35:01.528967Z",
"shell.execute_reply": "2024-04-27T05:35:01.527926Z"
},
"hidden_ranges": [],
"originalKey": "06bf2029-0ea4-40b4-aced-956f1411cb6e",
"papermill": {
"duration": 3.443005,
"end_time": "2024-04-27T05:35:01.543174",
"exception": false,
"start_time": "2024-04-27T05:34:58.100169",
"status": "completed"
},
"showInput": true,
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] ax.utils.notebook.plotting: Injecting Plotly library into cell. Do not overwrite or delete cell.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] 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": "77987d78",
"metadata": {
"execution": {
"iopub.execute_input": "2024-04-27T05:35:01.624618Z",
"iopub.status.busy": "2024-04-27T05:35:01.624148Z",
"iopub.status.idle": "2024-04-27T05:35:01.628489Z",
"shell.execute_reply": "2024-04-27T05:35:01.627972Z"
},
"papermill": {
"duration": 0.047095,
"end_time": "2024-04-27T05:35:01.629821",
"exception": false,
"start_time": "2024-04-27T05:35:01.582726",
"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": "2674add4",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-04-27T05:35:01.711673Z",
"iopub.status.busy": "2024-04-27T05:35:01.711193Z",
"iopub.status.idle": "2024-04-27T05:35:01.724146Z",
"shell.execute_reply": "2024-04-27T05:35:01.723493Z"
},
"executionStartTime": 1628191188673,
"executionStopTime": 1628191188746,
"hidden_ranges": [],
"originalKey": "c687973d-1b09-4a8f-9108-1f74adf64d4d",
"papermill": {
"duration": 0.055554,
"end_time": "2024-04-27T05:35:01.725448",
"exception": false,
"start_time": "2024-04-27T05:35:01.669894",
"status": "completed"
},
"requestMsgId": "ea523260-8896-48e4-a62f-3530d268b209",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] 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 04-27 05:35:01] 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 04-27 05:35:01] 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 04-27 05:35:01] 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 04-27 05:35:01] 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 04-27 05:35:01] ax.modelbridge.dispatch_utils: Using Models.BOTORCH_MODULAR since there is at least one ordered parameter and there are no unordered categorical parameters.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] 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 04-27 05:35:01] ax.modelbridge.dispatch_utils: calculated num_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] ax.modelbridge.dispatch_utils: num_completed_initialization_trials=0 num_remaining_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:01] 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 04-27 05:35:01] 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": "b7a69f73",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "70fd45e1-a2ce-4034-bb44-086507833472",
"papermill": {
"duration": 0.040682,
"end_time": "2024-04-27T05:35:01.807110",
"exception": false,
"start_time": "2024-04-27T05:35:01.766428",
"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": "17e2bfa0",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-04-27T05:35:01.890052Z",
"iopub.status.busy": "2024-04-27T05:35:01.889782Z",
"iopub.status.idle": "2024-04-27T05:35:01.893820Z",
"shell.execute_reply": "2024-04-27T05:35:01.893199Z"
},
"executionStartTime": 1628191201840,
"executionStopTime": 1628191201871,
"hidden_ranges": [],
"originalKey": "a0e4fa8d-ebc7-4dc6-b370-ed4a83e3208f",
"papermill": {
"duration": 0.047319,
"end_time": "2024-04-27T05:35:01.895166",
"exception": false,
"start_time": "2024-04-27T05:35:01.847847",
"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": "747eb4bc",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "4200cd7c-8e13-4cbf-b0c1-72b52d900aaf",
"papermill": {
"duration": 0.041023,
"end_time": "2024-04-27T05:35:01.977094",
"exception": false,
"start_time": "2024-04-27T05:35:01.936071",
"status": "completed"
},
"showInput": true,
"tags": []
},
"source": [
"### Run Optimization"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "7ee33d51",
"metadata": {
"customInput": null,
"execution": {
"iopub.execute_input": "2024-04-27T05:35:02.060579Z",
"iopub.status.busy": "2024-04-27T05:35:02.060074Z",
"iopub.status.idle": "2024-04-27T05:35:44.069143Z",
"shell.execute_reply": "2024-04-27T05:35:44.068471Z"
},
"executionStartTime": 1628191208271,
"executionStopTime": 1628191238749,
"originalKey": "f91b1a1e-c78a-4262-a211-a13115c007c1",
"papermill": {
"duration": 42.052519,
"end_time": "2024-04-27T05:35:44.070478",
"exception": false,
"start_time": "2024-04-27T05:35:02.017959",
"status": "completed"
},
"requestMsgId": "842a1cf8-97a3-43d6-83a3-f258ea96ae20",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 0 with parameters {'x1': 0.055765, 'x2': 0.256874} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 0 with data: {'a': (-126.27124, 0.0), 'b': (-7.196263, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 1 with parameters {'x1': 0.166228, 'x2': 0.13164} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 1 with data: {'a': (-80.174973, 0.0), 'b': (-13.172913, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 2 with parameters {'x1': 0.682078, 'x2': 0.963139} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 2 with data: {'a': (-189.994812, 0.0), 'b': (-4.374009, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 3 with parameters {'x1': 0.028653, 'x2': 0.059581} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 3 with data: {'a': (-235.993362, 0.0), 'b': (-5.920244, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 4 with parameters {'x1': 0.305908, 'x2': 0.022225} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 4 with data: {'a': (-59.037498, 0.0), 'b': (-13.313398, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Generated new trial 5 with parameters {'x1': 0.675325, 'x2': 0.24245} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:02] ax.service.ax_client: Completed trial 5 with data: {'a': (-19.66116, 0.0), 'b': (-9.448742, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:03] ax.service.ax_client: Generated new trial 6 with parameters {'x1': 1.0, 'x2': 0.183519} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:03] ax.service.ax_client: Completed trial 6 with data: {'a': (-2.005727, 0.0), 'b': (-9.511936, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:04] ax.service.ax_client: Generated new trial 7 with parameters {'x1': 0.0, 'x2': 0.853429} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:04] ax.service.ax_client: Completed trial 7 with data: {'a': (-31.960102, 0.0), 'b': (-1.330139, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:05] ax.service.ax_client: Generated new trial 8 with parameters {'x1': 0.0, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:05] ax.service.ax_client: Completed trial 8 with data: {'a': (-17.508297, 0.0), 'b': (-1.180408, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:06] ax.service.ax_client: Generated new trial 9 with parameters {'x1': 0.084573, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:06] ax.service.ax_client: Completed trial 9 with data: {'a': (-3.614368, 0.0), 'b': (-4.134211, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:08] ax.service.ax_client: Generated new trial 10 with parameters {'x1': 0.042022, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:08] ax.service.ax_client: Completed trial 10 with data: {'a': (-6.950634, 0.0), 'b': (-2.829522, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:09] ax.service.ax_client: Generated new trial 11 with parameters {'x1': 0.438534, 'x2': 0.613968} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:09] ax.service.ax_client: Completed trial 11 with data: {'a': (-39.083366, 0.0), 'b': (-6.776071, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:10] ax.service.ax_client: Generated new trial 12 with parameters {'x1': 0.083608, 'x2': 0.908278} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:10] ax.service.ax_client: Completed trial 12 with data: {'a': (-2.120916, 0.0), 'b': (-4.42214, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:12] ax.service.ax_client: Generated new trial 13 with parameters {'x1': 0.019316, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:12] ax.service.ax_client: Completed trial 13 with data: {'a': (-11.836764, 0.0), 'b': (-1.963683, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:15] ax.service.ax_client: Generated new trial 14 with parameters {'x1': 0.009383, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:15] ax.service.ax_client: Completed trial 14 with data: {'a': (-14.58805, 0.0), 'b': (-1.563544, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:17] ax.service.ax_client: Generated new trial 15 with parameters {'x1': 1.0, 'x2': 0.790897} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:17] ax.service.ax_client: Completed trial 15 with data: {'a': (-80.451439, 0.0), 'b': (-4.769857, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:20] ax.service.ax_client: Generated new trial 16 with parameters {'x1': 0.106768, 'x2': 0.90042} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:20] ax.service.ax_client: Completed trial 16 with data: {'a': (-1.079498, 0.0), 'b': (-4.996861, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:21] ax.service.ax_client: Generated new trial 17 with parameters {'x1': 0.058698, 'x2': 0.975858} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:21] ax.service.ax_client: Completed trial 17 with data: {'a': (-4.647222, 0.0), 'b': (-3.462553, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:24] ax.service.ax_client: Generated new trial 18 with parameters {'x1': 0.050534, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:24] ax.service.ax_client: Completed trial 18 with data: {'a': (-5.653658, 0.0), 'b': (-3.128189, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:27] ax.service.ax_client: Generated new trial 19 with parameters {'x1': 0.113774, 'x2': 0.838056} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:27] ax.service.ax_client: Completed trial 19 with data: {'a': (-0.513465, 0.0), 'b': (-5.410245, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:30] ax.service.ax_client: Generated new trial 20 with parameters {'x1': 0.071933, 'x2': 0.964664} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:30] ax.service.ax_client: Completed trial 20 with data: {'a': (-3.229003, 0.0), 'b': (-3.904418, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:33] ax.service.ax_client: Generated new trial 21 with parameters {'x1': 0.029989, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:33] ax.service.ax_client: Completed trial 21 with data: {'a': (-9.288929, 0.0), 'b': (-2.381368, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:37] ax.service.ax_client: Generated new trial 22 with parameters {'x1': 0.004631, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:37] ax.service.ax_client: Completed trial 22 with data: {'a': (-16.029118, 0.0), 'b': (-1.369791, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:39] ax.service.ax_client: Generated new trial 23 with parameters {'x1': 0.866478, 'x2': 0.438045} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:39] ax.service.ax_client: Completed trial 23 with data: {'a': (-33.997074, 0.0), 'b': (-7.035689, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:44] ax.service.ax_client: Generated new trial 24 with parameters {'x1': 0.065481, 'x2': 0.981885} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 04-27 05:35:44] ax.service.ax_client: Completed trial 24 with data: {'a': (-3.915551, 0.0), 'b': (-3.66026, 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": "61ebdcb5",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "e0a6feb4-8c38-42e4-9d7c-62b79307e043",
"papermill": {
"duration": 0.043114,
"end_time": "2024-04-27T05:35:44.156442",
"exception": false,
"start_time": "2024-04-27T05:35:44.113328",
"status": "completed"
},
"showInput": false,
"tags": []
},
"source": [
"### Plot Pareto Frontier"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "13e31820",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-04-27T05:35:44.244423Z",
"iopub.status.busy": "2024-04-27T05:35:44.243937Z",
"iopub.status.idle": "2024-04-27T05:36:00.771149Z",
"shell.execute_reply": "2024-04-27T05:36:00.770404Z"
},
"executionStartTime": 1628191262231,
"executionStopTime": 1628191270720,
"hidden_ranges": [],
"originalKey": "c2c2b222-6b68-4f1a-839f-16b50019ada4",
"papermill": {
"duration": 16.572761,
"end_time": "2024-04-27T05:36:00.772573",
"exception": false,
"start_time": "2024-04-27T05:35:44.199812",
"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.08530279141027526,
0.08530279156767215,
0.06781723526444179,
0.06497218494136026,
0.06730661302368701,
0.08530279156767215,
0.08530279156767215,
0.08530279156767215,
0.08530279156767215,
0.10120963760704393,
0.08530279151520652,
0.060315498399181974,
0.06711795586840683,
0.15583293437247098,
0.06223490812602069,
0.06825499416747409,
0.0792002837511173,
0.09533094617158781,
0.07843129667360547,
0.13337124935068093
],
"color": "rgba(128,177,211,0.4)",
"thickness": 2,
"type": "data"
},
"error_y": {
"array": [
0.004945960164030319,
0.004945960158499405,
0.004044095656587449,
0.003949783009900033,
0.0040334873031796295,
0.004945960158499405,
0.004945960158499405,
0.004945960158499405,
0.004945960158499405,
0.006165068894824083,
0.004945960151585761,
0.0037006606065956805,
0.004028612548448629,
0.008450543468826649,
0.003814544276652447,
0.003942633942675001,
0.0045394734613497315,
0.005214444624488942,
0.004784046807301588,
0.008846103352728977
],
"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
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 4.999793113309771e-16
x2: 1.0",
"Parameterization 1
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 2
a: -12.296 [-12.364, -12.228]
b: -1.894 [-1.898, -1.890]
Parameterization:
x1: 0.01756485641853163
x2: 1.0",
"Parameterization 3
a: -13.73 [-13.795, -13.665]
b: -1.684 [-1.688, -1.680]
Parameterization:
x1: 0.012349050431344398
x2: 1.0",
"Parameterization 4
a: -12.806 [-12.873, -12.739]
b: -1.818 [-1.822, -1.814]
Parameterization:
x1: 0.015668780136773253
x2: 1.0",
"Parameterization 5
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 6
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 7
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 8
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 9
a: -4.972 [-5.074, -4.871]
b: -3.316 [-3.322, -3.310]
Parameterization:
x1: 0.05613737611462468
x2: 0.9996263561409995",
"Parameterization 10
a: -17.507 [-17.592, -17.422]
b: -1.18 [-1.185, -1.175]
Parameterization:
x1: 7.067807657137224e-17
x2: 1.0",
"Parameterization 11
a: -14.733 [-14.794, -14.673]
b: -1.544 [-1.548, -1.540]
Parameterization:
x1: 0.008896697032771891
x2: 1.0",
"Parameterization 12
a: -12.926 [-12.993, -12.859]
b: -1.8 [-1.804, -1.796]
Parameterization:
x1: 0.015230681402191113
x2: 1.0",
"Parameterization 13
a: -2.07 [-2.226, -1.914]
b: -4.364 [-4.373, -4.356]
Parameterization:
x1: 0.08421123719902578
x2: 0.9292488641363822",
"Parameterization 14
a: -14.356 [-14.418, -14.294]
b: -1.596 [-1.600, -1.592]
Parameterization:
x1: 0.010178392515503424
x2: 1.0",
"Parameterization 15
a: -6.28 [-6.348, -6.212]
b: -2.978 [-2.982, -2.974]
Parameterization:
x1: 0.04618174047531666
x2: 1.0",
"Parameterization 16
a: -5.65 [-5.729, -5.570]
b: -3.13 [-3.135, -3.126]
Parameterization:
x1: 0.050588934683776524
x2: 1.0",
"Parameterization 17
a: -3.1 [-3.195, -3.005]
b: -3.951 [-3.957, -3.946]
Parameterization:
x1: 0.0733064213378454
x2: 0.9625918550604144",
"Parameterization 18
a: -4.36 [-4.438, -4.282]
b: -3.513 [-3.518, -3.508]
Parameterization:
x1: 0.06142823121992645
x2: 0.9894857056154385",
"Parameterization 19
a: -1.036 [-1.169, -0.902]
b: -4.937 [-4.946, -4.928]
Parameterization:
x1: 0.10268243101270431
x2: 0.8942284240298328"
],
"type": "scatter",
"x": [
-17.507085973298803,
-17.507085973305742,
-12.295982856909813,
-13.730373382046295,
-12.80600217567532,
-17.507085973305742,
-17.507085973305742,
-17.507085973305742,
-17.507085973305742,
-4.972308736068719,
-17.507085973305742,
-14.733346849823615,
-12.925710238649764,
-2.0701569281715138,
-14.35608836183226,
-6.2799962279368415,
-5.649642333105575,
-3.0998968607142956,
-4.360066836951717,
-1.0355691012618635
],
"y": [
-1.1802978560278699,
-1.1802978560271264,
-1.893766830772329,
-1.6839010298546473,
-1.8177518592462159,
-1.1802978560271264,
-1.1802978560271264,
-1.1802978560271264,
-1.1802978560271264,
-3.316141896368313,
-1.180297856027558,
-1.543848989909499,
-1.8001407078573157,
-4.364411915835551,
-1.5959325232945085,
-2.9776265126385493,
-3.1300855740498648,
-3.9513115176039415,
-3.512869085866935,
-4.936836384285896
]
}
],
"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": [
"