MCPcopy Create free account
hub / github.com/Simple-Robotics/aligator / splitProblemInTwo

Function splitProblemInTwo

tests/gar/parallel.cpp:20–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18const uint NUM_THREADS = 6;
19
20static std::array<problem_t, 2> splitProblemInTwo(const problem_t &problem,
21 uint t0) {
22 assert(problem.isInitialized());
23 uint N = (uint)problem.horizon();
24 assert(t0 < N);
25
26 problem_t::KnotVector knots1, knots2;
27 uint nx_t0 = problem.stages[t0].nx;
28
29 for (uint i = 0; i < t0; i++)
30 knots1.push_back(problem.stages[i]);
31
32 for (uint i = t0; i <= N; i++)
33 knots2.push_back(problem.stages[i]);
34
35 knot_t kn1_last = knots1.back(); // copy
36
37 problem_t p1(std::move(knots1), problem.nc0());
38 p1.G0 = problem.G0;
39 p1.g0 = problem.g0;
40 p1.addParameterization(nx_t0);
41 {
42 knot_t &p1_last = p1.stages.back();
43 p1_last.Gx = kn1_last.A.transpose();
44 p1_last.Gu = kn1_last.B.transpose();
45 p1_last.gamma = kn1_last.f;
46 kn1_last.A.setZero();
47 kn1_last.B.setZero();
48 kn1_last.f.setZero();
49 }
50
51 problem_t p2(std::move(knots2), 0);
52 p2.addParameterization(nx_t0);
53 {
54 knot_t &p2_first = p2.stages[0];
55 p2_first.Gx.setIdentity() *= -1;
56 }
57
58 return {std::move(p1), std::move(p2)};
59}
60
61/// Test the max-only formulation, where both legs are parameterized
62/// by the splitting variable (= costate at t0)

Callers 1

parallel.cppFile · 0.85

Calls 6

horizonMethod · 0.80
backMethod · 0.80
nc0Method · 0.80
addParameterizationMethod · 0.80
isInitializedMethod · 0.45
setZeroMethod · 0.45

Tested by

no test coverage detected