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

Function generateKnot

tests/gar/test_util.cpp:14–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14knot_t generateKnot(std::mt19937 rng, knot_gen_opts_t opts,
15 const aligator::polymorphic_allocator &alloc) {
16 normal_unary_op normal_op{rng};
17 auto nx = opts.nx;
18 auto nu = opts.nu;
19 auto nc = opts.nc;
20 auto nth = opts.nth;
21 uint wishartDof = nx + nu + 1;
22 knot_t out(nx, nu, nc, opts.nx2, nth, alloc);
23 MatrixXs _qsr = sampleWishartDistributedMatrix(nx + nu, wishartDof);
24 _qsr /= std::max(nx, nu);
25
26 out.Q = _qsr.topLeftCorner(nx, nx);
27 out.S = _qsr.topRightCorner(nx, nu);
28 if (opts.singular) {
29 uint dof = uint(0.8 * (nx + nu));
30 out.Q = sampleWishartDistributedMatrix(nx, dof);
31 }
32 out.R = _qsr.bottomRightCorner(nu, nu);
33 out.R.diagonal().array() *= 1 + 1e-6;
34 out.q.setRandom();
35 out.r.setRandom();
36
37 out.A.setRandom();
38 out.B.setRandom();
39 out.f = VectorXs::NullaryExpr(nx, normal_op);
40
41 if (nc > 0) {
42 out.C.setIdentity();
43 out.d.setRandom();
44 }
45
46 if (nth > 0) {
47 out.Gx = MatrixXs::NullaryExpr(nx, nth, normal_op);
48 out.Gu = MatrixXs::NullaryExpr(nu, nth, normal_op);
49 out.Gth = sampleWishartDistributedMatrix(nth, nth + 2);
50 out.gamma = VectorXs::NullaryExpr(nth, normal_op);
51 }
52
53 assert(out.get_allocator() == alloc);
54 return out;
55}
56
57problem_t generateLqProblem(std::mt19937 rng, const ConstVectorRef &x0,
58 uint horz, uint nx, uint nu, uint nth, uint nc,

Callers 1

generateLqProblemFunction · 0.70

Calls 2

get_allocatorMethod · 0.45

Tested by

no test coverage detected