How to change Simulate Annealing minimum optimization into maximum?
4 ビュー (過去 30 日間)
古いコメントを表示
I am looking for a maximum Simulate Annealing solver for multidimensional function. The below code works for finding the global minimum. How can I change it into maximum finder? fitness.m file:
function f = fitness(x)
ddd = x(1)+x(2)-(x(2)-2)^2;
eee = abs(ddd);
f = eee * sin(x(1));
end
main.m file:
clc,clear,close all
fitfcn = @fitness;
nvar =2;
Lb = 1*ones(size(1,nvar));
Ub = 3*ones(size(1,nvar));
opt = optimoptions(@simulannealbnd,'Display','iter',...
'reannealinterval',300,...
'plotfcn',@saplotbestf,...
'FunctionTolerance',1e-4);
[xf,fval,exitflag] = simulannealbnd(fitfcn,[1 1],Lb,Ub,opt);
0 件のコメント
回答 (1 件)
John D'Errico
2016 年 10 月 3 日
If you have a tool that minimizes an objective, is it not true that a maximum can be found instead by minimizing -f(X)?
2 件のコメント
John D'Errico
2016 年 10 月 4 日
編集済み: John D'Errico
2016 年 10 月 4 日
Um, the code you show has variables limited to lie between 1 and 3, not -3 and 3. Which is it? My guess is that since this function is unbounded, you have not really used the limits you show in that example. The only evidence that I have is your example is not consistent with your claim. In fact, it is often true that people think they have done something, yet their variables are not as they claim them to be. So I would check the values of the bounds variables Lb and Ub.
For example, over the interval from 1 to 3 in both variables, the function you have shown has a single unique maximum.
I cannot test your code since I do not have that toolbox, nor do I see how you tried to multiply the function by -1. (People do indeed screw up things as simple as that.)
参考
カテゴリ
Help Center および File Exchange で Simulated Annealing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!