How to create simulated annealing objective function?

Hello!
I want to create a objective function for Travelling salesman problem using simulated annealing with global optimization toolbox.
Does anyone have idea how to make these?
Thank you for help

댓글 수: 3

Walter Roberson
Walter Roberson 2015년 5월 28일
편집: Walter Roberson 2015년 5월 28일
Thank you.
Yes i can't look on the second link too.
for now my programe is looking like these: one .m file:
clc
close all
clear all
global pot
global y
global x
global bestfval_log
global N
bestfval_log = [];
ime=[1 2 3];
str1 = 'Enka';
str2 = 'Dvojka';
str3 = 'Trojka';
x=[1 2 3];
y=[1 2 3];
N=length(x);
figure ('Name', 'Popotnik');
axes('Color', [0.5 0.5 0.5]);
axis([0 10 0 10]);
hold on;
for i=1:N
plot(x(i), y(i), 'g+');
end
text(x(1),y(1),str1);
text(x(2),y(2),str2);
text(x(3),y(3),str3);
pot=1:N;
x0=[0 0];
[x, fval, exitFlag, output] = simulannealbnd(@kriterijskafunckija, x0);
and my objective function is:
function d = kriterijskafunkcija(pot)
%global pot
global x
global y
global N
%global d
d=0;
for i=1:N-1
d=d+((x(pot(i))-x(pot(i+1)))^2+(y(pot(i))-y(pot(i+1)))^2)^.5;
end
i=N;
d=d+((x(pot(i))-x(pot(1)))^2+(y(pot(i))-y(pot(1)))^2)^.5;
anyone knows how to move forward and make these work

댓글을 달려면 로그인하십시오.

답변 (2개)

Alan Weiss
Alan Weiss 2015년 5월 28일
편집: Alan Weiss 2015년 5월 28일

0 개 추천

The simulated annealing solver is based on continuous variables by default. Perhaps you could make it work for a custom data type, similar to the genetic algorithm solution. But travelling salesman problems are most easily formulated for integer variables. For solutions, see this MILP example which uses Optimization Toolbox, or this genetic algorithm example using Global Optimization Toolbox and a custom data type.
Alan Weiss
MATLAB mathematical toolbox documentation
Walter Roberson
Walter Roberson 2015년 5월 28일

0 개 추천

See my discussion in http://uk.mathworks.com/matlabcentral/answers/220440-simulated-annealing-how-to-solve-this-error as to what the problem is here (the code has exactly the same basic problem here), and as to why it is hard to fix.
The short summary: you can use Simulated Annealing techniques with Traveling Salesperson, but using simulannealbnd() itself for the problem is going to be difficult.

카테고리

도움말 센터File Exchange에서 Simulated Annealing에 대해 자세히 알아보기

질문:

2015년 5월 28일

답변:

2015년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by