diff --git a/Julia/README.md b/Julia/README.md index aa69493..86dd36d 100644 --- a/Julia/README.md +++ b/Julia/README.md @@ -1,5 +1,5 @@ # Julia -[![Dev](https://img.shields.io/badge/docs-latest-blue.svg)](https://TUM-ITR.github.io/PGopt) +[![Dev](https://img.shields.io/badge/docs-stable-blue?logo=Julia&logoColor=white)](https://TUM-ITR.github.io/PGopt) 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. diff --git a/Julia/docs/src/index.md b/Julia/docs/src/index.md index 36fca62..321dd95 100644 --- a/Julia/docs/src/index.md +++ b/Julia/docs/src/index.md @@ -12,9 +12,9 @@ This document describes the Julia implementation of `PGopt`, which does not requ 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). ## Installation -PGopt can be installed using the Julia package manager. Start a Pkg REPL (press `]` in a Julia REPL), and install PGopt via +`PGopt` can be installed using the Julia package manager. Start a Pkg REPL (press `]` in a Julia REPL), and install `PGopt` via ``` -pkg> add https://github.com/TUM-ITR/PGopt:Julia +pkg>add https://github.com/TUM-ITR/PGopt:Julia ``` 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 diff --git a/MATLAB/examples/PG_OCP_generic_basis_functions.m b/MATLAB/examples/PG_OCP_generic_basis_functions.m index 39b6d38..eed246e 100644 --- a/MATLAB/examples/PG_OCP_generic_basis_functions.m +++ b/MATLAB/examples/PG_OCP_generic_basis_functions.m @@ -1,6 +1,6 @@ % 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 % "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. -% Since the Julia implementation was used for the results in the paper, the results are not exactly reproduced due to different random numbers. +% Since the Julia implementation was used for the results in the paper, the results are not exactly reproduced. % Clear clear; @@ -170,7 +170,7 @@ %% Test the learned models. % Test the models with the test data by simulating it forward in time. -test_prediction(PG_samples, phi_sampling, g, R, 10, u_test, y_test); +% test_prediction(PG_samples, phi_sampling, g, R, 10, u_test, y_test); %% Plot autocorrelation. % plot_autocorrelation(PG_samples, 'max_lag', 100) @@ -198,8 +198,11 @@ % This function is only used for the optimization as it is less efficient. phi = @(x, u) phi_opt(n_phi, n_z, L, j_vec, x, u); +% Ipopt options +Ipopt_options = struct('linear_solver', 'ma57', 'max_iter', 10000); + % Solve the PG OCP. -[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); +[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); %% Test solution if solve_successful diff --git a/MATLAB/examples/PG_OCP_known_basis_functions.m b/MATLAB/examples/PG_OCP_known_basis_functions.m index d034b12..fd22af3 100644 --- a/MATLAB/examples/PG_OCP_known_basis_functions.m +++ b/MATLAB/examples/PG_OCP_known_basis_functions.m @@ -140,11 +140,14 @@ % Confidence parameter for the theoretical guarantees beta = 0.01; +% Ipopt options +Ipopt_options = struct('linear_solver', 'ma57', 'max_iter', 10000); + % Solve the PG OCP. -% [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); +% [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); % Solve the PG OCP and determine complexity s and max constraint violation probability via greedy algorithm. -[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); +[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); %% Test solution if solve_successful diff --git a/MATLAB/figures/PG_OCP_generic_basis_functions.svg b/MATLAB/figures/PG_OCP_generic_basis_functions.svg index f9cbaf2..95a4933 100644 --- a/MATLAB/figures/PG_OCP_generic_basis_functions.svg +++ b/MATLAB/figures/PG_OCP_generic_basis_functions.svg @@ -70,31 +70,31 @@ />predicted output vs. true output0510152025303540t-5-4-3-2-1012345predicted output vs. true output-5-4-3-2-10123456