Skip to content

Commit 781b7c8

Browse files
committed
fix python example
1 parent 98becdf commit 781b7c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/ocp_impl_example_opti.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def path_constraints(uk, xk ,k):
4141
opti = cs.Opti()
4242
x = []
4343
u = []
44+
ng = []
4445
for k in range(K):
4546
x.append(opti.variable(nx[k]))
4647
u.append(opti.variable(nu[k]))
@@ -51,6 +52,7 @@ def path_constraints(uk, xk ,k):
5152
path_constr = path_constraints(u[k], x[k], k)
5253
for constr in path_constr:
5354
opti.subject_to(constr)
55+
ng.append(cs.vvcat(path_constr).nnz())
5456
# set the objective
5557
J = 0
5658
for k in range(K):
@@ -60,4 +62,4 @@ def path_constraints(uk, xk ,k):
6062
opti.solver('fatrop', {'structure_detection':'manual', 'nx': nx, 'nu':nu, 'ng':ng, 'N':K-1, "expand": True, "fatrop.mu_init":1e-1, "jit":False, "jit_options": {"flags": "-O3", "verbose": True}})
6163
opti.to_function("opti_func", [], [opti.x]).generate('casadi_generated.c', {"with_header": True})
6264
# opti.solver('ipopt', {'ipopt.print_info_string': 'yes', 'ipopt.kappa_d':0.})
63-
opti.solve()
65+
opti.solve()

0 commit comments

Comments
 (0)