8000 Allow `solver_options.N_horizon=0` by Confectio · Pull Request #1498 · acados/acados · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow solver_options.N_horizon=0 #1498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
581f415
Change example to how it should be
Confectio Apr 8, 2025
d1207a2
Allow N = 0 in ocp options
Confectio Apr 8, 2025
b916645
Allow setting of N=0 in acados dims
Confectio Apr 8, 2025
ce4543e
Refactor make_consistent into smaller functions for costs and constra…
Confectio Apr 8, 2025
9292c50
add underscores
Confectio Apr 8, 2025
0269dab
Move checks for N_horizon to the beginning
Confectio Apr 8, 2025
46f98d5
Continue until solution sensitivities
Confectio Apr 8, 2025
44a0a41
continued until qp condensing size
Confectio Apr 8, 2025
2a7b9dd
First draft of new make_consistent
Confectio Apr 9, 2025
bce064e
bugfix
Confectio Apr 9, 2025
eff3e32
adjusted generation context
Confectio Apr 9, 2025
45aec86
Dont try to render some templates
Confectio Apr 9, 2025
00c40d5
create setup dims templating and updating time steps and cond_N
Confectio Apr 9, 2025
bdecb66
Add cond_N > N_horizon check
Confectio Apr 9, 2025
b77330f
remove unused list
Confectio Apr 9, 2025
b8d6dca
changes until 5) acados_create_setup_functions
Confectio Apr 9, 2025
19784e1
updated acados_setup_nlp_in
Confectio Apr 9, 2025
a1ea28a
Pray that I free all things that should be freed, and don't free thin…
Confectio Apr 9, 2025
d0d59b6
fix typo
Confectio Apr 9, 2025
01c62ab
Bugfixes in templating
Confectio Apr 9, 2025
c92e232
Dont obtain sens_u in example, because there is no u
Confectio Apr 9, 2025
5485e12
bugfix
Confectio Apr 9, 2025
85d8450
Bugfix
Confectio Apr 9, 2025
adac3c3
Bugfix stupid copypaste error
Confectio Apr 9, 2025
7d6fbdf
Bugfix in templating
Confectio Apr 9, 2025
6c91fc6
Change matlab example
Confectio Apr 9, 2025
18440da
Bugfix in templating
Confectio Apr 9, 2025
1658659
move env.sh to example dir
Confectio Apr 10, 2025
8d0bb27
Small beauty fix in acados ocp .py
Confectio Apr 10, 2025
0a7e1fb
Move qpdunes x0 elimination to make_consistent
Confectio Apr 10, 2025
6ad58b6
update matlab make consistent
Confectio Apr 10, 2025
eca0d9a
renaming
Confectio Apr 10, 2025
a9b3ce5
updated setup code generation context
Confectio Apr 10, 2025
3dd4256
Fix numpy array in matlab
Confectio Apr 10, 2025
aaf2509
Fix python syntax
Confectio Apr 10, 2025
9b136d9
Fix using python syntax in matlab II
Confectio Apr 10, 2025
7ee61d4
Fix more bugs
Confectio Apr 10, 2025
ac44091
Fix CMakeLists templating
Confectio Apr 10, 2025
688d03f
fix missing dim variables
Confectio Apr 10, 2025
dbd097e
Fix CMakeLists templating for sim solver
Confectio Apr 10, 2025
524bb8e
fix undefined N
Confectio Apr 10, 2025
7894521
only use N_horizon directly
Confectio Apr 10, 2025
5ff3804
fix missing variable
Confectio Apr 10, 2025
eb97f02
fixed undefined N
Confectio Apr 10, 2025
5acc655
Changed maratos test problem to N=0
Confectio Apr 10, 2025
be90790
Fix maratos test problem temporarily (added TODOS)
Confectio Apr 10, 2025
e41e9ec
Add env.sh to example
Confectio Apr 10, 2025
b61233e
Updated matlab example to N=0
Confectio Apr 10, 2025
d347d78
fix setting
Confectio Apr 10, 2025
b1e3575
get correct field
Confectio Apr 10, 2025
6af2ff1
made check more flexible for N=0
Confectio Apr 10, 2025
5a14a53
Forgot variable assignment
Confectio Apr 11, 2025
8cc5c3c
remove u and update comments in maratos
Confectio Apr 11, 2025
0fab54a
removed p in maratos
Confectio Apr 11, 2025
ea33ad5
Improve readability (some matlab indentation)
Confectio Apr 11, 2025
8aaf240
Remove some tabs, add underscores
Confectio Apr 11, 2025
c230e9b
More space between functions
Confectio Apr 11, 2025
c2de20c
space between functions
Confectio Apr 11, 2025
942a7fe
Update hpipm
Confectio Apr 11, 2025
45b5d8a
trailing spaces
FreyJo Apr 11, 2025
8bbd665
remove redundant return
FreyJo Apr 11, 2025
d600d23
rm prints
FreyJo Apr 11, 2025
1ec439e
Merge branch 'main' into NequalsZero
FreyJo Apr 12, 2025
3d17d43
undo changes in maratos test problem for now
FreyJo Apr 12, 2025
cdd8f07
remove return -1
FreyJo Apr 12, 2025
48a1c90
refactor maratos test
FreyJo Apr 12, 2025
96477bf
example: fully remove FOR_LOOPING, adjust test
FreyJo Apr 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@
x = SX.sym('x');

% dynamics: identity
model.disc_dyn_expr = x;
model.x = x;
model.name = strcat('convex_problem_', globalization);

%% solver settings
T = 1;
N_horizon = 1;
N_horizon = 0;

%% OCP formulation object
ocp = AcadosOcp();
Expand All @@ -63,11 +61,8 @@
% terminal cost term
ocp.cost.cost_type_e = 'EXTERNAL';
ocp.model.cost_expr_ext_cost_e = log(exp(model.x) + exp(-model.x));
ocp.cost.cost_type = 'EXTERNAL';
ocp.model.cost_expr_ext_cost = 0;

% define solver options
ocp.solver_options.tf = T;
ocp.solver_options.N_horizon = N_horizon;
ocp.solver_options.qp_solver = 'FULL_CONDENSING_HPIPM';
ocp.solver_options.hessian_approx = 'EXACT';
Expand All @@ -87,7 +82,6 @@

% set trajectory initialization
ocp_solver.set('init_x', xinit, 0);
ocp_solver.set('init_x', xinit, 1);

% solve
ocp_solver.solve();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#! /usr/bin/bash
#
# Copyright (c) The acados authors.
#
# This file is part of acados.
#
# The 2-Clause BSD License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.;
#


if [[ "${BASH_SOURCE[0]}" != "${0}" ]]
then
echo "Script is being sourced"
else
echo "ERROR: Script is a subshell"
echo "To affect your current shell enviroment source this script with:"
echo "source env.sh"
exit
fi

# check that this file is run
export ENV_RUN=true

# if acados folder not specified assume parent of the folder of the single examples
ACADOS_INSTALL_DIR=${ACADOS_INSTALL_DIR:-"$(pwd)/../../.."}
export ACADOS_INSTALL_DIR
echo
echo "ACADOS_INSTALL_DIR=$ACADOS_INSTALL_DIR"

# export casadi folder and matlab/octave mex folder
# MATLAB case
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/external/casadi-matlab/
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/acados_template_mex/

echo
echo "MATLABPATH=$MATLABPATH"
# Octave case
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/external/casadi-octave/
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/acados_template_mex/
echo
echo "OCTAVE_PATH=$OCTAVE_PATH"

# export acados mex flags
#export ACADOS_MEX_FLAGS="GCC=/usr/bin/gcc-4.9"

# if model folder not specified assume this folder
MODEL_FOLDER=${MODEL_FOLDER:-"./build"}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ACADOS_INSTALL_DIR/lib:$MODEL_FOLDER
export LD_RUN_PATH="$(pwd)"/c_generated_code
echo
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
75 changes: 75 additions & 0 deletions examples/acados_matlab_octave/generic_nlp/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#! /usr/bin/bash
#
# Copyright (c) The acados authors.
#
# This file is part of acados.
#
# The 2-Clause BSD License
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.;
#


if [[ "${BASH_SOURCE[0]}" != "${0}" ]]
then
echo "Script is being sourced"
else
echo "ERROR: Script is a subshell"
echo "To affect your current shell enviroment source this script with:"
echo "source env.sh"
exit
fi

# check that this file is run
export ENV_RUN=true

# if acados folder not specified assume parent of the folder of the single examples
ACADOS_INSTALL_DIR=${ACADOS_INSTALL_DIR:-"$(pwd)/../../.."}
export ACADOS_INSTALL_DIR
echo
echo "ACADOS_INSTALL_DIR=$ACADOS_INSTALL_DIR"

# export casadi folder and matlab/octave mex folder
# MATLAB case
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/external/casadi-matlab/
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/
export MATLABPATH=$MATLABPATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/acados_template_mex/

echo
echo "MATLABPATH=$MATLABPATH"
# Octave case
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/external/casadi-octave/
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/
export OCTAVE_PATH=$OCTAVE_PATH:$ACADOS_INSTALL_DIR/interfaces/acados_matlab_octave/acados_template_mex/
echo
echo "OCTAVE_PATH=$OCTAVE_PATH"

# export acados mex flags
#export ACADOS_MEX_FLAGS="GCC=/usr/bin/gcc-4.9"

# if model folder not specified assume this folder
MODEL_FOLDER=${MODEL_FOLDER:-"./build"}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ACADOS_INSTALL_DIR/lib:$MODEL_FOLDER
export LD_RUN_PATH="$(pwd)"/c_generated_code
echo
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
18 changes: 4 additions & 14 deletions examples/acados_matlab_octave/generic_nlp/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
model.name = 'generic_nlp';
model.x = x;
model.p = p;
model.f_expl_expr = casadi.SX.zeros(length(model.x),1);

%% acados ocp formulation
ocp = AcadosOcp();
Expand All @@ -66,27 +65,18 @@
% initial parameter values
ocp.parameter_values = zeros(length(model.p),1);

% set additional fields to prevent errors/warnings
ocp.cost.cost_type_0 = 'EXTERNAL';
ocp.model.cost_expr_ext_cost_0 = 0;
ocp.cost.cost_type = 'EXTERNAL';
ocp.model.cost_expr_ext_cost = 0;

%% solver options
ocp.solver_options.tf = 1;
ocp.solver_options.N_horizon = 1;
ocp.solver_options.N_horizon = 0;
ocp.solver_options.nlp_solver_type = 'SQP';
ocp.solver_options.integrator_type = 'ERK';
ocp.solver_options.sim_method_num_stages = 1;
ocp.solver_options.sim_method_num_steps = 1;
ocp.solver_options.qp_solver = 'FULL_CONDENSING_HPIPM'; %TODO: Change after PARTIAL_CONDENSING_HPIPM fix

%% create the solver
ocp_solver = AcadosOcpSolver(ocp);

%% solve the NLP
% initial guess
init_x = [2.5; 3.0];
ocp_solver.set('init_x', repmat(init_x,1,2));
ocp_solver.set('init_x', init_x);

% set the parameters
p_value = [1;1];
Expand All @@ -104,7 +94,7 @@
end

% display results
x_opt = ocp_solver.get('x',1);
x_opt = ocp_solver.get('x', 0);
disp('Optimal solution:') % should be [1;1] for p = [1;1]
disp(x_opt)
disp(['Total time: ', num2str(1e3*total_time), ' ms'])
Expand Down
Loading
Loading
0