Skip to content

Commit

Permalink
Fix Python example optim g24 (#238)
Browse files Browse the repository at this point in the history
* Fix optim_g24 with new API, keep it minimal

* Cleanup
  • Loading branch information
relf authored Jan 24, 2025
1 parent 6d3c5dc commit a0093b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
9 changes: 1 addition & 8 deletions doc/Egor_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,7 @@
" infill_strategy=egx.InfillStrategy.WB2,\n",
" target=-5.5,\n",
" trego=False,\n",
" # outdir=\"./out\",\n",
" # hot_start=True\n",
" ) \n",
"\n",
"# Specify regression and/or correlation models used to build the surrogates of objective and constraints\n",
"#egor = egx.Egor(g24, xlimits_g24, n_cstr=n_cstr_g24, n_doe=10,\n",
"# regr_spec=egx.RegressionSpec.LINEAR,\n",
"# corr_spec=egx.CorrelationSpec.MATERN32 | egx.CorrelationSpec.MATERN52) "
" ) "
]
},
{
Expand Down
17 changes: 5 additions & 12 deletions python/egobox/examples/optim_g24.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,15 @@ def g24(point):
return np.array([G24(p), G24_c1(p), G24_c2(p)]).T


# Configure the optimizer. See help(egor) for options
egor = egx.Egor(
g24,
xspecs_g24,
n_doe=10,
n_cstr=n_cstr_g24,
cstr_tol=1e-3,
cstr_tol=[1e-3] * n_cstr_g24,
infill_strategy=egx.InfillStrategy.WB2,
# expected=egx.ExpectedOptimum(val=-5.50, tol=1e-2),
# outdir="./out",
# hot_start=True
) # see help(egor) for options
target=-5.50, # known reference objective value
)

# Restrict regression and correlation models used
# egor = egx.Egor(g24, xlimits_g24, n_cstr=n_cstr_g24, n_doe=10,
# regr_spec=egx.RegressionSpec.LINEAR,
# corr_spec=egx.CorrelationSpec.MATERN32 | egx.CorrelationSpec.MATERN52)

res = egor.minimize(max_iters=30)
res = egor.minimize(g24, max_iters=30)
print(f"Optimization f={res.y_opt} at {res.x_opt}")

0 comments on commit a0093b1

Please sign in to comment.