COPP C++ API
C++ interface for COPP trajectory optimization
Loading...
Searching...
No Matches
copp2_socp.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <initializer_list>
4#include <optional>
5#include <vector>
6
7#include "copp/clarabel.hpp"
8#include "copp/core.hpp"
9#include "copp/objective.hpp"
10#include "copp/robot.hpp"
11
13{
14
26 {
27 public:
29 const Robot &robot,
30 std::vector<Objective> objectives,
33
35 const Robot &robot,
36 std::initializer_list<Objective> objectives,
39
40 const Robot &robot() const noexcept { return *robot_; }
41 const std::vector<Objective> &objectives() const noexcept { return objectives_; }
42 IndexInterval idx_s_interval() const noexcept { return idx_s_interval_; }
43 Boundary2 a_boundary() const noexcept { return a_boundary_; }
44 std::size_t s_len() const noexcept { return s_len_; }
45
46 private:
47 const Robot *robot_ = nullptr;
48 std::vector<Objective> objectives_;
49 IndexInterval idx_s_interval_;
50 Boundary2 a_boundary_;
51 std::size_t s_len_ = 0;
52 };
53
61 struct Result
62 {
63 std::optional<std::vector<double>> a;
64 std::vector<double> x;
65 std::vector<double> z;
66 std::vector<double> s;
68 double obj_val = 0.0;
69 double obj_val_dual = 0.0;
70 double solve_time = 0.0;
71 std::uint32_t iterations = 0;
72 double r_prim = 0.0;
73 double r_dual = 0.0;
75 std::optional<double> objective_value;
76 std::vector<double> objective_terms;
77
78 bool has_a() const noexcept { return a.has_value(); }
79 };
80
86 COPP_API std::vector<double> solve(
87 const Problem &problem,
88 const clarabel::Options &options = {});
90 const Problem &problem,
91 const clarabel::Options &options,
93 {
94 return detail::expected_from([&] { return solve(problem, options); });
95 }
97 {
98 return solve(problem, clarabel::Options{}, tag);
99 }
100
103 const Problem &problem,
104 const clarabel::Options &options = {});
106 const Problem &problem,
107 const clarabel::Options &options,
109 {
110 return detail::expected_from([&] { return solve_expert(problem, options); });
111 }
113 {
114 return solve_expert(problem, clarabel::Options{}, tag);
115 }
116
117} // namespace copp::solver::copp2_socp
Small C++17 expected-like result used by no-throw overloads.
Definition core.hpp:527
Robot facade backed by Rust Robot<CppRobotModel>.
Definition robot.hpp:318
COPP2-SOCP problem descriptor.
IndexInterval idx_s_interval() const noexcept
Boundary2 a_boundary() const noexcept
const Robot & robot() const noexcept
Problem(const Robot &robot, std::vector< Objective > objectives, IndexInterval idx_s_interval, Boundary2 a_boundary={})
Problem(const Robot &robot, std::initializer_list< Objective > objectives, IndexInterval idx_s_interval, Boundary2 a_boundary={})
const std::vector< Objective > & objectives() const noexcept
std::size_t s_len() const noexcept
#define COPP_API
Definition core.hpp:23
SolverStatus
Clarabel termination status reported by expert SOCP results.
Definition clarabel.hpp:32
auto expected_from(Fn &&fn) -> Expected< typename std::decay< decltype(fn())>::type >
Definition core.hpp:580
Second-order convex-objective Clarabel SOCP backend with normal profile-returning APIs and expert dia...
COPP_API Result solve_expert(const Problem &problem, const clarabel::Options &options={})
Solve COPP2-SOCP and always return Clarabel diagnostics.
COPP_API std::vector< double > solve(const Problem &problem, const clarabel::Options &options={})
Solve COPP2-SOCP and return an accepted node profile a(s).
Second-order endpoint boundary values.
Definition core.hpp:77
Closed station-index interval used by TOPP/COPP problem descriptors.
Definition core.hpp:67
Tag object selecting no-throw overloads.
Definition core.hpp:608
Linear solver metadata captured from Clarabel after a solve.
Definition clarabel.hpp:49
Shared Clarabel options for COPP/TOPP SOCP-style solvers.
Definition clarabel.hpp:117
Expert COPP2-SOCP result with raw Clarabel diagnostics.
std::vector< double > objective_terms
bool has_a() const noexcept
clarabel::LinearSolverInfo linsolver
clarabel::SolverStatus solver_status
std::optional< double > objective_value
std::optional< std::vector< double > > a