9x1, x2 = cs.SX.sym(
"x1"), cs.SX.sym(
"x2")
14f_expr = (1 - x1) ** 2 + p * (x2 - x1 ** 2) ** 2
16 (x1 - 0.5) ** 3 - x2 + 1,
23f = cs.Function(
"f", [x, p], [f_expr])
24g = cs.Function(
"g", [x, p], [g_expr])
30prob = pa.generate_and_compile_casadi_problem(f, g)
34prob.C.lowerbound = [-0.25, -0.5]
35prob.C.upperbound = [1.5, 2.5]
36prob.D.lowerbound = [-np.inf, -np.inf]
37prob.D.upperbound = [0, 0]
43innersolver = pa.StructuredPANOCLBFGSSolver()
44solver = pa.ALMSolver(innersolver)
47inner_solver = pa.StructuredPANOCLBFGSSolver(
50 'stop_crit': pa.PANOCStopCrit.ApproxKKT,
65 inner_solver=inner_solver
71x0 = np.array([0.1, 1.8])
72y0 = np.zeros((prob.m,))
75x_sol, y_sol, stats =
solver(prob, x0, y0)
79print(f
"Solution: {x_sol}")
80print(f
"Multipliers: {y_sol}")
81print(f
"Cost: {prob.f(x_sol)}")
82print(f
"ε: {stats['ε']}")
83print(f
"δ: {stats['δ']}")