Skip to content

Commit 35117e7

Browse files
committed
Update build_gp_surrogates notebook for vocs
1 parent b9e8161 commit 35117e7

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

doc/source/user_guide/advanced_usage/build_gp_surrogates.ipynb

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"\n",
1212
"The :class:`~optimas.diagnostics.ExplorationDiagnostics` class\n",
1313
"provides a simple way of fitting a Gaussian process (GP) model to any of the\n",
14-
"objectives or analyzed parameters of an ``optimas``\n",
14+
"objectives or observables of an ``optimas``\n",
1515
":class:`~optimas.explorations.Exploration`, independently of which generator\n",
1616
"was used. This is useful to get a better understanding of the underlying\n",
1717
"function, make predictions, etc.\n",
@@ -29,7 +29,7 @@
2929
"\n",
3030
"The following cell sets up and runs an optimization with two input parameters\n",
3131
"``x1`` and ``x2``, two objectives ``f1`` and ``f2``, and one additional\n",
32-
"analyzed parameter ``p1``.\n",
32+
"observable ``p1``.\n",
3333
"At each evaluation, the ``eval_func_sf_moo`` function is run,\n",
3434
"which assigns a value to each outcome parameter according to the analytical\n",
3535
"formulas\n",
@@ -55,9 +55,9 @@
5555
"source": [
5656
"import numpy as np\n",
5757
"from optimas.explorations import Exploration\n",
58-
"from optimas.core import VaryingParameter, Objective, Parameter\n",
5958
"from optimas.generators import RandomSamplingGenerator\n",
6059
"from optimas.evaluators import FunctionEvaluator\n",
60+
"from gest_api.vocs import VOCS\n",
6161
"\n",
6262
"\n",
6363
"def eval_func_sf_moo(input_params, output_params):\n",
@@ -70,17 +70,20 @@
7070
" output_params[\"p1\"] = np.sin(x1) + np.cos(x2)\n",
7171
"\n",
7272
"\n",
73-
"var1 = VaryingParameter(\"x1\", 0.0, 5.0)\n",
74-
"var2 = VaryingParameter(\"x2\", -5.0, 5.0)\n",
75-
"par1 = Parameter(\"p1\")\n",
76-
"obj1 = Objective(\"f1\", minimize=True)\n",
77-
"obj2 = Objective(\"f2\", minimize=False)\n",
78-
"\n",
79-
"gen = RandomSamplingGenerator(\n",
80-
" varying_parameters=[var1, var2],\n",
81-
" objectives=[obj1, obj2],\n",
82-
" analyzed_parameters=[par1],\n",
73+
"# Create VOCS object defining variables, objectives, and observables.\n",
74+
"vocs = VOCS(\n",
75+
" variables={\n",
76+
" \"x1\": [0.0, 5.0],\n",
77+
" \"x2\": [-5.0, 5.0],\n",
78+
" },\n",
79+
" objectives={\n",
80+
" \"f1\": \"MINIMIZE\",\n",
81+
" \"f2\": \"MAXIMIZE\",\n",
82+
" },\n",
83+
" observables=[\"p1\"],\n",
8384
")\n",
85+
"\n",
86+
"gen = RandomSamplingGenerator(vocs=vocs)\n",
8487
"ev = FunctionEvaluator(function=eval_func_sf_moo)\n",
8588
"exploration = Exploration(\n",
8689
" generator=gen,\n",
@@ -125,18 +128,18 @@
125128
"raw_mimetype": "text/restructuredtext"
126129
},
127130
"source": [
128-
"Building a GP model of each objective and analyzed parameter\n",
129-
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n",
131+
"Building a GP model of each objective and observable\n",
132+
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n",
130133
"\n",
131134
"To build a GP model, simply call\n",
132135
":meth:`~optimas.diagnostics.Exploration.build_gp_model` on the diagnostics,\n",
133136
"indicating the name of the variable to which the model should be fitted.\n",
134-
"This variable can be any ``objective`` or ``analyzed_parameter`` of the\n",
137+
"This variable can be any ``objective`` or ``observable`` of the\n",
135138
"optimization.\n",
136139
"\n",
137-
"Note that when building a surrogate model of an analyzed parameter, it is\n",
140+
"Note that when building a surrogate model of an observable, it is\n",
138141
"required to provide a value to the ``minimize`` argument. This parameter\n",
139-
"should therefore be ``True`` if lower values of the analyzed parameter are\n",
142+
"should therefore be ``True`` if lower values of the observable are\n",
140143
"better than higher values. This information is necessary, e.g., for determining\n",
141144
"the best point in the model."
142145
]
@@ -147,7 +150,7 @@
147150
"metadata": {},
148151
"outputs": [],
149152
"source": [
150-
"# Build one model for each objective and analyzed parameter.\n",
153+
"# Build one model for each objective and observable.\n",
151154
"f1_model = diags.build_gp_model(\"f1\")\n",
152155
"f2_model = diags.build_gp_model(\"f2\")\n",
153156
"p1_model = diags.build_gp_model(\"p1\", minimize=False)"

0 commit comments

Comments
 (0)