RW - COSTbest=COSTcurrent sbest= scurrent end...

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

View Full Document Right Arrow Icon
function solution= RW(sinitial, maxiter) solution = zeros(maxiter,5); scurrent= sinitial; sbest= scurrent; COSTbest =cost(scurrent); for i=1:maxiter scurrent= neighbor(scurrent); COSTcurrent= cost(scurrent); if COSTcurrent<COSTbest
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COSTbest=COSTcurrent; sbest= scurrent; end solution(i,1)= i; solution(i,2)= scurrent; solution(i,3)= sbest; solution(i,4)= COSTcurrent; solution(i,5)= COSTbest; end else display('s not in valid range'); end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online