{
"cells": [
{
"cell_type": "markdown",
"id": "441c7d7b",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "95e7a97a-bf78-48d4-a0c1-c0e8dfc4fed9",
"papermill": {
"duration": 0.010323,
"end_time": "2024-03-01T16:53:50.196380",
"exception": false,
"start_time": "2024-03-01T16:53:50.186057",
"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": "6187ee09",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-03-01T16:53:50.216301Z",
"iopub.status.busy": "2024-03-01T16:53:50.215824Z",
"iopub.status.idle": "2024-03-01T16:53:53.569064Z",
"shell.execute_reply": "2024-03-01T16:53:53.568291Z"
},
"hidden_ranges": [],
"originalKey": "06bf2029-0ea4-40b4-aced-956f1411cb6e",
"papermill": {
"duration": 3.37934,
"end_time": "2024-03-01T16:53:53.584902",
"exception": false,
"start_time": "2024-03-01T16:53:50.205562",
"status": "completed"
},
"showInput": true,
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:53] ax.utils.notebook.plotting: Injecting Plotly library into cell. Do not overwrite or delete cell.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:53] 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": "72db42d0",
"metadata": {
"execution": {
"iopub.execute_input": "2024-03-01T16:53:53.669876Z",
"iopub.status.busy": "2024-03-01T16:53:53.669544Z",
"iopub.status.idle": "2024-03-01T16:53:53.674534Z",
"shell.execute_reply": "2024-03-01T16:53:53.673980Z"
},
"papermill": {
"duration": 0.049568,
"end_time": "2024-03-01T16:53:53.675941",
"exception": false,
"start_time": "2024-03-01T16:53:53.626373",
"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": "62a05e07",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-03-01T16:53:53.760448Z",
"iopub.status.busy": "2024-03-01T16:53:53.760148Z",
"iopub.status.idle": "2024-03-01T16:53:53.772157Z",
"shell.execute_reply": "2024-03-01T16:53:53.771617Z"
},
"executionStartTime": 1628191188673,
"executionStopTime": 1628191188746,
"hidden_ranges": [],
"originalKey": "c687973d-1b09-4a8f-9108-1f74adf64d4d",
"papermill": {
"duration": 0.056051,
"end_time": "2024-03-01T16:53:53.773505",
"exception": false,
"start_time": "2024-03-01T16:53:53.717454",
"status": "completed"
},
"requestMsgId": "ea523260-8896-48e4-a62f-3530d268b209",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] 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 03-01 16:53:53] ax.modelbridge.dispatch_utils: calculated num_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:53] ax.modelbridge.dispatch_utils: num_completed_initialization_trials=0 num_remaining_initialization_trials=5\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:53] 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 03-01 16:53:53] 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": "5b3e9f16",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "70fd45e1-a2ce-4034-bb44-086507833472",
"papermill": {
"duration": 0.041773,
"end_time": "2024-03-01T16:53:53.857159",
"exception": false,
"start_time": "2024-03-01T16:53:53.815386",
"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": "35a8ce50",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-03-01T16:53:53.944629Z",
"iopub.status.busy": "2024-03-01T16:53:53.943945Z",
"iopub.status.idle": "2024-03-01T16:53:53.948725Z",
"shell.execute_reply": "2024-03-01T16:53:53.947951Z"
},
"executionStartTime": 1628191201840,
"executionStopTime": 1628191201871,
"hidden_ranges": [],
"originalKey": "a0e4fa8d-ebc7-4dc6-b370-ed4a83e3208f",
"papermill": {
"duration": 0.050952,
"end_time": "2024-03-01T16:53:53.950186",
"exception": false,
"start_time": "2024-03-01T16:53:53.899234",
"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": "8916c5ac",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "4200cd7c-8e13-4cbf-b0c1-72b52d900aaf",
"papermill": {
"duration": 0.043839,
"end_time": "2024-03-01T16:53:54.039742",
"exception": false,
"start_time": "2024-03-01T16:53:53.995903",
"status": "completed"
},
"showInput": true,
"tags": []
},
"source": [
"### Run Optimization"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c0fdb51a",
"metadata": {
"customInput": null,
"execution": {
"iopub.execute_input": "2024-03-01T16:53:54.127944Z",
"iopub.status.busy": "2024-03-01T16:53:54.127397Z",
"iopub.status.idle": "2024-03-01T16:54:34.160111Z",
"shell.execute_reply": "2024-03-01T16:54:34.159446Z"
},
"executionStartTime": 1628191208271,
"executionStopTime": 1628191238749,
"originalKey": "f91b1a1e-c78a-4262-a211-a13115c007c1",
"papermill": {
"duration": 40.078358,
"end_time": "2024-03-01T16:54:34.161594",
"exception": false,
"start_time": "2024-03-01T16:53:54.083236",
"status": "completed"
},
"requestMsgId": "842a1cf8-97a3-43d6-83a3-f258ea96ae20",
"showInput": true,
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Generated new trial 0 with parameters {'x1': 0.48288, 'x2': 0.275986} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Completed trial 0 with data: {'a': (-5.142522, 0.0), 'b': (-9.898978, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Generated new trial 1 with parameters {'x1': 0.134802, 'x2': 0.268957} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Completed trial 1 with data: {'a': (-62.162186, 0.0), 'b': (-10.800673, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Generated new trial 2 with parameters {'x1': 0.370686, 'x2': 0.8452} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Completed trial 2 with data: {'a': (-74.82235, 0.0), 'b': (-5.688198, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Generated new trial 3 with parameters {'x1': 0.969948, 'x2': 0.520872} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Completed trial 3 with data: {'a': (-27.836662, 0.0), 'b': (-6.297413, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Generated new trial 4 with parameters {'x1': 0.125801, 'x2': 0.859272} using model Sobol.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:54] ax.service.ax_client: Completed trial 4 with data: {'a': (-0.867915, 0.0), 'b': (-5.516521, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:55] ax.service.ax_client: Generated new trial 5 with parameters {'x1': 0.039816, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:55] ax.service.ax_client: Completed trial 5 with data: {'a': (-7.335642, 0.0), 'b': (-2.7495, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:55] ax.service.ax_client: Generated new trial 6 with parameters {'x1': 0.0, 'x2': 0.934472} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:55] ax.service.ax_client: Completed trial 6 with data: {'a': (-22.774462, 0.0), 'b': (-1.243101, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:56] ax.service.ax_client: Generated new trial 7 with parameters {'x1': 0.080412, 'x2': 0.976766} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:56] ax.service.ax_client: Completed trial 7 with data: {'a': (-2.9375, 0.0), 'b': (-4.10206, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:57] ax.service.ax_client: Generated new trial 8 with parameters {'x1': 0.791625, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:57] ax.service.ax_client: Completed trial 8 with data: {'a': (-209.408173, 0.0), 'b': (-4.124902, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:58] ax.service.ax_client: Generated new trial 9 with parameters {'x1': 1.0, 'x2': 0.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:58] ax.service.ax_client: Completed trial 9 with data: {'a': (-10.960894, 0.0), 'b': (-10.179487, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:59] ax.service.ax_client: Generated new trial 10 with parameters {'x1': 0.0, 'x2': 0.686808} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:53:59] ax.service.ax_client: Completed trial 10 with data: {'a': (-60.130199, 0.0), 'b': (-1.551386, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:01] ax.service.ax_client: Generated new trial 11 with parameters {'x1': 0.014104, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:01] ax.service.ax_client: Completed trial 11 with data: {'a': (-13.235865, 0.0), 'b': (-1.754744, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:03] ax.service.ax_client: Generated new trial 12 with parameters {'x1': 0.737699, 'x2': 0.1505} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:03] ax.service.ax_client: Completed trial 12 with data: {'a': (-20.71714, 0.0), 'b': (-10.239253, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:04] ax.service.ax_client: Generated new trial 13 with parameters {'x1': 0.057301, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:04] ax.service.ax_client: Completed trial 13 with data: {'a': (-4.841271, 0.0), 'b': (-3.353148, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:06] ax.service.ax_client: Generated new trial 14 with parameters {'x1': 0.105055, 'x2': 0.92249} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:06] ax.service.ax_client: Completed trial 14 with data: {'a': (-1.540693, 0.0), 'b': (-4.872642, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:08] ax.service.ax_client: Generated new trial 15 with parameters {'x1': 0.026195, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:08] ax.service.ax_client: Completed trial 15 with data: {'a': (-10.144938, 0.0), 'b': (-2.234716, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:10] ax.service.ax_client: Generated new trial 16 with parameters {'x1': 0.005983, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:10] ax.service.ax_client: Completed trial 16 with data: {'a': (-15.611118, 0.0), 'b': (-1.425004, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:11] ax.service.ax_client: Generated new trial 17 with parameters {'x1': 1.0, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:11] ax.service.ax_client: Completed trial 17 with data: {'a': (-145.872208, 0.0), 'b': (-4.005316, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:14] ax.service.ax_client: Generated new trial 18 with parameters {'x1': 0.047956, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:14] ax.service.ax_client: Completed trial 18 with data: {'a': (-6.014504, 0.0), 'b': (-3.039499, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:17] ax.service.ax_client: Generated new trial 19 with parameters {'x1': 0.068038, 'x2': 0.994146} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:17] ax.service.ax_client: Completed trial 19 with data: {'a': (-3.859597, 0.0), 'b': (-3.702148, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:20] ax.service.ax_client: Generated new trial 20 with parameters {'x1': 0.019997, 'x2': 1.0} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:20] ax.service.ax_client: Completed trial 20 with data: {'a': (-11.661202, 0.0), 'b': (-1.9908, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:23] ax.service.ax_client: Generated new trial 21 with parameters {'x1': 0.126831, 'x2': 0.921181} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:23] ax.service.ax_client: Completed trial 21 with data: {'a': (-3.124254, 0.0), 'b': (-5.252728, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:25] ax.service.ax_client: Generated new trial 22 with parameters {'x1': 0.649606, 'x2': 0.598178} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:25] ax.service.ax_client: Completed trial 22 with data: {'a': (-68.30246, 0.0), 'b': (-6.188535, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:30] ax.service.ax_client: Generated new trial 23 with parameters {'x1': 0.08667, 'x2': 0.926483} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:30] ax.service.ax_client: Completed trial 23 with data: {'a': (-1.913823, 0.0), 'b': (-4.436513, 0.0)}.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:34] ax.service.ax_client: Generated new trial 24 with parameters {'x1': 0.106921, 'x2': 0.877944} using model BoTorch.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[INFO 03-01 16:54:34] ax.service.ax_client: Completed trial 24 with data: {'a': (-0.78245, 0.0), 'b': (-5.094986, 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": "5ba9fd2c",
"metadata": {
"code_folding": [],
"customInput": null,
"hidden_ranges": [],
"originalKey": "e0a6feb4-8c38-42e4-9d7c-62b79307e043",
"papermill": {
"duration": 0.044153,
"end_time": "2024-03-01T16:54:34.250177",
"exception": false,
"start_time": "2024-03-01T16:54:34.206024",
"status": "completed"
},
"showInput": false,
"tags": []
},
"source": [
"### Plot Pareto Frontier"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "e3ca5196",
"metadata": {
"code_folding": [],
"customInput": null,
"execution": {
"iopub.execute_input": "2024-03-01T16:54:34.340754Z",
"iopub.status.busy": "2024-03-01T16:54:34.340119Z",
"iopub.status.idle": "2024-03-01T16:54:47.219484Z",
"shell.execute_reply": "2024-03-01T16:54:47.218735Z"
},
"executionStartTime": 1628191262231,
"executionStopTime": 1628191270720,
"hidden_ranges": [],
"originalKey": "c2c2b222-6b68-4f1a-839f-16b50019ada4",
"papermill": {
"duration": 12.92661,
"end_time": "2024-03-01T16:54:47.220988",
"exception": false,
"start_time": "2024-03-01T16:54:34.294378",
"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.1606896206265993,
0.1606896204947358,
0.053241053959593505,
0.0979160216012601,
0.09457874806001623,
0.1606896204947358,
0.1606896204947358,
0.1606896204947358,
0.0646621317689169,
0.05684940041735298,
0.07669516077734144,
0.09363953511491604,
0.0979413700350636,
0.0514966929491626,
0.049645468093818264,
0.05465753089134514,
0.1606896204947358,
0.08750245770628126,
0.05554128772797905,
0.10197483029352178
],
"color": "rgba(128,177,211,0.4)",
"thickness": 2,
"type": "data"
},
"error_y": {
"array": [
0.010039306754028931,
0.010039306755011053,
0.003122765174879558,
0.005795246563815328,
0.0055767283192943344,
0.010039306755011053,
0.010039306755011053,
0.010039306755011053,
0.0037154871523780893,
0.0033628814820902703,
0.0043811806585703295,
0.00551546764200118,
0.005796911083249481,
0.003021346386528912,
0.0029420278219484787,
0.003202086712622631,
0.010039306755993174,
0.004871193070361635,
0.0032296435202578246,
0.0051257685854219385
],
"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.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 1.6964755048367037e-16
x2: 1.0",
"Parameterization 1
b: -1.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 2
b: -1.613 [-1.616, -1.610]
a: -14.237 [-14.290, -14.184]
Parameterization:
x1: 0.010588551792101178
x2: 1.0",
"Parameterization 3
b: -1.342 [-1.348, -1.337]
a: -16.228 [-16.326, -16.131]
Parameterization:
x1: 0.0039725648250079695
x2: 1.0",
"Parameterization 4
b: -1.354 [-1.359, -1.348]
a: -16.142 [-16.237, -16.048]
Parameterization:
x1: 0.0042498014575547615
x2: 1.0",
"Parameterization 5
b: -1.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 6
b: -1.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 7
b: -1.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 2.3901950154049643e-19
x2: 1.0",
"Parameterization 8
b: -1.493 [-1.497, -1.489]
a: -15.105 [-15.170, -15.041]
Parameterization:
x1: 0.007645582638698324
x2: 1.0",
"Parameterization 9
b: -3.453 [-3.456, -3.450]
a: -4.53 [-4.586, -4.473]
Parameterization:
x1: 0.06023419287776504
x2: 0.9977969319361266",
"Parameterization 10
b: -4.531 [-4.535, -4.526]
a: -1.709 [-1.786, -1.632]
Parameterization:
x1: 0.08980735478319636
x2: 0.9223543684853478",
"Parameterization 11
b: -1.357 [-1.363, -1.352]
a: -16.117 [-16.211, -16.024]
Parameterization:
x1: 0.004329944279158417
x2: 1.0",
"Parameterization 12
b: -1.342 [-1.348, -1.337]
a: -16.229 [-16.327, -16.131]
Parameterization:
x1: 0.003970501705423474
x2: 1.0",
"Parameterization 13
b: -2.161 [-2.164, -2.158]
a: -10.593 [-10.645, -10.542]
Parameterization:
x1: 0.02430273683607183
x2: 1.0",
"Parameterization 14
b: -1.883 [-1.886, -1.880]
a: -12.373 [-12.422, -12.323]
Parameterization:
x1: 0.017285215659655656
x2: 1.0",
"Parameterization 15
b: -2.853 [-2.856, -2.850]
a: -6.84 [-6.895, -6.786]
Parameterization:
x1: 0.042667289272550174
x2: 1.0",
"Parameterization 16
b: -1.179 [-1.189, -1.169]
a: -17.491 [-17.652, -17.330]
Parameterization:
x1: 0.0
x2: 1.0",
"Parameterization 17
b: -4.384 [-4.389, -4.379]
a: -2.029 [-2.117, -1.942]
Parameterization:
x1: 0.08527071120809132
x2: 0.9311964949867242",
"Parameterization 18
b: -1.577 [-1.580, -1.573]
a: -14.495 [-14.551, -14.440]
Parameterization:
x1: 0.009702572346602805
x2: 1.0",
"Parameterization 19
b: -4.936 [-4.942, -4.931]
a: -0.975 [-1.077, -0.873]
Parameterization:
x1: 0.10173190237166747
x2: 0.8895030367819299"
],
"type": "scatter",
"x": [
-17.490877036726644,
-17.4908770367295,
-14.237092606396363,
-16.228456266767147,
-16.14217440382504,
-17.4908770367295,
-17.4908770367295,
-17.4908770367295,
-15.1052238031622,
-4.529621025384046,
-1.7091515627059835,
-16.117277322892903,
-16.22909925787482,
-10.593175722375722,
-12.372648702307814,
-6.840421444782642,
-17.4908770367295,
-2.029376265668649,
-14.495394883881122,
-0.9750405262062074
],
"y": [
-1.1789531588227398,
-1.1789531588233908,
-1.6127229678583546,
-1.3424737970943776,
-1.353854419931729,
-1.1789531588233908,
-1.1789531588233908,
-1.1789531588233908,
-1.492873348246433,
-3.4530186996982724,
-4.530679346185984,
-1.3571434798448596,
-1.3423890892044001,
-2.160758525275295,
-1.8827754079166898,
-2.8527218319750145,
-1.1789531588233908,
-4.383842856122269,
-1.5767094057681241,
-4.936478330069894
]
}
],
"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": [
"