Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. clear;
  2. tic;
  3. liczba_krokow = 20000;
  4. pokaz_co = 1000;
  5. p=0.01;
  6. T = 100;
  7. Tmin = 0.01;
  8. wT = 0.995;
  9. c = 0.1;
  10. r=0.1;
  11. w=0.995;
  12. [X1 X2] = meshgrid(-10:p:10,-10:p:10);
  13. Z = [];
  14. i=1;
  15. j=1;
  16. while i<=length(X1)
  17. j=1;
  18. while j<=length(X2)
  19. Z(i,j)= liczY(X1(i),X2(j));
  20. j=j+1;
  21. end
  22. i=i+1;
  23. end
  24.  
  25. x10=round((rand()*20-10)*100)/100;
  26. x20=round((rand()*20-10)*100)/100;
  27. f0=liczY(x10,x20);
  28. kro=1;
  29. while T>Tmin
  30. x1n=round((x10+r*randn())*100)/100;
  31. x2n=round((x20+r*randn())*100)/100;
  32. fn=liczY(x1n,x2n);
  33. if fn<f0
  34. x10=x1n;
  35. x20=x2n;
  36. else if rand < 1/(1+exp(fn-f0/(c*T)))
  37. x10=x1n;
  38. x20=x2n;
  39. end
  40. end
  41. T=T*w;
  42. end
  43. mesh(X1,X2,Z);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement