matlab - What's wrong with my Hopfield Neural Network solution to the Traveling Salesman Problem? -


first off, homework. think it's clear i've made effort , i'm looking hints, not code.

the problem following. equation of operation has 4 components altering given neuron.

  • a) 1 part ensure each city visited @ once.
  • b) 1 ensure each position (first, second, third, etc) has @ 1 city.
  • c) 1 part ensure total number of active neurons equal number of cities.
  • d) 1 part minimize distance.

if weight d heavily enough has effect, network settles on invalid tour (for example, visit a, d, nowhere, e, c). can, however, deweight d , code find solutions, not minimal distance.

i'd extremely grateful advice, i've been banging head against keyboard while. code should understandable familiar solving tsp hopfield network.

das code:

%parameters n=5; theta = .5; u0 = 0.02; h = .1; limit = 2000;  %init u u=zeros(n,n); uinit = -u0/2*log(n-1); %p94 uinit = - u0/2 * ln(n-1)  i=1:n     j=1:n         u(i,j) = uinit * (1+rand()*0.2-0.1); %add noise [-0.1*uinit 0.1*uinit]     end end   %loop index=1:limit     = ceil(rand()*n);     k = ceil(rand()*n);      %runge kutta     k1 = h*du(u,i,k,0);     k2 = h*du(u,i,k, k1/2);     k3 = h*du(u,i,k, k2/2);     k4 = h*du(u,i,k, k3);     u(i,k) = u(i,k) + (k1 + 2*k2 + 2*k3 + k4)/6; end  vfinal = hardlim(v(u)-theta) 

du()

function  out=du(u,x,i,c)  dist = [0, 41, 45, 32, 32;         41, 0, 36, 64, 54;         45, 36, 0, 76, 32;         32, 64, 76, 0, 60;         32, 54, 32, 60, 0];  t = 1; n = 5; = 10; b = 10; c = 10; d = .0001;   acomp = a*sum(v(u(x,:))) - a*v(u(x,i)); bcomp = b*sum(v(u(:,i))) - b*v(u(x,i)); ccomp = c*(sum(sum(v(u)))-n);  dcomp = 0; before = i-1; after = i+1; if before == 0     before = 5; end if after == 6     after = 1; end y=1:5     dcomp = dcomp + dist(x,y) * (v(u(y,after)) + v(u(y,before))); end dcomp = dcomp * d;  out = -1*(u(x,i)+c)/t - acomp - bcomp - ccomp - dcomp; 

v()

function  out=v(u) u0 = 0.02; out = (1 + tanh(u/u0))/2; 

i have never tried solving tsp neural network, have found solves well, , quickly, taking genetic approach.

i have done many neural network projects, though, , guess since tsp can, in general, have many solutions on single network (of cities), neural network dragged , forth between solutions, never converging on one.

john r. doner


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -