{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

RS - COSTtest= cost(stest if COSTtest<COSTbest COSTbest=...

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

View Full Document Right Arrow Icon
function solution = RS(sinitial, maxiter) if (sinitial >= 0 && sinitial <= 500) solution = zeros(maxiter,5); snew= sinitial; sbest= snew; COSTnew= cost(snew); COSTbest= cost(snew); for i=1:maxiter x= randi([0,500]); %prevent S from staying the same while x == snew x= randi([0 500]); end stest= x;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COSTtest= cost(stest); if COSTtest<COSTbest COSTbest= COSTtest; COSTnew= COSTtest; snew= stest; sbest= snew; end solution(i,1)= i; solution(i,2)= snew; solution(i,3)= sbest; solution(i,4)= COSTnew; solution(i,5)= COSTbest; end else display('s not in valid range'); end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online