alpaqa 0.0.1
Nonconvex constrained optimization
Functions | Variables
rosenbrock Namespace Reference

Functions

def cb (it)
 

Variables

 x1
 
 x2
 
 p = cs.SX.sym("p")
 
tuple f_expr = (1 - x1) ** 2 + p * (x2 - x1 ** 2) ** 2
 
 g_expr
 
 x = cs.vertcat(x1, x2)
 
 f = cs.Function("f", [x, p], [f_expr])
 
 g = cs.Function("g", [x, p], [g_expr])
 
 prob = pa.generate_and_compile_casadi_problem(f, g)
 
 lowerbound
 
 upperbound
 
 param
 
 innersolver
 
list iterates = []
 
 solver
 
 x0 = np.array([0.1, 1.8])
 
 y0 = np.zeros((prob.m,))
 
 x_sol
 
 y_sol
 
 stats
 
 cost_function_v = np.vectorize(prob.f, signature='(n)->()')
 
 constraint_g_v = np.vectorize(prob.g, signature='(n)->(m)')
 
 y = np.linspace(-0.5, 2.5, 256)
 
 X
 
 Y
 
 XY = np.vstack([[X], [Y]]).T
 
 figsize
 
 Zf = cost_function_v(XY).T
 
 Zg = constraint_g_v(XY)
 
 Zgc = Zg[:,:,0].T
 
 Zgl = Zg[:,:,1].T
 
list fx = [patheffects.withTickedStroke(spacing=7, linewidth=0.8)]
 
 cgc = plt.contour(X, Y, Zgc, [0], colors='black', linewidths=0.8, linestyles='-')
 
 collections
 
 path_effects
 
 cgl = plt.contour(X, Y, Zgl, [0], colors='black', linewidths=0.8, linestyles='-')
 
 xl = plt.contour(X, Y, -X, [-prob.C.lowerbound[0]], colors='black', linewidths=0.8, linestyles='-')
 
 xy = np.array(iterates)
 
 markersize
 
 linewidth
 
 fillstyle
 

Function Documentation

◆ cb()

def rosenbrock.cb (   it)

Definition at line 56 of file rosenbrock.py.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ x1

x1

Definition at line 9 of file rosenbrock.py.

◆ x2

x2

Definition at line 9 of file rosenbrock.py.

◆ p

p = cs.SX.sym("p")

Definition at line 11 of file rosenbrock.py.

◆ f_expr

tuple f_expr = (1 - x1) ** 2 + p * (x2 - x1 ** 2) ** 2

Definition at line 14 of file rosenbrock.py.

◆ g_expr

g_expr
Initial value:
1= cs.vertcat(
2 (x1 - 0.5) ** 3 - x2 + 1,
3 x1 + x2 - 1.5,
4)

Definition at line 15 of file rosenbrock.py.

◆ x

x = cs.vertcat(x1, x2)

Definition at line 21 of file rosenbrock.py.

◆ f

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

Definition at line 23 of file rosenbrock.py.

◆ g

g = cs.Function("g", [x, p], [g_expr])

Definition at line 24 of file rosenbrock.py.

◆ prob

prob = pa.generate_and_compile_casadi_problem(f, g)

Definition at line 30 of file rosenbrock.py.

◆ lowerbound

lowerbound

Definition at line 34 of file rosenbrock.py.

◆ upperbound

upperbound

Definition at line 35 of file rosenbrock.py.

◆ param

param

Definition at line 40 of file rosenbrock.py.

◆ innersolver

innersolver
Initial value:
1= pa.StructuredPANOCLBFGSSolver(
2 pa.StructuredPANOCLBFGSParams(
3 max_iter=1000,
4 stop_crit=pa.PANOCStopCrit.ApproxKKT,
5 ),
6 pa.LBFGSParams(
7 memory=10,
8 ),
9)

Definition at line 43 of file rosenbrock.py.

◆ iterates

list iterates = []

Definition at line 55 of file rosenbrock.py.

◆ solver

solver
Initial value:
1= pa.ALMSolver(
2 pa.ALMParams(
3 ε=1e-10,
4 δ=1e-10,
5 Σ_0=0,
6 σ_0=2,
7 Δ=20,
8 ),
9 innersolver
10)

Definition at line 62 of file rosenbrock.py.

◆ x0

x0 = np.array([0.1, 1.8])

Definition at line 76 of file rosenbrock.py.

◆ y0

y0 = np.zeros((prob.m,))

Definition at line 77 of file rosenbrock.py.

◆ x_sol

x_sol

Definition at line 80 of file rosenbrock.py.

◆ y_sol

y_sol

Definition at line 80 of file rosenbrock.py.

◆ stats

stats

Definition at line 80 of file rosenbrock.py.

◆ cost_function_v

cost_function_v = np.vectorize(prob.f, signature='(n)->()')

Definition at line 95 of file rosenbrock.py.

◆ constraint_g_v

constraint_g_v = np.vectorize(prob.g, signature='(n)->(m)')

Definition at line 96 of file rosenbrock.py.

◆ y

y = np.linspace(-0.5, 2.5, 256)

Definition at line 99 of file rosenbrock.py.

◆ X

X

Definition at line 100 of file rosenbrock.py.

◆ Y

Y

Definition at line 100 of file rosenbrock.py.

◆ XY

XY = np.vstack([[X], [Y]]).T

Definition at line 101 of file rosenbrock.py.

◆ figsize

figsize

Definition at line 103 of file rosenbrock.py.

◆ Zf

Definition at line 105 of file rosenbrock.py.

◆ Zg

Definition at line 109 of file rosenbrock.py.

◆ Zgc

Zgc = Zg[:,:,0].T

Definition at line 110 of file rosenbrock.py.

◆ Zgl

Zgl = Zg[:,:,1].T

Definition at line 111 of file rosenbrock.py.

◆ fx

list fx = [patheffects.withTickedStroke(spacing=7, linewidth=0.8)]

Definition at line 112 of file rosenbrock.py.

◆ cgc

cgc = plt.contour(X, Y, Zgc, [0], colors='black', linewidths=0.8, linestyles='-')

Definition at line 113 of file rosenbrock.py.

◆ collections

collections

Definition at line 114 of file rosenbrock.py.

◆ path_effects

path_effects

Definition at line 114 of file rosenbrock.py.

◆ cgl

cgl = plt.contour(X, Y, Zgl, [0], colors='black', linewidths=0.8, linestyles='-')

Definition at line 115 of file rosenbrock.py.

◆ xl

xl = plt.contour(X, Y, -X, [-prob.C.lowerbound[0]], colors='black', linewidths=0.8, linestyles='-')

Definition at line 117 of file rosenbrock.py.

◆ xy

xy = np.array(iterates)

Definition at line 125 of file rosenbrock.py.

◆ markersize

markersize

Definition at line 126 of file rosenbrock.py.

◆ linewidth

linewidth

Definition at line 126 of file rosenbrock.py.

◆ fillstyle

fillstyle

Definition at line 127 of file rosenbrock.py.