How to change Simulate Annealing minimum optimization into maximum?

조회 수: 5 (최근 30일)
Micro Torrent
Micro Torrent 2016년 10월 3일
편집: John D'Errico 2016년 10월 4일
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);

답변 (1개)

John D'Errico
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
Micro Torrent
Micro Torrent 2016년 10월 4일
편집: Micro Torrent 2016년 10월 4일
Thank you John. I simply multiply the equation to -1 to find the minimum instead of the maximum but the result doesn't converge to a specific value. The Wolframalpha.com shows the same local optimum points in both case. Why I couldn't get the same result in Matlab? I limit my input variable to Lb=-3 and Ub=3 but the input value at the best result goes to 125 or -250, why?
Did I miss something?
John D'Errico
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 CenterFile Exchange에서 Simulated Annealing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by