Multi objective Bayesopt in MATLAB
이전 댓글 표시
Hello,
How can I use the BayesOpt of MATLAB for optimizing a multi objective problem? I mean when I have multiple cost functions rather than only one.
If it is not possible in the default version of BayesOpt of MATLAB, can I have some additional codes for this aim?
Thanks in advance
답변 (1개)
Alan Weiss
2021년 5월 5일
0 개 추천
There is no provision for using bayesopt for multiobjective problems. You have several choices:
- Use bayesopt as the optimizer in a procedure such as described in Generate and Plot Pareto Front.
- Use a multiobjective solver such as gamultiobj or paretosearch from Global Optimization Toolbox.
Alan Weiss
MATLAB mathematical toolbox documentation
댓글 수: 4
xu supeng
2021년 7월 13일
Could you give an example that use bayesopt as the optimizer to find the pareto Front ?
Alan Weiss
2021년 7월 13일
This code is essentially the same example as Generate and Plot Pareto Front. Using bayesopt is slow; I plot only 20 solution points, and limit bayesopt to 10 function evaluations per point.
x = optimizableVariable('x',[-2 2]);
N = 20;
xsol = zeros(N,1);
ysol = zeros(N,2);
alpha = linspace(0,1,N);
for i = 1:N
sol = bayesopt(@(x)myobj(x,alpha(i)),x,...
'IsObjectiveDeterministic',true,"Verbose",0,"PlotFcn",[],...
'MaxObjectiveEvaluations',10);
xsol(i) = sol.XAtMinObjective.x;
ysol(i,:) = objective(xsol(i));
end
figure
plot(ysol(:,1),ysol(:,2),'ko');
xlabel('f_1')
ylabel('f_2')
function mo = myobj(in,alpha)
x = in.x;
% mo = alpha*x^2 + (1 - alpha)*(1 - x)^2;
mo = dot(objective(x),[alpha 1-alpha]);
end
function objfun = objective(x)
objfun = zeros(1,2);
objfun(2) = (1 - x)^2;
objfun(1) = x^2;
end
Alan Weiss
MATLAB mathematical toolbox documentation
xu supeng
2021년 7월 14일
Thanks for your quikc reply. It works, but I still have some questions to ask you. First, it seems the program calculate the objfun(1) and objfun(2) seperately and then use the weight to define an objective mo( = objective(1) * alpha + objective(2) * (1-alpha) ) that the bayesopt to optimize. My question is, whether this kind of method too simple? or is this resonable (common) in find the pareto Front?
My second question is if there are three or three more objectives, how to define the mo ? and how to find the pareto Front ? (Just curious)
Alan Weiss
2021년 7월 14일
You are correct, I was just doing a sweep over alpha with objective mo = objective(1) * alpha + objective(2) * (1-alpha). If you have more objectives, you can have more nonnegative multipliers, and sweep over them with the sum of the multipliers equal to 1.
This is not always the best way to solve multiobjective problems, it might miss some things, but it enables you to get some sort of results using a single-objective minimizer.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Model Building and Assessment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!