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), where X is a one-row table with one column per optimizable variable.
  • Supports real, integer, and categorical optimizableVariable objects, including Transform='log' for valid numeric ranges and Optimize=false fixed 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, empty PlotFcn/OutputFcn, and XConstraintFcn logical feasibility filters.
  • The objective may return a scalar objective value or a struct with Objective and optional ConstraintViolations fields. 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.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.