bayesopt — Run deterministic Bayesian optimization over optimizableVariable metadata.
bayesopt(fun, vars, Name, Value) evaluates a scalar objective over optimizableVariable metadata and returns a BayesianOptimization compatibility object.
Syntax
results = bayesopt(fun, vars, Name, Value)How bayesopt works
- The objective is called as
fun(X), whereXis a one-row table with one column per optimizable variable. - Supports real, integer, and categorical
optimizableVariableobjects, includingTransform='log'for valid numeric ranges andOptimize=falsefixed variables. - Uses deterministic low-discrepancy seed points followed by a Gaussian-process surrogate with expected-improvement-style acquisition for reproducible in-memory optimization loops.
- Finite integer/categorical search spaces terminate cleanly when all unique candidate points have been exhausted before
MaxObjectiveEvaluations. - Name-value support includes
MaxObjectiveEvaluations,NumSeedPoints,AcquisitionFunctionName,ExplorationRatio,IsObjectiveDeterministic,Verbose,UseParallel=false, emptyPlotFcn/OutputFcn, andXConstraintFcnlogical feasibility filters. - The objective may return a scalar objective value or a struct with
Objectiveand optionalConstraintViolationsfields. Constraint violations less than or equal to zero are feasible. - The result object exposes
XTrace,ObjectiveTrace,ObjectiveMinimumTrace,ObjectiveEvaluationTimeTrace,FeasibilityTrace,OptimizationTrace,XAtMinObjective,MinObjective,BestPoint,BestObjective,VariableDescriptions,Options,Output,ExitFlag, and surrogate metadata. - Warm starts, conditional variables, plotting/output callbacks, parallel evaluation, GPU-resident optimization, datastore-backed objectives, and multi-output result forms remain outside this slice and raise explicit compatibility errors.
GPU memory and residency
bayesopt is a host control-flow solver. It gathers variable metadata and option inputs before evaluation, rejects UseParallel=true, and does not run objective scheduling or surrogate updates on a GPU provider.
Examples
Minimize a scalar objective over two real variables
x = optimizableVariable('x',[-1 1]);
y = optimizableVariable('y',[-1 1]);
results = bayesopt(@objective, {x y}, 'MaxObjectiveEvaluations', 24, 'NumSeedPoints', 6)Expected output:
results is a BayesianOptimization compatibility object with trace tables and the best observed point.Filter candidates with an XConstraintFcn
x = optimizableVariable('x',[-1 1]);
results = bayesopt(@objective, x, 'XConstraintFcn', @isFeasible)Expected output:
Only rows for which isFeasible(X) returns true are evaluated by the objective.Using bayesopt with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how bayesopt changes the result.
Run a small bayesopt example, explain the result, then change one input and compare the output.
Related Stats functions
Ml
classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne
Summary
binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normalize · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv
Random
binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd
Hist
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.