This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: HW1 Solutions Total points possible: 20 Simple optimization algorithms: We wish to minimize the following simple one dimensional cost function: Costs( s ) = (400 – ( s – 21) 2 ) * sin( s *pi/6) Constraints : s integervalued, s 500 Part(a): (2 points) Write a MATLAB function cost.m that implements the cost function, i.e. accepts input s , and returns COST( s ). Make sure the cost function is correct (i.e. COST(10) 241.621). Submit a plot of the given cost function with respect to s over the range of s . If plot is plotted as a line, comment that the function is discontinuous because of the constraints, but accept the line graph since it is easier to see. Part (b): (2 points) Write a MATLAB function neighbor.m that implements the neighborhood function, taking a single input s , and outputting a single neighboring value snew . The neighborhood is defined as follows: For each element s in the space, pick a neighboring solution randomly between max( s25,0) and min( s +25, 500). Note: s itself should not be in the neighborhood. However, it was not stated in the problem statement to do so, so you have not been penalized, but you should always ensure in future neighborhood definitions that s is not a neighbor of itself. HW1 Solutions Part (c): Random walk algorithm (2 points) Write a MATLAB function RW.m which implements the Random Walk algorithm. The function should have two inputs: a starting point sinitial , and a maximum number of...
View
Full Document
 Fall '11
 Shoemaker
 Optimization, Random walk, Matlab function

Click to edit the document details