SA - if (deltaCOST<0) scurrent= snew;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [solution sbest] = SA(sinitial,Tinitial,alpha,beta,Minitial,maxiter) solution= zeros(maxiter,3); T= Tinitial; M= Minitial; scurrent= sinitial; sbest= scurrent; snew= scurrent; COSTcurrent= cost(scurrent); COSTbest= COSTcurrent; iter= 0; i while (iter < maxiter) Mtemp= M; while (Mtemp>0) rnd= rand(); if (rnd > .5) snew(1)= neighbor(scurrent(1)); else snew(2)= neighbor(scurrent(2)); end COSTnew=cost(snew); deltaCOST=COSTnew-COSTcurrent;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (deltaCOST<0) scurrent= snew; COSTcurrent=COSTnew; if (COSTnew<COSTbest) sbest= snew; COSTbest=COSTnew; end else rnd2= rand(); if (rnd2<exp(-1*deltaCOST/T)) scurrent= snew; COSTcurrent=COSTnew; end end Mtemp=Mtemp-1; end iter= iter + M; T= alpha*T; M= beta*M; solution(iter,1)= iter; solution(iter,2)= COSTcurrent; solution(iter,3)= COSTbest; end e...
View Full Document

This note was uploaded on 10/02/2011 for the course ORIE 5430 taught by Professor Shoemaker during the Fall '11 term at Cornell.

Ask a homework question - tutors are online