Closed pkofod closed 4 years ago
in NWI with
is_something(x) = isnothing(x) ? false : true function polynomial!(H, g, x) fx = (10.0 - x[1])^2 + (7.0 - x[2])^4 + (108.0 - x[3])^4 if is_something(g) g[1] = -2.0 * (10.0 - x[1]) g[2] = -4.0 * (7.0 - x[2])^3 g[3] = -4.0 * (108.0 - x[3])^3 end if is_something(H) H[1, 1] = 2.0 H[1, 2] = 0.0 H[1, 3] = 0.0 H[2, 1] = 0.0 H[2, 2] = 12.0 * (7.0 - x[2])^2 H[2, 3] = 0.0 H[3, 1] = 0.0 H[3, 2] = 0.0 H[3, 3] = 12.0 * (108.0 - x[3])^2 end objective_return(fx, g, H) end x0 = [0.0, 0.0, 0.0] xopt = [10.0, 7.0, 108.0] td_obj = TwiceDiffed(polynomial!) minimize!(td_obj, copy(x0), (SR1(Direct()), NWI()))
in NWI with