{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw1 - HW1 Solutions Total points possible 20 Simple...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the 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 integer-valued, 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( s-25,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

{[ snackBarMessage ]}

### Page1 / 5

hw1 - HW1 Solutions Total points possible 20 Simple...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online