Skip to content

Commit

Permalink
OCP: Allow specifying separate penalty_alm_split_N
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Oct 17, 2023
1 parent a195d41 commit a1c4c9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/alpaqa/casadi_generator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,18 @@ def write_casadi_problem_data(sofile, C, D, param, l1_reg, penalty_alm_split):
writerow(l1_reg)
f.write(str(penalty_alm_split))

def write_casadi_control_problem_data(sofile, U, D, D_N, x_init, param, penalty_alm_split=0):
def write_casadi_control_problem_data(
sofile, U, D, D_N, x_init, param, penalty_alm_split=0, penalty_alm_split_N=None
):
if U is None and D is None and D_N is None and x_init is None and param is None:
return
U = ([], []) if U is None else U
D = ([], []) if D is None else D
D_N = ([], []) if D_N is None else D_N
x_init = [] if x_init is None else x_init
param = [] if param is None else param
if penalty_alm_split_N is None:
penalty_alm_split_N = penalty_alm_split
with open(f"{splitext(sofile)[0]}.csv", "w") as f:
opt = dict(delimiter=",", newline="\n")
ravelrow = lambda x: np.reshape(x, (1, -1), order="A")
Expand All @@ -562,4 +566,4 @@ def write_casadi_control_problem_data(sofile, U, D, D_N, x_init, param, penalty_
writerow(try_ub(D_N))
writerow(x_init)
writerow(param)
f.write(str(penalty_alm_split))
f.write(f"{penalty_alm_split} {penalty_alm_split_N}")
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ void CasADiControlProblem<Conf>::load_numerical_data(
wrap_data_load("param", this->param);
// Penalty/ALM split is a single integer
read_single("penalty_alm_split", this->penalty_alm_split);
read_single("penalty_alm_split_N", this->penalty_alm_split_N);
}

template <Config Conf>
Expand Down

0 comments on commit a1c4c9d

Please sign in to comment.