alpaqa 0.0.1
Nonconvex constrained optimization
Namespaces | Functions | Variables
rosenbrock.py File Reference

Go to the source code of this file.

Namespaces

namespace  rosenbrock
 

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