Go to the source code of this file.
|
| int | n = 10 |
| |
| int | ε = 1e-12 |
| |
| | rng = nprand.default_rng(seed=123) |
| |
| | A = rng.random(size=(n, n)) |
| |
| | Q |
| |
| | D = np.diag(rng.normal(scale=4, size=(n, ))) |
| |
| | q = rng.normal(scale=1, size=(n, )) |
| |
| | x_ = cs.SX.sym('x', n) |
| |
| float | px = x_ + 0.2 * cs.sin(x_[::-1]) |
| |
| float | f_ = 0.5 * (x_.T @ A @ px) + cs.dot(q, x_) |
| |
| | f = cs.Function("f", [x_], [f_]) |
| |
| | grad_f_ = cs.gradient(f_, x_) |
| |
| | grad_f = cs.Function("grad_f", [x_], [grad_f_]) |
| |
| | hess_f_ = cs.jacobian(grad_f_, x_) |
| |
| | hess_f = cs.Function("hess_f", [x_], [hess_f_]) |
| |
| int | L = la.norm(D)**2 |
| |