MATLAB Answers

Baysian Optimisation. Any way of increasing the sample size of candidates solutions to satisfy XConstraintFunction in bayesopt()?

3 views (last 30 days)
Bob Hickish
Bob Hickish on 4 Oct 2017
Commented: Bob Hickish on 1 Nov 2017
I'm investigating the suitability of bayesopt() for problems of increasing dimensionality and range within the variables. As both of these increase, the number of solutions in the solution space grows quickly, whilst the number of feasible solutions grows less quickly. I have included a constraint function as an input to bayesopt(). The bayeopt() algorithm checks whether this can be satisfied be inputting 10,000 possible solutions (I assume drawn from the solution space) to it and seeing if any are feasible. However as mentioned before, the solution space grows a lot more quickly than the number of feasible solutions. This means that it becomes very unlikely to draw a feasible solution in 10,000 selections. If a feasible solution is not found, bayesopt() considers there to be no feasible solutions and terminates the algorithm. However, I know that there are feasible solutions so would like the algorithm to continue so I can see how it performs. Is there a way of increasing the 10,000 limit? I can see the variable that would be need to changed in the bayesopt() code, but when I try to change it I get a pop up box saying that I dont have access to alter the file.

  1 Comment

Bob Hickish
Bob Hickish on 5 Oct 2017
Furthermore, it is strange that one can provide an InitialX to bayesopt() but the ConstrainFunction checking process doesn't evaluate this. Is there anyway of passing InitialX to the constraint function during the checking process to convince bayesopt() that the constraint function is satisfiable? Thanks

Sign in to comment.

Accepted Answer

Don Mathis
Don Mathis on 6 Oct 2017
Unfortunately the API doesn't allow that, but you can assign into the Options object once you have one. The bayesopt function creates one right away, so you could do something like this:
x = optimizableVariable('x',[-8,8]);
fun = @(T)sin(T.x);
BO = my_bayesopt(fun, x)
function Results = my_bayesopt(ObjectiveFcn, VariableDescriptions, varargin)
Options = bayesoptim.BayesoptOptions(ObjectiveFcn, VariableDescriptions, varargin);
Options.NumRestartCandidates = 1e6;
Results = BayesianOptimization(Options);
end

  6 Comments

Show 3 older comments
Bob Hickish
Bob Hickish on 12 Oct 2017
Ah ok, thank you Don for the clarification on the 10000, NumRestartCandidates and XConstraintFcn. I'm back again to ask if you can think of another solution that does not involve editing the MATLAB program files. I ask because, whilst your earlier solution was fine for working on my local machine, I am now wanting to run my script on an HPC for which I am not an administrator and so hence don't have access to altering the code within bayesopt(). Before when I have had similar problems you have suggested that I create a new folder in the working directory with the same name as the function so that it comes up on the path before the actual function. Would something similar work here? Somehow removing the call to checkXConstraintFcnSatisfiability would be best, but any suggestions appreciated!
Don Mathis
Don Mathis on 13 Oct 2017
You can define your own modified version of the BayesianOptimization class and have your "my_bayesopt" function call that. Put a copy of BayesianOptimization.m into your local folder and rename it MyBayesianOptimization.m. Then, inside MyBayesianOptimization.m,
  • Rename the class on line 1:
classdef MyBayesianOptimization
  • Rename the constructor:
function this = MyBayesianOptimization(Options)
  • Make checkXConstraintFcnSatisfiability do nothing:
function checkXConstraintFcnSatisfiability(this)
end
Inside your my_bayesopt.m, make it call your new class:
function Results = my_bayesopt(ObjectiveFcn, VariableDescriptions, varargin)
Options = bayesoptim.BayesoptOptions(ObjectiveFcn, VariableDescriptions, varargin);
Options.NumRestartCandidates = 1e6;
Results = MyBayesianOptimization(Options);
end
This works for me in MATLAB version R2016b. Let me know how it goes.

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!