|
| solver = pa.PANOCSolver(pa.PANOCParams(), pa.LBFGSDirection(pa.LBFGSParams())) |
|
| l = pa.LBFGSParams(cbfgs=pa.LBFGSParamsCBFGS(α=5)) |
|
| α |
|
| hess_prod = lambda L, x, v: cs.gradient(cs.jtimes(L, x, v, False), x) |
|
int | n = 2 |
|
int | m = 2 |
|
| x = cs.SX.sym("x", n) |
|
| λ = cs.SX.sym("λ", m) |
|
| v = cs.SX.sym("v", n) |
|
| Q = np.array([[1.5, 0.5], [0.5, 1.5]]) |
|
| f_ = x.T @ Q @ x |
|
| g_ = x |
|
int | L = f_ + cs.dot(λ, g_) if m > 0 else f_ |
|
| f = cs.Function("f", [x], [f_]) |
|
| grad_f = cs.Function("grad_f", [x], [cs.gradient(f_, x)]) |
|
| g = cs.Function("g", [x], [g_]) |
|
| grad_g_prod = cs.Function("grad_g_prod", [x, λ], [cs.jtimes(g_, x, λ, True)]) |
|
| grad_gi = lambda x, i: grad_g_prod(x, np.eye(1, m, i)) |
|
| Hess_L = cs.Function("Hess_L", [x, λ], [cs.hessian(L, x)[0]]) |
|
| Hess_L_prod = cs.Function("Hess_L_prod", [x, λ, v], [hess_prod(L, x, v)]) |
|
| p = pa.Problem(n, m) |
|
| hess_L |
|
| hess_L_prod |
|
| lowerbound |
|
| upperbound |
|
| x0 = np.array([3, 3]) |
|
| y0 = np.zeros((m,)) |
|
int | Σ = 1e3 * np.ones((m,)) |
|
int | ε = 1e-8 |
|
| y |
|
| err_z |
|
| stats |
|
| almparams = pa.ALMParams(max_iter=20, print_interval=1, preconditioning=False) |
|
| almsolver = pa.ALMSolver(almparams, solver) |
|
| old_x0 = x0 |
|
| sol = almsolver(p, x=x0, y=y0) |
|
string | name = "testproblem" |
|
| p0 = np.array([1.5, 0.5, 1.5]) |
|
| prob = pa.generate_and_compile_casadi_problem(f, g, name=name) |
|
| param |
|
| prob1 = pa.ProblemWithParamWithCounters(prob) |
|
| prob2 = pa.ProblemWithCounters(prob) |
|
| C = pa.Box([10], [-2.5]) |
|
| params |
|
| max_iter |
|