PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
Classes | Variables
panocpy.test Namespace Reference

Classes

class  CustomInnerSolver
 
class  Dir
 

Variables

 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"
 
 cgen
 
 num_p
 
 prefix
 
 cfile = cgen.generate(join(tmpdir, ""))
 
 sofile = join(tmpdir, f"{name}.so")
 
 C = pa.Box([10], [-2.5])
 
 params
 

Variable Documentation

◆ solver

solver = pa.PANOCSolver(pa.PANOCParams(), pa.LBFGSDirection(pa.LBFGSParams()))
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 8 of file test.py.

◆ l

l = pa.LBFGSParams(cbfgs=pa.LBFGSParamsCBFGS(α=5))

Definition at line 29 of file test.py.

◆ α

α

Definition at line 31 of file test.py.

◆ hess_prod

hess_prod = lambda L, x, v: cs.gradient(cs.jtimes(L, x, v, False), x)

Definition at line 36 of file test.py.

◆ n

int n = 2

Definition at line 38 of file test.py.

◆ m

int m = 2

Definition at line 39 of file test.py.

◆ x

x = cs.SX.sym("x", n)
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 40 of file test.py.

◆ λ

λ = cs.SX.sym("λ", m)

Definition at line 41 of file test.py.

◆ v

v = cs.SX.sym("v", n)

Definition at line 42 of file test.py.

◆ Q

Q = np.array([[1.5, 0.5], [0.5, 1.5]])

Definition at line 44 of file test.py.

◆ f_

float f_ = x.T @ Q @ x

Definition at line 45 of file test.py.

◆ g_

g_ = x

Definition at line 46 of file test.py.

◆ L

int L = f_ + cs.dot(λ, g_) if m > 0 else f_

Definition at line 47 of file test.py.

◆ f

f = cs.Function("f", [x], [f_])

Definition at line 49 of file test.py.

◆ grad_f

int grad_f = cs.Function("grad_f", [x], [cs.gradient(f_, x)])

Definition at line 50 of file test.py.

◆ g

g = cs.Function("g", [x], [g_])
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 51 of file test.py.

◆ grad_g_prod

grad_g_prod = cs.Function("grad_g_prod", [x, λ], [cs.jtimes(g_, x, λ, True)])

Definition at line 52 of file test.py.

◆ grad_gi

grad_gi = lambda x, i: grad_g_prod(x, np.eye(1, m, i))

Definition at line 53 of file test.py.

◆ Hess_L

Hess_L = cs.Function("Hess_L", [x, λ], [cs.hessian(L, x)[0]])

Definition at line 54 of file test.py.

◆ Hess_L_prod

Hess_L_prod = cs.Function("Hess_L_prod", [x, λ, v], [hess_prod(L, x, v)])

Definition at line 55 of file test.py.

◆ p

p = pa.Problem(n, m)
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 57 of file test.py.

◆ hess_L

hess_L

Definition at line 63 of file test.py.

◆ hess_L_prod

hess_L_prod

Definition at line 64 of file test.py.

◆ lowerbound

lowerbound

Definition at line 65 of file test.py.

◆ upperbound

upperbound

Definition at line 66 of file test.py.

◆ x0

list x0 = np.array([3, 3])

Definition at line 68 of file test.py.

◆ y0

y0 = np.zeros((m,))

Definition at line 69 of file test.py.

◆ Σ

int Σ = 1e3 * np.ones((m,))

Definition at line 70 of file test.py.

◆ ε

int ε = 1e-8

Definition at line 71 of file test.py.

◆ y

y
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 76 of file test.py.

◆ err_z

err_z

Definition at line 76 of file test.py.

◆ stats

stats
Examples
CasADi/Rosenbrock/main.cpp, and CUTEst/Rosenbrock/main.cpp.

Definition at line 76 of file test.py.

◆ almparams

almparams = pa.ALMParams(max_iter=20, print_interval=1, preconditioning=False)

Definition at line 86 of file test.py.

◆ almsolver

almsolver = pa.ALMSolver(almparams, solver)

Definition at line 87 of file test.py.

◆ old_x0

old_x0 = x0

Definition at line 140 of file test.py.

◆ sol

sol = almsolver(p, x=x0, y=y0)

Definition at line 142 of file test.py.

◆ name

name = "testproblem"

Definition at line 169 of file test.py.

◆ cgen

cgen

Definition at line 170 of file test.py.

◆ num_p

num_p

Definition at line 170 of file test.py.

◆ prefix

prefix

Definition at line 172 of file test.py.

◆ cfile

cfile = cgen.generate(join(tmpdir, ""))

Definition at line 173 of file test.py.

◆ sofile

sofile = join(tmpdir, f"{name}.so")

Definition at line 174 of file test.py.

◆ C

C = pa.Box([10], [-2.5])

Definition at line 204 of file test.py.

◆ params

params

Definition at line 217 of file test.py.