MATLAB: Bayesopt options pair: ‘InitialX’, {1×6} results in first cell-array entry taken as initial for all variables

bayesoptinitialxMATLAB

Hi there,
I'm using bayesopt as follows:
results = bayesopt(fun, [aa1,aa2,aa3,aa4,aa5,aa6], 'AcquisitionFunctionName', 'expected-improvement-plus','IsObjectiveDeterministic',true, 'MaxObjectiveEvaluations', 30, 'InitialX', {0.4 0.3 0.5 0.3 0.6 0.2})
which is resulting in all my variables being initialized with 0.4, instead of the full cell-array given.

Best Answer

Thanks for pointing this out. That's a bug, because bayesopt should not accept a cell array as the value for 'InitialX'. It expects a table. Internally, it accesses the cell array as though it were a table, and the result is wrong, as you noticed.
An easy fix is to pass a table instead of a cell array, like this:
'InitialX', cell2table({0.4 0.3 0.5 0.3 0.6 0.2})