Generating plots from the ALGORITHMS FOR OPTIMIZATION book by Kochenderfer et al

I was reading through the Algorithms for Optimization book by Kochenderfer and Wheeler. The books is replete with excellent julia code for running optimization algorithms. One challenge I have with the book is that they did not provide plotting code, to help replicate the graphs in the book. I believe that the authors are working on including plotting code for the next edition, but until then I would like to try writing some of these plots myself.

I was wondering if someone could help my to generate the following plot for gradient descent on the Rosenbrock banana function. Plotting the function is not hard, but I am not sure how to plot those isocline or level sets of the Rosenbrock function.

I have the gradient descent code and also code for the Rosenbrock function below, but could someone help to plot the isoclines here. Thanks.

Here is the plot from the book with the isoclines (p.71):

Here is the code.

abstract type DescentMethod end
struct GradientDescent <: DescentMethod

init!(M::GradientDescent, f, ∇f, x) = M

function step!(M::GradientDescent, f, ∇f, x)
    α, g = M.α, ∇f(x)
    return x - α*g

rosenbrock(x; a=1, b=5) = (a-x[1])^2 + b*(x[2] - x[1]^2)^2

Have you checked the GitHub repos ?

1 Like

Ohh, I did not even see these notebooks. I looked at the repo for the books, but did not catch the repo for the notebooks. Okay very good. This is even better. Thanks for pointing these out.

1 Like