MATLAB Answers

Modifying results from bayesopt

1 view (last 30 days)
Alexander on 9 Nov 2017
Commented: Alexander on 13 Nov 2017
Hey guys, following use case: I call bayesopt and get the results structure from it.
Now, the results structure contains a field, named 'NextPoint'. This is the x vector, which is going to be evaluated after a resuming. Given the fact, I know a better point, which is worth to be calculated next, how to replace the automatic one? A direct try yields
You cannot set the read-only property 'NextPoint' of BayesianOptimization.
error message.

  1 Comment

Alexander on 9 Nov 2017
To clarify:
1. I already tried to do this from an OutputFcn, with the same error;
2. I even know the function value at the "better point". So, indeed, I have not to recalculate it. I just want to apply some additional knowledge to the results structure of bayesopt, which can be used for continuation.

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 9 Nov 2017
In order to do this, I think that you are going to have to do two things:
  • Evaluate the point manually.
  • Start the Bayesian optimization afresh, using the returned points (the ones already evaluated by bayesopt) plus put in your new value and point. Use the 'InitialX' and 'Initial Objective' name-value pairs.
Please let us know if this works for you.
Alan Weiss
MATLAB mathematical toolbox documentation


Alexander on 10 Nov 2017
Yes, this works. I was not aware, that 'XTrace' and 'ObjectiveTrace' holds the whole history of data, which I can reuse.
However, the result is somewhat disillusioning, as I tried to parallelize both: bayesopt as well as the manual evaluation of additional points, which does not play well together.
But the idea of setting 'InitialX' and 'InitialObjective' and restarting bayesopt works.
Thanks a lot :)
Alexander on 13 Nov 2017
Ok, after some evaluation, I figured out the unexpected behavior. I attached an example.
Therein: as I understood correctly, what you suggested is the solution in lines 28-35.
However, if I add the ’UseParallel’ option, and provide the 'InitialX‘ array the optimizer does not restart. I didn’t find any documentation on the fact that setting 'InitialX‘ property together with ’UseParallel’ prevent the optimizer to run. Is this a bug?
What I did as a dirty workaround is in lines 25-26. However for being able to set XNext property I had to adjust the access modifier in BayesianOptimization.m to public, in line 1808.
Thanks anyway for help and any further comments.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by