Skip to content

Commit caed178

Browse files
committed
update gen scripts/notebooks
1 parent ff1fa9e commit caed178

File tree

769 files changed

+102305
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

769 files changed

+102305
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "e1ef5215",
6+
"metadata": {},
7+
"source": [
8+
"<a href=\"https://colab.research.google.com/github/sgbaird/honegumi/blob/main/docs/generated_notebooks/ax/objective-multi%2Bmodel-FULLYBAYESIAN%2Bcustom_gen-True%2Bexisting_data-False%2Bsum_constraint-False%2Border_constraint-False%2Blinear_constraint-False%2Bcomposition_constraint-False%2Bcategorical-False%2Bcustom_threshold-False%2Bsynchrony-batch.ipynb\"><img alt=\"Open In Colab\" src=\"https://colab.research.google.com/assets/colab-badge.svg\"></a>"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "c788e0b6",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"%pip install ax-platform"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"id": "748e6dd2",
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"import numpy as np\n",
29+
"from ax.service.ax_client import AxClient, ObjectiveProperties\n",
30+
"\n",
31+
"from ax.modelbridge.factory import Models\n",
32+
"from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy\n",
33+
"\n",
34+
"\n",
35+
"obj1_name = \"branin\"\n",
36+
"obj2_name = \"branin_swapped\"\n",
37+
"\n",
38+
"\n",
39+
"def branin_moo(x1, x2):\n",
40+
" y = float(\n",
41+
" (x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2\n",
42+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1)\n",
43+
" + 10\n",
44+
" )\n",
45+
"\n",
46+
" # second objective has x1 and x2 swapped\n",
47+
" y2 = float(\n",
48+
" (x1 - 5.1 / (4 * np.pi**2) * x2**2 + 5.0 / np.pi * x2 - 6.0) ** 2\n",
49+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x2)\n",
50+
" + 10\n",
51+
" )\n",
52+
"\n",
53+
" return {obj1_name: y, obj2_name: y2}\n",
54+
"\n",
55+
"\n",
56+
"gs = GenerationStrategy(\n",
57+
" steps=[\n",
58+
" GenerationStep(\n",
59+
" model=Models.SOBOL,\n",
60+
" num_trials=4, # https://github.com/facebook/Ax/issues/922\n",
61+
" min_trials_observed=3,\n",
62+
" max_parallelism=5,\n",
63+
" model_kwargs={\"seed\": 999},\n",
64+
" model_gen_kwargs={},\n",
65+
" ),\n",
66+
" GenerationStep(\n",
67+
" model=Models.FULLYBAYESIANMOO,\n",
68+
" num_trials=-1,\n",
69+
" max_parallelism=3,\n",
70+
" model_kwargs={\"num_samples\": 256, \"warmup_steps\": 512},\n",
71+
" ),\n",
72+
" ]\n",
73+
")\n",
74+
"\n",
75+
"ax_client = AxClient(generation_strategy=gs)\n",
76+
"\n",
77+
"ax_client.create_experiment(\n",
78+
" parameters=[\n",
79+
" {\"name\": \"x1\", \"type\": \"range\", \"bounds\": [-5.0, 10.0]},\n",
80+
" {\"name\": \"x2\", \"type\": \"range\", \"bounds\": [0.0, 10.0]},\n",
81+
" ],\n",
82+
" objectives={\n",
83+
" obj1_name: ObjectiveProperties(minimize=True),\n",
84+
" obj2_name: ObjectiveProperties(minimize=True),\n",
85+
" },\n",
86+
")\n",
87+
"\n",
88+
"\n",
89+
"batch_size = 2\n",
90+
"\n",
91+
"\n",
92+
"for _ in range(19):\n",
93+
"\n",
94+
" parameterizations, optimization_complete = ax_client.get_next_trials(batch_size)\n",
95+
" for trial_index, parameterization in list(parameterizations.items()):\n",
96+
" # extract parameters\n",
97+
" x1 = parameterization[\"x1\"]\n",
98+
" x2 = parameterization[\"x2\"]\n",
99+
"\n",
100+
" results = branin_moo(x1, x2)\n",
101+
" ax_client.complete_trial(trial_index=trial_index, raw_data=results)\n",
102+
"\n",
103+
"pareto_results = ax_client.get_pareto_optimal_parameters()"
104+
]
105+
}
106+
],
107+
"metadata": {
108+
"jupytext": {
109+
"cell_metadata_filter": "-all",
110+
"main_language": "python",
111+
"notebook_metadata_filter": "-all"
112+
}
113+
},
114+
"nbformat": 4,
115+
"nbformat_minor": 5
116+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "8a726861",
6+
"metadata": {},
7+
"source": [
8+
"<a href=\"https://colab.research.google.com/github/sgbaird/honegumi/blob/main/docs/generated_notebooks/ax/objective-multi%2Bmodel-FULLYBAYESIAN%2Bcustom_gen-True%2Bexisting_data-False%2Bsum_constraint-False%2Border_constraint-False%2Blinear_constraint-False%2Bcomposition_constraint-False%2Bcategorical-False%2Bcustom_threshold-False%2Bsynchrony-single.ipynb\"><img alt=\"Open In Colab\" src=\"https://colab.research.google.com/assets/colab-badge.svg\"></a>"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "9e8904fa",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"%pip install ax-platform"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"id": "c73576d7",
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"import numpy as np\n",
29+
"from ax.service.ax_client import AxClient, ObjectiveProperties\n",
30+
"\n",
31+
"from ax.modelbridge.factory import Models\n",
32+
"from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy\n",
33+
"\n",
34+
"\n",
35+
"obj1_name = \"branin\"\n",
36+
"obj2_name = \"branin_swapped\"\n",
37+
"\n",
38+
"\n",
39+
"def branin_moo(x1, x2):\n",
40+
" y = float(\n",
41+
" (x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2\n",
42+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1)\n",
43+
" + 10\n",
44+
" )\n",
45+
"\n",
46+
" # second objective has x1 and x2 swapped\n",
47+
" y2 = float(\n",
48+
" (x1 - 5.1 / (4 * np.pi**2) * x2**2 + 5.0 / np.pi * x2 - 6.0) ** 2\n",
49+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x2)\n",
50+
" + 10\n",
51+
" )\n",
52+
"\n",
53+
" return {obj1_name: y, obj2_name: y2}\n",
54+
"\n",
55+
"\n",
56+
"gs = GenerationStrategy(\n",
57+
" steps=[\n",
58+
" GenerationStep(\n",
59+
" model=Models.SOBOL,\n",
60+
" num_trials=4, # https://github.com/facebook/Ax/issues/922\n",
61+
" min_trials_observed=3,\n",
62+
" max_parallelism=5,\n",
63+
" model_kwargs={\"seed\": 999},\n",
64+
" model_gen_kwargs={},\n",
65+
" ),\n",
66+
" GenerationStep(\n",
67+
" model=Models.FULLYBAYESIANMOO,\n",
68+
" num_trials=-1,\n",
69+
" max_parallelism=3,\n",
70+
" model_kwargs={\"num_samples\": 256, \"warmup_steps\": 512},\n",
71+
" ),\n",
72+
" ]\n",
73+
")\n",
74+
"\n",
75+
"ax_client = AxClient(generation_strategy=gs)\n",
76+
"\n",
77+
"ax_client.create_experiment(\n",
78+
" parameters=[\n",
79+
" {\"name\": \"x1\", \"type\": \"range\", \"bounds\": [-5.0, 10.0]},\n",
80+
" {\"name\": \"x2\", \"type\": \"range\", \"bounds\": [0.0, 10.0]},\n",
81+
" ],\n",
82+
" objectives={\n",
83+
" obj1_name: ObjectiveProperties(minimize=True),\n",
84+
" obj2_name: ObjectiveProperties(minimize=True),\n",
85+
" },\n",
86+
")\n",
87+
"\n",
88+
"\n",
89+
"for _ in range(19):\n",
90+
"\n",
91+
" parameterization, trial_index = ax_client.get_next_trial()\n",
92+
"\n",
93+
" # extract parameters\n",
94+
" x1 = parameterization[\"x1\"]\n",
95+
" x2 = parameterization[\"x2\"]\n",
96+
"\n",
97+
" results = branin_moo(x1, x2)\n",
98+
" ax_client.complete_trial(trial_index=trial_index, raw_data=results)\n",
99+
"\n",
100+
"pareto_results = ax_client.get_pareto_optimal_parameters()"
101+
]
102+
}
103+
],
104+
"metadata": {
105+
"jupytext": {
106+
"cell_metadata_filter": "-all",
107+
"main_language": "python",
108+
"notebook_metadata_filter": "-all"
109+
}
110+
},
111+
"nbformat": 4,
112+
"nbformat_minor": 5
113+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "01163a12",
6+
"metadata": {},
7+
"source": [
8+
"<a href=\"https://colab.research.google.com/github/sgbaird/honegumi/blob/main/docs/generated_notebooks/ax/objective-multi%2Bmodel-FULLYBAYESIAN%2Bcustom_gen-True%2Bexisting_data-False%2Bsum_constraint-False%2Border_constraint-False%2Blinear_constraint-False%2Bcomposition_constraint-False%2Bcategorical-False%2Bcustom_threshold-True%2Bsynchrony-batch.ipynb\"><img alt=\"Open In Colab\" src=\"https://colab.research.google.com/assets/colab-badge.svg\"></a>"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"id": "32409e12",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"%pip install ax-platform"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"id": "0109f7ee",
25+
"metadata": {},
26+
"outputs": [],
27+
"source": [
28+
"import numpy as np\n",
29+
"from ax.service.ax_client import AxClient, ObjectiveProperties\n",
30+
"\n",
31+
"from ax.modelbridge.factory import Models\n",
32+
"from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy\n",
33+
"\n",
34+
"\n",
35+
"obj1_name = \"branin\"\n",
36+
"obj2_name = \"branin_swapped\"\n",
37+
"\n",
38+
"\n",
39+
"def branin_moo(x1, x2):\n",
40+
" y = float(\n",
41+
" (x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2\n",
42+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1)\n",
43+
" + 10\n",
44+
" )\n",
45+
"\n",
46+
" # second objective has x1 and x2 swapped\n",
47+
" y2 = float(\n",
48+
" (x1 - 5.1 / (4 * np.pi**2) * x2**2 + 5.0 / np.pi * x2 - 6.0) ** 2\n",
49+
" + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x2)\n",
50+
" + 10\n",
51+
" )\n",
52+
"\n",
53+
" return {obj1_name: y, obj2_name: y2}\n",
54+
"\n",
55+
"\n",
56+
"gs = GenerationStrategy(\n",
57+
" steps=[\n",
58+
" GenerationStep(\n",
59+
" model=Models.SOBOL,\n",
60+
" num_trials=4, # https://github.com/facebook/Ax/issues/922\n",
61+
" min_trials_observed=3,\n",
62+
" max_parallelism=5,\n",
63+
" model_kwargs={\"seed\": 999},\n",
64+
" model_gen_kwargs={},\n",
65+
" ),\n",
66+
" GenerationStep(\n",
67+
" model=Models.FULLYBAYESIANMOO,\n",
68+
" num_trials=-1,\n",
69+
" max_parallelism=3,\n",
70+
" model_kwargs={\"num_samples\": 256, \"warmup_steps\": 512},\n",
71+
" ),\n",
72+
" ]\n",
73+
")\n",
74+
"\n",
75+
"ax_client = AxClient(generation_strategy=gs)\n",
76+
"\n",
77+
"ax_client.create_experiment(\n",
78+
" parameters=[\n",
79+
" {\"name\": \"x1\", \"type\": \"range\", \"bounds\": [-5.0, 10.0]},\n",
80+
" {\"name\": \"x2\", \"type\": \"range\", \"bounds\": [0.0, 10.0]},\n",
81+
" ],\n",
82+
" objectives={\n",
83+
" obj1_name: ObjectiveProperties(minimize=True, threshold=25.0),\n",
84+
" obj2_name: ObjectiveProperties(minimize=True, threshold=15.0),\n",
85+
" },\n",
86+
")\n",
87+
"\n",
88+
"\n",
89+
"batch_size = 2\n",
90+
"\n",
91+
"\n",
92+
"for _ in range(19):\n",
93+
"\n",
94+
" parameterizations, optimization_complete = ax_client.get_next_trials(batch_size)\n",
95+
" for trial_index, parameterization in list(parameterizations.items()):\n",
96+
" # extract parameters\n",
97+
" x1 = parameterization[\"x1\"]\n",
98+
" x2 = parameterization[\"x2\"]\n",
99+
"\n",
100+
" results = branin_moo(x1, x2)\n",
101+
" ax_client.complete_trial(trial_index=trial_index, raw_data=results)\n",
102+
"\n",
103+
"pareto_results = ax_client.get_pareto_optimal_parameters()"
104+
]
105+
}
106+
],
107+
"metadata": {
108+
"jupytext": {
109+
"cell_metadata_filter": "-all",
110+
"main_language": "python",
111+
"notebook_metadata_filter": "-all"
112+
}
113+
},
114+
"nbformat": 4,
115+
"nbformat_minor": 5
116+
}

0 commit comments

Comments
 (0)