Variables subject to optimization are updated in-place at the end of optimization.
Of course, the code will not work.
I was unable to find YouTube videos that fully explained step-by-step procedures.
The tol vector must be of length n the dimension specified in the nlopt::opt constructor.
It helps to organize an application into small, human-digestible chunks.
Demo It works: See the Pen by Chris Coyier on.