Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
275 commits
Select commit Hold shift + click to select a range
18bf48c
Merge pull request #2 from astomodynamics:devel
astomodynamics Mar 12, 2024
ff84800
update readme
astomodynamics Mar 12, 2024
09f432a
delete print-out
astomodynamics Mar 12, 2024
9cdc497
delete unnecessary files
astomodynamics Mar 12, 2024
aceb9bc
fidelity check for backward pass
astomodynamics Mar 12, 2024
fdcfbbe
introduce osqp to forward pass
astomodynamics Mar 12, 2024
e1bc632
update readme
astomodynamics Mar 12, 2024
bdf87b0
Change objective gradient output datatype
astomodynamics Mar 12, 2024
00fbfd9
Update README
astomodynamics Mar 12, 2024
4d6d354
Change jacobian and hessian output datatype
astomodynamics Mar 13, 2024
f53d4e6
comment out temporary
astomodynamics Mar 13, 2024
23521bc
create and test control-limited DDP
astomodynamics Mar 13, 2024
afdbc34
Merge pull request #3 from astomodynamics:devel
astomodynamics Mar 13, 2024
628cedf
Update README.md
astomodynamics Mar 13, 2024
14b9e91
Update README.md
astomodynamics Mar 13, 2024
3184b64
Delete DS_store
astomodynamics Mar 13, 2024
4af2b10
Merge pull request #4 from astomodynamics:devel
astomodynamics Mar 13, 2024
28bafde
Delete cmake file
astomodynamics Mar 13, 2024
2bc3f3b
Update README.md
astomodynamics Mar 13, 2024
2a39570
Update cmakelists for fetch content
astomodynamics Mar 13, 2024
6b1078b
Update README
astomodynamics Mar 13, 2024
133074b
Update README
astomodynamics Mar 13, 2024
0f5d287
Update README
astomodynamics Mar 13, 2024
76394c2
Update README.md
astomodynamics Mar 13, 2024
818493f
Update README.md
astomodynamics Mar 13, 2024
daeee29
Update README.md
astomodynamics Mar 13, 2024
a65cd96
Update README.md
astomodynamics Mar 13, 2024
76a1e09
Update README.md
astomodynamics Mar 13, 2024
3981072
Update README.md
astomodynamics Mar 13, 2024
3e85fba
Update README.md
astomodynamics Mar 13, 2024
63cd374
Update README.md
astomodynamics Mar 13, 2024
1459bb1
Update README.md
astomodynamics Mar 13, 2024
7e62f6e
Update README.md
astomodynamics Mar 13, 2024
5147ce4
Update README.md
astomodynamics Mar 13, 2024
f67d9b3
Update README.md
astomodynamics Mar 13, 2024
065aebe
Update README.md
astomodynamics Mar 13, 2024
fbc722d
Migrate from OsqpEigen to OsqpCpp
astomodynamics Mar 13, 2024
fb2cc4f
osqp migration
astomodynamics Mar 13, 2024
8425309
Merge pull request #5 from astomodynamics:osqp-cpp-migration
astomodynamics Mar 13, 2024
5c6f3de
Fix output datatype
astomodynamics Mar 13, 2024
0a2fb02
Fix header file issues
astomodynamics Mar 13, 2024
44d377c
Add CDDP as a library
astomodynamics Mar 13, 2024
b5dc60e
Add Library export
astomodynamics Mar 13, 2024
873fbfc
Add control box constraints t
astomodynamics Mar 18, 2024
6d83a05
Merge pull request #6 from astomodynamics/devel_constraint
astomodynamics Mar 18, 2024
21de3a2
Update CMakeLists.txt
astomodynamics Mar 19, 2024
ae2d315
Update CMakeLists.txt
astomodynamics Mar 19, 2024
ed61e6f
Update CMakeLists.txt
astomodynamics Mar 19, 2024
6df7506
Update DynamicalSystem.hpp
astomodynamics Mar 19, 2024
ee9a46b
Update DynamicalSystem.hpp
astomodynamics Mar 19, 2024
f6af371
Update CMakeLists.txt
astomodynamics Mar 19, 2024
cbb46c7
Modify files for cmake modification (build tested)
astomodynamics Mar 19, 2024
0aa0507
Update CDDPProblem.cpp
astomodynamics Mar 19, 2024
1ba9973
Update CartPole.hpp
astomodynamics Mar 19, 2024
e065da3
Update DoubleIntegrator.hpp
astomodynamics Mar 19, 2024
c70eedf
Update DubinsCar.hpp
astomodynamics Mar 19, 2024
5c1a28f
Update Pendulum.hpp
astomodynamics Mar 19, 2024
e19bc7b
Update ObjectiveFunctionTests.cpp
astomodynamics Mar 19, 2024
8166a4c
Add install to cmake
astomodynamics Mar 19, 2024
16f08b3
Update CMakeLists.txt
astomodynamics Mar 19, 2024
21c739c
Change header names
astomodynamics Mar 19, 2024
34ae096
Modify header files
astomodynamics Mar 19, 2024
d52e9da
Add Google test, but not implemented
astomodynamics Mar 19, 2024
ef684a3
Add matplotplusplus library
astomodynamics Mar 20, 2024
2a9f7bd
Update README.md
astomodynamics Mar 21, 2024
2138a3f
Update README.md
astomodynamics Mar 21, 2024
6de97a9
Update README.md
astomodynamics Mar 21, 2024
cbc93a9
Update README.md
astomodynamics Mar 21, 2024
dbcd745
Update README.md
astomodynamics Mar 21, 2024
1ae6e81
Update README.md
astomodynamics Mar 21, 2024
9a6914b
Update README.md
astomodynamics Mar 21, 2024
6aef812
Update README.md
astomodynamics Mar 23, 2024
5027165
Update README.md
astomodynamics Mar 29, 2024
44526c1
Update README.md
astomodynamics Apr 16, 2024
685ff1e
Update cmake
astomodynamics May 13, 2024
a95ea40
Update cmake
astomodynamics May 13, 2024
b1208d7
Add installation part in cmake
astomodynamics May 13, 2024
9efaea8
update readme
astomodynamics May 13, 2024
5bd7a6e
update readme
astomodynamics May 13, 2024
60133ed
Change for ros integration
astomodynamics May 14, 2024
f093bb6
update files for ros integration test
astomodynamics May 14, 2024
a968617
Change DynamicalSystem insertion method for ROS
astomodynamics May 17, 2024
8238f32
Modify CDDPProblem initialization
astomodynamics May 17, 2024
7401cfc
Add timer for optimization process
astomodynamics May 19, 2024
845a1bf
Merge pull request #7 from astomodynamics/ros_integration_test
astomodynamics May 20, 2024
ef162f2
Add TrackingCost object
astomodynamics May 22, 2024
c2d7379
Merge pull request #8 from astomodynamics:ros_integration_test
astomodynamics May 22, 2024
f69c0a3
Modify cmake
astomodynamics May 22, 2024
fc1fa4b
Merge pull request #9 from astomodynamics:ros_integration_test
astomodynamics May 22, 2024
f2a54b5
Add ilqr option
astomodynamics May 31, 2024
16fb0c7
Draft acceleration cost
astomodynamics May 31, 2024
f25af06
Merge pull request #10 from astomodynamics:ros_integration_test
astomodynamics Jun 15, 2024
d6b9409
minor commit (#11)
astomodynamics Sep 30, 2024
b4ab571
remove print out
astomodynamics Oct 8, 2024
5c18c87
change timer scale
astomodynamics Oct 8, 2024
67be150
Update README.md
astomodynamics Oct 8, 2024
ebc2c53
Update README.md
astomodynamics Oct 8, 2024
ba4bad7
Update README.md
astomodynamics Oct 8, 2024
e06ff30
Major_mod (#12)
astomodynamics Oct 25, 2024
e2ef63c
Update README.md
astomodynamics Oct 25, 2024
350ea1f
Control-limited DDP (#13)
astomodynamics Oct 25, 2024
6c9b556
debug timer (#15)
astomodynamics Oct 25, 2024
59ef7ee
Ros integration (#16)
astomodynamics Oct 27, 2024
9ae57fb
Update README.md
astomodynamics Oct 28, 2024
0619be8
Examples updated (#18)
astomodynamics Nov 25, 2024
ffdfb87
Pendulum and cartpole models (#19)
astomodynamics Nov 25, 2024
8f5a0af
fix a bug (#20)
astomodynamics Nov 25, 2024
c928306
Pendulum_cddp (#21)
astomodynamics Nov 29, 2024
79bb609
Update pendulum gif
astomodynamics Nov 29, 2024
0bb0cd0
Cartpole_cddp (#22)
astomodynamics Dec 1, 2024
e993454
Update README
astomodynamics Dec 1, 2024
bbae966
Update README
astomodynamics Dec 1, 2024
f0a56cb
Update README
astomodynamics Dec 1, 2024
b6682c5
Update README
astomodynamics Dec 1, 2024
73432a2
create quadrotor model (#23)
astomodynamics Dec 1, 2024
d82e402
add quadrotor visualization (#24)
astomodynamics Dec 1, 2024
14402d1
Update README
astomodynamics Dec 1, 2024
342b6b4
Update README
astomodynamics Dec 1, 2024
b055613
Update cmake
astomodynamics Dec 1, 2024
64fa4e6
Modify matplotlibcpp.hpp for 3d plot (#25)
astomodynamics Dec 1, 2024
8e29a41
Quadrotor visualization (#26)
astomodynamics Dec 1, 2024
3a16ad5
Update README.md
astomodynamics Dec 1, 2024
cd72ff9
quadrotor example (#27)
astomodynamics Dec 1, 2024
d9d1555
Add spacecraft model (#28)
astomodynamics Dec 1, 2024
2b4512b
remove plots from test
astomodynamics Dec 1, 2024
6e78b23
Update README.md
astomodynamics Dec 2, 2024
3a08336
create manipulator model (#29)
astomodynamics Dec 2, 2024
6587aa7
Add manipulator example (#30)
astomodynamics Dec 2, 2024
af2ac92
Update README.md
astomodynamics Dec 2, 2024
e7bb0d5
add libtorch dependency to cmake (#31)
astomodynamics Dec 3, 2024
b7a64f2
Add torch pendulum (#32)
astomodynamics Dec 3, 2024
b2bddd5
fix constraint call
astomodynamics Dec 3, 2024
84fa37c
Remove frame files to reduce repo size (#33)
astomodynamics Dec 5, 2024
701cd4e
Fix compilation error on constraints (#35)
astomodynamics Dec 7, 2024
fd9b9f6
Update cmake for the use of local libtorch (#36)
astomodynamics Dec 7, 2024
4ee83af
Update README.md (#37)
astomodynamics Dec 7, 2024
ecd9920
Create ci.yaml (#38)
astomodynamics Dec 7, 2024
e79bcd2
Update ci.yaml
astomodynamics Dec 7, 2024
9267943
Update ci.yaml
astomodynamics Dec 7, 2024
94a6f1f
Update ci.yaml
astomodynamics Dec 7, 2024
e6476c9
Update ci.yaml
astomodynamics Dec 7, 2024
d705daa
Update README.md
astomodynamics Dec 7, 2024
4cbe31c
Update README.md (#39)
astomodynamics Dec 7, 2024
2df6f6f
Change ci.yaml: from nvidia/cuda:12.4.0-base-ubuntu22.04 to self-hos…
astomodynamics Dec 7, 2024
3257d18
Update ci.yaml
astomodynamics Dec 7, 2024
bd7ae70
Update ci.yaml
astomodynamics Dec 7, 2024
5a3725d
Remove ci.yaml
astomodynamics Dec 7, 2024
aa2558b
Update ci.yaml by adding dockerfile
astomodynamics Dec 7, 2024
e7d9da0
Update Dockerfile
astomodynamics Dec 7, 2024
7f32cb5
Update Dockerfile
astomodynamics Dec 7, 2024
7879030
Update Dockerfile
astomodynamics Dec 7, 2024
25e483d
Update Dockerfile
astomodynamics Dec 7, 2024
a6222ec
Update ci.yaml
astomodynamics Dec 7, 2024
35d56eb
Update ci.yaml, Dockerfile, and CmakeLists.txt
astomodynamics Dec 7, 2024
0d367e2
Update CMakeLists.txt
astomodynamics Dec 7, 2024
2e34386
Update Dockerfile
astomodynamics Dec 7, 2024
a4a0c58
Update CMakeLists.txt
astomodynamics Dec 7, 2024
8e115ec
Update LICENSE related lines
astomodynamics Dec 8, 2024
18765ed
Update CMakeLists.txt, workflow yaml name, and README.md (#41)
astomodynamics Dec 9, 2024
9f5437c
Dev (#42)
astomodynamics Dec 11, 2024
d7f1f8e
Fix CLDDP and LogDDP (#43)
astomodynamics Dec 11, 2024
9f01a70
Update README.md (#44)
astomodynamics Dec 11, 2024
abe24fd
Add new car model (#45)
astomodynamics Dec 11, 2024
09c2d79
Add spacecraft landing model (#46)
astomodynamics Dec 12, 2024
49526e0
Remove plotting from master (#47)
astomodynamics Dec 12, 2024
be15cfa
Create twobody spacecraft model (#48)
astomodynamics Dec 14, 2024
68c551e
Car Example with updated Control-limited DDP (#49)
astomodynamics Dec 17, 2024
9a04d78
Update README.md (#50)
astomodynamics Dec 17, 2024
76a628e
Create an animation class (#51)
astomodynamics Dec 17, 2024
73c9f0e
Create a new qp solver based on sdqp (#52)
astomodynamics Dec 17, 2024
79296d6
Update DDP solvers (#53)
astomodynamics Dec 17, 2024
23ee1fb
Sqp solver development (#54)
astomodynamics Dec 18, 2024
a3aa284
Add Casadi solver for baseline (#55)
astomodynamics Dec 19, 2024
a5abfb8
Update Cmakelists (#56)
astomodynamics Dec 20, 2024
375f04c
Fix dependency error in git action (#57)
astomodynamics Dec 20, 2024
d999347
Add Spacecraft models (#58)
astomodynamics Dec 21, 2024
b67fccd
Update CMakeLists.txt (#59)
astomodynamics Dec 21, 2024
b2bb9d5
CDDP solver cleanup (#60)
astomodynamics Dec 24, 2024
8be9ecb
Neural dynamics update (#61)
astomodynamics Dec 24, 2024
5564094
Add neural dynamics scripts (#62)
astomodynamics Dec 26, 2024
a34c913
Enhance CDDP with barrier and constraint improvements (#63)
astomodynamics Dec 27, 2024
cb8d461
Fix error in test file (#65)
astomodynamics Dec 27, 2024
14d44a1
Modify CDDP to update reference states and update reference state acc…
astomodynamics Dec 27, 2024
1e08692
Disable LibTorch by default and conditionally include related sources…
astomodynamics Dec 27, 2024
6c3387e
Fixed major error in CMakeLists.txt (#69)
astomodynamics Dec 27, 2024
549a401
Update CMakeLists.txt; Change torch dependency default (#70)
astomodynamics Dec 27, 2024
1d9c72f
Add HCW example and update CMakeLists.txt to include new executables …
astomodynamics Jan 14, 2025
03ad6c7
hcw mpc simulations (#72)
astomodynamics Jan 18, 2025
a48fa9a
Unicycle model and Dubins Car model (#74)
astomodynamics Feb 3, 2025
4414b0d
Add ipddp to gitignore (#75)
astomodynamics Feb 3, 2025
b7dbb16
Remove ipddp (#76)
astomodynamics Feb 3, 2025
7f1d5e6
Merge early version of ipddp to master (#77)
astomodynamics Feb 6, 2025
1bdaafb
casadi examples and sqp solver created (#78)
astomodynamics Feb 11, 2025
f83c1fb
Remove sqp solver and casadi from default config (#79)
astomodynamics Feb 11, 2025
4855c7a
Fix compilation bugs (#80)
astomodynamics Feb 11, 2025
cc8268b
IPDDP development (infeasible) (#81)
astomodynamics Feb 25, 2025
9d77063
Update README.md (#82)
astomodynamics Feb 25, 2025
6fca7e3
Implement active-set DDP for unicycle with obstacle avoidance (#83)
astomodynamics Mar 2, 2025
91936bd
Add multiple examples of IPDDP trajectory (#84)
astomodynamics Mar 4, 2025
cc51e1b
Add additional case study of IPDDP (#85)
astomodynamics Mar 4, 2025
a46d5e2
Update README.md (#86)
astomodynamics Mar 4, 2025
7d62dc5
Update README.md (#87)
astomodynamics Mar 4, 2025
9b4f87b
Update README.md (#88)
astomodynamics Mar 6, 2025
81defc4
Update scripts for matplotplusplus (#89)
astomodynamics Mar 11, 2025
718d84a
Update Dockerfile
astomodynamics Mar 11, 2025
e10cf2f
Merge pull request #90 from astomodynamics/astomodynamics-patch-1
astomodynamics Mar 11, 2025
88e538f
Add safe quadrotor flight (#91)
astomodynamics Mar 11, 2025
60002f6
Update CMakeLists.txt (#92)
astomodynamics Mar 11, 2025
7562bb4
Add ROE model (#93)
astomodynamics Mar 11, 2025
1f327cf
Add Second-Order Derivatives and Autodiff Support (#95)
astomodynamics Apr 1, 2025
444a2d7
Usv_dynamics (#96)
astomodynamics Apr 8, 2025
2b8b0d3
Add Second Order Cone Constraint and Linear Constraint (#97)
astomodynamics Apr 8, 2025
b4c5683
Update README.md (#98)
astomodynamics Apr 8, 2025
f538b42
Add spacecraft linear docking example (#99)
astomodynamics Apr 12, 2025
bff837d
Fix test (#100)
astomodynamics Apr 12, 2025
eef3988
Implement tests for MRP, Quaternion, and Euler attitude dynamics (#101)
astomodynamics Apr 17, 2025
d7d6c2c
CI improvement and fix tests (#102)
astomodynamics May 2, 2025
862a6c8
Enhance CMake and CI configuration for Eigen3 support (#103)
astomodynamics May 2, 2025
e0eec76
Update CMakeLists.txt and build.yaml (#105)
astomodynamics May 2, 2025
3aaacb6
Refactor ipddp_core.cpp: Updates to Backward Pass and Forward Pass (#…
astomodynamics May 26, 2025
4d8479d
Integrate Constraint Hessians into IPDDP Solver (#109)
astomodynamics May 26, 2025
d58678b
Integrate MSIPDDP Solver (#110)
astomodynamics May 27, 2025
08e11a9
Update test_msipddp_core.cpp (#111)
astomodynamics May 27, 2025
659258b
Add some RPO examples (#112)
astomodynamics May 28, 2025
21876cf
Enhanced IPDDP/MSIPDDP Initialization (#114)
astomodynamics May 28, 2025
64ecc99
Update README.md (#115)
astomodynamics May 28, 2025
7a5af5f
Update RPO code/results (#116)
astomodynamics May 28, 2025
c8d8b12
Refactor: Enhance IPDDP Solver Options and Forward Pass Logic (#117)
astomodynamics May 31, 2025
83bdf90
Comprehensive Updates to CDDP Solvers, Constraint Handling, and Testi…
astomodynamics May 31, 2025
8fbfc9d
fix bug in asddp (#119)
astomodynamics Jun 2, 2025
0ee856f
IPDDP parameter updates (#120)
astomodynamics Jun 2, 2025
9271e2d
Improve solvers (#121)
astomodynamics Jun 2, 2025
7595327
Refactor dynamics functions to include time parameter (#122)
astomodynamics Jun 3, 2025
1e68390
Spacecraft Model Update (#123)
astomodynamics Jun 3, 2025
0672931
Fix compilation bug (#124)
astomodynamics Jun 3, 2025
a2f6dc7
Fix compilation error (#125)
astomodynamics Jun 3, 2025
b0bb048
Remove unnecessary library option from cmake (#126)
astomodynamics Jun 3, 2025
a9e5332
feat: Add SNOPT solver integration with CasADi (#127)
astomodynamics Jun 6, 2025
2cf9c8f
Update README.md (#128)
astomodynamics Jun 11, 2025
ae27f61
Major CDDP Solver Architecture Refactor (#129)
astomodynamics Jul 5, 2025
bd9c9ad
Update examples to new modular solver API (#130)
astomodynamics Jul 6, 2025
5ae56eb
Solver preparation (#131)
astomodynamics Jul 6, 2025
f99a527
Add rate-based quadrotor dynamics model (#132)
astomodynamics Jul 8, 2025
d0427b6
Add Forklift dynamics model and parking example (#133)
astomodynamics Jul 12, 2025
31459e7
Add ACADOS integration and improve benchmark visualizations (#134)
astomodynamics Jul 13, 2025
780b4e1
Optimize LDLT solver recomputation logic for performance (#135)
astomodynamics Jul 13, 2025
d067f09
Fix state and control jacobian computation in constraint implementati…
astomodynamics Jul 14, 2025
479ce68
Add solver information and options printing functionality (#140)
astomodynamics Jul 16, 2025
4629df6
Merge remote-tracking branch 'origin/master' into dev4
astomodynamics Jul 18, 2025
f69f891
feat: Add configurable barrier update strategies for interior point m…
astomodynamics Jul 19, 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
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

# CMakeLists.txt for the CDDP examples

add_executable(test_barrier_strategies test_barrier_strategies.cpp)
target_link_libraries(test_barrier_strategies cddp)

add_executable(cddp_bicycle cddp_bicycle.cpp)
target_link_libraries(cddp_bicycle cddp)

Expand Down
152 changes: 152 additions & 0 deletions examples/test_barrier_strategies.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
Example demonstrating the three barrier update strategies for IPDDP and MSIPDDP
*/

#include <iostream>
#include <memory>
#include <string>
#include <Eigen/Dense>

#include "cddp.hpp"

int main()
{
// Problem setup
const int horizon = 50;
const double timestep = 0.05;
const int state_dim = 3;
const int control_dim = 2;

// Initial and goal states
Eigen::VectorXd X0(state_dim);
X0 << 0.0, 0.0, 0.0; // x, y, theta

Eigen::VectorXd Xg(state_dim);
Xg << 2.0, 2.0, 0.0;

// Test each barrier strategy
std::vector<std::string> solvers = {"IPDDP", "MSIPDDP"};
std::vector<cddp::BarrierStrategy> strategies = {
cddp::BarrierStrategy::ADAPTIVE,
cddp::BarrierStrategy::MONOTONIC,
cddp::BarrierStrategy::IPOPT
};
std::vector<std::string> strategy_names = {"ADAPTIVE", "MONOTONIC", "IPOPT"};

for (const auto& solver_name : solvers)
{
std::cout << "\n========================================\n";
std::cout << "Testing " << solver_name << " Solver\n";
std::cout << "========================================\n";

for (size_t i = 0; i < strategies.size(); ++i)
{
std::cout << "\n--- Barrier Strategy: " << strategy_names[i] << " ---\n";

// Create CDDP solver first
cddp::CDDP cddp_solver(X0, Xg, horizon, timestep);

// Create and set dynamics model
auto dynamics = std::make_unique<cddp::Unicycle>(timestep);
cddp_solver.setDynamicalSystem(std::move(dynamics));

// Create and set objective
Eigen::MatrixXd Q = Eigen::MatrixXd::Identity(state_dim, state_dim);
Q(0, 0) = 10.0; // x
Q(1, 1) = 10.0; // y
Q(2, 2) = 1.0; // theta

Eigen::MatrixXd R = Eigen::MatrixXd::Identity(control_dim, control_dim);
R(0, 0) = 0.1; // linear velocity
R(1, 1) = 0.1; // angular velocity

Eigen::MatrixXd Qf = 100.0 * Q;

std::vector<Eigen::VectorXd> empty_reference;
auto objective = std::make_unique<cddp::QuadraticObjective>(
Q, R, Qf, Xg, empty_reference, timestep);
cddp_solver.setObjective(std::move(objective));

// Add constraints
Eigen::VectorXd u_upper(control_dim);
u_upper << 1.0, 2.0; // max linear vel, max angular vel

cddp_solver.addPathConstraint("ControlConstraint",
std::make_unique<cddp::ControlConstraint>(u_upper));

// State bounds (keep robot in a region)
Eigen::VectorXd x_lower(state_dim), x_upper_state(state_dim);
x_lower << -0.5, -0.5, -M_PI;
x_upper_state << 2.5, 2.5, M_PI;

cddp_solver.addPathConstraint("StateConstraint",
std::make_unique<cddp::StateConstraint>(x_lower, x_upper_state));

// Configure options
cddp::CDDPOptions opts;
opts.max_iterations = 100;
opts.tolerance = 1e-4;
opts.verbose = false;
opts.debug = true; // Enable debug output to see barrier updates
opts.return_iteration_info = true;

// Set barrier strategy
if (solver_name == "IPDDP") {
opts.ipddp.barrier.strategy = strategies[i];
opts.ipddp.barrier.mu_initial = 1.0;
opts.ipddp.barrier.mu_update_factor = 0.2;
opts.ipddp.barrier.mu_update_power = 1.5;
} else {
opts.msipddp.barrier.strategy = strategies[i];
opts.msipddp.barrier.mu_initial = 1.0;
opts.msipddp.barrier.mu_update_factor = 0.2;
opts.msipddp.barrier.mu_update_power = 1.5;
}

cddp_solver.setOptions(opts);

// Initialize with straight line trajectory
std::vector<Eigen::VectorXd> X_init(horizon + 1);
std::vector<Eigen::VectorXd> U_init(horizon);

for (int t = 0; t <= horizon; ++t) {
double alpha = static_cast<double>(t) / horizon;
X_init[t] = (1.0 - alpha) * X0 + alpha * Xg;
}

for (int t = 0; t < horizon; ++t) {
U_init[t] = Eigen::VectorXd::Zero(control_dim);
}

cddp_solver.setInitialTrajectory(X_init, U_init);

// Solve
cddp::CDDPSolution solution = cddp_solver.solve(solver_name);

// Print results
auto status_message = std::any_cast<std::string>(solution.at("status_message"));
auto iterations = std::any_cast<int>(solution.at("iterations_completed"));
auto solve_time = std::any_cast<double>(solution.at("solve_time_ms"));
auto final_cost = std::any_cast<double>(solution.at("final_objective"));

std::cout << "Status: " << status_message << "\n";
std::cout << "Iterations: " << iterations << "\n";
std::cout << "Final cost: " << final_cost << "\n";
std::cout << "Solve time: " << solve_time << " ms\n";

// Extract final barrier parameter
try {
double final_mu = std::any_cast<double>(solution.at("final_barrier_parameter_mu"));
std::cout << "Final barrier μ: " << final_mu << "\n";
} catch (const std::exception& e) {
std::cout << "Final barrier μ: Not available\n";
}
}
}

std::cout << "\n========================================\n";
std::cout << "Test completed successfully!\n";
std::cout << "========================================\n";

return 0;
}
12 changes: 12 additions & 0 deletions include/cddp-cpp/cddp_core/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@

namespace cddp
{
/**
* @brief Barrier parameter update strategy for interior point methods.
*/
enum class BarrierStrategy
{
ADAPTIVE, ///< Adaptive strategy based on KKT progress (default)
MONOTONIC, ///< Monotonic decrease with fixed reduction factor
IPOPT ///< IPOPT-style adaptive barrier update
};

/**
* @brief Options for the line search procedure.
*
Expand Down Expand Up @@ -71,6 +81,8 @@ namespace cddp
double min_fraction_to_boundary =
0.99; ///< Minimum fraction to boundary for primal/dual step calculation
///< (tau).
BarrierStrategy strategy =
BarrierStrategy::ADAPTIVE; ///< Barrier parameter update strategy.
};

/**
Expand Down
128 changes: 89 additions & 39 deletions src/cddp_core/ipddp_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1838,56 +1838,106 @@ namespace cddp
return; // No constraints case - no barrier update needed
}

// Compute termination metric from current infeasibility metrics with IPOPT-style scaling
double scaled_inf_du = computeScaledDualInfeasibility(context);
double termination_metric = std::max({scaled_inf_du, context.inf_pr_, context.inf_comp_});

// More aggressive barrier parameter update strategy
double barrier_update_threshold = std::max(barrier_opts.mu_update_factor * mu_, mu_ * 2.0);

if (termination_metric <= barrier_update_threshold)
// Select barrier update strategy
switch (barrier_opts.strategy)
{
// Adaptive barrier reduction strategy
double reduction_factor = barrier_opts.mu_update_factor;

if (mu_ > 1e-12)
case BarrierStrategy::MONOTONIC:
{
double kkt_progress_ratio = termination_metric / mu_;

// Very aggressive reduction for good KKT satisfaction
if (kkt_progress_ratio < 0.01)
{
reduction_factor = barrier_opts.mu_update_factor * 0.1;
}
// Aggressive reduction if we're significantly satisfying KKT conditions
else if (kkt_progress_ratio < 0.1)
// Monotonic decrease: always reduce by fixed factor
mu_ = std::max(barrier_opts.mu_min_value,
barrier_opts.mu_update_factor * mu_);
resetFilter(context);
if (options.debug)
{
reduction_factor = barrier_opts.mu_update_factor * 0.3;
std::cout << "[IPDDP Barrier] Monotonic update: μ = "
<< std::scientific << std::setprecision(2) << mu_ << std::endl;
}
// Moderate reduction if we're moderately satisfying KKT conditions
else if (kkt_progress_ratio < 0.5)
break;
}

case BarrierStrategy::IPOPT:
{
// IPOPT-style barrier update
double scaled_inf_du = computeScaledDualInfeasibility(context);
double error_k = std::max({scaled_inf_du, context.inf_pr_, context.inf_comp_});

// IPOPT uses: μ_new = max(ε_tol/10, min(κ_μ * μ, μ^θ_μ))
// where update happens when error_k ≤ κ_ε * μ
double kappa_epsilon = 10.0; // IPOPT default

if (error_k <= kappa_epsilon * mu_)
{
reduction_factor = barrier_opts.mu_update_factor * 0.6;
double new_mu_linear = barrier_opts.mu_update_factor * mu_;
double new_mu_superlinear = std::pow(mu_, barrier_opts.mu_update_power);
mu_ = std::max(options.tolerance / 10.0,
std::min(new_mu_linear, new_mu_superlinear));
resetFilter(context);
if (options.debug)
{
std::cout << "[IPDDP Barrier] IPOPT update: error = "
<< std::scientific << std::setprecision(2) << error_k
<< " ≤ " << kappa_epsilon << " * μ = " << kappa_epsilon * mu_
<< " → μ = " << mu_ << std::endl;
}
}
// Standard reduction otherwise
break;
}

case BarrierStrategy::ADAPTIVE:
default:
{
// Current adaptive strategy (default)
double scaled_inf_du = computeScaledDualInfeasibility(context);
double termination_metric = std::max({scaled_inf_du, context.inf_pr_, context.inf_comp_});

// Update barrier parameter with bounds
double new_mu_linear = reduction_factor * mu_;
double new_mu_superlinear = std::pow(mu_, barrier_opts.mu_update_power);
// More aggressive barrier parameter update strategy
double barrier_update_threshold = std::max(barrier_opts.mu_update_factor * mu_, mu_ * 2.0);

if (termination_metric <= barrier_update_threshold)
{
// Adaptive barrier reduction strategy
double reduction_factor = barrier_opts.mu_update_factor;

mu_ = std::max(options.tolerance / 100.0,
std::min(new_mu_linear, new_mu_superlinear));
if (mu_ > 1e-12)
{
double kkt_progress_ratio = termination_metric / mu_;

// Reset filter when barrier parameter changes
resetFilter(context);
// Very aggressive reduction for good KKT satisfaction
if (kkt_progress_ratio < 0.01)
{
reduction_factor = barrier_opts.mu_update_factor * 0.1;
}
// Aggressive reduction if we're significantly satisfying KKT conditions
else if (kkt_progress_ratio < 0.1)
{
reduction_factor = barrier_opts.mu_update_factor * 0.3;
}
// Moderate reduction if we're moderately satisfying KKT conditions
else if (kkt_progress_ratio < 0.5)
{
reduction_factor = barrier_opts.mu_update_factor * 0.6;
}
// Standard reduction otherwise
}

if (options.debug)
{
std::cout << "[IPDDP Barrier] Termination metric: " << std::scientific << std::setprecision(2)
<< termination_metric << " (scaled inf_du: " << scaled_inf_du
<< ", inf_pr: " << context.inf_pr_ << ", inf_comp: " << context.inf_comp_
<< ") → μ: " << mu_ << std::endl;
// Update barrier parameter with bounds
double new_mu_linear = reduction_factor * mu_;
double new_mu_superlinear = std::pow(mu_, barrier_opts.mu_update_power);

mu_ = std::max(options.tolerance / 100.0,
std::min(new_mu_linear, new_mu_superlinear));

// Reset filter when barrier parameter changes
resetFilter(context);

if (options.debug)
{
std::cout << "[IPDDP Barrier] Adaptive update: termination metric = "
<< std::scientific << std::setprecision(2) << termination_metric
<< " → μ = " << mu_ << std::endl;
}
}
break;
}
}
}
Expand Down
Loading
Loading