Skip to content

Commit e871b3c

Browse files
Tidied up the MATLAB code. Updated the MATLAB plots. Updated the documentation.
1 parent 8f6a08e commit e871b3c

9 files changed

Lines changed: 112 additions & 144 deletions

Julia/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Julia
2-
[![Dev](https://img.shields.io/badge/docs-latest-blue.svg)](https://TUM-ITR.github.io/PGopt)
2+
[![Dev](https://img.shields.io/badge/docs-stable-blue?logo=Julia&logoColor=white)](https://TUM-ITR.github.io/PGopt)
33

44
This folder contains the Julia implementation of `PGopt`, which does not require proprietary software. The open-source solver [Altro](https://github.com/RoboticExplorationLab/Altro.jl) is used for the optimization. The results presented in the paper were generated with this version, and the software reproduces these results exactly.
55

Julia/docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ This document describes the Julia implementation of `PGopt`, which does not requ
1212
Besides the Julia implementation, there is also a MATLAB implementation, which is more general and allows arbitrary cost functions $J_H(u_{1:H},x_{1:H},y_{1:H})$, measurement functions $y=g(x,u)$, and constraints $h(u_{1:H},x_{1:H},y_{1:H})$. Further information can be found [here](https://github.com/TUM-ITR/PGopt/tree/main/MATLAB).
1313

1414
## Installation
15-
PGopt can be installed using the Julia package manager. Start a Pkg REPL (press `]` in a Julia REPL), and install PGopt via
15+
`PGopt` can be installed using the Julia package manager. Start a Pkg REPL (press `]` in a Julia REPL), and install `PGopt` via
1616
```
17-
pkg> add https://github.com/TUM-ITR/PGopt:Julia
17+
pkg>add https://github.com/TUM-ITR/PGopt:Julia
1818
```
1919

2020
Alternatively, to inspect the source code more easily, download the source code from [GitHub](https://github.com/TUM-ITR/PGopt). Navigate to the folder `PGopt/Julia`, start a Pkg REPL (press `]` in a Julia REPL), and install the dependencies via

MATLAB/examples/PG_OCP_generic_basis_functions.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% This code produces results for the optimal control approach with generic basis functions similar to the ones given in Section V-B (Fig. 3) of the paper
22
% "Learning-Based Optimal Control with Performance Guarantees for Unknown Systems with Latent States", available as pre-print on arXiv: https://arxiv.org/abs/2303.17963.
3-
% Since the Julia implementation was used for the results in the paper, the results are not exactly reproduced due to different random numbers.
3+
% Since the Julia implementation was used for the results in the paper, the results are not exactly reproduced.
44

55
% Clear
66
clear;
@@ -170,7 +170,7 @@
170170

171171
%% Test the learned models.
172172
% Test the models with the test data by simulating it forward in time.
173-
test_prediction(PG_samples, phi_sampling, g, R, 10, u_test, y_test);
173+
% test_prediction(PG_samples, phi_sampling, g, R, 10, u_test, y_test);
174174

175175
%% Plot autocorrelation.
176176
% plot_autocorrelation(PG_samples, 'max_lag', 100)
@@ -198,8 +198,11 @@
198198
% This function is only used for the optimization as it is less efficient.
199199
phi = @(x, u) phi_opt(n_phi, n_z, L, j_vec, x, u);
200200

201+
% Ipopt options
202+
Ipopt_options = struct('linear_solver', 'ma57', 'max_iter', 10000);
203+
201204
% Solve the PG OCP.
202-
[u_opt, x_opt, y_opt, J_opt, solve_successful, ~, ~] = solve_PG_OCP(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, 'J_u', true, 'K_pre_solve', 10);
205+
[u_opt, x_opt, y_opt, J_opt, solve_successful, ~, ~] = solve_PG_OCP(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, 'J_u', true, 'K_pre_solve', 5, 'solver_opts', Ipopt_options);
203206

204207
%% Test solution
205208
if solve_successful

MATLAB/examples/PG_OCP_known_basis_functions.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,14 @@
140140
% Confidence parameter for the theoretical guarantees
141141
beta = 0.01;
142142

143+
% Ipopt options
144+
Ipopt_options = struct('linear_solver', 'ma57', 'max_iter', 10000);
145+
143146
% Solve the PG OCP.
144-
% [u_opt, x_opt, y_opt, J_opt, solve_successful, ~, ~] = solve_PG_OCP(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, 'J_u', true, 'K_pre_solve', 10);
147+
% [u_opt, x_opt, y_opt, J_opt, solve_successful, ~, ~] = solve_PG_OCP(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, 'J_u', true, 'K_pre_solve', 5);
145148

146149
% Solve the PG OCP and determine complexity s and max constraint violation probability via greedy algorithm.
147-
[u_opt, x_opt, y_opt, J_opt, solve_successful, s, epsilon_prob, epsilon_perc, time_first_solve, time_guarantees, num_failed_optimizations] = solve_PG_OCP_greedy_guarantees(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, beta, 'J_u', true, 'K_pre_solve', 10);
150+
[u_opt, x_opt, y_opt, J_opt, solve_successful, s, epsilon_prob, epsilon_perc, time_first_solve, time_guarantees, num_failed_optimizations] = solve_PG_OCP_greedy_guarantees(PG_samples, phi, g, R, H, cost_function, scenario_constraints, input_constraints, beta, 'J_u', true, 'K_pre_solve', 5, 'solver_opts', Ipopt_options);
148151

149152
%% Test solution
150153
if solve_successful

0 commit comments

Comments
 (0)